Blame view

php/classes/AmdaAction.php 44.5 KB
16035364   Benjamin Renard   First commit
1
2
3
<?php
/**
 * @class AmdaAction
aa94fd24   elena   Merge with last svn
4
 * @version $Id: AmdaAction.php 2976 2015-07-01 15:05:40Z benjamin $
16035364   Benjamin Renard   First commit
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 *
 */


class AmdaAction {

    private $xmlFiles  = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml', 
                                'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
                                'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',	 
                                'myData' => 'Files.xml', 
                                'request' => 'Request.xml', 'condition' => 'Request.xml',
                                'bkgWorks' => 'jobs.xml');

    private $user, $amdaStat;
aa94fd24   elena   Merge with last svn
19

16035364   Benjamin Renard   First commit
20
    public function __construct() 
aa94fd24   elena   Merge with last svn
21
22
23
24
25
    {                 
        $dd = new UserMgr();
        $this->user = $dd->user;
        if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
                 $this->amdaStat = new AmdaStats($dd->user);
16035364   Benjamin Renard   First commit
26
27
28
29
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
    }

    private function getUrlDirs($url) {
        //TODO replace by ftp php class methods: ftp_nlist() etc
        require_once "simple_html_dom.php";
          
        $url = html_entity_decode($url);        
        $trimmed_url = trim($url);
        if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1) {
            if (file_exists("temp.html")) unlink("temp.html"); 
            exec("wget -O temp.html ".$url);
            
            $html = file_get_html('temp.html');
            $dirs = $html->find('a[href]');
            foreach ($dirs as $dir) {
                $name =  $dir->innertext; //$dir->href;
                $isLeaf = strrpos($name, "/") !== strlen($name) - 1;
                $childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name,
                                    'nodeType' => 'url', 'leaf' => $isLeaf); 
            }
            
        }
      return $childrenToReturn;  
    }
      
