src/js/serializers/PlatformSerializer.js
branchnew-model
changeset 900 7673d645a8e0
parent 882 61c384dda19e
child 902 14022f1d49ab
--- a/src/js/serializers/PlatformSerializer.js	Fri May 11 15:42:22 2012 +0200
+++ b/src/js/serializers/PlatformSerializer.js	Fri May 11 19:22:13 2012 +0200
@@ -123,6 +123,31 @@
                     })
                 }
             }
+        },
+        mashup : {
+            serialized_name : "mashups",
+            model_name : "mashup",
+            deserializer : function(_data, _source) {
+                console.log("Before");
+                var _res = new IriSP.Model.Mashup(_data.id, _source);
+                _res.title = _data.meta["dc:title"];
+                _res.description = _data.meta["dc:description"];
+                console.log(_data);
+                for (var _i = 0; _i < _data.segments.length; _i++) {
+                    console.log("Adding segment "+_data.segments[_i])
+                    _res.addSegmentById(_data.segments[_i]);
+                }
+                return _res;        
+            },
+            serializer : function(_data, _source) {
+                return {
+                    "dc:title": _data.title,
+                    "dc:description": _data.description,
+                    segments: _data.segments.map(function(_annotation) {
+                        return _source.unNamespace(_id);
+                    })
+                }
+            }
         }
     },
     serialize : function(_source) {