diff options
Diffstat (limited to 'node_modules/montage/data/mapping.js')
-rw-r--r-- | node_modules/montage/data/mapping.js | 632 |
1 files changed, 632 insertions, 0 deletions
diff --git a/node_modules/montage/data/mapping.js b/node_modules/montage/data/mapping.js new file mode 100644 index 00000000..bdaf6180 --- /dev/null +++ b/node_modules/montage/data/mapping.js | |||
@@ -0,0 +1,632 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/data/mapping | ||
8 | @requires montage/data/blueprint | ||
9 | @requires montage/data/store-connection-information | ||
10 | @requires montage/core/core | ||
11 | @requires montage/core/logger | ||
12 | */ | ||
13 | var Montage = require("montage").Montage; | ||
14 | var Blueprint = require("data/blueprint").Blueprint; | ||
15 | var BlueprintBinder = require("data/blueprint").BlueprintBinder; | ||
16 | var Attribute = require("data/blueprint").Attribute; | ||
17 | var Association = require("data/blueprint").Association; | ||
18 | var StoreConnectionInformation = require("data/store-connection-information").StoreConnectionInformation; | ||
19 | var logger = require("core/logger").logger("mapping"); | ||
20 | /** | ||
21 | * A mapping is an abstract class that is defined by each access store to represent the way to map an object or a property in the backing store. | ||
22 | @class module:montage/data/mapping.Mapping | ||
23 | @extends module:montage/core/core.Montage | ||
24 | */ | ||
25 | var Mapping = exports.Mapping = Montage.create(Montage, /** @lends module:montage/data/mapping.Mapping# */ { | ||
26 | |||
27 | /** | ||
28 | * @private | ||
29 | */ | ||
30 | _owner:{ | ||
31 | serializable:true, | ||
32 | enumerable:false, | ||
33 | value:null | ||
34 | }, | ||
35 | |||
36 | |||
37 | /** | ||
38 | * The owner is the blueprint object (binder, blueprint attribute or association) that is supported by this mapping | ||
39 | */ | ||
40 | owner:{ | ||
41 | get:function () { | ||
42 | return this._owner; | ||
43 | } | ||
44 | }, | ||
45 | |||
46 | /** | ||
47 | * @private | ||
48 | */ | ||
49 | _parent:{ | ||
50 | serializable:true, | ||
51 | enumerable:false, | ||
52 | value:null | ||
53 | }, | ||
54 | |||
55 | /** | ||
56 | * The parent is the mapping object that contains this mapping | ||
57 | */ | ||
58 | parent:{ | ||
59 | get:function () { | ||
60 | return this._parent; | ||
61 | } | ||
62 | }, | ||
63 | |||
64 | /** | ||
65 | Name of the mapping. The name is used to identify a mapping. | ||
66 | @function | ||
67 | @returns {String} this.parent.name | ||
68 | */ | ||
69 | name:{ | ||
70 | get:function () { | ||
71 | return this.parent.name; | ||
72 | } | ||
73 | }, | ||
74 | |||
75 | |||
76 | /** | ||
77 | Store module Id associated with this binder mapping. | ||
78 | @type {Property} | ||
79 | @default {ID} montage/data/store | ||
80 | */ | ||
81 | storeModuleId:{ | ||
82 | get:function () { | ||
83 | return this.parent.storeModuleId; | ||
84 | } | ||
85 | }, | ||
86 | |||
87 | /** | ||
88 | Store prototype name associated with this binder mapping. | ||
89 | @type {Property} | ||
90 | @default {String} "Store" | ||
91 | */ | ||
92 | storePrototypeName:{ | ||
93 | get:function () { | ||
94 | return this.parent.storePrototypeName; | ||
95 | } | ||
96 | }, | ||
97 | |||
98 | |||
99 | /** | ||
100 | Initialize a newly allocated mapping. | ||
101 | @function | ||
102 | @param {owner} owner of this mapping | ||
103 | @param {parent} container of this mapping | ||
104 | @returns itself | ||
105 | */ | ||
106 | initWithOwnerAndParent:{ | ||
107 | value:function (owner, parent) { | ||
108 | this._owner = owner; | ||
109 | this._parent = parent; | ||
110 | return this; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | }); | ||
115 | |||
116 | /** | ||
117 | * A mapping folder is a group of binder mappings that all relate to the same binder.<br/> | ||
118 | * Together they provide exactly one mapping for each blueprint, attribute and association described in the binder.<br/> | ||
119 | * | ||
120 | * @class module:montage/data/mapping.MappingFolder | ||
121 | * @extends module:montage/data/mapping.Mapping | ||
122 | */ | ||
123 | var MappingFolder = exports.MappingFolder = Montage.create(Mapping, /** @lends module:montage/data/mapping.MappingFolder# */ { | ||
124 | |||
125 | /** | ||
126 | @private | ||
127 | */ | ||
128 | _name:{ | ||
129 | serializable:true, | ||
130 | enumerable:false, | ||
131 | value:null | ||
132 | }, | ||
133 | |||
134 | /** | ||
135 | Name of the mapping. The name is used to identify a mapping. | ||
136 | @function | ||
137 | @returns {String} this._name | ||
138 | */ | ||
139 | name:{ | ||
140 | get:function () { | ||
141 | return this._name; | ||
142 | } | ||
143 | }, | ||
144 | |||
145 | /** | ||
146 | Binder that owns this mapping. | ||
147 | @type {Property} | ||
148 | @default {ID} montage/data/blueprint.BlueprintBinder | ||
149 | */ | ||
150 | binder:{ | ||
151 | get:function () { | ||
152 | return this._owner; | ||
153 | } | ||
154 | }, | ||
155 | |||
156 | /** | ||
157 | Initialize a newly allocated mapping. | ||
158 | @function | ||
159 | @param {binder} owner of this mapping | ||
160 | @param {name} name of this mapping. The name should be unique for a binder. | ||
161 | @returns itself | ||
162 | */ | ||
163 | initWithBinderAndName:{ | ||
164 | value:function (binder, name) { | ||
165 | var newMapping = this.initWithOwnerAndParent(binder, null); | ||
166 | newMapping._name = name; | ||
167 | return newMapping; | ||
168 | } | ||
169 | }, | ||
170 | |||
171 | /** | ||
172 | The identifier is the name of the blueprint, dot, the name of the | ||
173 | attribute, and is used to make the serialization of attributes more | ||
174 | readable. | ||
175 | @type {Property} | ||
176 | @default {String} this.name | ||
177 | */ | ||
178 | identifier:{ | ||
179 | get:function () { | ||
180 | return [ | ||
181 | this.name, | ||
182 | this.owner.name | ||
183 | ].join("_"); | ||
184 | } | ||
185 | }, | ||
186 | |||
187 | /** | ||
188 | @private | ||
189 | */ | ||
190 | _mappings:{ | ||
191 | serializable:true, | ||
192 | enumerable:false, | ||
193 | distinct:true, | ||
194 | value:new Array(5) | ||
195 | }, | ||
196 | |||
197 | /** | ||
198 | @private | ||
199 | */ | ||
200 | _mappingForStoreId:{ | ||
201 | value:new Object(), | ||
202 | serializable:false, | ||
203 | distinct:true, | ||
204 | enumerable:false, | ||
205 | writable:false | ||
206 | }, | ||
207 | |||
208 | deserializedFromSerialization:{ | ||
209 | value:function () { | ||
210 | var aMapping, index; | ||
211 | for (index = 0; typeof (aMapping = this._mappings[index]) !== "undefined"; index++) { | ||
212 | var key = [ | ||
213 | aMapping.storePrototypeName, | ||
214 | aMapping.storeModuleId | ||
215 | ].join("_"); | ||
216 | this._mappingForStoreId[key] = aMapping; | ||
217 | } | ||
218 | } | ||
219 | }, | ||
220 | |||
221 | /** | ||
222 | List of mappings attached to this object. | ||
223 | @function | ||
224 | @returns mappings | ||
225 | */ | ||
226 | mappings:{ | ||
227 | get:function () { | ||
228 | return this._mappings; | ||
229 | } | ||
230 | }, | ||
231 | |||
232 | /** | ||
233 | Add a mapping to the list of mappings. | ||
234 | @function | ||
235 | @param {mapping} mapping to add. | ||
236 | @returns mapping | ||
237 | */ | ||
238 | addMapping:{ | ||
239 | value:function (mapping) { | ||
240 | if (mapping !== null) { | ||
241 | var index = |