/*****************************************************************
*                           PUBLIC FUNCTIONS
*****************************************************************/ 
 
    /*
    *   $obj = { id: node.id,  nodeType: node.nodeType }
    */
    public function getTree($obj) {
  
       $node = $obj->node;
       
    // to correct 'restricted' parameters  
        if (strpos($node, restricted) !== false) {
            $node = str_replace(restricted,"",$node);
        }

       $nodeType = $obj->nodeType;
       $remoteBase = false;
       $isRemoteDataSet = false;

        if ($nodeType == 'url') 
        {
            $url = $node == 'root' ? $obj->baseId : $node;		   
            return  $this->getUrlDirs($url);
        }

        if ($obj->baseId) $remoteBase = true;

        if ($node == 'root' && $remoteBase)  $node = $obj->baseId;

        if ($node == 'root' && !$remoteBase)  
        { 
            $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
            $childrenToReturn = $json_o->nodes;	      
        }         
        else 
        {
            $Dom = new DomDocument("1.0");

            switch ($nodeType) 
            {
                case 'sharedtimeTable':
                            $xmlName = SHAREDPATH.'/WS/Tt.xml';
                            break;
                case 'bkgWorks': 
                        $xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
                        break;
                case 'source':
                        $xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';		    
                        break;
                case 'destination': 
                        $xmlName = USERWSDIR.'RemoteParams.xml';		   
                        break; 
                default:
                        $xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
            }

	    if ($remoteBase)  
            {               
                 $nodeType = 'remoteParam';
	    } 		 
           
	    $Dom->load($xmlName);
             
	    if ($node == "myRemoteSimuData-treeRootNode") 
                                        $node = "myRemoteData-treeRootNode";

	    $nodeToOpen = $Dom->getElementById($node);
	    $children = $nodeToOpen->childNodes;

	    foreach ($children as $child)  
	      if ($child->nodeType == XML_ELEMENT_NODE) {
		  $isLeaf = true;
	  
                if ($child->hasChildNodes())
                    foreach ($child->childNodes as $grandChild)  
                    if ($grandChild -> nodeType == XML_ELEMENT_NODE)  {
                            $isLeaf = false;
                            break;
                        }

                if ($child->tagName == 'folder')  $isLeaf = false;

                //TODO MAKE PROPERLY  as function of nodetype !!!!    
                $info = ''; 
                $id =  $child->getAttribute('xml:id');
                $name = $child->getAttribute('name');                
                $help = $child->getAttribute('att');
                if ($child->hasAttribute('dataStart')) $dataStart = $child->getAttribute('dataStart');
                if ($child->hasAttribute('dataStop')) $dataStop = $child->getAttribute('dataStop');

                $specialNode = false;
                $isParameter = false;
                $skip = false;
		$isAddable =  false;
                $isSimulation = false;
                $rank = null;

                switch ($nodeType) 
                {
		    case 'bkgWorks': 
			$specialNode = true;
			$status = $child->getAttribute('status');
		    //     if ($status == 'done') continue;				 
			$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'leaf' => $isLeaf,
					  'pid' => $child->getAttribute('pid'), 'status' => $status, 
					  'jobType' => $child->getAttribute('jobType'), 'info' => $child->getAttribute('info'));
		    break;

		    case 'condition':
			$objectMgr = new RequestMgr();
			$info = $objectMgr->getObject($id)->expression;  
		    break; 

		    case 'request':
 		  	
		 	$objectMgr = new RequestMgr();
		 	$objplot = $objectMgr->getObject($id); 
		 	for ($i=0; $i < count($objplot->children); $i++) { 
		 	    for ($j=0; $j < count($objplot->children[$i]->children); $j++) {
		 			$info = $info.' '.$objplot->children[$i]->children[$j]->name;
		 		}
		 	}
			  
		    break; 

		    case 'alias': 
			$info = $id;
			$id = 'alias_'.$id;
                        if ($isLeaf) $isParameter = true;  
		    break;

                    case 'timeTable':
                    case 'sharedtimeTable':
bdac8820   elena   show size for cat...
185
                    case 'catalog':                   
16035364   Benjamin Renard   First commit
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
                        if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
                    break;

                    case 'derivedParam':
                            $info = $child->getAttribute('buildchain');
                            if ($isLeaf) $isParameter = true;
                    break;

                    case 'localParam':

                        $globalStart = null;
                        $globalStop = null;
                        $timeRestriction = false;
                        $specialNode = true;
                        $isParameter = false;
                        $needsArgs = false;
                        $isSpectra = false;                         
                        $isStack = false;

                        if ($child->hasAttribute('desc')) $info = $child->getAttribute('desc');

                        if ($child->hasAttribute('sampling')) 
                        {
                            $info =  "Sampling: ".$child->getAttribute('sampling')."<br/>";
                            if ($child->getAttribute('dataStart') == 'depending on mission')
                            {
                                $info .= "Time Range: ".$child->getAttribute('dataStart')."<br/>";
                            }                             
                            else 
                            {                                
                                $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>";                                
                            }  
                            
                            if ($child->getAttribute('restricted') > 1) {
                                $restricted  = $child->getAttribute('restricted');
                                $info .= "<b>Time Restriction</b>: -$restricted days<br/>";
                            }
                       
                            $info .= "Source: ".$child->getAttribute('dataSource');
                        }
                            
                        if ($child->hasAttribute('units')) $info = $child->getAttribute('units');

                        if ($child->tagName == 'parameter') 
                        {
                                $isParameter = true;
                                $isScatter = true;

                                if ($child->parentNode->hasAttribute('dataStart'))
                                {
                                    $globalStart = $child->parentNode->getAttribute('dataStart');
                                    $globalStop = $child->parentNode->getAttribute('dataStop');  
                                }

                                if ($child->parentNode->getAttribute('restricted') > 1 )
                                {
                                    $timeRestriction = true;
                                     
aec5ba13   Elena.Budnik   not tested param ...
244
245
246
247
248
249
250
251
252
                                }
                                
                                /*------------------- to show not tested parameters ------*/      
				 
                                 if ($child->getAttribute('tbd'))
                                            $info .= "<br/><b>Not tested yet</b>";
				 
				    /*------------------- --------------------------------------*/    				 	                                    
                                
16035364   Benjamin Renard   First commit
253
                        }
aec5ba13   Elena.Budnik   not tested param ...
254
                        
16035364   Benjamin Renard   First commit
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283

                        if ($child->tagName == 'component')
                        {
                                $isParameter = true;
                                $isScatter = true;

                                if ($child->parentNode->parentNode->hasAttribute('dataStart'))
                                {
                                    $globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
                                    $globalStop = $child->parentNode->parentNode->getAttribute('dataStop');  
                                } 

                                if ($child->parentNode->parentNode->getAttribute('restricted') > 1)
                                {
                                    $timeRestriction = true;
                                     
                                }  
         
                        }
                      
                       if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
                                                                                   
                        if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')) {

                              if ($child->getAttribute('display_type') == 'spectrogram') {
                                    $needsArgs = true;                                     
                                    $isSpectra = true; 
                                    $isScatter = false;
                               }
73fd2e71   Elena.Budnik   stackplot
284
                               else if ($child->getAttribute('display_type') == 'stackplot') {                                    
16035364   Benjamin Renard   First commit
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
                                     $isStack = true;
                                     $isScatter = false;
                               }
                        }  
                
                        if ($isParameter) 
                        {
                            if ($child->tagName == 'parameter' && $child->childNodes->length == 1)
                            { 
                                $needsArgs = true;                               
                            }                                          
                             if (substr($id,0,4) == 'bt96' || substr($id,0,6) == 'ba2000'|| substr($id,0,5) == 'bcain' || substr($id,0,7) == 'bmorsch' ) 
                             {                              
                                 $needsArgs = true;
                             }
                            
                            if ($id == 'mex_n_sw' || $id == 'mex_v_sw') 
                             {
                                  $not_yet = true;
                                 
                             }

aa94fd24   elena   Merge with last svn
307
                            //TODO proper conditions
16035364   Benjamin Renard   First commit
308
309
310
                            if (substr($id,0,3) == 'ros') 
                             {
                                if ( !(strpos($id,'_r_') || strpos($id,'_xyz_') || strpos($id,'_cg_')
aa94fd24   elena   Merge with last svn
311
312
                                     || strpos($id,'_sc_') || strpos($id,'_aux_') || strpos($id,'_sw_') 
                                     || strpos($id,'_tao_') )) 
16035364   Benjamin Renard   First commit
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
                                {                                 
                                   $not_yet = true;
                                } 
                             }

                            $objectMgr = new AliasMgr();
                            $alias = $objectMgr->getAlias($id);
                            
                            $childrenToReturn[] = array('text' => $name,'alias' => $alias, 
                                'id' => $id,'nodeType' => $nodeType, 'info' => $info,
                                'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
                                'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
                                'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
                        }
                        else 
                        {
                            if ($child->tagName == 'mission') 
                            {
                                $disable = ($child->getAttribute('available') != "1");
                                $rank = $child->getAttribute('rank');
                            }
                            else
                            {
                                $disable = $child->getAttribute('restricted');
                            }
                            
                            if ($disable)
                            {
                                if ($disable == 1) {
                                    $info .=  "<br/><b>Restricted access</b>";
                                }
                                else {                                   
                                    $disable = false;                                     
                                }
                            }

                            $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info, 
                                'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);                               				    			 			   
                        }
                    break;

                    case 'remoteSimuParam' :

                        $isSimulation = true;
  			if ($id == 'spase://IMPEX/SimulationModel/FMI/GUMICS' ) {
                                        $isLeaf = false;
                                        $isAddable = true;
                        }
                        if ($child->tagName == 'dataCenter') {
                                if ($child->getAttribute('isSimulation')) break;
                                else {
                                    $skip = true;
                                    break;
                                }
                        }
                        if ($child->tagName == 'simulationRegion') 
                            {
                                 $rank = $child->getAttribute('rank');
                            }
 		    case 'remoteParam' :
                         
                        if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter') {
                                $skip = true;
                                break;
                        }

                        $isDeletable = $child->hasAttribute('isDeletable');
			$specialNode = true;
			$isParameter = false; 
                        $isSpectra = false; 
                   
                        switch ($id)  
                        {
                            case 'CDAWEB'  : 
                            case 'OMNIWEB' :  
                                            $isLeaf = false;
                                            break;
                            case 'THEMIS' :
                                            $rank = 5;
                                            break;
                            case 'MAPSKP' :
                                            $rank = 9;
                                            break;
                            case 'VEXGRAZ' :
                                            $rank = 2;
                                            break;
                            default:
                        }
 
                        $info = $child->getAttribute('desc');

// 			if ($info && !$isSimulation) { 
			       $info = str_replace(';', "<br/>Time Range: ", $info);
// 			}
			if ($child->tagName == 'dataset') {
			    /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) 
			      $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>";  */     
// 			      $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>";
                        }
			if (($child->tagName == 'parameter') || ($child->tagName == 'component')) {
				    $isParameter = true;
				    $isScatter = true;					   
			}
			
			$needsArgs =  $child->hasAttribute('needsArgs');

			if (($child->tagName == 'parameter' && $child->hasChildNodes()) || $needsArgs) $isScatter = false;
			
			if ($remoteBase) {
			    if ($child->tagName == 'dataset') $isRemoteDataSet = true; 
			}

			if ($isParameter) {
                            $disable = $child->parentNode->getAttribute('disabled');			   			  
			    $objectMgr = new AliasMgr();
			    $alias = $objectMgr->getAlias($id);


                            if ($child->hasAttribute('display_type') 
                            && $child->getAttribute('display_type') == 'spectrogram'){
                                                $needsArgs = true; 
                                                $isScatter = false;
                                                $isSpectra = true;
                        }       

			    $childrenToReturn[] = array('text' => $name,'alias' => $alias, 
				      'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
				      'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter, 
				      'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs);
			  }
			  else { 
                            if ($child->tagName == 'dataCenter')   
                                $restricted = ($child->getAttribute('available') != "1");                                                        
                            else
                                $restricted = false;
                                 
                            if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') 
                                                                                     $restricted = FALSE;
                            if ($restricted)
                                $info .= "<br/><b>Open soon !</b>";                                                             
                            
                            if ($child->tagName == 'dataset')
                                $nonavailable = ($child->getAttribute('disabled'));
                            else
                                $nonavailable = false;
                            
                            if ($nonavailable)
                                $info .= "<br/><b>Not available yet</b>";

                            if ($child->getAttribute('url'))
                                    $info .= "<br/>".$child->getAttribute('url');

                            if ($child->hasAttribute('obsolete')) {
                                $info = $child->getAttribute('desc');
                                $obsolete = true;
                            }
                            else
                                $obsolete = false;

                            $disable = $restricted || $nonavailable || $obsolete;
			    $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
			    'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable, 
                            'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);				    			 			   
			  }
			
		    break;
		     case 'myData' :  
			    $info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
			  //  $info = str_replace("\n","<br/>",$info);
			    break;

                    case 'myDataParam' :

                        $globalStart = null;
                        $globalStop = null;
                        $specialNode = true;
                        $size = $child->getAttribute('size');
                        $isScatter = $size == 1;
                        $mask = $child->getAttribute('mask');
                        $isSpectra = false;

                        
                        if ($isLeaf) {
                            $isParameter = true;
                            $info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
                            $isSpectra = $child->getAttribute('plottype') === 'Spectra';
                        }

                        if ($child->hasAttribute('desc')) {
                            $globalStart = substr(str_replace('-','/',$child->getAttribute('desc')), 0, 16);
                            $globalStop =  substr(str_replace( '-','/',$child->getAttribute('desc')), 17, 22);
                        }

                        $childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,  
                        'globalStart' => $globalStart, 'globalStop' => $globalStop,
                        'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf, 
                        'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

                        break;
                    default: 
		}
	
		if (!$specialNode && !$skip) {
		       if ($child->hasAttribute('desc')) 
			    $info = $child->getAttribute('desc');
			$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, 
                                                    'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
		}
	      }
		// if $childrenToReturn we have to return []
		 if ($childrenToReturn == null) {			
			$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
		 }
        }

      return  $childrenToReturn;
 }

    public  function saveTree($obj) 
    {
            $paramMgr = new ParamMgr();
            return $paramMgr->saveTree($obj);            
    }

    public  function doNothing($obj) 
    {	    
        return array("res" => 'ok');
        
    }

    public  function deleteFromTree($obj) 
    {    
        $paramMgr = new ParamMgr();
        return $paramMgr->deleteFromTree($obj);
        
    }

