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