equal
deleted
inserted
replaced
1 /* ldt_annotate serializer: Used when Putting annotations on the platform */ |
1 /* ldt_annotate serializer: Used when Putting annotations on the platform */ |
|
2 import _ from "lodash"; |
2 |
3 |
3 if (typeof IriSP.serializers === "undefined") { |
4 const ldt_annotate = function(IriSP) { return { |
4 IriSP.serializers = {}; |
|
5 } |
|
6 |
|
7 IriSP.serializers.ldt_annotate = { |
|
8 serializeAnnotation : function(_data, _source) { |
5 serializeAnnotation : function(_data, _source) { |
9 var _annType = _data.getAnnotationType(); |
6 var _annType = _data.getAnnotationType(); |
10 return { |
7 return { |
11 id: _data.id, |
8 id: _data.id, |
12 begin: _data.begin.milliseconds, |
9 begin: _data.begin.milliseconds, |
43 _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
40 _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
44 _anntype.title = _anndata.type_title; |
41 _anntype.title = _anndata.type_title; |
45 _source.getAnnotationTypes().push(_anntype); |
42 _source.getAnnotationTypes().push(_anntype); |
46 } |
43 } |
47 _ann.setAnnotationType(_anntype.id); |
44 _ann.setAnnotationType(_anntype.id); |
48 var _tagIds = IriSP._(_anndata.tags).map(function(_title) { |
45 var _tagIds = _(_anndata.tags).map(function(_title) { |
49 var _tags = _source.getTags(true).searchByTitle(_title, true); |
46 var _tags = _source.getTags(true).searchByTitle(_title, true); |
50 if (_tags.length) { |
47 if (_tags.length) { |
51 var _tag = _tags[0]; |
48 var _tag = _tags[0]; |
52 } |
49 } |
53 else { |
50 else { |
78 _source.addList('tag', new IriSP.Model.List(_source.directory)); |
75 _source.addList('tag', new IriSP.Model.List(_source.directory)); |
79 _source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
76 _source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
80 _source.addList('annotation', new IriSP.Model.List(_source.directory)); |
77 _source.addList('annotation', new IriSP.Model.List(_source.directory)); |
81 this.deserializeAnnotation(_data, _source); |
78 this.deserializeAnnotation(_data, _source); |
82 } |
79 } |
83 }; |
80 }}; |
|
81 |
|
82 export default ldt_annotate; |
84 |
83 |
85 /* End ldt_annotate serializer */ |
84 /* End ldt_annotate serializer */ |