/*
*  temporary object fromUpload
*/ 
    public  function getUploadedObject($name, $format, $nodeType)
    {  
            switch ($nodeType) 
            {
                case 'timeTable' : 
                        $objectMgr = new TimeTableMgr();		  
                        break;
                case 'myDataParam' : 
                        $objectMgr = new FilesMgr();			  	  
                        break;
                default:
                        return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
            }
            return  $objectMgr -> getUploadedObject($name, $format, true);
aa94fd24   elena   Merge with last svn
567

16035364   Benjamin Renard   First commit
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
    }	

/*
*  fill ascii file into grid 
*/ 
    public  function getAsciiFile($obj) 
    {  
            $objectMgr = new FilesMgr();			  	  			
            return  $objectMgr -> getAsciiFile($obj->fileName);
    }
	
    public  function getParamInfo($object) 
    {   	     
            $objectMgr = new FilesMgr();			  	   	 
            return  $objectMgr -> getParamInfo($object);
    }	

/*
*  temporary object from Search 
*/ 
    public  function getTmpObject($folderId, $name, $nodeType) {  
aa94fd24   elena   Merge with last svn
589

16035364   Benjamin Renard   First commit
590
591
592
593
 
	    switch ($nodeType) {
		  case 'timeTable' : 
			   $objectMgr = new TimeTableMgr();		  
d18b535d   elena   catalog draft + c...
594
595
596
597
			   break; 
		 case 'catalog' :
			   $objectMgr = new CatalogMgr();		  
			   break; 	   
16035364   Benjamin Renard   First commit
598
599
600
601
		  default:
			    return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
              }
	      return  $objectMgr -> getTmpObject($folderId, $name, true);
aa94fd24   elena   Merge with last svn
602

16035364   Benjamin Renard   First commit
603
604
605
606
607
608
609
610
611
612
613
614
615
    }
 

    public  function getObject($id, $nodeType) {  
 
	    switch ($nodeType) {
		  case 'myDataParam':
		  case 'derivedParam' : 
			   $objectMgr = new DerivedParamMgr($nodeType);			   
			   break;
		  case 'timeTable' : 
		  case 'sharedtimeTable' :
			   $objectMgr = new TimeTableMgr();			  
048b4d77   elena   catalogs +
616
617
618
			   break;  
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();			  
16035364   Benjamin Renard   First commit
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
			   break; 
		  case 'condition' : 		  
		  case 'request' :
			   $objectMgr = new RequestMgr($nodeType);			  
			   break; 
		  case 'bkgWorks' :
		  	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		  	return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
			   break;
		  case 'myData' :
			   $objectMgr = new FilesMgr();			  
			   break;
		  default:
			    return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> getObject($id, $nodeType);
    }
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
    public  function deleteObject($obj) {  
 
	    switch ($obj->nodeType) {  
		  
		  case 'myDataParam' : 
		  case 'derivedParam' : 
			   $objectMgr = new DerivedParamMgr($obj->nodeType);			   
			   break;
		  case 'timeTable' : 
			   $objectMgr = new TimeTableMgr();			  
d18b535d   elena   catalog draft + c...
650
651
652
			   break; 
		  case 'catalog' : 
			   $objectMgr = new CatalogMgr();			  
16035364   Benjamin Renard   First commit
653
654
655
656
657
658
659
660
661
662
663
664
			   break;
		  case 'condition' : 		  
		  case 'request' :
			   $objectMgr = new RequestMgr($obj->nodeType);			  
			   break;
		  case 'alias' :
		  	   $objectMgr = new AliasMgr();
		  	   $obj->id = substr($obj->id,strlen('alias_'));
		  	   break;   
		  case 'bkgWorks' :
		  	   require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		  	   return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);
aa94fd24   elena   Merge with last svn
665

16035364   Benjamin Renard   First commit
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
		  case 'myData' :
				$objectMgr = new FilesMgr();
			   break;
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> deleteObject($obj);
    }

/*
*   $obj = { id: node.id, old_name: node.text, name: value,  parent : node.parentNode.id, leaf: node.leaf, nodeType: node.nodeType }
*/
    public  function renameObject($obj) {  
 
	    switch ($obj->nodeType) {
		  
		  case 'myDataParam' :
		  case 'derivedParam' : 
			   $objectMgr = new DerivedParamMgr($obj->nodeType);			   
			   break;
		  case 'timeTable' : 
			   $objectMgr = new TimeTableMgr();			  
d18b535d   elena   catalog draft + c...
689
690
			   break;
		  case 'catalog' : 
255e4546   elena   bug in cat rename
691
			   $objectMgr = new CatalogMgr();			  
16035364   Benjamin Renard   First commit
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
			   break;		  
		  case 'condition' : 
		  case 'request' : 
			   $objectMgr = new RequestMgr($obj->nodeType);			  
			   break;
		  case 'alias' :
		  	   $objectMgr = new AliasMgr();  
		  	   break;   
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> renameObject($obj);
    }

/*   
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
    public  function createObject($obj, $folder) {  
 
	    switch ($obj->nodeType) {

		  case 'myDataParam' :                           
		  case 'derivedParam' :
                        if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success) 
                             $this->amdaStat->addTask('create', $this->user, null);

                        $objectMgr = new DerivedParamMgr($obj->nodeType);			   
                        break;		  
		  case 'timeTable' : 
                        $objectMgr = new TimeTableMgr();			  
d18b535d   elena   catalog draft + c...
723
724
725
			   break; 
		  case 'catalog' : 
                        $objectMgr = new CatalogMgr();			  
16035364   Benjamin Renard   First commit
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
			   break;
		  case 'condition' :
		  case 'request' : 
			   $objectMgr = new RequestMgr($obj->nodeType);			  
			   break;		
		  case 'alias' :
			    $objectMgr = new AliasMgr();  
			    break;   
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> createObject($obj, $folder);
    }

/*   
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
    public  function modifyObject($obj) {
 
	    switch ($obj->nodeType) {  

		  case 'myDataParam' : 
		  case 'derivedParam' : 
			   $objectMgr = new DerivedParamMgr($obj->nodeType);			   
			   break;
		  case 'timeTable' : 
			   $objectMgr = new TimeTableMgr();			  
d18b535d   elena   catalog draft + c...
754
755
756
757
			   break;
		  case 'catalog' : 
			   $objectMgr = new CatalogMgr();			  
			   break;  	   
16035364   Benjamin Renard   First commit
758
759
760
761
762
763
764
765
766
		  case 'condition' : 
		  case 'request' :
			   $objectMgr = new RequestMgr($obj->nodeType);			  
			   break;
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> modifyObject($obj);
aa94fd24   elena   Merge with last svn
767
    }   
16035364   Benjamin Renard   First commit
768
769
770
771
772
773
774
775
776
777
/*
 * {obj.name, obj.nodeType, obj.leaf}
 */
    public function validNameObject($obj) {
		switch ($obj->nodeType) {
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
				break;
			case 'timeTable' :
d18b535d   elena   catalog draft + c...
778
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
779
780
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
781
782
783
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
784
785
786
787
788
789
790
791
792
793
794
795
796
797
			case 'condition' :
			case 'request' :
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}

		return  $objectMgr -> validNameObject($obj);
    }

/*
*   Get Jobs en cours
*/
aa94fd24   elena   Merge with last svn
798

16035364   Benjamin Renard   First commit
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
    public  function getJobs()
    {
    	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
    	return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);  
    }


	/* AKKA-KERNEL-INT
	Move user check from RequestMgr.php to AmdaAction.php
	*/
	private function checkUser($obj)
	{
		if (defined('NEWKERNEL_DEBUG') && NEWKERNEL_DEBUG)
		{
			$this->user = NEWKERNEL_DEBUG_USER;
			return array('success' => true);
		}
			
		
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
        {
			//$dd = new WSUserMgr();
            //$dd->init($obj->username,$obj->password,$obj->sessionID);
			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support not implemented");
        }
        else
			$dd = new UserMgr();
			
        //TODO error handling 
        if (($res = $dd -> ddCheckUser()) != 0)
		{
			if ($res == 156) 
				return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!');

            return array('success' => false, 'message' => 'ddLogin error: '.$res);
        }

        if ($dd->user == 'impex')
		{
			//if ($dd->getWsSize() > DISK_QUOTA * 100)
			//	error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
        }
        else
		{
			// check disk space
            if ($dd->getWsSize() > DISK_QUOTA)
				return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available');
        }
		
        $this->user = $dd->user;
        
		return array('success' => true, 'userHost' => $dd -> getIPclient());
	}
	
	private function executeRequest($obj, $function)
	{
		$res = $this->checkUser($obj);
		
		if (!$res['success'])
			return $res;
		
		$requestManager = new RequestManagerClass();
		
		try {
			$res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj);
		} catch (Exception $e) {
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
		}
		
		return $res;
	}
	
