| author | veltr |
| Wed, 11 Apr 2012 16:39:03 +0200 | |
| branch | new-model |
| changeset 856 | 41c574c807d1 |
| child 858 | ad1ffe0c0955 |
| permissions | -rw-r--r-- |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
1 |
if (typeof IriSP.serializers === "undefined") { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
2 |
IriSP.serializers = {} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
3 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
4 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
5 |
IriSP.serializers.platform = { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
6 |
deSerialize : function(_data, _container) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
7 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
8 |
var _types = [ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
9 |
{ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
10 |
serialized_name : "medias", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
11 |
model_name : "media", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
12 |
deserializer : function(_data) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
13 |
var _res = new IriSP.Model.Media(_data.id, _data); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
14 |
_res.url = _data.href; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
15 |
_res.title = _data.meta["dc:title"]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
16 |
_res.description = _data.meta["dc:description"]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
17 |
_res.setDuration(_data.meta["dc:duration"]); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
18 |
return _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
19 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
20 |
}, |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
21 |
{ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
22 |
serialized_name : "annotation-types", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
23 |
model_name : "annotationType", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
24 |
deserializer : function(_data) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
25 |
var _res = new IriSP.Model.AnnotationType(_data.id, _data); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
26 |
_res.title = _data["dc:title"]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
27 |
_res.description = _data["dc:description"]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
28 |
return _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
29 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
30 |
}, |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
31 |
{ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
32 |
serialized_name : "annotations", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
33 |
model_name : "annotation", |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
34 |
deserializer : function(_data) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
35 |
var _res = new IriSP.Model.Annotation(_data.id, _data); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
36 |
_res.title = _data.content.title; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
37 |
_res.description = _data.content.description; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
38 |
_res.setMedia(_data.media, _container); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
39 |
_res.setAnnotationType(_data.meta["id-ref"], _container); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
40 |
_res.setBegin(_data.begin); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
41 |
_res.setEnd(_data.end); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
42 |
return _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
43 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
44 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
45 |
]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
46 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
47 |
IriSP._(_types).each(function(_type) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
48 |
if (typeof _data[_type.serialized_name] !== "undefined") { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
49 |
var _list = new IriSP.Model.List(); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
50 |
IriSP._(_data[_type.serialized_name]).each(function(_el) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
51 |
_list.addElement(_type.deserializer(_el)); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
52 |
}); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
53 |
_container.addList(_type.model_name, _list); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
54 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
55 |
}); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
56 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
57 |
if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
58 |
_container.setCurrentMediaById(_data.meta.main_media["id-ref"]); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
59 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
60 |
_container.setDefaultCurrentMedia(); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
61 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
diff
changeset
|
62 |
} |