Blame view

js/app/models/ExecutableNode.js 4.35 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** 
 * Project  : AMDA-NG4
 * Name     : ExecutableNode.js
 * @class   amdaModel.ExecutableNode
 * @extends amdaModel.InteractiveNode
 * @brief   Generic Model of Executable Node
 * @author  elena
 * @version $Id: ExecutableNode.js 1662 2013-07-02 15:10:22Z benjamin $
 * @todo
 *******************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 *  :           :12/07/2011: elena - creation
 * 
 */

Ext.define('amdaModel.ExecutableNode', {
    extend: 'amdaModel.InteractiveNode',
    
//TODO use resultModel in execute method Is it needed???
    
    fields: [ 'jobNode', 'resultModel'],

    statics: { jobTreeLoaded : false },
    
    constructor : function(config) {
3a5f60a1   elena   proper use os sta...
27
28
        this.callParent(arguments);        
	 this.set('ownerTreeId',amdaUI.ExplorerUI.OPE_TAB.TREE_ID);
81fae858   Benjamin Renard   Remove a cyclical...
29
        this.set('jobNode', 'amdaModel.BkgJobNode');		 
16035364   Benjamin Renard   First commit
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    },
    
    loadJobTree : function() {            
	var rootNode = Ext.getCmp(amdaUI.ExplorerUI.JOB_TAB.TREE_ID).getRootNode();	
	var me = this;
	amdaModel.InteractiveNode.preloadNodes(rootNode,
    		function()
            	{
					amdaModel.ExecutableNode.jobTreeLoaded = true;
					me.realExecute(); 
            	});
    },   
    	   
    execute : function(isDirty) {
      
	if (!amdaModel.ExecutableNode.jobTreeLoaded) this.loadJobTree();
	else this.realExecute(); 
	   
    },
   
    /**
     * Method to execute this node 
     */
    realExecute : function() {
	  
dca17cf3   Benjamin Renard   New implementatio...
55
    	var isInteractivePlot = (this.get('nodeType') == 'request') && (this.get('object').get('file-output') == 'INTERACTIVE'); 
16035364   Benjamin Renard   First commit
56
57
       
	if (!loadMask.isMasked())
dca17cf3   Benjamin Renard   New implementatio...
58
                    loadMask.show(isInteractivePlot);
16035364   Benjamin Renard   First commit
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        
        AmdaAction.execute({nodeType : this.get('nodeType')}, this.get('object').getJsonValues(true), function(res,e){
	  	     
	    loadMask.hide();
	  
        	//AKKA - Rework of the result treatment for the integration with the new kernel
     	   	if (!e.status)
     	    {
     		    myDesktopApp.errorMsg('Internal error during request');
     		    return;
     	    }
     	   
     	    if (!res.success)
     	    {
     		    myDesktopApp.errorMsg(res.message);
     		    return;
     	    }
     	    
e6e5b259   Benjamin Renard   Add kill plot req...
77
78
79
     	    if (res.killed)
     	    	return;
     	    
dca17cf3   Benjamin Renard   New implementatio...
80
81
82
     	    if (isInteractivePlot)
     	    {
     	    	myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
87658ba0   Benjamin Renard   TT Navigation in ...
83
     	    		module.updateInteractiveSession(res, true);
dca17cf3   Benjamin Renard   New implementatio...
84
85
86
87
88
89
     	    	});
     	    }
     	    else
     	    {
     	    	var newobj = this.createJobObject(res);	    
     	    	var newNode = Ext.create(this.get('jobNode'), 
16035364   Benjamin Renard   First commit
90
91
92
93
94
95
96
97
98
99
100
101
102
     	    		{
     	    			info : res.info,
     	    			jobType : this.get('nodeType'),
     	    			processId : res.id,
     	    			id : res.id,
     	    			text : res.name,
     	    			status : res.status,
     	    			start : res.start,
     	    			stop : res.stop,
     	    			tabId : res.tabId,
     	    			leaf : true,
     	    			object : newobj});
     	    
dca17cf3   Benjamin Renard   New implementatio...
103
104
105
106
     	    	newNode.get('object').on('execute', function() {
     	    		// Then call the node creation method
     	    		this.execute(arguments);
     	    	}, newNode);
16035364   Benjamin Renard   First commit
107
     	    
dca17cf3   Benjamin Renard   New implementatio...
108
109
110
111
     	    	switch (res.status)
     	    	{
     	    	case amdaModel.BkgJobNode.STATUS_LIST.DONE :
     	    		newNode.createJobNode(true);
18d4a11e   Benjamin Renard   Save and load plo...
112
     	    		newNode.editNode(true, false);
dca17cf3   Benjamin Renard   New implementatio...
113
114
115
116
117
118
119
     	    		break;
     	    	case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
     	    		newNode.createJobNode(false);
     	    		break;
     	    	default:
     	    		newNode.createJobNode(true);
     	    	}
16035364   Benjamin Renard   First commit
120
     	    }
dca17cf3   Benjamin Renard   New implementatio...
121
        }, this );
16035364   Benjamin Renard   First commit
122
123
124
125
126
127
128
129
130
131
132
133
134
135
    },  

    createJobObject: function(res) {
      
		    var obj =  this.get('object').getJsonValues();		    
//TODO text, name, outputName - if all is needed        
	             //new object to attach to new bkgJobNode	
//TODO Ext.clone()  		     	  
	 	    var newobj = Ext.copyTo({}, obj, this.get('object').propertiesToCopy);
	 	   newobj.resultId = res.result;	
           newobj.folderId = res.folder;
           newobj.processId= res.id;
           newobj.tabId = res.tabId;
           newobj.name = res.name;
18d4a11e   Benjamin Renard   Save and load plo...
136
		   newobj = Ext.create(this.get('object').$className, newobj);
16035364   Benjamin Renard   First commit
137
138
139
140
141
142
143
144
145
146
		 return   newobj;  
	},
    /**
     * override isExecutable to return true 
     */
    isExecutable: function(){
        return true;
    }

});