/*   
*    Main EXECUTE PROCEDURE 
*/
    public  function execute($node, $obj)
	{ 
		require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		if (isset($obj->action))
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
		else
			return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
    }
    
/*
a0b3d64e   Benjamin Renard   Derived parameter...
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
 * Generate derived parameter compilation
 */
    public function compilParam($obj)
    {
    	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
    	return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
    }

/*
 * Delete derived parameter compilation
 */
   public function compilParamDelete($obj)
   {
		require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		$res = $this->checkUser($obj);
		
		if (!$res['success'])
			return $res;
		
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
    	return array("success" => true);
   }
    
/*
e6e5b259   Benjamin Renard   Add kill plot req...
912
 * kill plot process
16035364   Benjamin Renard   First commit
913
914
 */
    
e6e5b259   Benjamin Renard   Add kill plot req...
915
916
917
918
    public function killPlotRequest()
    {   
    	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
    	return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
16035364   Benjamin Renard   First commit
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
    }

/*
 * merge time tables
 */
    public  function merge($obj)   {

        if ($this->amdaStat->success)
            $this->amdaStat->addTask('ttoper', $this->user, null);
                
        $objectMgr = new TimeTableMgr();

    return  $objectMgr -> merge($obj);

    }

    
/*
 * intersect time tables
 */
        public  function intersect($obj)   {

            if ($this->amdaStat->success)
                $this->amdaStat->addTask('ttoper', $this->user, null);

            $objectMgr = new TimeTableMgr();
            $result = $objectMgr -> intersect($obj);

            return  $result;
        }
