diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/data | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/data')
27 files changed, 7054 insertions, 0 deletions
diff --git a/node_modules/montage/data/blueprint.js b/node_modules/montage/data/blueprint.js new file mode 100755 index 00000000..b3a66167 --- /dev/null +++ b/node_modules/montage/data/blueprint.js | |||
@@ -0,0 +1,1062 @@ | |||
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/blueprint | ||
8 | @requires montage/core/core | ||
9 | @requires montage/data/store | ||
10 | @requires montage/data/objectid | ||
11 | @requires data/query | ||
12 | @requires core/exception | ||
13 | @requires data/objectproperty | ||
14 | @requires core/promise | ||
15 | @requires core/logger | ||
16 | */ | ||
17 | var Montage = require("montage").Montage; | ||
18 | var Store = require("data/store").Store; | ||
19 | var TemporaryObjectId = require("data/objectid").TemporaryObjectId; | ||
20 | var Query = require("data/query").Query; | ||
21 | var Exception = require("core/exception").Exception; | ||
22 | var ObjectProperty = require("data/objectproperty").ObjectProperty; | ||
23 | var Promise = require("core/promise").Promise; | ||
24 | var logger = require("core/logger").logger("blueprint"); | ||
25 | /** | ||
26 | @class module:montage/data/blueprint.BlueprintBinder | ||
27 | @classdesc A blueprint binder is a collection of of blueprints for a specific access type. It also includes the connection information. | ||
28 | @extends module:montage/core/core.Montage | ||
29 | */ | ||
30 | var BlueprintBinder = exports.BlueprintBinder = Montage.create(Montage,/** @lends module:montage/data/blueprint.BlueprintBinder# */ { | ||
31 | |||
32 | /** | ||
33 | Description TODO | ||
34 | @private | ||
35 | */ | ||
36 | _blueprintForPrototypeTable: { | ||
37 | value: {}, | ||
38 | serializable: false, | ||
39 | distinct: true, | ||
40 | enumerable: false, | ||
41 | writable: false | ||
42 | }, | ||
43 | /** | ||
44 | Description TODO | ||
45 | @type {Property} | ||
46 | @default {Table} {} | ||
47 | */ | ||
48 | restrictionsTable: { | ||
49 | value: {}, | ||
50 | serializable: true, | ||
51 | distinct: true, | ||
52 | enumerable: false, | ||
53 | writable: false | ||
54 | }, | ||
55 | /** | ||
56 | Description TODO | ||
57 | @type {Property} | ||
58 | @default {String} null | ||
59 | */ | ||
60 | name: { | ||
61 | value: null, | ||
62 | serializable: true | ||
63 | }, | ||
64 | /** | ||
65 | Description TODO | ||
66 | @function | ||
67 | @param {String} name TODO | ||
68 | @returns itself | ||
69 | */ | ||
70 | initWithName: { | ||
71 | value: function(name) { | ||
72 | this.name = (name !== null ? name : "default"); | ||
73 | return this; | ||
74 | } | ||
75 | }, | ||
76 | /** | ||
77 | Description TODO | ||
78 | @type {Property} | ||
79 | @default {Array} new Array(30) | ||
80 | */ | ||
81 | blueprints: { | ||
82 | serializable: true, | ||
83 | distinct: true, | ||
84 | writable: false, | ||
85 | value: new Array(30) | ||
86 | }, | ||
87 | /** | ||
88 | Description TODO | ||
89 | @function | ||
90 | @param {Array} blueprint TODO | ||
91 | @returns blueprint | ||
92 | */ | ||
93 | addBlueprint: { | ||
94 | value: function(blueprint) { | ||
95 | if (blueprint !== null) { | ||
96 | var index = this.blueprints.indexOf(blueprint); | ||
97 | if (index < 0) { | ||
98 | if (blueprint.binder !== null) { | ||
99 | blueprint.binder.removeBlueprint(blueprint); | ||
100 | } | ||
101 | this.blueprints.push(blueprint); | ||
102 | blueprint.binder = this; | ||
103 | // | ||
104 | var key = blueprint.moduleId + "." + blueprint.prototypeName; | ||
105 | this._blueprintForPrototypeTable[key] = blueprint; | ||
106 | } | ||
107 | } | ||
108 | return blueprint; | ||
109 | } | ||
110 | }, | ||
111 | /** | ||
112 | Description TODO | ||
113 | @function | ||
114 | @param {Array} blueprint TODO | ||
115 | @returns blueprint | ||
116 | */ | ||
117 | removeBlueprint: { | ||
118 | value: function(blueprint) { | ||
119 | if (blueprint !== null) { | ||
120 | var index = this.blueprints.indexOf(blueprint); | ||
121 | if (index >= 0) { | ||
122 | this.blueprints.splice(index, 1); | ||
123 | blueprint.binder = null; | ||
124 | // Remove the cached entry | ||
125 | var key = blueprint.moduleId + "." + blueprint.prototypeName; | ||
126 | delete this._blueprintForPrototypeTable[key]; | ||
127 | } | ||
128 | } | ||
129 | return blueprint; | ||
130 | } | ||
131 | }, | ||
132 | /** | ||
133 | Description TODO | ||
134 | @function | ||
135 | @param {String} name TODO | ||
136 | @param {String} moduleID TODO | ||
137 | @returns this.addBlueprint(this.createBlueprint().initWithNameAndModuleId(name, moduleId)) | ||
138 | */ | ||
139 | addBlueprintNamed : { | ||
140 | value: function(name, moduleId) { | ||
141 | return this.addBlueprint(this.createBlueprint().initWithNameAndModuleId(name, moduleId)); | ||
142 | } | ||
143 | }, | ||
144 | /** | ||
145 | Description TODO | ||
146 | @function | ||
147 | @returns Blueprint.create() | ||
148 | */ | ||
149 | createBlueprint: { | ||
150 | value: function() { | ||
151 | return Blueprint.create(); | ||
152 | } | ||
153 | }, | ||
154 | /** | ||
155 | Description TODO | ||
156 | @function | ||
157 | @param {String} name TODO | ||
158 | @param {Selector} defaultSelector TODO | ||
159 | @returns restriction | ||
160 | */ | ||
161 | addRestriction: { | ||
162 | value: function(name, defaultSelector) { | ||
163 | var restriction = null; | ||
164 | if (name != null && defaultSelector != null) { | ||
165 | restriction = this.restrictionsTable[name] = defaultSelector; | ||
166 | } | ||
167 | return restriction; | ||
168 | } | ||
169 | }, | ||
170 | /** | ||
171 | Description TODO | ||
172 | @function | ||
173 | @param {String} name TODO | ||
174 | @returns restriction | ||
175 | */ | ||
176 | removeRestriction: { | ||
177 | value: function(name) { | ||
178 | if (name !== null) { | ||
179 | var restriction = this.restrictionsTable[name] | ||
180 | if (restriction != null) { | ||
181 | delete restriction; | ||
182 | } | ||
183 | } | ||
184 | return restriction; | ||
185 | } | ||
186 | }, | ||