crea/integration/metadataplayer/LdtPlayer-core.js
changeset 15 f1d070549d94
parent 13 692a26b5274b
child 30 8cda6414d63e
--- a/crea/integration/metadataplayer/LdtPlayer-core.js	Wed Jun 06 18:35:36 2012 +0200
+++ b/crea/integration/metadataplayer/LdtPlayer-core.js	Wed Jun 06 19:36:25 2012 +0200
@@ -2066,91 +2066,7 @@
             break;
     }
     
-};/* Used when Putting annotations on the platform */
-
-if (typeof IriSP.serializers === "undefined") {
-    IriSP.serializers = {}
-}
-
-IriSP.serializers.ldt_annotate = {
-    types :  {
-        annotation : {
-            serialized_name : "annotations",
-            serializer : function(_data, _source) {
-                return {
-                    begin: _data.begin.milliseconds,
-                    end: _data.end.milliseconds,
-                    content: {
-                        data: _data.description
-                    },
-                    tags: _data.getTagTexts(),
-                    media: _source.unNamespace(_data.getMedia().id),
-                    title: _data.title,
-                    type_title: _data.getAnnotationType().title,
-                    type: _source.unNamespace(_data.getAnnotationType().id)
-                }
-            }
-        }
-    },
-    serialize : function(_source) {
-        var _res = {},
-            _this = this;
-        _source.forEach(function(_list, _typename) {
-            if (typeof _this.types[_typename] !== "undefined") {
-                _res[_this.types[_typename].serialized_name] = _list.map(function(_el) {
-                    return _this.types[_typename].serializer(_el, _source);
-                });
-            }
-        });
-        _res.meta = {
-            creator: _source.creator,
-            created: _source.created
-        }
-        return JSON.stringify(_res);
-    },
-    deSerialize : function(_data, _source) {
-        if (typeof _data == "string") {
-            _data = JSON.parse(_data);
-        }
-        _source.addList('tag', new IriSP.Model.List(_source.directory));
-        _source.addList('annotationType', new IriSP.Model.List(_source.directory));
-        _source.addList('annotation', new IriSP.Model.List(_source.directory));
-        if (typeof _data.annotations == "object" && _data.annotations && _data.annotations.length) {
-            var _anndata = _data.annotations[0],
-                _ann = new IriSP.Model.Annotation(_anndata.id, _source);
-            _ann.title = _anndata.content.title || "";
-            _ann.description = _anndata.content.data || "";
-            _ann.created = new Date(_data.meta.created);
-            _ann.setMedia(_anndata.media, _source);
-            var _anntypes = _source.getAnnotationTypes(true).searchByTitle(_anndata.type_title);
-            if (_anntypes.length) {
-                var _anntype = _anntypes[0];
-            } else {
-                var _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
-                _anntype.title = _anndata.type_title;
-                _source.getAnnotationTypes().push(_anntype);
-            }
-            _ann.setAnnotationType(_anntype.id);
-            var _tagIds = IriSP._(_anndata.tags).map(function(_title) {
-                var _tags = _source.getTags(true).searchByTitle(_title);
-                if (_tags.length) {
-                    var _tag = _tags[0];
-                }
-                else {
-                    _tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source);
-                    _tag.title = _title;
-                    _source.getTags().push(_tag);
-                }
-                return _tag.id;
-            });
-            _ann.setTags(_tagIds);
-            _ann.setBegin(_anndata.begin);
-            _ann.setEnd(_anndata.end);
-            _ann.creator = _data.meta.creator;
-            _source.getAnnotations().push(_ann);
-        }
-    }
-}/* LDT Platform Serializer */
+};/* LDT Platform Serializer */
 
 if (typeof IriSP.serializers === "undefined") {
     IriSP.serializers = {}
@@ -2251,6 +2167,9 @@
                 if (typeof _data.meta["dc:source"] !== "undefined" && typeof _data.meta["dc:source"].content !== "undefined") {
                     _res.source = JSON.parse(_data.meta["dc:source"].content);
                 }
+                if (typeof _data.audio !== "undefined" && _data.audio.href) {
+                    _res.audio = _data.audio;
+                }
                 return _res;
             },
             serializer : function(_data, _source) {
@@ -2273,7 +2192,8 @@
                        return {
                            "id-ref" : _source.unNamespace(_id)
                        } 
-                    })
+                    }),
+                    audio : _data.audio
                 }
             }
         },
@@ -2345,3 +2265,88 @@
     }
 }
 
+/* Used when Putting annotations on the platform */
+
+if (typeof IriSP.serializers === "undefined") {
+    IriSP.serializers = {}
+}
+
+IriSP.serializers.ldt_annotate = {
+    types :  {
+        annotation : {
+            serialized_name : "annotations",
+            serializer : function(_data, _source) {
+                return {
+                    begin: _data.begin.milliseconds,
+                    end: _data.end.milliseconds,
+                    content: {
+                        data: _data.description
+                    },
+                    tags: _data.getTagTexts(),
+                    media: _source.unNamespace(_data.getMedia().id),
+                    title: _data.title,
+                    type_title: _data.getAnnotationType().title,
+                    type: _source.unNamespace(_data.getAnnotationType().id)
+                }
+            }
+        }
+    },
+    serialize : function(_source) {
+        var _res = {},
+            _this = this;
+        _source.forEach(function(_list, _typename) {
+            if (typeof _this.types[_typename] !== "undefined") {
+                _res[_this.types[_typename].serialized_name] = _list.map(function(_el) {
+                    return _this.types[_typename].serializer(_el, _source);
+                });
+            }
+        });
+        _res.meta = {
+            creator: _source.creator,
+            created: _source.created
+        }
+        return JSON.stringify(_res);
+    },
+    deSerialize : function(_data, _source) {
+        if (typeof _data == "string") {
+            _data = JSON.parse(_data);
+        }
+        _source.addList('tag', new IriSP.Model.List(_source.directory));
+        _source.addList('annotationType', new IriSP.Model.List(_source.directory));
+        _source.addList('annotation', new IriSP.Model.List(_source.directory));
+        if (typeof _data.annotations == "object" && _data.annotations && _data.annotations.length) {
+            var _anndata = _data.annotations[0],
+                _ann = new IriSP.Model.Annotation(_anndata.id, _source);
+            _ann.title = _anndata.content.title || "";
+            _ann.description = _anndata.content.data || "";
+            _ann.created = new Date(_data.meta.created);
+            _ann.setMedia(_anndata.media, _source);
+            var _anntypes = _source.getAnnotationTypes(true).searchByTitle(_anndata.type_title);
+            if (_anntypes.length) {
+                var _anntype = _anntypes[0];
+            } else {
+                var _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
+                _anntype.title = _anndata.type_title;
+                _source.getAnnotationTypes().push(_anntype);
+            }
+            _ann.setAnnotationType(_anntype.id);
+            var _tagIds = IriSP._(_anndata.tags).map(function(_title) {
+                var _tags = _source.getTags(true).searchByTitle(_title);
+                if (_tags.length) {
+                    var _tag = _tags[0];
+                }
+                else {
+                    _tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source);
+                    _tag.title = _title;
+                    _source.getTags().push(_tag);
+                }
+                return _tag.id;
+            });
+            _ann.setTags(_tagIds);
+            _ann.setBegin(_anndata.begin);
+            _ann.setEnd(_anndata.end);
+            _ann.creator = _data.meta.creator;
+            _source.getAnnotations().push(_ann);
+        }
+    }
+}
\ No newline at end of file