048b4d77   elena   catalogs +
949
        
f9c8b272   elena   edit catalog
950
        public function initTTCache($isCatalog = false, $nparams)
16035364   Benjamin Renard   First commit
951
        {
048b4d77   elena   catalogs +
952
953
954
        	if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
        	else              $cacheMgr = new CatalogCacheMgr();
        	
f9c8b272   elena   edit catalog
955
        	return $cacheMgr->initTTCache($nparams);
16035364   Benjamin Renard   First commit
956
957
        }
        
d18b535d   elena   catalog draft + c...
958
        
16035364   Benjamin Renard   First commit
959
960
        public function initTTCacheFromTT($id, $type)
        {
048b4d77   elena   catalogs +
961
962
963
        	if ($type == 'catalog') $cacheMgr = new CatalogCacheMgr();
        	else $cacheMgr = new TimeTableCacheMgr();
        	
16035364   Benjamin Renard   First commit
964
965
966
        	return $cacheMgr->initFromTT($id, $type);
        }
        
9d412dda   elena   catalog tmp and r...
967
        public function initForChart($id, $name, $isTmpObject, $type)
86263051   elena   visu second draft
968
969
        {
        	if ($type == 'catalog') $objMgr = new CatalogMgr();
9d412dda   elena   catalog tmp and r...
970
971
        	        	         	
        	return $objMgr->initForChart($id, $name, $isTmpObject, $type);
86263051   elena   visu second draft
972
973
        }
        
