17 })(this)); |
17 })(this)); |
18 |
18 |
19 } |
19 } |
20 } |
20 } |
21 |
21 |
22 IriSP.Serializer = function(DataLoader) { |
22 /* the base abstract "class" */ |
23 this.DataLoader = DataLoader; |
23 IriSP.Serializer = function(DataLoader, url) { |
|
24 this._DataLoader = DataLoader; |
|
25 this._url = url; |
24 }; |
26 }; |
|
27 |
|
28 IriSP.Serializer.prototype.serialize = function(data) { }; |
|
29 IriSP.Serializer.prototype.deserialize = function(data) {}; |
|
30 |
|
31 IriSP.JSONSerializer = function(DataLoader, url) { |
|
32 IriSP.Serializer.call(this, DataLoader, url); |
|
33 } |
|
34 |
|
35 IriSP.JSONSerializer.prototype = IriSP.Serializer; |
|
36 |
|
37 IriSP.JSONSerializer.prototype.serialize = function(data) { |
|
38 return JSON.stringify(data); |
|
39 }; |
|
40 |
|
41 IriSP.JSONSerializer.prototype.deserialize = function(data) { |
|
42 return JSON.parse(data); |
|
43 }; |
|
44 |
|
45 IriSP.SerializerFactory = function(DataLoader) { |
|
46 this._dataloader = DataLoader; |
|
47 }; |
|
48 |
|
49 IriSP.SerializerFactory.prototype.getSerializer = function(config) { |
|
50 /* This function returns serializer set-up with the correct |
|
51 configuration |
|
52 */ |
|
53 switch(config.metadata.load) { |
|
54 case "json": |
|
55 return new IriSP.JSONSerializer(this._dataloader, config.metadata.src); |
|
56 default: |
|
57 return undefined; |
|
58 } |
|
59 }; |
|
60 |
25 |
61 |
26 IriSP.getMetadata = function() { |
62 IriSP.getMetadata = function() { |
27 |
63 |
28 IriSP.jQuery.ajax({ |
64 IriSP.jQuery.ajax({ |
29 dataType: IriSP.config.metadata.load, |
65 dataType: IriSP.config.metadata.load, |