Commit 42e2e019dbb600d7f98c916536b439b6340b4b60
1 parent
dd143fd0
Exists in
master
and in
100 other branches
Next step for cache rework
Showing
12 changed files
with
290 additions
and
282 deletions
Show diff stats
js/app/models/InteractiveNode.js
1 | -/** | 1 | +/** |
2 | * Project : AMDA-NG4 | 2 | * Project : AMDA-NG4 |
3 | * Name : InteractiveNode.js | 3 | * Name : InteractiveNode.js |
4 | * @class amdaModel.InteractiveNode | 4 | * @class amdaModel.InteractiveNode |
@@ -14,10 +14,10 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -14,10 +14,10 @@ Ext.define('amdaModel.InteractiveNode', { | ||
14 | requires: [ | 14 | requires: [ |
15 | 'amdaPlotObj.PlotRequestObject' | 15 | 'amdaPlotObj.PlotRequestObject' |
16 | ], | 16 | ], |
17 | - | ||
18 | - fields: [ | 17 | + |
18 | + fields: [ | ||
19 | {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, | 19 | {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, |
20 | - {name: 'objectDataModel', type: 'string', persist: false}, | 20 | + {name: 'objectDataModel', type: 'string', persist: false}, |
21 | {name: 'object', type: 'object', persist: false}, | 21 | {name: 'object', type: 'object', persist: false}, |
22 | {name: 'moduleId', type: 'string', persist: false}, | 22 | {name: 'moduleId', type: 'string', persist: false}, |
23 | {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, | 23 | {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, |
@@ -28,7 +28,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -28,7 +28,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
28 | statics: { | 28 | statics: { |
29 | preloadNodes : function(node,onready) | 29 | preloadNodes : function(node,onready) |
30 | { | 30 | { |
31 | - var me = this; | 31 | + var me = this; |
32 | var nodesToLoad = new Array(); | 32 | var nodesToLoad = new Array(); |
33 | nodesToLoad.push(node); | 33 | nodesToLoad.push(node); |
34 | this.preloadTreeNode(node, nodesToLoad, function (node) | 34 | this.preloadTreeNode(node, nodesToLoad, function (node) |
@@ -38,7 +38,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -38,7 +38,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
38 | { | 38 | { |
39 | if (!element.isLoaded()) | 39 | if (!element.isLoaded()) |
40 | isFinish = false; | 40 | isFinish = false; |
41 | - }); | 41 | + }); |
42 | if (isFinish && onready) | 42 | if (isFinish && onready) |
43 | onready.call(); | 43 | onready.call(); |
44 | }); | 44 | }); |
@@ -47,29 +47,29 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -47,29 +47,29 @@ Ext.define('amdaModel.InteractiveNode', { | ||
47 | preloadTreeNode : function(node, nodesToLoad, onloaded) | 47 | preloadTreeNode : function(node, nodesToLoad, onloaded) |
48 | { | 48 | { |
49 | var me = this; | 49 | var me = this; |
50 | - | 50 | + |
51 | if (node.isLoaded()) | 51 | if (node.isLoaded()) |
52 | { | 52 | { |
53 | node.eachChild(function(n) | 53 | node.eachChild(function(n) |
54 | - { | 54 | + { |
55 | if (!n.isLoaded() && !n.isRealLeaf()) | 55 | if (!n.isLoaded() && !n.isRealLeaf()) |
56 | { | 56 | { |
57 | nodesToLoad.push(n); | 57 | nodesToLoad.push(n); |
58 | me.preloadTreeNode(n,nodesToLoad,onloaded); | 58 | me.preloadTreeNode(n,nodesToLoad,onloaded); |
59 | } | 59 | } |
60 | }); | 60 | }); |
61 | - | 61 | + |
62 | if (onloaded) | 62 | if (onloaded) |
63 | onloaded.call(me,node); | 63 | onloaded.call(me,node); |
64 | return; | 64 | return; |
65 | - } | ||
66 | - | 65 | + } |
66 | + | ||
67 | node.store.load({ | 67 | node.store.load({ |
68 | - node : node, | 68 | + node : node, |
69 | callback : function(records, operation, successful) | 69 | callback : function(records, operation, successful) |
70 | { | 70 | { |
71 | records.forEach(function (record) | 71 | records.forEach(function (record) |
72 | - { | 72 | + { |
73 | if (!record.isLoaded() && !record.isRealLeaf()) | 73 | if (!record.isLoaded() && !record.isRealLeaf()) |
74 | { | 74 | { |
75 | nodesToLoad.push(record); | 75 | nodesToLoad.push(record); |
@@ -82,21 +82,21 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -82,21 +82,21 @@ Ext.define('amdaModel.InteractiveNode', { | ||
82 | }); | 82 | }); |
83 | } | 83 | } |
84 | }, | 84 | }, |
85 | - | 85 | + |
86 | onReady : null, | 86 | onReady : null, |
87 | - | 87 | + |
88 | constructor : function(config) | 88 | constructor : function(config) |
89 | { | 89 | { |
90 | - this.callParent(arguments); | ||
91 | - this.set('nodeType',this.self.nodeType); | 90 | + this.callParent(arguments); |
91 | + this.set('nodeType',this.self.nodeType); | ||
92 | this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | 92 | this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); |
93 | if (this.get('id')) { // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? | 93 | if (this.get('id')) { // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? |
94 | - // if id of this node have root category suffix | 94 | + // if id of this node have root category suffix |
95 | if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) | 95 | if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) |
96 | { | 96 | { |
97 | // set the expanded property to true | 97 | // set the expanded property to true |
98 | this.set('expanded',true); | 98 | this.set('expanded',true); |
99 | - } | 99 | + } |
100 | } | 100 | } |
101 | }, | 101 | }, |
102 | 102 | ||
@@ -104,7 +104,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -104,7 +104,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
104 | { | 104 | { |
105 | return this.isLeaf(); | 105 | return this.isLeaf(); |
106 | }, | 106 | }, |
107 | - | 107 | + |
108 | /** | 108 | /** |
109 | * this method is overriden into ExecutableNode to return true | 109 | * this method is overriden into ExecutableNode to return true |
110 | */ | 110 | */ |
@@ -116,7 +116,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -116,7 +116,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
116 | /** | 116 | /** |
117 | * open Module with THIS NODE | 117 | * open Module with THIS NODE |
118 | */ | 118 | */ |
119 | - editInModule : function (contextNode, onReady) | 119 | + editInModule : function (contextNode, onReady) |
120 | { | 120 | { |
121 | // set the contextNode of this node | 121 | // set the contextNode of this node |
122 | this.set('contextNode',contextNode); | 122 | this.set('contextNode',contextNode); |
@@ -124,50 +124,50 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -124,50 +124,50 @@ Ext.define('amdaModel.InteractiveNode', { | ||
124 | var me = this; | 124 | var me = this; |
125 | myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { | 125 | myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { |
126 | // If the node to edit is not already linked to this module | 126 | // If the node to edit is not already linked to this module |
127 | - if (module.getLinkedNode() != me) | 127 | + if (module.getLinkedNode() != me) |
128 | { | 128 | { |
129 | // set relative node into parameter Module | 129 | // set relative node into parameter Module |
130 | - module.setLinkedNode(me); | ||
131 | - if (contextNode==null) | 130 | + module.setLinkedNode(me); |
131 | + if (contextNode==null) | ||
132 | { | 132 | { |
133 | // set the root node as contextNode | 133 | // set the root node as contextNode |
134 | contextNode = me.getRootNode(); | 134 | contextNode = me.getRootNode(); |
135 | - } | ||
136 | - module.setContextNode(contextNode); | ||
137 | - | 135 | + } |
136 | + module.setContextNode(contextNode); | ||
137 | + | ||
138 | } else if (module.getLinkedNode() != null){ | 138 | } else if (module.getLinkedNode() != null){ |
139 | //TODO the node to edit is already edited | 139 | //TODO the node to edit is already edited |
140 | // myDesktopApp.warningMsg('This object is being edited'); | 140 | // myDesktopApp.warningMsg('This object is being edited'); |
141 | //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' | 141 | //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' |
142 | //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' | 142 | //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' |
143 | } | 143 | } |
144 | - // Opening parameter window | ||
145 | - module.createWindow(onReady); | ||
146 | - }); | 144 | + // Opening parameter window |
145 | + module.createWindow(onReady); | ||
146 | + }); | ||
147 | }, | 147 | }, |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * Method to rename the workspace node | 150 | * Method to rename the workspace node |
151 | */ | 151 | */ |
152 | - rename: function(value,callBackFn) | ||
153 | - { | 152 | + rename: function(value,callBackFn) |
153 | + { | ||
154 | var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; | 154 | var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; |
155 | - AmdaAction.renameObject(dataToSend, callBackFn); | 155 | + AmdaAction.renameObject(dataToSend, callBackFn); |
156 | }, | 156 | }, |
157 | - | 157 | + |
158 | /** | 158 | /** |
159 | * Method to rename the workspace node when D&D | 159 | * Method to rename the workspace node when D&D |
160 | */ | 160 | */ |
161 | - renameDD: function(parentId, callBackFn) | ||
162 | - { | 161 | + renameDD: function(parentId, callBackFn) |
162 | + { | ||
163 | var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; | 163 | var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; |
164 | AmdaAction.renameObject(dataToSend, callBackFn); | 164 | AmdaAction.renameObject(dataToSend, callBackFn); |
165 | }, | 165 | }, |
166 | - | 166 | + |
167 | /** | 167 | /** |
168 | * validation method on name (used in module forms) | 168 | * validation method on name (used in module forms) |
169 | * @param name the name to validate | 169 | * @param name the name to validate |
170 | -* @returns | 170 | +* @returns |
171 | */ | 171 | */ |
172 | isValidName : function(name, callBackFn) | 172 | isValidName : function(name, callBackFn) |
173 | { | 173 | { |
@@ -180,42 +180,42 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -180,42 +180,42 @@ Ext.define('amdaModel.InteractiveNode', { | ||
180 | * node linked to a Module | 180 | * node linked to a Module |
181 | */ | 181 | */ |
182 | update : function(opt) | 182 | update : function(opt) |
183 | - { | 183 | + { |
184 | AmdaAction.modifyObject(this.get('object').getJsonValues(true), function(res,e){ | 184 | AmdaAction.modifyObject(this.get('object').getJsonValues(true), function(res,e){ |
185 | - | 185 | + |
186 | if(e.status) { | 186 | if(e.status) { |
187 | - if (res.id) { | 187 | + if (res.id) { |
188 | if (!this.get('contextNode')) { | 188 | if (!this.get('contextNode')) { |
189 | // set the root node of 'Derived Parameters' tree as contextNode | 189 | // set the root node of 'Derived Parameters' tree as contextNode |
190 | this.set('contextNode',this.getRootNode()); | 190 | this.set('contextNode',this.getRootNode()); |
191 | } | 191 | } |
192 | this.get('contextNode').expand(false,false); | 192 | this.get('contextNode').expand(false,false); |
193 | this.myGetOwnerTree().getSelectionModel().select(this); | 193 | this.myGetOwnerTree().getSelectionModel().select(this); |
194 | - | 194 | + |
195 | if (opt) | 195 | if (opt) |
196 | { | 196 | { |
197 | 197 | ||
198 | var scope = opt.scope ? opt.scope : this; | 198 | var scope = opt.scope ? opt.scope : this; |
199 | if (opt.callback) | 199 | if (opt.callback) |
200 | opt.callback.call(scope,'update'); | 200 | opt.callback.call(scope,'update'); |
201 | - | ||
202 | - } | ||
203 | - if(opt.notDisplayMsg){ | ||
204 | - //do nothing | ||
205 | - }else{ | ||
206 | - Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); | ||
207 | - } | 201 | + if(opt.notDisplayMsg){ |
202 | + //do nothing | ||
203 | + }else{ | ||
204 | + Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); | ||
205 | + } | ||
206 | + | ||
207 | + } | ||
208 | 208 | ||
209 | // fix the modifications for object | 209 | // fix the modifications for object |
210 | this.get('object').commit(); | 210 | this.get('object').commit(); |
211 | - | 211 | + |
212 | if (res.info) { | 212 | if (res.info) { |
213 | this.set('info',res.info); | 213 | this.set('info',res.info); |
214 | } | 214 | } |
215 | - | 215 | + |
216 | // myDataParam and Parameter special update | 216 | // myDataParam and Parameter special update |
217 | this.specialUpdate(res, false); | 217 | this.specialUpdate(res, false); |
218 | - | 218 | + |
219 | // reload object into the view of corresponding Module | 219 | // reload object into the view of corresponding Module |
220 | var me = this; | 220 | var me = this; |
221 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { | 221 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { |
@@ -224,7 +224,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -224,7 +224,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
224 | } | 224 | } |
225 | else { | 225 | else { |
226 | //TODO proper error message handling | 226 | //TODO proper error message handling |
227 | - // error code from server; but e.status==true | 227 | + // error code from server; but e.status==true |
228 | // revert all modifications since last load or commit | 228 | // revert all modifications since last load or commit |
229 | this.get('object').reject(); | 229 | this.get('object').reject(); |
230 | myDesktopApp.errorMsg(res.error); | 230 | myDesktopApp.errorMsg(res.error); |
@@ -233,7 +233,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -233,7 +233,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
233 | else { | 233 | else { |
234 | // revert all modifications since last load or commit | 234 | // revert all modifications since last load or commit |
235 | this.get('object').reject(); | 235 | this.get('object').reject(); |
236 | - myDesktopApp.errorMsg(e.message); | 236 | + myDesktopApp.errorMsg(e.message); |
237 | } | 237 | } |
238 | },this); | 238 | },this); |
239 | }, | 239 | }, |
@@ -242,30 +242,30 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -242,30 +242,30 @@ Ext.define('amdaModel.InteractiveNode', { | ||
242 | * Method to create a new AmdaObject by server side and create the workspace node linked to a Module | 242 | * Method to create a new AmdaObject by server side and create the workspace node linked to a Module |
243 | * under its contextNode or the root node corresponding to this nodeType category | 243 | * under its contextNode or the root node corresponding to this nodeType category |
244 | */ | 244 | */ |
245 | - create : function(opt) | 245 | + create : function(opt) |
246 | { | 246 | { |
247 | if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { | 247 | if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { |
248 | // set the root node of 'Derived Parameters' tree as contextNode | 248 | // set the root node of 'Derived Parameters' tree as contextNode |
249 | this.set('contextNode',this.getRootNode()); | 249 | this.set('contextNode',this.getRootNode()); |
250 | - } | ||
251 | - // call the Ext.Direct method to create parameter | ||
252 | - AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ | 250 | + } |
251 | + // call the Ext.Direct method to create parameter | ||
252 | + AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ | ||
253 | //success | 253 | //success |
254 | - if(e.status) | ||
255 | - { | 254 | + if(e.status) |
255 | + { | ||
256 | // if correct response received | 256 | // if correct response received |
257 | if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { | 257 | if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { |
258 | // 'save as' case ; delete old node if it exists | 258 | // 'save as' case ; delete old node if it exists |
259 | - if (this.toRename) | 259 | + if (this.toRename) |
260 | { | 260 | { |
261 | - this.toRename = false; | 261 | + this.toRename = false; |
262 | var myRoot = this.getRootNode(); | 262 | var myRoot = this.getRootNode(); |
263 | // search the same named node to override | 263 | // search the same named node to override |
264 | var updateNode = myRoot.findChild('text',this.get('object').get('name'),true); | 264 | var updateNode = myRoot.findChild('text',this.get('object').get('name'),true); |
265 | // destroy the overrided node | 265 | // destroy the overrided node |
266 | updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... | 266 | updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... |
267 | - updateNode.destroy(); | ||
268 | - } | 267 | + updateNode.destroy(); |
268 | + } | ||
269 | // set text of this node | 269 | // set text of this node |
270 | this.set('text',this.get('object').get('name')); | 270 | this.set('text',this.get('object').get('name')); |
271 | 271 | ||
@@ -274,52 +274,52 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -274,52 +274,52 @@ Ext.define('amdaModel.InteractiveNode', { | ||
274 | this.internalId = res.id; | 274 | this.internalId = res.id; |
275 | 275 | ||
276 | // set id of node's object | 276 | // set id of node's object |
277 | - this.get('object').set('id',res.id); | 277 | + this.get('object').set('id',res.id); |
278 | if (res.created){ | 278 | if (res.created){ |
279 | // set the created date | 279 | // set the created date |
280 | this.get('object').set('created',res.created); | 280 | this.get('object').set('created',res.created); |
281 | } | 281 | } |
282 | - | 282 | + |
283 | if (res.info){ | 283 | if (res.info){ |
284 | // set the tooltip | 284 | // set the tooltip |
285 | this.set('info',res.info); | 285 | this.set('info',res.info); |
286 | } | 286 | } |
287 | //set globalStart & global Stop to be used for time selection | 287 | //set globalStart & global Stop to be used for time selection |
288 | this.specialUpdate(res, true); | 288 | this.specialUpdate(res, true); |
289 | - | 289 | + |
290 | //TODO do we need this commission ??? | 290 | //TODO do we need this commission ??? |
291 | // fix the modifications for object | 291 | // fix the modifications for object |
292 | - this.get('object').commit(); | 292 | + this.get('object').commit(); |
293 | 293 | ||
294 | // if ownerTree panel is not active | 294 | // if ownerTree panel is not active |
295 | if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()) { | 295 | if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()) { |
296 | // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view | 296 | // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view |
297 | - this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); | 297 | + this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); |
298 | } | 298 | } |
299 | if(opt.notDisplayMsg){ | 299 | if(opt.notDisplayMsg){ |
300 | //do nothing | 300 | //do nothing |
301 | - }else{ | ||
302 | - Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); | 301 | + }else{ |
302 | + Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); | ||
303 | } | 303 | } |
304 | - | 304 | + |
305 | // expand the contextNode | 305 | // expand the contextNode |
306 | this.get('contextNode').expand(false, function() { | 306 | this.get('contextNode').expand(false, function() { |
307 | if (!this.get('contextNode').findChild('text',this.get('text'))) { | 307 | if (!this.get('contextNode').findChild('text',this.get('text'))) { |
308 | - // create node in tree as child of contextNode | ||
309 | - this.get('contextNode').appendChild(this); | 308 | + // create node in tree as child of contextNode |
309 | + this.get('contextNode').appendChild(this); | ||
310 | } | 310 | } |
311 | - // select the new node | 311 | + // select the new node |
312 | this.myGetOwnerTree().getSelectionModel().select(this); | 312 | this.myGetOwnerTree().getSelectionModel().select(this); |
313 | if (opt) { | 313 | if (opt) { |
314 | var scope = opt.scope ? opt.scope : this; | 314 | var scope = opt.scope ? opt.scope : this; |
315 | if (opt.callback) | 315 | if (opt.callback) |
316 | opt.callback.call(scope,'create'); | 316 | opt.callback.call(scope,'create'); |
317 | - } | 317 | + } |
318 | }, this); | 318 | }, this); |
319 | - } | 319 | + } |
320 | // error code from server; but e.status==true | 320 | // error code from server; but e.status==true |
321 | else { | 321 | else { |
322 | - myDesktopApp.errorMsg(res.error); | 322 | + myDesktopApp.errorMsg(res.error); |
323 | // revert all modifications since last load or commit | 323 | // revert all modifications since last load or commit |
324 | this.get('object').reject(); | 324 | this.get('object').reject(); |
325 | } | 325 | } |
@@ -331,14 +331,14 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -331,14 +331,14 @@ Ext.define('amdaModel.InteractiveNode', { | ||
331 | //TODO: this.destroy(); | 331 | //TODO: this.destroy(); |
332 | myDesktopApp.errorMsg(e.message); | 332 | myDesktopApp.errorMsg(e.message); |
333 | } | 333 | } |
334 | - },this); | 334 | + },this); |
335 | }, | 335 | }, |
336 | 336 | ||
337 | specialUpdate : function() {}, | 337 | specialUpdate : function() {}, |
338 | /** | 338 | /** |
339 | * Generic part of Context Menu | 339 | * Generic part of Context Menu |
340 | -* | ||
341 | -*/ | 340 | +* |
341 | +*/ | ||
342 | allMenuItems : function() { | 342 | allMenuItems : function() { |
343 | var src = this.self.objectName; | 343 | var src = this.self.objectName; |
344 | var menuItems = | 344 | var menuItems = |
@@ -383,14 +383,14 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -383,14 +383,14 @@ Ext.define('amdaModel.InteractiveNode', { | ||
383 | return menuMulti; | 383 | return menuMulti; |
384 | }, | 384 | }, |
385 | 385 | ||
386 | - getAllContextMenuItems: function(){ | ||
387 | - return this.allMenuItems(); | 386 | + getAllContextMenuItems: function(){ |
387 | + return this.allMenuItems(); | ||
388 | }, | 388 | }, |
389 | 389 | ||
390 | getMultiContextMenuItems: function(){ | 390 | getMultiContextMenuItems: function(){ |
391 | return this.allMenuMultiItems(); | 391 | return this.allMenuMultiItems(); |
392 | }, | 392 | }, |
393 | - | 393 | + |
394 | /** | 394 | /** |
395 | * default implementation | 395 | * default implementation |
396 | * no menu display if there's no override of this function | 396 | * no menu display if there's no override of this function |
@@ -398,99 +398,99 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -398,99 +398,99 @@ Ext.define('amdaModel.InteractiveNode', { | ||
398 | getMultiContextMenuItems: function(){ | 398 | getMultiContextMenuItems: function(){ |
399 | return null; | 399 | return null; |
400 | }, | 400 | }, |
401 | - | 401 | + |
402 | /** | 402 | /** |
403 | * Context Menu Actions | 403 | * Context Menu Actions |
404 | -* | ||
405 | -*/ | 404 | +* |
405 | +*/ | ||
406 | onMenuItemClick : function(menu,item,event) { | 406 | onMenuItemClick : function(menu,item,event) { |
407 | // fnId parsing : | 407 | // fnId parsing : |
408 | var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); | 408 | var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); |
409 | 409 | ||
410 | switch (fnId) { | 410 | switch (fnId) { |
411 | case 'deleteNode': | 411 | case 'deleteNode': |
412 | - this.deleteNode(); | 412 | + this.deleteNode(); |
413 | break; | 413 | break; |
414 | case 'createDir': | 414 | case 'createDir': |
415 | - this.createDir(); | 415 | + this.createDir(); |
416 | break; | 416 | break; |
417 | case 'createLeaf': | 417 | case 'createLeaf': |
418 | this.createLeaf(this); | 418 | this.createLeaf(this); |
419 | - break; | 419 | + break; |
420 | case 'renameNode': | 420 | case 'renameNode': |
421 | this.renameNode(false); | 421 | this.renameNode(false); |
422 | break; | 422 | break; |
423 | - case 'editLeaf': | ||
424 | - this.editLeaf(); | ||
425 | - break; | 423 | + case 'editLeaf': |
424 | + this.editLeaf(); | ||
425 | + break; | ||
426 | case 'deleteMulti': | 426 | case 'deleteMulti': |
427 | this.deleteMulti(); | 427 | this.deleteMulti(); |
428 | - break; | ||
429 | - case 'plotParam': | ||
430 | - this.createPlot(this); | ||
431 | break; | 428 | break; |
432 | - case 'downParam': | ||
433 | - this.createDownload(this); | ||
434 | - break; | 429 | + case 'plotParam': |
430 | + this.createPlot(this); | ||
431 | + break; | ||
432 | + case 'downParam': | ||
433 | + this.createDownload(this); | ||
434 | + break; | ||
435 | default: | 435 | default: |
436 | break; | 436 | break; |
437 | } // switch end | 437 | } // switch end |
438 | }, | 438 | }, |
439 | - | 439 | + |
440 | getTimeFromNode: function(node) { | 440 | getTimeFromNode: function(node) { |
441 | var startString = new String(node.get('globalStart')); | 441 | var startString = new String(node.get('globalStart')); |
442 | var stopString = new String(node.get('globalStop')); | 442 | var stopString = new String(node.get('globalStop')); |
443 | 443 | ||
444 | - var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | 444 | + var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); |
445 | var stopDate = new Date(stopString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | 445 | var stopDate = new Date(stopString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); |
446 | 446 | ||
447 | if (stopDate - startDate > 86400000 ) { | 447 | if (stopDate - startDate > 86400000 ) { |
448 | - var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); | 448 | + var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); |
449 | // var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; | 449 | // var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; |
450 | var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d'), stop: Ext.Date.format(stopDate, 'Y/m/d')}; | 450 | var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d'), stop: Ext.Date.format(stopDate, 'Y/m/d')}; |
451 | - } | 451 | + } |
452 | else { | 452 | else { |
453 | var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; | 453 | var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; |
454 | } | 454 | } |
455 | - return timeObj; | 455 | + return timeObj; |
456 | }, | 456 | }, |
457 | 457 | ||
458 | - createPlot: function(node) | ||
459 | - { | ||
460 | - if (node.get('disable')) return; | 458 | + createPlot: function(node) |
459 | + { | ||
460 | + if (node.get('disable')) return; | ||
461 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { | 461 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { |
462 | - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { | 462 | + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { |
463 | var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); | 463 | var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); |
464 | - var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); | 464 | + var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); |
465 | // edit newNode into Plot Module with node as contextNode | 465 | // edit newNode into Plot Module with node as contextNode |
466 | newNode.editInModule(); | 466 | newNode.editInModule(); |
467 | - if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | ||
468 | - module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); | 467 | + if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { |
468 | + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); | ||
469 | } | 469 | } |
470 | - } | ||
471 | - module.getUiContent().addParameter(node); | 470 | + } |
471 | + module.getUiContent().addParameter(node); | ||
472 | }); | 472 | }); |
473 | }, | 473 | }, |
474 | - | ||
475 | - createDownload: function(node) | ||
476 | - { | 474 | + |
475 | + createDownload: function(node) | ||
476 | + { | ||
477 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { | 477 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { |
478 | - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { | 478 | + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { |
479 | var request = Ext.create(amdaModel.Download.$className); | 479 | var request = Ext.create(amdaModel.Download.$className); |
480 | - amdaModel.DownloadNode.set('object',request); | 480 | + amdaModel.DownloadNode.set('object',request); |
481 | // singleton! | 481 | // singleton! |
482 | amdaModel.DownloadNode.editInModule(); | 482 | amdaModel.DownloadNode.editInModule(); |
483 | if ((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { | 483 | if ((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { |
484 | - module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); | 484 | + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); |
485 | } | 485 | } |
486 | - } | ||
487 | - var paramName; | 486 | + } |
487 | + var paramName; | ||
488 | var components = null; | 488 | var components = null; |
489 | switch (node.$className) { | 489 | switch (node.$className) { |
490 | - case 'amdaModel.AliasNode' : | 490 | + case 'amdaModel.AliasNode' : |
491 | paramName = "#"+node.get('text'); | 491 | paramName = "#"+node.get('text'); |
492 | break; | 492 | break; |
493 | - case 'amdaModel.DerivedParamComponentNode' : | 493 | + case 'amdaModel.DerivedParamComponentNode' : |
494 | paramId = node.get('text'); | 494 | paramId = node.get('text'); |
495 | var parentId = paramId.substr(0, paramId.length - 3); | 495 | var parentId = paramId.substr(0, paramId.length - 3); |
496 | paramName= "ws_" + parentId; | 496 | paramName= "ws_" + parentId; |
@@ -502,18 +502,18 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -502,18 +502,18 @@ Ext.define('amdaModel.InteractiveNode', { | ||
502 | components['index1'] = component_index[1]; | 502 | components['index1'] = component_index[1]; |
503 | } | 503 | } |
504 | break; | 504 | break; |
505 | - case 'amdaModel.DerivedParamNode' : | 505 | + case 'amdaModel.DerivedParamNode' : |
506 | paramName = "ws_"+node.get('text'); | 506 | paramName = "ws_"+node.get('text'); |
507 | break; | 507 | break; |
508 | case 'amdaModel.MyDataParamNode' : | 508 | case 'amdaModel.MyDataParamNode' : |
509 | - paramName = 'wsd_'+node.get('text'); | ||
510 | - break; | ||
511 | - default : | 509 | + paramName = 'wsd_'+node.get('text'); |
510 | + break; | ||
511 | + default : | ||
512 | if (node.get('alias')!= "" ) | 512 | if (node.get('alias')!= "" ) |
513 | paramName = "#"+node.get('alias'); | 513 | paramName = "#"+node.get('alias'); |
514 | - else | 514 | + else |
515 | paramName = node.get('id'); | 515 | paramName = node.get('id'); |
516 | - } | 516 | + } |
517 | var component_info = node.get('component_info'); | 517 | var component_info = node.get('component_info'); |
518 | if (component_info && component_info.parentId) { | 518 | if (component_info && component_info.parentId) { |
519 | //It's a component | 519 | //It's a component |
@@ -523,23 +523,23 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -523,23 +523,23 @@ Ext.define('amdaModel.InteractiveNode', { | ||
523 | components['index1'] = component_info.index1; | 523 | components['index1'] = component_info.index1; |
524 | if (component_info.index2) | 524 | if (component_info.index2) |
525 | components['index2'] = component_info.index2; | 525 | components['index2'] = component_info.index2; |
526 | - } | ||
527 | - module.addParam(paramName,true,node.get('needsArgs'),components); | ||
528 | - }); | 526 | + } |
527 | + module.addParam(paramName,true,node.get('needsArgs'),components); | ||
528 | + }); | ||
529 | }, | 529 | }, |
530 | - | ||
531 | - deleteNode: function() { | 530 | + |
531 | + deleteNode: function() { | ||
532 | // if the target is a directory | 532 | // if the target is a directory |
533 | if (!this.isRealLeaf()) { | 533 | if (!this.isRealLeaf()) { |
534 | // determine if this directory is empty before launching the delete confirmation method | 534 | // determine if this directory is empty before launching the delete confirmation method |
535 | - this.isNotEmptyDir(this.confirmDirectoryDeletion); | 535 | + this.isNotEmptyDir(this.confirmDirectoryDeletion); |
536 | // else (the target is a leaf) | 536 | // else (the target is a leaf) |
537 | } else { | 537 | } else { |
538 | // no confirmation prompt for leaves | 538 | // no confirmation prompt for leaves |
539 | this.confirmDirectoryDeletion(false); | 539 | this.confirmDirectoryDeletion(false); |
540 | } | 540 | } |
541 | }, | 541 | }, |
542 | - | 542 | + |
543 | /** | 543 | /** |
544 | * this method return if node has Childs even if it was not already loaded | 544 | * this method return if node has Childs even if it was not already loaded |
545 | */ | 545 | */ |
@@ -547,21 +547,21 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -547,21 +547,21 @@ Ext.define('amdaModel.InteractiveNode', { | ||
547 | var hasChilds; | 547 | var hasChilds; |
548 | // if node not already loaded | 548 | // if node not already loaded |
549 | if (!this.isLoaded()){ | 549 | if (!this.isLoaded()){ |
550 | - // call directFunction to load this node | 550 | + // call directFunction to load this node |
551 | AmdaAction.getTree({node:this.get('id'),nodeType:this.get('nodeType')},function(res,e){ | 551 | AmdaAction.getTree({node:this.get('id'),nodeType:this.get('nodeType')},function(res,e){ |
552 | callbackFn.call(this,res.length>0?true:false); | 552 | callbackFn.call(this,res.length>0?true:false); |
553 | },this); | 553 | },this); |
554 | - } | 554 | + } |
555 | else { | 555 | else { |
556 | callbackFn.call(this,this.hasChildNodes()); | 556 | callbackFn.call(this,this.hasChildNodes()); |
557 | } | 557 | } |
558 | }, | 558 | }, |
559 | - | 559 | + |
560 | /** | 560 | /** |
561 | * this method is used to display a confirmation message | 561 | * this method is used to display a confirmation message |
562 | */ | 562 | */ |
563 | confirmDirectoryDeletion : function(isNotEmptyDir) | 563 | confirmDirectoryDeletion : function(isNotEmptyDir) |
564 | - { | 564 | + { |
565 | // if this is a non-empty directory | 565 | // if this is a non-empty directory |
566 | if (isNotEmptyDir) { | 566 | if (isNotEmptyDir) { |
567 | // Prompt to the user if he also wants to delete its content | 567 | // Prompt to the user if he also wants to delete its content |
@@ -571,28 +571,28 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -571,28 +571,28 @@ Ext.define('amdaModel.InteractiveNode', { | ||
571 | this.realDelete(); | 571 | this.realDelete(); |
572 | } | 572 | } |
573 | },this); | 573 | },this); |
574 | - } | 574 | + } |
575 | else { | 575 | else { |
576 | this.realDelete(); | 576 | this.realDelete(); |
577 | - } | 577 | + } |
578 | }, | 578 | }, |
579 | - | 579 | + |
580 | /* | 580 | /* |
581 | * Call the extDirect method to delete parameter | 581 | * Call the extDirect method to delete parameter |
582 | -* Callback method needed to execute node deletion in tree if id in result or to show error msg | 582 | +* Callback method needed to execute node deletion in tree if id in result or to show error msg |
583 | */ | 583 | */ |
584 | realDelete : function() | 584 | realDelete : function() |
585 | - { | ||
586 | - AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){ | ||
587 | - //TODO proper errors handling | ||
588 | - // node deletion in tree | 585 | + { |
586 | + AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){ | ||
587 | + //TODO proper errors handling | ||
588 | + // node deletion in tree | ||
589 | if (res) { // if success | 589 | if (res) { // if success |
590 | if (res.id) { | 590 | if (res.id) { |
591 | //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | 591 | //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); |
592 | if (this.parentNode) { | 592 | if (this.parentNode) { |
593 | if (this.isRealLeaf()){ | 593 | if (this.isRealLeaf()){ |
594 | var moduleId = this.get('moduleId'); | 594 | var moduleId = this.get('moduleId'); |
595 | - // if really interactive node | 595 | + // if really interactive node |
596 | if (moduleId) { | 596 | if (moduleId) { |
597 | var win = myDesktopApp.getDesktop().getWindow(moduleId); | 597 | var win = myDesktopApp.getDesktop().getWindow(moduleId); |
598 | // if window is really open | 598 | // if window is really open |
@@ -600,72 +600,72 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -600,72 +600,72 @@ Ext.define('amdaModel.InteractiveNode', { | ||
600 | var me = this; | 600 | var me = this; |
601 | myDesktopApp.getLoadedModule(moduleId, true, function (module) { | 601 | myDesktopApp.getLoadedModule(moduleId, true, function (module) { |
602 | var editedNode = module.getLinkedNode(); | 602 | var editedNode = module.getLinkedNode(); |
603 | - | ||
604 | - // file node is not linked directly to the module | 603 | + |
604 | + // file node is not linked directly to the module | ||
605 | var isThisFile = false; | 605 | var isThisFile = false; |
606 | - if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | 606 | + if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') |
607 | if (editedNode.get('fileObject').get('fileName') == me.get('text')) | 607 | if (editedNode.get('fileObject').get('fileName') == me.get('text')) |
608 | - isThisFile = true; | ||
609 | - | ||
610 | - // node was created BEFORE tree loading; node.id are different ; but it is the same node | 608 | + isThisFile = true; |
609 | + | ||
610 | + // node was created BEFORE tree loading; node.id are different ; but it is the same node | ||
611 | if ( editedNode && editedNode.get('id') == me.get('id') && editedNode !== me ) { | 611 | if ( editedNode && editedNode.get('id') == me.get('id') && editedNode !== me ) { |
612 | module.setLinkedNode(me); | 612 | module.setLinkedNode(me); |
613 | isThisFile = true; | 613 | isThisFile = true; |
614 | } | 614 | } |
615 | - | 615 | + |
616 | if (me.$className == 'amdaModel.DerivedParamNode') { | 616 | if (me.$className == 'amdaModel.DerivedParamNode') { |
617 | var obj = { | 617 | var obj = { |
618 | paramId : 'ws_'+me.get('text') | 618 | paramId : 'ws_'+me.get('text') |
619 | }; | 619 | }; |
620 | AmdaAction.compilParamDelete(obj); | 620 | AmdaAction.compilParamDelete(obj); |
621 | } | 621 | } |
622 | - | ||
623 | - if (editedNode === me || isThisFile ){ | 622 | + |
623 | + if (editedNode === me || isThisFile ){ | ||
624 | var newNode = Ext.ModelManager.create({leaf : true}, me.$className); | 624 | var newNode = Ext.ModelManager.create({leaf : true}, me.$className); |
625 | // several tabs could be connected to one node | 625 | // several tabs could be connected to one node |
626 | if (moduleId === myDesktopApp.dynamicModules.plot.id) { | 626 | if (moduleId === myDesktopApp.dynamicModules.plot.id) { |
627 | var linkedNodes = module.linkedNodes; | 627 | var linkedNodes = module.linkedNodes; |
628 | - | 628 | + |
629 | if (linkedNodes) { | 629 | if (linkedNodes) { |
630 | - linkedNodes.each(function(key, value){ | ||
631 | - if (value === me) { | 630 | + linkedNodes.each(function(key, value){ |
631 | + if (value === me) { | ||
632 | linkedNodes.replace(key,newNode); | 632 | linkedNodes.replace(key,newNode); |
633 | var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | 633 | var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); |
634 | - tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); | ||
635 | - } | 634 | + tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); |
635 | + } | ||
636 | }, me); | 636 | }, me); |
637 | - } | ||
638 | - } | 637 | + } |
638 | + } | ||
639 | newNode.editInModule(); | 639 | newNode.editInModule(); |
640 | } | 640 | } |
641 | - }); | 641 | + }); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | - } | ||
645 | - //update mask info in myData | 644 | + } |
645 | + //update mask info in myData | ||
646 | if (res.maskDesc && !res.maskDeleted) { | 646 | if (res.maskDesc && !res.maskDeleted) { |
647 | this.parentNode.set('info', res.maskDesc); | 647 | this.parentNode.set('info', res.maskDesc); |
648 | this.updateMyDataParam(res.mask, res.maskDesc); | 648 | this.updateMyDataParam(res.mask, res.maskDesc); |
649 | - } | ||
650 | - this.remove(); | 649 | + } |
650 | + this.remove(); | ||
651 | } | 651 | } |
652 | - //TODO Several special node-dependent actions - to move to node functions.. | ||
653 | - // nodes of another nodeType to be deleted as they depend on deleted node | 652 | + //TODO Several special node-dependent actions - to move to node functions.. |
653 | + // nodes of another nodeType to be deleted as they depend on deleted node | ||
654 | if (res.params) { | 654 | if (res.params) { |
655 | this.deleteDependence(res.params); | 655 | this.deleteDependence(res.params); |
656 | //TODO reset | 656 | //TODO reset |
657 | - } | ||
658 | - // mask was deleted or updated - to update mydata tree | 657 | + } |
658 | + // mask was deleted or updated - to update mydata tree | ||
659 | if (res.maskDeleted) { | 659 | if (res.maskDeleted) { |
660 | - this.updateMyData(); | ||
661 | - } | 660 | + this.updateMyData(); |
661 | + } | ||
662 | } | 662 | } |
663 | else { | 663 | else { |
664 | - myDesktopApp.warningMsg(res.error); | 664 | + myDesktopApp.warningMsg(res.error); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | else { | 667 | else { |
668 | - myDesktopApp.errorMsg(e.message); | 668 | + myDesktopApp.errorMsg(e.message); |
669 | } | 669 | } |
670 | }, this); | 670 | }, this); |
671 | }, | 671 | }, |
@@ -681,7 +681,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -681,7 +681,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
681 | item.deleteNode(); | 681 | item.deleteNode(); |
682 | }) | 682 | }) |
683 | }, | 683 | }, |
684 | - | 684 | + |
685 | /* | 685 | /* |
686 | * Create Folder | 686 | * Create Folder |
687 | */ | 687 | */ |
@@ -710,9 +710,9 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -710,9 +710,9 @@ Ext.define('amdaModel.InteractiveNode', { | ||
710 | newNode.renameNode(true); | 710 | newNode.renameNode(true); |
711 | }); | 711 | }); |
712 | }, | 712 | }, |
713 | - | 713 | + |
714 | /* | 714 | /* |
715 | -* | 715 | +* |
716 | */ | 716 | */ |
717 | createLeaf: function(contextNode) { | 717 | createLeaf: function(contextNode) { |
718 | // create new node with the same type than the contextNode | 718 | // create new node with the same type than the contextNode |
@@ -730,7 +730,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -730,7 +730,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
730 | renameNode: function(deleteOnFailure) | 730 | renameNode: function(deleteOnFailure) |
731 | { | 731 | { |
732 | if (this.myGetOwnerTree()) | 732 | if (this.myGetOwnerTree()) |
733 | - { | 733 | + { |
734 | // load the rootNode and recursively all its child nodes if not already loaded | 734 | // load the rootNode and recursively all its child nodes if not already loaded |
735 | var me = this; | 735 | var me = this; |
736 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | 736 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), |
@@ -752,48 +752,48 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -752,48 +752,48 @@ Ext.define('amdaModel.InteractiveNode', { | ||
752 | * load the rootNode and recursively all its child nodes | 752 | * load the rootNode and recursively all its child nodes |
753 | * to know all names of DerivedParameters | 753 | * to know all names of DerivedParameters |
754 | */ | 754 | */ |
755 | - editLeaf: function(onReady) | ||
756 | - { | 755 | + editLeaf: function(onReady) |
756 | + { | ||
757 | var me = this; | 757 | var me = this; |
758 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | 758 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), |
759 | function() | 759 | function() |
760 | { | 760 | { |
761 | - if (me.get('object')) | 761 | + if (me.get('object')) |
762 | { | 762 | { |
763 | // launch edition of parameter into parameter module | 763 | // launch edition of parameter into parameter module |
764 | me.editInModule(null, onReady); | 764 | me.editInModule(null, onReady); |
765 | } | 765 | } |
766 | else | 766 | else |
767 | - { | 767 | + { |
768 | // call the ext method to get the details of parameter | 768 | // call the ext method to get the details of parameter |
769 | - // the edition of real parameter is done into callback method getObjectCallback | ||
770 | - if (onReady) | 769 | + // the edition of real parameter is done into callback method getObjectCallback |
770 | + if (onReady) | ||
771 | me.onReady = onReady; | 771 | me.onReady = onReady; |
772 | - | 772 | + |
773 | AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); | 773 | AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); |
774 | } | 774 | } |
775 | - }); | 775 | + }); |
776 | }, | 776 | }, |
777 | 777 | ||
778 | /* | 778 | /* |
779 | -* | 779 | +* |
780 | */ | 780 | */ |
781 | getObjectCallback : function(result,remoteEvent) | 781 | getObjectCallback : function(result,remoteEvent) |
782 | { | 782 | { |
783 | var t = remoteEvent.getTransaction(); | 783 | var t = remoteEvent.getTransaction(); |
784 | - | ||
785 | - if (result) { | 784 | + |
785 | + if (result) { | ||
786 | var paramObj = Ext.create(this.get('objectDataModel'), result); | 786 | var paramObj = Ext.create(this.get('objectDataModel'), result); |
787 | // set parameter into node | 787 | // set parameter into node |
788 | this.set('object',paramObj); | 788 | this.set('object',paramObj); |
789 | - // Edition of parameter into parameter Module | 789 | + // Edition of parameter into parameter Module |
790 | this.editInModule(null, this.onReady); | 790 | this.editInModule(null, this.onReady); |
791 | this.onReady = null; | 791 | this.onReady = null; |
792 | - } | 792 | + } |
793 | else { | 793 | else { |
794 | // EXCEPTION : parameter not found !? | 794 | // EXCEPTION : parameter not found !? |
795 | myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | 795 | myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" |
796 | - + this.get('name') + "' found!"); | 796 | + + this.get('name') + "' found!"); |
797 | } | 797 | } |
798 | - } | 798 | + } |
799 | }); | 799 | }); |
js/app/views/CatalogUI.js
@@ -672,7 +672,7 @@ Ext.define('amdaUI.CatalogUI', { | @@ -672,7 +672,7 @@ Ext.define('amdaUI.CatalogUI', { | ||
672 | 'isCatalog' : true, | 672 | 'isCatalog' : true, |
673 | 'data' : {} | 673 | 'data' : {} |
674 | }; | 674 | }; |
675 | - obj['data']['activeColumn.dataIndex'] = value; | 675 | + obj['data'][activeColumn.dataIndex] = value; |
676 | 676 | ||
677 | //Interval is modified on the server side | 677 | //Interval is modified on the server side |
678 | me.editing = true; | 678 | me.editing = true; |
php/TTCacheDump.php
1 | <?php | 1 | <?php |
2 | -/*define ("USERWSDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/WS/"); | ||
3 | -define ("USERTTDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/TT/"); | ||
4 | - | ||
5 | -require_once("classes/AmdaObjectMgr.php"); | ||
6 | -require_once("classes/TimeTableMgr.php"); | ||
7 | -require_once("classes/CatalogMgr.php"); | ||
8 | -require_once("classes/TimeTableCacheMgr.php"); | ||
9 | -require_once("classes/TimeTableCacheObject.php"); | ||
10 | -require_once("classes/IntervalCacheObject.php"); | ||
11 | -require_once("classes/CatalogCacheMgr.php"); | ||
12 | -*/ | ||
13 | 2 | ||
14 | require_once("config.php"); | 3 | require_once("config.php"); |
15 | 4 | ||
@@ -17,6 +6,7 @@ define ("USERWSDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/WS/"); | @@ -17,6 +6,7 @@ define ("USERWSDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/WS/"); | ||
17 | define ("USERTTDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/TT/"); | 6 | define ("USERTTDIR", "/home/amda_admin/AMDA-GIT/AMDA_IHM/data/testKernel/TT/"); |
18 | 7 | ||
19 | $cacheMgr = new CatalogCacheMgr(); | 8 | $cacheMgr = new CatalogCacheMgr(); |
9 | +#$cacheMgr = new TimeTableCacheMgr(); | ||
20 | 10 | ||
21 | $cacheMgr->dump(); | 11 | $cacheMgr->dump(); |
22 | 12 |
php/classes/AmdaAction.php
@@ -654,20 +654,51 @@ class AmdaAction | @@ -654,20 +654,51 @@ class AmdaAction | ||
654 | $fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name))); | 654 | $fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name))); |
655 | file_put_contents(USERTEMPDIR . $name, $fileContent); | 655 | file_put_contents(USERTEMPDIR . $name, $fileContent); |
656 | 656 | ||
657 | + $isTTCat = FALSE; | ||
657 | switch ($nodeType) | 658 | switch ($nodeType) |
658 | { | 659 | { |
659 | case 'timeTable' : | 660 | case 'timeTable' : |
660 | $objectMgr = new TimeTableMgr(); | 661 | $objectMgr = new TimeTableMgr(); |
662 | + $isTTCat = TRUE; | ||
661 | break; | 663 | break; |
662 | case 'myDataParam' : | 664 | case 'myDataParam' : |
663 | $objectMgr = new FilesMgr(); | 665 | $objectMgr = new FilesMgr(); |
664 | break; | 666 | break; |
665 | case 'catalog' : | 667 | case 'catalog' : |
666 | $objectMgr = new CatalogMgr(); | 668 | $objectMgr = new CatalogMgr(); |
669 | + $isTTCat = TRUE; | ||
667 | break; | 670 | break; |
668 | default: | 671 | default: |
669 | return array("error" => $nodeType." NOT_IMPLEMENTED_YET"); | 672 | return array("error" => $nodeType." NOT_IMPLEMENTED_YET"); |
670 | } | 673 | } |
674 | + if ($isTTCat) { | ||
675 | + //Pre-process: convert to INTERNAL format if needed | ||
676 | + if (($format == 'ASCII') || ($format == 'VOT')) { | ||
677 | + $result = $this->executeRequest((Object) array( | ||
678 | + 'compression' => 'none', | ||
679 | + 'fileformat' => 'internal', | ||
680 | + 'sendToSamp' => FALSE, | ||
681 | + 'list' => array( | ||
682 | + (Object) array( | ||
683 | + 'path' => USERTEMPDIR . $name, | ||
684 | + 'format' => $format, | ||
685 | + 'name' => pathinfo($name, PATHINFO_FILENAME), | ||
686 | + ) | ||
687 | + ), | ||
688 | + ), FunctionTypeEnumClass::TTCONVERT); | ||
689 | + if (!$result['success']) { | ||
690 | + return array("error" => "Error during file conversion"); | ||
691 | + } | ||
692 | + $name = basename($result['download']); | ||
693 | + $convertedFile = USERDIR.'/DOWNLOAD.TEMP/'.$name; | ||
694 | + if (!file_exists($convertedFile)) { | ||
695 | + return array("error" => "Error during file conversion"); | ||
696 | + } | ||
697 | + | ||
698 | + $format = 'internal'; | ||
699 | + rename($convertedFile, USERTEMPDIR . '/' . $name); | ||
700 | + } | ||
701 | + } | ||
671 | return $objectMgr->getUploadedObject($name, $format, true); | 702 | return $objectMgr->getUploadedObject($name, $format, true); |
672 | } | 703 | } |
673 | 704 | ||
@@ -1117,7 +1148,6 @@ class AmdaAction | @@ -1117,7 +1148,6 @@ class AmdaAction | ||
1117 | { | 1148 | { |
1118 | if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); | 1149 | if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); |
1119 | else $cacheMgr = new CatalogCacheMgr(); | 1150 | else $cacheMgr = new CatalogCacheMgr(); |
1120 | - | ||
1121 | return $cacheMgr->initFromUploadedFile($name, $format); | 1151 | return $cacheMgr->initFromUploadedFile($name, $format); |
1122 | } | 1152 | } |
1123 | 1153 | ||
@@ -1192,7 +1222,6 @@ class AmdaAction | @@ -1192,7 +1222,6 @@ class AmdaAction | ||
1192 | 1222 | ||
1193 | public function getTTCacheStatistics($obj) | 1223 | public function getTTCacheStatistics($obj) |
1194 | { | 1224 | { |
1195 | - error_log("name",$obj->name ); | ||
1196 | if($obj->name == "timeTableUi"){ | 1225 | if($obj->name == "timeTableUi"){ |
1197 | $cacheMgr = new TimeTableCacheMgr(); | 1226 | $cacheMgr = new TimeTableCacheMgr(); |
1198 | }elseif($obj->name == "catalogUI"){ | 1227 | }elseif($obj->name == "catalogUI"){ |
php/classes/CatalogCacheIntervalObject.php
@@ -27,6 +27,17 @@ class CatalogCacheIntervalObject extends TimeTableCacheIntervalObject | @@ -27,6 +27,17 @@ class CatalogCacheIntervalObject extends TimeTableCacheIntervalObject | ||
27 | return $this->params; | 27 | return $this->params; |
28 | } | 28 | } |
29 | 29 | ||
30 | + public function modifyInterval($data) { | ||
31 | + parent::modifyInterval($data); | ||
32 | + foreach ($this->cacheObject->getParametersInfo() as $parameter) { | ||
33 | + if (array_key_exists($parameter['id'], $data)) { | ||
34 | + $this->setParamValue($parameter['id'], $data->{$parameter['id']}); | ||
35 | + $this->setIsModified(true); | ||
36 | + } | ||
37 | + } | ||
38 | + return $this->isModified(); | ||
39 | + } | ||
40 | + | ||
30 | public function writeBin($handle) | 41 | public function writeBin($handle) |
31 | { | 42 | { |
32 | parent::writeBin($handle); | 43 | parent::writeBin($handle); |
php/classes/CatalogCacheMgr.php
@@ -42,31 +42,14 @@ class CatalogCacheMgr extends TimeTableCacheMgr | @@ -42,31 +42,14 @@ class CatalogCacheMgr extends TimeTableCacheMgr | ||
42 | return array('parameters' => $this->cache->getParametersInfo()); | 42 | return array('parameters' => $this->cache->getParametersInfo()); |
43 | } | 43 | } |
44 | 44 | ||
45 | - protected function loadAdditionalDescription($id, $type) { | ||
46 | - $params_desc = $this->objectMgr->getCatalogParamDescription($id, "", FALSE, $type); | 45 | + protected function loadAdditionalDescription($options) { |
46 | + $params_desc = $this->objectMgr->getCatalogParamDescription($options); | ||
47 | if (!$params_desc['success']) { | 47 | if (!$params_desc['success']) { |
48 | return array(); | 48 | return array(); |
49 | } | 49 | } |
50 | return array('parameters' => $params_desc['parameters']); | 50 | return array('parameters' => $params_desc['parameters']); |
51 | } | 51 | } |
52 | 52 | ||
53 | - public function initFromTmpObject($folderId, $name) { | ||
54 | - $result = parent::initFromTmpObject($folderId, $name); | ||
55 | - if (!$result['success']) { | ||
56 | - return $result; | ||
57 | - } | ||
58 | - | ||
59 | - $params_desc = $this->objectMgr->getCatalogParamDescription($id, $name, FALSE, $type); | ||
60 | - if (!$params_desc['success']) { | ||
61 | - return $params_desc; | ||
62 | - } | ||
63 | - | ||
64 | - foreach ($params_desc['parameters'] as $parameter) { | ||
65 | - $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type'])); | ||
66 | - } | ||
67 | - | ||
68 | - return $result+ array('parameters' => $this->cache->getParametersInfo()); | ||
69 | - } | ||
70 | 53 | ||
71 | public function initFromUploadedFile($name, $format) | 54 | public function initFromUploadedFile($name, $format) |
72 | { | 55 | { |
php/classes/CatalogCacheObject.php
@@ -121,16 +121,11 @@ class CatalogCacheObject extends TimeTableCacheObject | @@ -121,16 +121,11 @@ class CatalogCacheObject extends TimeTableCacheObject | ||
121 | if ($interval->getId() == $cacheId) | 121 | if ($interval->getId() == $cacheId) |
122 | { | 122 | { |
123 | foreach($data as $key => $value) { | 123 | foreach($data as $key => $value) { |
124 | - if (strpos($key, 'param') !== FALSE) { | ||
125 | - $params = $interval->getParams(); | ||
126 | - $paramIndex = (int)substr($key,5); | ||
127 | - $params[$paramIndex-2] = $value; | ||
128 | - $interval->setParams($params); | ||
129 | - $interval->setIsModified(true); | ||
130 | - $this->isModified = true; | ||
131 | - } | 124 | + $interval->setParamValue($key, $value); |
125 | + $interval->setIsModified(true); | ||
126 | + $this->isModified = true; | ||
132 | } | 127 | } |
133 | - return true; | 128 | + return $this->isModified; |
134 | } | 129 | } |
135 | } | 130 | } |
136 | 131 |
php/classes/CatalogMgr.php
@@ -209,15 +209,15 @@ class CatalogMgr extends TimeTableMgr | @@ -209,15 +209,15 @@ class CatalogMgr extends TimeTableMgr | ||
209 | return $paramsElement; | 209 | return $paramsElement; |
210 | } | 210 | } |
211 | 211 | ||
212 | - protected function createIntervalElement($interval) | 212 | + protected function createIntervalElement($interval, $options = array()) |
213 | { | 213 | { |
214 | $newInterval = $this->objectDom->createElement('intervals'); | 214 | $newInterval = $this->objectDom->createElement('intervals'); |
215 | $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); | 215 | $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); |
216 | $newInterval->appendChild($this->objectDom->createElement('stop',$interval['stop'])); | 216 | $newInterval->appendChild($this->objectDom->createElement('stop',$interval['stop'])); |
217 | - foreach ($interval as $key =>$value) { | ||
218 | - if (substr($key,0,5) == 'param') | ||
219 | - $newInterval->appendChild($this->objectDom->createElement('param', $value)); | ||
220 | - | 217 | + if (!empty($options['parameters'])) { |
218 | + foreach ($options['parameters'] as $parameter) { | ||
219 | + $newInterval->appendChild($this->objectDom->createElement('param', $interval[$parameter['id']])); | ||
220 | + } | ||
221 | } | 221 | } |
222 | return $newInterval; | 222 | return $newInterval; |
223 | } | 223 | } |
@@ -325,36 +325,34 @@ class CatalogMgr extends TimeTableMgr | @@ -325,36 +325,34 @@ class CatalogMgr extends TimeTableMgr | ||
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | - public function getCatalogParamDescription($id, $name, $isTmpObject, $type) | 328 | + public function getCatalogParamDescription($options) |
329 | { | 329 | { |
330 | - if ($type == 'sharedcatalog') { | 330 | + if (isset($options['type']) && ($options['type'] == 'sharedcatalog')) { |
331 | //Shared object | 331 | //Shared object |
332 | $sharedObjMgr = new SharedObjectsMgr(); | 332 | $sharedObjMgr = new SharedObjectsMgr(); |
333 | - $path = $sharedObjMgr->getDataFilePath('catalog', $id); | 333 | + $path = $sharedObjMgr->getDataFilePath('catalog', $options['id']); |
334 | } | 334 | } |
335 | - elseif (!$isTmpObject) { | ||
336 | - $path = USERTTDIR.$id.'.xml'; | 335 | + elseif (!isset($options['isTmpObject']) || !$options['isTmpObject']) { |
336 | + $path = USERTTDIR.$options['id'].'.xml'; | ||
337 | } | 337 | } |
338 | else { | 338 | else { |
339 | - $path = USERWORKINGDIR.$id.'/'.$name.'.xml'; | 339 | + $path = $options['folder'].'/'.$options['name'].'.xml'; |
340 | } | 340 | } |
341 | 341 | ||
342 | //load intervals from Catalog id | 342 | //load intervals from Catalog id |
343 | if (!file_exists($path)) | 343 | if (!file_exists($path)) |
344 | - return array('success' => false, 'message' => "Cannot find Catalog file ".$id); | 344 | + return array('success' => false, 'message' => "Cannot find Catalog file ".$path); |
345 | 345 | ||
346 | if (!$this->objectDom->load($path)) | 346 | if (!$this->objectDom->load($path)) |
347 | - return array('success' => false, 'message' => "Cannot load Catalog file ".$id); | 347 | + return array('success' => false, 'message' => "Cannot load Catalog file"); |
348 | 348 | ||
349 | -// if (!($objToGet = $this->objectDom->getElementById($id))) | ||
350 | -// return array('success' => false, 'message' => NO_SUCH_ID." ".$id); | ||
351 | 349 | ||
352 | $nameNodes = $this->objectDom->getElementsByTagName('name'); | 350 | $nameNodes = $this->objectDom->getElementsByTagName('name'); |
353 | 351 | ||
354 | if ($nameNodes->length > 0) | 352 | if ($nameNodes->length > 0) |
355 | $nameReal = $nameNodes->item(0)->nodeValue; | 353 | $nameReal = $nameNodes->item(0)->nodeValue; |
356 | else | 354 | else |
357 | - $nameReal = $name; | 355 | + $nameReal = $options['name']; |
358 | 356 | ||
359 | $xpath = new DOMXPath($this->objectDom); | 357 | $xpath = new DOMXPath($this->objectDom); |
360 | $intervals = $xpath->query('//intervals'); | 358 | $intervals = $xpath->query('//intervals'); |
php/classes/TimeTableCacheIntervalObject.php
@@ -93,7 +93,18 @@ class TimeTableCacheIntervalObject | @@ -93,7 +93,18 @@ class TimeTableCacheIntervalObject | ||
93 | return $result; | 93 | return $result; |
94 | } | 94 | } |
95 | 95 | ||
96 | + public function modifyInterval($data) { | ||
97 | + if (array_key_exists('start', $data)) { | ||
98 | + $this->setStartFromISO($data->{'start'}); | ||
99 | + $this->setIsModified(true); | ||
100 | + } | ||
101 | + if (array_key_exists('stop', $data)) { | ||
102 | + $this->setStopFromISO($data->{'stop'}); | ||
103 | + $this->setIsModified(true); | ||
104 | + } | ||
96 | 105 | ||
106 | + return $this->isModified(); | ||
107 | + } | ||
97 | 108 | ||
98 | public function writeBin($handle) { | 109 | public function writeBin($handle) { |
99 | fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); | 110 | fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); |
@@ -110,7 +121,7 @@ class TimeTableCacheIntervalObject | @@ -110,7 +121,7 @@ class TimeTableCacheIntervalObject | ||
110 | } | 121 | } |
111 | 122 | ||
112 | public function dump() { | 123 | public function dump() { |
113 | - echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; | 124 | + echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".TimeUtils::stamp2iso($this->start).", stop = ".TimeUtils::stamp2iso($this->stop).", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; |
114 | } | 125 | } |
115 | } | 126 | } |
116 | ?> | 127 | ?> |
php/classes/TimeTableCacheMgr.php
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | return array(); | 26 | return array(); |
27 | } | 27 | } |
28 | 28 | ||
29 | - protected function loadAdditionalDescription($id, $type) { | 29 | + protected function loadAdditionalDescription($options) { |
30 | return array(); | 30 | return array(); |
31 | } | 31 | } |
32 | 32 | ||
@@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
39 | } | 39 | } |
40 | 40 | ||
41 | public function initFromObject($id, $type) { | 41 | public function initFromObject($id, $type) { |
42 | - $options = $this->loadAdditionalDescription($id, $type); | 42 | + $options = $this->loadAdditionalDescription(array('id' => $id, 'type' => $type, 'isTmpObject' => FALSE)); |
43 | //Create new cache | 43 | //Create new cache |
44 | $info = $this->resetCache($options); | 44 | $info = $this->resetCache($options); |
45 | 45 | ||
@@ -92,8 +92,9 @@ | @@ -92,8 +92,9 @@ | ||
92 | 92 | ||
93 | 93 | ||
94 | public function initFromTmpObject($folderId, $name) { | 94 | public function initFromTmpObject($folderId, $name) { |
95 | + $options = $this->loadAdditionalDescription(array('folder' => USERWORKINGDIR.$folderId, 'name' => $name, 'isTmpObject' => TRUE)); | ||
95 | //Create new cache | 96 | //Create new cache |
96 | - $this->resetCache(); | 97 | + $info = $this->resetCache($options); |
97 | 98 | ||
98 | //Load intervals from TmpObject file (DD_Search output) | 99 | //Load intervals from TmpObject file (DD_Search output) |
99 | $intervals_res = $this->objectMgr->getTmpObject($folderId, $name); | 100 | $intervals_res = $this->objectMgr->getTmpObject($folderId, $name); |
@@ -118,12 +119,13 @@ | @@ -118,12 +119,13 @@ | ||
118 | $this->cache->updateIndexes(); | 119 | $this->cache->updateIndexes(); |
119 | 120 | ||
120 | //Save cache file | 121 | //Save cache file |
121 | - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); | 122 | + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()) + $info; |
122 | } | 123 | } |
123 | 124 | ||
124 | public function initFromUploadedFile($name, $format) { | 125 | public function initFromUploadedFile($name, $format) { |
126 | + $options = $this->loadAdditionalDescription(array('folder' => USERTEMPDIR, 'name' => $name, 'isTmpObject' => TRUE)); | ||
125 | //Create new cache | 127 | //Create new cache |
126 | - $this->resetCache(); | 128 | + $info = $this->resetCache($options); |
127 | 129 | ||
128 | //Load intervals from uploaded file | 130 | //Load intervals from uploaded file |
129 | $intervals_res = $this->objectMgr->getUploadedObject($name, $format); | 131 | $intervals_res = $this->objectMgr->getUploadedObject($name, $format); |
@@ -148,7 +150,7 @@ | @@ -148,7 +150,7 @@ | ||
148 | $this->cache->updateIndexes(); | 150 | $this->cache->updateIndexes(); |
149 | 151 | ||
150 | //Save cache file | 152 | //Save cache file |
151 | - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); | 153 | + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()) + $info; |
152 | } | 154 | } |
153 | 155 | ||
154 | public function saveInObject($id, $action, $token) { | 156 | public function saveInObject($id, $action, $token) { |
@@ -165,7 +167,9 @@ | @@ -165,7 +167,9 @@ | ||
165 | 167 | ||
166 | $this->cache->reset(); | 168 | $this->cache->reset(); |
167 | 169 | ||
168 | - return $this->objectMgr->saveIntervals($id, $intervals, $action); | 170 | + $options = $this->loadAdditionalDescription(array('id' => $id)); |
171 | + | ||
172 | + return $this->objectMgr->saveIntervals($id, $intervals, $action, $options); | ||
169 | } | 173 | } |
170 | 174 | ||
171 | public function getIntervals($start,$limit,$sort_obj,$filter_json) { | 175 | public function getIntervals($start,$limit,$sort_obj,$filter_json) { |
php/classes/TimeTableCacheObject.php
@@ -93,20 +93,7 @@ class TimeTableCacheObject | @@ -93,20 +93,7 @@ class TimeTableCacheObject | ||
93 | { | 93 | { |
94 | if ($interval->getId() == $cacheId) | 94 | if ($interval->getId() == $cacheId) |
95 | { | 95 | { |
96 | - foreach ($data as $key => $value) { | ||
97 | - switch ($key) { | ||
98 | - case 'start' : | ||
99 | - $interval->setStartFromISO($value); | ||
100 | - $interval->setIsModified(true); | ||
101 | - $this->isModified = true; | ||
102 | - break; | ||
103 | - case 'stop': | ||
104 | - $interval->setStopFromISO($value); | ||
105 | - $interval->setIsModified(true); | ||
106 | - $this->isModified = true; | ||
107 | - break; | ||
108 | - } | ||
109 | - } | 96 | + $this->isModified = $interval->modifyInterval($data); |
110 | return $this->isModified; | 97 | return $this->isModified; |
111 | } | 98 | } |
112 | } | 99 | } |
php/classes/TimeTableMgr.php
@@ -511,7 +511,7 @@ class TimeTableMgr extends AmdaObjectMgr | @@ -511,7 +511,7 @@ class TimeTableMgr extends AmdaObjectMgr | ||
511 | * @param $action | 511 | * @param $action |
512 | * @return array | 512 | * @return array |
513 | */ | 513 | */ |
514 | - public function saveIntervals($id, $intervals, $action) | 514 | + public function saveIntervals($id, $intervals, $action, $options = array()) |
515 | { | 515 | { |
516 | if (substr($id, 0, 6) == 'shared') { | 516 | if (substr($id, 0, 6) == 'shared') { |
517 | return ['success' => false, 'message' => "Cannot save shared TimeTable"]; | 517 | return ['success' => false, 'message' => "Cannot save shared TimeTable"]; |
@@ -543,7 +543,7 @@ class TimeTableMgr extends AmdaObjectMgr | @@ -543,7 +543,7 @@ class TimeTableMgr extends AmdaObjectMgr | ||
543 | 543 | ||
544 | //add new intervals | 544 | //add new intervals |
545 | foreach ($intervals as $interval) { | 545 | foreach ($intervals as $interval) { |
546 | - $newInterval = $this->createIntervalElement($interval); | 546 | + $newInterval = $this->createIntervalElement($interval, $options); |
547 | $this->objectDom->documentElement->appendChild($newInterval); | 547 | $this->objectDom->documentElement->appendChild($newInterval); |
548 | } | 548 | } |
549 | 549 | ||
@@ -562,11 +562,11 @@ class TimeTableMgr extends AmdaObjectMgr | @@ -562,11 +562,11 @@ class TimeTableMgr extends AmdaObjectMgr | ||
562 | * @param $interval | 562 | * @param $interval |
563 | * @return DOMElement | 563 | * @return DOMElement |
564 | */ | 564 | */ |
565 | - protected function createIntervalElement($interval) | 565 | + protected function createIntervalElement($interval, $options = array()) |
566 | { | 566 | { |
567 | $newInterval = $this->objectDom->createElement('intervals'); | 567 | $newInterval = $this->objectDom->createElement('intervals'); |
568 | - $newInterval->appendChild($this->objectDom->createElement('start', $interval->start)); | ||
569 | - $newInterval->appendChild($this->objectDom->createElement('stop', $interval->stop)); | 568 | + $newInterval->appendChild($this->objectDom->createElement('start', $interval['start'])); |
569 | + $newInterval->appendChild($this->objectDom->createElement('stop', $interval['stop'])); | ||
570 | return $newInterval; | 570 | return $newInterval; |
571 | } | 571 | } |
572 | 572 |