d18b535d   elena   catalog draft + c...
974
        public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
16035364   Benjamin Renard   First commit
975
        {
d18b535d   elena   catalog draft + c...
976
977
978
979
980
981
			if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
				 
			else              $cacheMgr = new CatalogCacheMgr();
					   
			 
		
16035364   Benjamin Renard   First commit
982
983
984
985
986
987
988
989
990
991
992
        	return $cacheMgr->initFromTmpObject($folderId, $name);
        }
        
        public function initTTCacheFromUploadedFile($name, $format)
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->initFromUploadedFile($name, $format);
        }
        
        public function readTTCacheIntervals($o)
        {
d18b535d   elena   catalog draft + c...
993
994
995
        	if ($o->typeTT == 'catalog') $cacheMgr = new CatalogCacheMgr();
        	else $cacheMgr = new TimeTableCacheMgr();
        	
16035364   Benjamin Renard   First commit
996
997
        	return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter);
        }
86263051   elena   visu second draft
998
999
1000
1001
1002
1003
        
	 public function readIntervalsForChart($o)
        {
        	if ($o->typeTT == 'catalog') $objMgr = new CatalogMgr();
        	 
        	
9d412dda   elena   catalog tmp and r...
1004
        	return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT);
86263051   elena   visu second draft
1005
1006
        }
        
