1 | jsx3.util.Logger.getLogger("org.isocat").info("Loading class[org.isocat.data.Basket]"); |
---|
2 | |
---|
3 | /** |
---|
4 | * The Basket class |
---|
5 | * @author Menzo.Windhouwer@mpi.nl |
---|
6 | */ |
---|
7 | jsx3.lang.Class.defineClass("org.isocat.data.Basket", org.isocat.data.DCS, [], function(Basket, Basket_prototype) { |
---|
8 | |
---|
9 | /** |
---|
10 | * The class logger |
---|
11 | */ |
---|
12 | Basket.log = jsx3.util.Logger.getLogger("org.isocat.data.Basket"); |
---|
13 | |
---|
14 | /** |
---|
15 | * The Basket key |
---|
16 | */ |
---|
17 | Basket_prototype._key; |
---|
18 | |
---|
19 | /** |
---|
20 | * The Basket name |
---|
21 | */ |
---|
22 | Basket_prototype._name; |
---|
23 | |
---|
24 | /** |
---|
25 | * The Basket meta CDF record |
---|
26 | */ |
---|
27 | Basket_prototype._meta; |
---|
28 | |
---|
29 | /** |
---|
30 | * The Basket data CDF record list |
---|
31 | */ |
---|
32 | Basket_prototype._data; |
---|
33 | |
---|
34 | /** |
---|
35 | * Constructor |
---|
36 | */ |
---|
37 | Basket_prototype.init = function() { |
---|
38 | org.isocat.data.Basket.log.info("initialize Basket["+this+"]"); |
---|
39 | |
---|
40 | this._key = jsx3.xml.CDF.getKey(); |
---|
41 | org.isocat.data.Basket.log.info("- key["+this._key+"]"); |
---|
42 | |
---|
43 | this._name = ""; |
---|
44 | |
---|
45 | this._meta = null; |
---|
46 | org.isocat.data.Basket.log.info("- metadata["+this._meta+"]"); |
---|
47 | |
---|
48 | this._data = jsx3.xml.CDF.Document.newDocument();; |
---|
49 | org.isocat.data.Basket.log.info("- data["+this._data+"]"); |
---|
50 | |
---|
51 | org.isocat.APP.getCache().setDocument(this.cacheId(),this._data); |
---|
52 | |
---|
53 | org.isocat.data.Basket.log.info("initialized Basket["+this+"]"); |
---|
54 | |
---|
55 | // create message |
---|
56 | var message = { |
---|
57 | jss: "org.pagebus.msg.Message", |
---|
58 | jssv: "1.0.0", |
---|
59 | header: { }, |
---|
60 | body: this |
---|
61 | }; |
---|
62 | |
---|
63 | // publish the message using PageBus |
---|
64 | window.PageBus.publish("org.isocat.data.Basket.init", message); |
---|
65 | }; |
---|
66 | |
---|
67 | Basket_prototype.meta = function() { |
---|
68 | return this._meta; |
---|
69 | } |
---|
70 | |
---|
71 | Basket_prototype.type = function() { |
---|
72 | return "basket"; |
---|
73 | } |
---|
74 | |
---|
75 | Basket_prototype.key = function() { |
---|
76 | return this._key; |
---|
77 | } |
---|
78 | |
---|
79 | Basket_prototype.id = function() { |
---|
80 | return "id:" + this.type() + "-" + this.key(); |
---|
81 | } |
---|
82 | |
---|
83 | Basket_prototype.name = function(n) { |
---|
84 | if (typeof(n) != 'undefined') { |
---|
85 | this._name = n; |
---|
86 | } |
---|
87 | return this._name; |
---|
88 | } |
---|
89 | |
---|
90 | Basket_prototype.mode = function() { |
---|
91 | return "r"; |
---|
92 | } |
---|
93 | |
---|
94 | Basket_prototype.editable = function() { |
---|
95 | return false; |
---|
96 | } |
---|
97 | |
---|
98 | Basket_prototype.persistent = function() { |
---|
99 | return false; |
---|
100 | } |
---|
101 | |
---|
102 | Basket_prototype.cacheId = function() { |
---|
103 | return this.type() + "-" + this.key(); |
---|
104 | } |
---|
105 | |
---|
106 | Basket_prototype.uri = function(format) { |
---|
107 | var url = "http://localhost:8080/isocat/rest/user/"+escape(org.isocat.profile.user())+"/basket"+format; |
---|
108 | url += "?dcif-cleanup=false"; |
---|
109 | var keys = this.data().selectNodes("/data/record/@jsxid"); |
---|
110 | for (var iter = keys.iterator();iter.hasNext();) { |
---|
111 | var key = iter.next(); |
---|
112 | url += "&dc="+key.getValue(); |
---|
113 | } |
---|
114 | return url; |
---|
115 | }; |
---|
116 | |
---|
117 | Basket_prototype.getParams = function(xsl) { |
---|
118 | return {jsxid:'id'}; |
---|
119 | }; |
---|
120 | |
---|
121 | }); |
---|