| author | durandn |
| Tue, 01 Sep 2015 15:24:26 +0200 | |
| changeset 1045 | b06345320ffb |
| parent 1032 | 74ac0be7655c |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 1015 | 1 |
/* START segmentapi-serializer.js */ |
2 |
||
3 |
if (typeof IriSP.serializers === "undefined") { |
|
4 |
IriSP.serializers = {}; |
|
5 |
} |
|
6 |
||
| 1014 | 7 |
IriSP.serializers.segmentapi = { |
8 |
deSerialize : function(_data, _source) { |
|
9 |
var _annotationlist = new IriSP.Model.List(_source.directory), |
|
10 |
_medialist = new IriSP.Model.List(_source.directory); |
|
11 |
_source.addList("media", _medialist); |
|
12 |
|
|
13 |
function deserializeObject(_s) { |
|
14 |
var _ann = new IriSP.Model.Annotation(_s.element_id, _source), |
|
15 |
_media = _source.getElement(_s.iri_id); |
|
16 |
if (!_media) { |
|
17 |
_media = new IriSP.Model.Media(_s.iri_id, _source); |
|
18 |
_source.getMedias().push(_media); |
|
19 |
} |
|
20 |
_ann.setMedia(_s.iri_id); |
|
21 |
_ann.title = _s.title; |
|
|
1032
74ac0be7655c
small corrections to allow js compilation
ymh <ymh.work@gmail.com>
parents:
1015
diff
changeset
|
22 |
_ann.description = _s['abstract']; |
| 1014 | 23 |
_ann.begin = new IriSP.Model.Time(_s.start_ts); |
24 |
_ann.end = new IriSP.Model.Time(_s.start_ts + _s.duration); |
|
25 |
_ann.keywords = (_s.tags ? _s.tags.split(",") : []); |
|
26 |
_ann.project_id = _s.project_id; |
|
27 |
_annotationlist.push(_ann); |
|
28 |
} |
|
29 |
|
|
30 |
if (typeof _data.objects !== "undefined") { |
|
31 |
IriSP._(_data.objects).each(deserializeObject); |
|
32 |
} else { |
|
33 |
deserializeObject(_data); |
|
34 |
} |
|
35 |
_source.addList("annotation", _annotationlist); |
|
36 |
} |
|
37 |
}; |
|
38 |
||
39 |
/* END segmentapi-serializer.js */ |