16035364   Benjamin Renard   First commit
1007
1008
1009
1010
1011
1012
1013
1014
        public function saveTTCacheIntervalsInTT($o)
        {
        	$cacheMgr = new TimeTableCacheMgr();
            return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
        }
        
        public function addTTCacheInterval($o)
        {
f9c8b272   elena   edit catalog
1015
1016
1017
          	if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
          	else $cacheMgr = new TimeTableCacheMgr();
    	
16035364   Benjamin Renard   First commit
1018
1019
1020
            return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
        }
        
70aabdee   elena   catalog draft
1021
        public function removeTTCacheIntervalFromId($id, $isCatalog = false)
16035364   Benjamin Renard   First commit
1022
        {
70aabdee   elena   catalog draft
1023
1024
        	if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
        	else $cacheMgr = new TimeTableCacheMgr();
f9c8b272   elena   edit catalog
1025
  	
16035364   Benjamin Renard   First commit
1026
1027
1028
1029
1030
        	return $cacheMgr->removeIntervalFromId($id);
        }
        
        public function modifyTTCacheInterval($o)
        {
f9c8b272   elena   edit catalog
1031
1032
1033
1034
1035
1036
1037
1038
        	if ($o->isCatalog) {
        	
			$cacheMgr = new CatalogCacheMgr();
		return $cacheMgr->modifyIntervalFromId($o);
		
		}
          	else $cacheMgr = new TimeTableCacheMgr();
          	
16035364   Benjamin Renard   First commit
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
        	return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop);
        }
        
        public function operationTTCacheIntervals($extendTime, $shiftTime)
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->operationIntervals($extendTime, $shiftTime);
        }
        
        public function mergeTTCacheIntervals()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->mergeIntervals();
        }
        
        public function getTTCacheStatistics()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->getStatistics();
        }
        
        public function getTTCacheStatus()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->getStatus();
        }
aa94fd24   elena   Merge with last svn
1065

16035364   Benjamin Renard   First commit
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
/*
 * Send a feedback
 * 
 */
        public function sendFeedback($feed)
        {
            $feedMgr = new FeedbackMgr();
            return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
        }
    
/*
 * Save state
 * 
 */
        public function saveState($datas)
        {
            $myStateMgr = new StateMgr();
            return $myStateMgr->saveState($datas);
        }
    
/*
 * Load state
 * 
 */    
        public function loadState($o)
        {	
                $myStateMgr = new StateMgr();
                return $myStateMgr->loadState();
        }
	
/* 
 * SAMP
 */
        public function sendToSAMP($o)
        {                
                if ($this->amdaStat->success)
                    $this->amdaStat->addTask('samp', $this->user, null);

                $objectMgr = new RequestMgr();
                $res = $objectMgr->generateVOTableFromDownloadResult($o->folderId, $o->downId,true,true);
                if ($res['success'])
                {
                    foreach ($res['files'] as $key => $value)
                    $res['files'][$key] = str_replace(BASE_PATH,"",$value);
                }
                return $res;
        }
	
/*
 * HST Images
 */
        public function getHstImagesUrl($o)
        {
                if ($this->amdaStat->success)
                    $this->amdaStat->addTask('images', $this->user, null);
                
                $myHstMgr = new HstMgr();
                $res = $myHstMgr->getImagesUrl($o->startTime, $o->stopTime, $o->planet);
                //if ($domRes->length <= 0)
                //	return array('success' => false, 'message' => 'Cannot find HST Images for this request.');
                return array('success' => true, 'result' => $res);
        }
	
        public function getAPISImagesUrl($o)
        {
                if ($this->amdaStat->success) 
                    $this->amdaStat->addTask('images', $this->user, null);
                		
                $apisMgr = new APISMgr();
b7796276   Benjamin Renard   Migration to supp...
1135
                $res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);
16035364   Benjamin Renard   First commit
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214

                return $res;
        }	
/*
 * Filters
 */
        public function loadFilterList($o)
        {
                $filtersMgr = new FiltersMgr(); 
                $res = $filtersMgr->loadList();
                return $res;
        }

        public function loadFilters($o)
        {
                $filtersMgr = new FiltersMgr();
                if (isset($o->id))
                    $res = $filtersMgr->loadFilter($o->id);
                else
                    $res = $filtersMgr->loadAll();
                return $res;
        }
	
        public function saveFilter($o)
        {
                $filtersMgr = new FiltersMgr();		
                return $filtersMgr->save($o);
        }
	
        public function createFilter($o)
        {
                $filtersMgr = new FiltersMgr();		
                return $filtersMgr->create($o);
        }
	
        public function destroyFilter($o)
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->delete($o);
                return;
        }
	
        public function getCrtFilterId()
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->getCrtId();
                return $res;
        }
	
        public function getCrtFilterResult()
        {
                $filtersMgr = new FiltersMgr();		
                return $filtersMgr->getCrtResult();
        }
	
        public function setCrtFilterId($o)
        {
                $filtersMgr = new FiltersMgr();		
                return $filtersMgr->setCrtId($o->id);
        }
	
        public function resetFilter()
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->reset();
                return $res;
        }
  
	public function logout($isGuest)
	{
                if ($isGuest) {
                    $guestMgr = new Guest($this->user);
                    $guestMgr->deleteGuest();
                }
                else {
                    $myBaseMgr = new BaseManager();
                    $myBaseMgr->delSimuFiles('mysimudata');   
		    $myBaseMgr->delSimuFiles('mywsrdata');     
                
18d4a11e   Benjamin Renard   Save and load plo...
1215
                    $this->cleanUserWS();
16035364   Benjamin Renard   First commit
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
                 }               
		return;
	} 

        public function getInfo($obj)
        {
                if (file_exists(HELPPATH.$obj->name)) 
                {
                        $content = file_get_contents(HELPPATH.$obj->name);		      
                        return  array('success' => true, 'result' => $content);
                }
                return array('success' => false);
                
        }	
	
        public function getUserInfo()
        {
                    $dd = new UserMgr();
                    return $dd->getUserInfo();
        }

        public function convertWS()
        {
                 $dd = new UserMgr();
                 return $dd->convertWS();
        }

// $obj ={"Object":"Earth","RunCount":"2",
// "SW_Density_value":"10","SW_Density_weight":"1","SW_Density_scale":"7","SW_Temperature_value":"100", ....}
        public function getRun($obj)
        {

            $myBestRunsMgr = new BestRunsMgr();
            $res = $myBestRunsMgr->getRun($obj);
        
            return  $res; 
        }
        
    //$obj = array of IDs    
        public function addRun($obj)
        {
            $myBestRunsMgr = new BestRunsMgr();
            $myBestRunsMgr->init();
            $myBestRunsMgr->addRuns($obj);

            $res =  array('success' => true,'addedRuns' => $obj);
        return $res;
aa94fd24   elena   Merge with last svn
1263
        }        
16035364   Benjamin Renard   First commit
1264
1265
1266
        //AKKA - New action to clean user WS
        public function cleanUserWS()
        {
70aabdee   elena   catalog draft
1267
          	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
e82af71b   elena   catalog draft
1268
         	return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
16035364   Benjamin Renard   First commit
1269
1270
1271
1272
1273
1274
1275
1276
        }

        public function deleteSpecialInfo($name)
        {
             if (file_exists(USERDIR.$name)) 
                                    unlink(USERDIR.$name);
             return array('success' => true);
        }
9f08f4eb   Benjamin Renard   Zoom in interacti...
1277
        
488b1401   Benjamin Renard   Interactive multi...
1278
        public function interactivePlot($obj, $multiPlotState)
9f08f4eb   Benjamin Renard   Zoom in interacti...
1279
1280
        {
        	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
488b1401   Benjamin Renard   Interactive multi...
1281
1282
1283
1284
1285
        	$inputobj = (Object)array(
        		'action' => $obj,
        		'multiPlotState' => $multiPlotState
        	);
        	return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
9f08f4eb   Benjamin Renard   Zoom in interacti...
1286
        }
ced82260   Benjamin Renard   Get initial plot ...
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
        
        public function getParamPlotInit($obj)
        {
        	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
        	$inputobj = (Object)array(
        			'paramId' => $obj->paramId,
        			'type' => 'plot_init'
        	);
        	return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
        }
16035364   Benjamin Renard   First commit
1297
1298
}
?>
aa94fd24   elena   Merge with last svn