Blame view

php/classes/AmdaAction.php 46.8 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
 *
 */


class AmdaAction {

5de62950   Nathanael Jourdane   Improve the VOTab...
11
    private $xmlFiles  = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
16035364   Benjamin Renard   First commit
12
                                'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
5de62950   Nathanael Jourdane   Improve the VOTab...
13
14
                                'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
                                'myData' => 'Files.xml',
16035364   Benjamin Renard   First commit
15
16
17
18
                                'request' => 'Request.xml', 'condition' => 'Request.xml',
                                'bkgWorks' => 'jobs.xml');

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

5de62950   Nathanael Jourdane   Improve the VOTab...
20
21
    public function __construct()
    {
aa94fd24   elena   Merge with last svn
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
    }

    private function getUrlDirs($url) {
        //TODO replace by ftp php class methods: ftp_nlist() etc
        require_once "simple_html_dom.php";
5de62950   Nathanael Jourdane   Improve the VOTab...
31
32

        $url = html_entity_decode($url);
16035364   Benjamin Renard   First commit
33
34
        $trimmed_url = trim($url);
        if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1) {
5de62950   Nathanael Jourdane   Improve the VOTab...
35
            if (file_exists("temp.html")) unlink("temp.html");
16035364   Benjamin Renard   First commit
36
            exec("wget -O temp.html ".$url);
5de62950   Nathanael Jourdane   Improve the VOTab...
37

16035364   Benjamin Renard   First commit
38
39
40
41
42
43
            $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,
5de62950   Nathanael Jourdane   Improve the VOTab...
44
                                    'nodeType' => 'url', 'leaf' => $isLeaf);
16035364   Benjamin Renard   First commit
45
            }
5de62950   Nathanael Jourdane   Improve the VOTab...
46

16035364   Benjamin Renard   First commit
47
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
48
      return $childrenToReturn;
16035364   Benjamin Renard   First commit
49
    }
5de62950   Nathanael Jourdane   Improve the VOTab...
50

16035364   Benjamin Renard   First commit
51
52
/*****************************************************************
*                           PUBLIC FUNCTIONS
5de62950   Nathanael Jourdane   Improve the VOTab...
53
54
*****************************************************************/

16035364   Benjamin Renard   First commit
55
56
57
58
    /*
    *   $obj = { id: node.id,  nodeType: node.nodeType }
    */
    public function getTree($obj) {
5de62950   Nathanael Jourdane   Improve the VOTab...
59

16035364   Benjamin Renard   First commit
60
       $node = $obj->node;
5de62950   Nathanael Jourdane   Improve the VOTab...
61
62

    // to correct 'restricted' parameters
16035364   Benjamin Renard   First commit
63
64
65
66
67
68
69
70
        if (strpos($node, restricted) !== false) {
            $node = str_replace(restricted,"",$node);
        }

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

5de62950   Nathanael Jourdane   Improve the VOTab...
71
        if ($nodeType == 'url')
16035364   Benjamin Renard   First commit
72
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
73
            $url = $node == 'root' ? $obj->baseId : $node;
16035364   Benjamin Renard   First commit
74
75
76
77
78
79
80
            return  $this->getUrlDirs($url);
        }

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

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

5de62950   Nathanael Jourdane   Improve the VOTab...
81
82
        if ($node == 'root' && !$remoteBase)
        {
16035364   Benjamin Renard   First commit
83
            $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
5de62950   Nathanael Jourdane   Improve the VOTab...
84
85
86
            $childrenToReturn = $json_o->nodes;
        }
        else
16035364   Benjamin Renard   First commit
87
88
89
        {
            $Dom = new DomDocument("1.0");

5de62950   Nathanael Jourdane   Improve the VOTab...
90
            switch ($nodeType)
16035364   Benjamin Renard   First commit
91
92
            {
                case 'sharedtimeTable':
169f14d2   Benjamin Renard   Add shared object...
93
94
95
                case 'sharedcatalog':
                		$xmlName = SHAREDPATH.'/SharedObjectTree.xml';
                           break;
5de62950   Nathanael Jourdane   Improve the VOTab...
96
                case 'bkgWorks':
16035364   Benjamin Renard   First commit
97
98
99
                        $xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
                        break;
                case 'source':
5de62950   Nathanael Jourdane   Improve the VOTab...
100
101
102
103
                        $xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
                        break;
                case 'destination':
                        $xmlName = USERWSDIR.'RemoteParams.xml';
16035364   Benjamin Renard   First commit
104
                        break;
16035364   Benjamin Renard   First commit
105
106
107
108
                default:
                        $xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
            }

5de62950   Nathanael Jourdane   Improve the VOTab...
109
110
	    if ($remoteBase)
            {
16035364   Benjamin Renard   First commit
111
                 $nodeType = 'remoteParam';
5de62950   Nathanael Jourdane   Improve the VOTab...
112
113
	    }

16035364   Benjamin Renard   First commit
114
	    $Dom->load($xmlName);
5de62950   Nathanael Jourdane   Improve the VOTab...
115
116

	    if ($node == "myRemoteSimuData-treeRootNode")
169f14d2   Benjamin Renard   Add shared object...
117
			$node = "myRemoteData-treeRootNode";
5de62950   Nathanael Jourdane   Improve the VOTab...
118

16035364   Benjamin Renard   First commit
119
120
121
	    $nodeToOpen = $Dom->getElementById($node);
	    $children = $nodeToOpen->childNodes;

5de62950   Nathanael Jourdane   Improve the VOTab...
122
	    foreach ($children as $child)
16035364   Benjamin Renard   First commit
123
124
	      if ($child->nodeType == XML_ELEMENT_NODE) {
		  $isLeaf = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
125

16035364   Benjamin Renard   First commit
126
                if ($child->hasChildNodes())
5de62950   Nathanael Jourdane   Improve the VOTab...
127
                    foreach ($child->childNodes as $grandChild)
16035364   Benjamin Renard   First commit
128
129
130
131
                    if ($grandChild -> nodeType == XML_ELEMENT_NODE)  {
                            $isLeaf = false;
                            break;
                        }
16035364   Benjamin Renard   First commit
132
133
                if ($child->tagName == 'folder')  $isLeaf = false;

5de62950   Nathanael Jourdane   Improve the VOTab...
134
135
                //TODO MAKE PROPERLY  as function of nodetype !!!!
                $info = '';
16035364   Benjamin Renard   First commit
136
                $id =  $child->getAttribute('xml:id');
5de62950   Nathanael Jourdane   Improve the VOTab...
137
                $name = $child->getAttribute('name');
16035364   Benjamin Renard   First commit
138
139
140
141
142
143
                $help = $child->getAttribute('att');
                if ($child->hasAttribute('dataStart')) $dataStart = $child->getAttribute('dataStart');
                if ($child->hasAttribute('dataStop')) $dataStop = $child->getAttribute('dataStop');

                $specialNode = false;
                $isParameter = false;
57bf8841   Elena.Budnik   correct mydataPar...
144
                $isAddable =  false;
16035364   Benjamin Renard   First commit
145
146
147
                $isSimulation = false;
                $rank = null;

5de62950   Nathanael Jourdane   Improve the VOTab...
148
                switch ($nodeType)
16035364   Benjamin Renard   First commit
149
                {
5de62950   Nathanael Jourdane   Improve the VOTab...
150
		    case 'bkgWorks':
16035364   Benjamin Renard   First commit
151
152
			$specialNode = true;
			$status = $child->getAttribute('status');
5de62950   Nathanael Jourdane   Improve the VOTab...
153
		    //     if ($status == 'done') continue;
16035364   Benjamin Renard   First commit
154
			$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'leaf' => $isLeaf,
5de62950   Nathanael Jourdane   Improve the VOTab...
155
					  'pid' => $child->getAttribute('pid'), 'status' => $status,
16035364   Benjamin Renard   First commit
156
157
158
159
160
					  'jobType' => $child->getAttribute('jobType'), 'info' => $child->getAttribute('info'));
		    break;

		    case 'condition':
			$objectMgr = new RequestMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
161
162
			$info = $objectMgr->getObject($id)->expression;
		    break;
16035364   Benjamin Renard   First commit
163
164

		    case 'request':
5de62950   Nathanael Jourdane   Improve the VOTab...
165

16035364   Benjamin Renard   First commit
166
		 	$objectMgr = new RequestMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
167
168
		 	$objplot = $objectMgr->getObject($id);
		 	for ($i=0; $i < count($objplot->children); $i++) {
16035364   Benjamin Renard   First commit
169
170
171
172
		 	    for ($j=0; $j < count($objplot->children[$i]->children); $j++) {
		 			$info = $info.' '.$objplot->children[$i]->children[$j]->name;
		 		}
		 	}
16035364   Benjamin Renard   First commit
173

5de62950   Nathanael Jourdane   Improve the VOTab...
174
175
176
		    break;

		    case 'alias':
16035364   Benjamin Renard   First commit
177
178
			$info = $id;
			$id = 'alias_'.$id;
5de62950   Nathanael Jourdane   Improve the VOTab...
179
                        if ($isLeaf) $isParameter = true;
16035364   Benjamin Renard   First commit
180
181
182
		    break;

                    case 'timeTable':
5de62950   Nathanael Jourdane   Improve the VOTab...
183
                    case 'catalog':
16035364   Benjamin Renard   First commit
184
185
                        if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
                    break;
169f14d2   Benjamin Renard   Add shared object...
186
187
188
189
190
191
192
193
                    case 'sharedtimeTable':
                    case 'sharedcatalog':
                    	if ($isLeaf) {
                    		$info = '<b>Nb intervals:</b> '.$child->getAttribute('nbIntervals').'<br/>';
                    		$info .= '<b>Shared by:</b> '.$child->getAttribute('sharedBy').' ('.$child->getAttribute('sharedDate').')<br/>';
                    		$info .= '<b>Description:</b> '.$child->getAttribute('description');
                    	}
                    	break;
16035364   Benjamin Renard   First commit
194
195
196
197
198
199
200
201
202
203
204
205
206
                    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;
5de62950   Nathanael Jourdane   Improve the VOTab...
207
                        $isSpectra = false;
16035364   Benjamin Renard   First commit
208
209
                        $isStack = false;

3197b3e2   Elena.Budnik   globalStart, Glob...
210
                        if ($child->hasAttribute('desc')) {
f740e66b   Nathanael Jourdane   Improve the VOTab...
211

3197b3e2   Elena.Budnik   globalStart, Glob...
212
				$info = $child->getAttribute('desc');
f740e66b   Nathanael Jourdane   Improve the VOTab...
213
214
215

				if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
					$info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
3197b3e2   Elena.Budnik   globalStart, Glob...
216
				}
f740e66b   Nathanael Jourdane   Improve the VOTab...
217

3197b3e2   Elena.Budnik   globalStart, Glob...
218
219
				if ($child->getAttribute('dataStart') == 'depending on mission'){
					$info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
f740e66b   Nathanael Jourdane   Improve the VOTab...
220
221
				}

3197b3e2   Elena.Budnik   globalStart, Glob...
222
223
224
225
226
				if ($child->getAttribute('restriction') > 1) {
					$restricted  = $child->getAttribute('restriction');
					$info .= "<br/><b>Time Restriction</b>: -$restricted days";
				}
			   }
16035364   Benjamin Renard   First commit
227

f740e66b   Nathanael Jourdane   Improve the VOTab...
228

b02c37dd   Elena.Budnik   before merge
229
<<<<<<< HEAD
5de62950   Nathanael Jourdane   Improve the VOTab...
230
                        if ($child->hasAttribute('sampling'))
16035364   Benjamin Renard   First commit
231
232
233
234
235
                        {
                            $info =  "Sampling: ".$child->getAttribute('sampling')."<br/>";
                            if ($child->getAttribute('dataStart') == 'depending on mission')
                            {
                                $info .= "Time Range: ".$child->getAttribute('dataStart')."<br/>";
5de62950   Nathanael Jourdane   Improve the VOTab...
236
237
238
239
240
241
                            }
                            else
                            {
                                $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>";
                            }

16035364   Benjamin Renard   First commit
242
243
244
245
                            if ($child->getAttribute('restricted') > 1) {
                                $restricted  = $child->getAttribute('restricted');
                                $info .= "<b>Time Restriction</b>: -$restricted days<br/>";
                            }
5de62950   Nathanael Jourdane   Improve the VOTab...
246

16035364   Benjamin Renard   First commit
247
248
                            $info .= "Source: ".$child->getAttribute('dataSource');
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
249

b02c37dd   Elena.Budnik   before merge
250
251
=======
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
16035364   Benjamin Renard   First commit
252
253
                        if ($child->hasAttribute('units')) $info = $child->getAttribute('units');

5de62950   Nathanael Jourdane   Improve the VOTab...
254
                        if ($child->tagName == 'parameter')
16035364   Benjamin Renard   First commit
255
256
257
258
259
260
261
                        {
                                $isParameter = true;
                                $isScatter = true;

                                if ($child->parentNode->hasAttribute('dataStart'))
                                {
                                    $globalStart = $child->parentNode->getAttribute('dataStart');
5de62950   Nathanael Jourdane   Improve the VOTab...
262
                                    $globalStop = $child->parentNode->getAttribute('dataStop');
16035364   Benjamin Renard   First commit
263
264
                                }

0f5fecfc   Elena.Budnik   only "restriction...
265
                                if ($child->parentNode->getAttribute('restriction') > 1 )
16035364   Benjamin Renard   First commit
266
267
                                {
                                    $timeRestriction = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
268

aec5ba13   Elena.Budnik   not tested param ...
269
                                }
5de62950   Nathanael Jourdane   Improve the VOTab...
270
271
272

                                /*------------------- to show not tested parameters ------*/

aec5ba13   Elena.Budnik   not tested param ...
273
274
                                 if ($child->getAttribute('tbd'))
                                            $info .= "<br/><b>Not tested yet</b>";
5de62950   Nathanael Jourdane   Improve the VOTab...
275
276
277

				    /*------------------- --------------------------------------*/

16035364   Benjamin Renard   First commit
278
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
279

16035364   Benjamin Renard   First commit
280

63ac7745   Benjamin Renard   Support component...
281
                        $component_info = array();
16035364   Benjamin Renard   First commit
282
283
284
285
286
287
288
289
                        if ($child->tagName == 'component')
                        {
                                $isParameter = true;
                                $isScatter = true;

                                if ($child->parentNode->parentNode->hasAttribute('dataStart'))
                                {
                                    $globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
5de62950   Nathanael Jourdane   Improve the VOTab...
290
291
                                    $globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
                                }
16035364   Benjamin Renard   First commit
292

0f5fecfc   Elena.Budnik   only "restriction...
293
                                if ($child->parentNode->parentNode->getAttribute('restriction') > 1)
16035364   Benjamin Renard   First commit
294
295
                                {
                                    $timeRestriction = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
296
297

                                }
63ac7745   Benjamin Renard   Support component...
298
299
300
301
302

                                if ($child->hasAttribute("index1"))
                                	$component_info["index1"] = $child->getAttribute('index1');
                                if ($child->hasAttribute("index2"))
                                	$component_info["index2"] = $child->getAttribute('index2');
5de62950   Nathanael Jourdane   Improve the VOTab...
303

63ac7745   Benjamin Renard   Support component...
304
                                $component_info["parentId"] = $child->parentNode->getAttribute('xml:id');
16035364   Benjamin Renard   First commit
305
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
306

16035364   Benjamin Renard   First commit
307
                       if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
5de62950   Nathanael Jourdane   Improve the VOTab...
308

16035364   Benjamin Renard   First commit
309
310
311
                        if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')) {

                              if ($child->getAttribute('display_type') == 'spectrogram') {
5de62950   Nathanael Jourdane   Improve the VOTab...
312
313
                                    $needsArgs = true;
                                    $isSpectra = true;
16035364   Benjamin Renard   First commit
314
315
                                    $isScatter = false;
                               }
5de62950   Nathanael Jourdane   Improve the VOTab...
316
                               else if ($child->getAttribute('display_type') == 'stackplot') {
16035364   Benjamin Renard   First commit
317
318
319
                                     $isStack = true;
                                     $isScatter = false;
                               }
5de62950   Nathanael Jourdane   Improve the VOTab...
320
321
322
                        }

                        if ($isParameter)
16035364   Benjamin Renard   First commit
323
324
                        {
                            if ($child->tagName == 'parameter' && $child->childNodes->length == 1)
5de62950   Nathanael Jourdane   Improve the VOTab...
325
326
327
328
                            {
                                $needsArgs = true;
                            }
                             if (substr($id,0,4) == 'bt96' || substr($id,0,6) == 'ba2000'|| substr($id,0,5) == 'bcain' || substr($id,0,7) == 'bmorsch' )
b02c37dd   Elena.Budnik   before merge
329
<<<<<<< HEAD
5de62950   Nathanael Jourdane   Improve the VOTab...
330
                             {
16035364   Benjamin Renard   First commit
331
332
                                 $needsArgs = true;
                             }
5de62950   Nathanael Jourdane   Improve the VOTab...
333
334

                            if ($id == 'mex_n_sw' || $id == 'mex_v_sw')
16035364   Benjamin Renard   First commit
335
336
                             {
                                  $not_yet = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
337

16035364   Benjamin Renard   First commit
338
339
                             }

aa94fd24   elena   Merge with last svn
340
                            //TODO proper conditions
5de62950   Nathanael Jourdane   Improve the VOTab...
341
                            if (substr($id,0,3) == 'ros')
16035364   Benjamin Renard   First commit
342
343
                             {
                                if ( !(strpos($id,'_r_') || strpos($id,'_xyz_') || strpos($id,'_cg_')
5de62950   Nathanael Jourdane   Improve the VOTab...
344
345
346
                                     || strpos($id,'_sc_') || strpos($id,'_aux_') || strpos($id,'_sw_')
                                     || strpos($id,'_tao_') ))
                                {
16035364   Benjamin Renard   First commit
347
                                   $not_yet = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
348
                                }
b02c37dd   Elena.Budnik   before merge
349
=======
f740e66b   Nathanael Jourdane   Improve the VOTab...
350
                             {
16035364   Benjamin Renard   First commit
351
                                 $needsArgs = true;
b02c37dd   Elena.Budnik   before merge
352
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
16035364   Benjamin Renard   First commit
353
354
355
356
                             }

                            $objectMgr = new AliasMgr();
                            $alias = $objectMgr->getAlias($id);
5de62950   Nathanael Jourdane   Improve the VOTab...
357
358

                            $childrenToReturn[] = array('text' => $name,'alias' => $alias,
63ac7745   Benjamin Renard   Support component...
359
                                'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
16035364   Benjamin Renard   First commit
360
361
362
363
                                'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
                                'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
                                'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
364
                        else
16035364   Benjamin Renard   First commit
365
                        {
5de62950   Nathanael Jourdane   Improve the VOTab...
366
                            if ($child->tagName == 'mission')
16035364   Benjamin Renard   First commit
367
                            {
0f5fecfc   Elena.Budnik   only "restriction...
368
                                $disable = $child->hasAttribute('restriction');
16035364   Benjamin Renard   First commit
369
370
371
372
                                $rank = $child->getAttribute('rank');
                            }
                            else
                            {
0f5fecfc   Elena.Budnik   only "restriction...
373
                                $disable = $child->hasAttribute('restriction');
16035364   Benjamin Renard   First commit
374
                            }
5de62950   Nathanael Jourdane   Improve the VOTab...
375

16035364   Benjamin Renard   First commit
376
377
378
379
380
                            if ($disable)
                            {
                                if ($disable == 1) {
                                    $info .=  "<br/><b>Restricted access</b>";
                                }
5de62950   Nathanael Jourdane   Improve the VOTab...
381
382
                                else {
                                    $disable = false;
16035364   Benjamin Renard   First commit
383
384
385
                                }
                            }

5de62950   Nathanael Jourdane   Improve the VOTab...
386
387
                            $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
                                'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
16035364   Benjamin Renard   First commit
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
                        }
                    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;
                                }
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
405
                        if ($child->tagName == 'simulationRegion')
16035364   Benjamin Renard   First commit
406
407
408
409
                            {
                                 $rank = $child->getAttribute('rank');
                            }
 		    case 'remoteParam' :
5de62950   Nathanael Jourdane   Improve the VOTab...
410

16035364   Benjamin Renard   First commit
411
412
413
414
415
416
                        if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter') {
                                $skip = true;
                                break;
                        }

                        $isDeletable = $child->hasAttribute('isDeletable');
b02c37dd   Elena.Budnik   before merge
417
<<<<<<< HEAD
16035364   Benjamin Renard   First commit
418
			$specialNode = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
419
420
421
422
			$isParameter = false;
                        $isSpectra = false;

                        switch ($id)
b02c37dd   Elena.Budnik   before merge
423
=======
f740e66b   Nathanael Jourdane   Improve the VOTab...
424

0f5fecfc   Elena.Budnik   only "restriction...
425
			   $specialNode = true;
f740e66b   Nathanael Jourdane   Improve the VOTab...
426
427
428
429
430
			   $isParameter = false;
                        $isSpectra = false;

                        switch ($id)

b02c37dd   Elena.Budnik   before merge
431
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
16035364   Benjamin Renard   First commit
432
                        {
5de62950   Nathanael Jourdane   Improve the VOTab...
433
434
                            case 'CDAWEB'  :
                            case 'OMNIWEB' :
16035364   Benjamin Renard   First commit
435
436
437
438
439
440
441
442
443
444
445
446
447
                                            $isLeaf = false;
                                            break;
                            case 'THEMIS' :
                                            $rank = 5;
                                            break;
                            case 'MAPSKP' :
                                            $rank = 9;
                                            break;
                            case 'VEXGRAZ' :
                                            $rank = 2;
                                            break;
                            default:
                        }
5de62950   Nathanael Jourdane   Improve the VOTab...
448

16035364   Benjamin Renard   First commit
449
450
                        $info = $child->getAttribute('desc');

5de62950   Nathanael Jourdane   Improve the VOTab...
451
// 			if ($info && !$isSimulation) {
16035364   Benjamin Renard   First commit
452
453
454
			       $info = str_replace(';', "<br/>Time Range: ", $info);
// 			}
			if ($child->tagName == 'dataset') {
5de62950   Nathanael Jourdane   Improve the VOTab...
455
456
			    /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop'))
			      $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>";  */
16035364   Benjamin Renard   First commit
457
458
459
460
// 			      $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>";
                        }
			if (($child->tagName == 'parameter') || ($child->tagName == 'component')) {
				    $isParameter = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
461
				    $isScatter = true;
16035364   Benjamin Renard   First commit
462
			}
5de62950   Nathanael Jourdane   Improve the VOTab...
463

16035364   Benjamin Renard   First commit
464
465
466
			$needsArgs =  $child->hasAttribute('needsArgs');

			if (($child->tagName == 'parameter' && $child->hasChildNodes()) || $needsArgs) $isScatter = false;
5de62950   Nathanael Jourdane   Improve the VOTab...
467

16035364   Benjamin Renard   First commit
468
			if ($remoteBase) {
5de62950   Nathanael Jourdane   Improve the VOTab...
469
			    if ($child->tagName == 'dataset') $isRemoteDataSet = true;
16035364   Benjamin Renard   First commit
470
471
472
			}

			if ($isParameter) {
5de62950   Nathanael Jourdane   Improve the VOTab...
473
                            $disable = $child->parentNode->getAttribute('disabled');
16035364   Benjamin Renard   First commit
474
475
476
477
			    $objectMgr = new AliasMgr();
			    $alias = $objectMgr->getAlias($id);


5de62950   Nathanael Jourdane   Improve the VOTab...
478
                            if ($child->hasAttribute('display_type')
16035364   Benjamin Renard   First commit
479
                            && $child->getAttribute('display_type') == 'spectrogram'){
5de62950   Nathanael Jourdane   Improve the VOTab...
480
                                                $needsArgs = true;
16035364   Benjamin Renard   First commit
481
482
                                                $isScatter = false;
                                                $isSpectra = true;
5de62950   Nathanael Jourdane   Improve the VOTab...
483
                        }
16035364   Benjamin Renard   First commit
484

5de62950   Nathanael Jourdane   Improve the VOTab...
485
			    $childrenToReturn[] = array('text' => $name,'alias' => $alias,
16035364   Benjamin Renard   First commit
486
				      'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
5de62950   Nathanael Jourdane   Improve the VOTab...
487
				      'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
63ac7745   Benjamin Renard   Support component...
488
				      'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
16035364   Benjamin Renard   First commit
489
			  }
5de62950   Nathanael Jourdane   Improve the VOTab...
490
491
492
			  else {
                            if ($child->tagName == 'dataCenter')
                                $restricted = ($child->getAttribute('available') != "1");
16035364   Benjamin Renard   First commit
493
494
                            else
                                $restricted = false;
5de62950   Nathanael Jourdane   Improve the VOTab...
495
496

                            if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ')
16035364   Benjamin Renard   First commit
497
498
                                                                                     $restricted = FALSE;
                            if ($restricted)
5de62950   Nathanael Jourdane   Improve the VOTab...
499
500
                                $info .= "<br/><b>Open soon !</b>";

16035364   Benjamin Renard   First commit
501
502
503
504
                            if ($child->tagName == 'dataset')
                                $nonavailable = ($child->getAttribute('disabled'));
                            else
                                $nonavailable = false;
5de62950   Nathanael Jourdane   Improve the VOTab...
505

16035364   Benjamin Renard   First commit
506
507
508
509
510
511
512
513
514
515
516
517
518
519
                            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;
b02c37dd   Elena.Budnik   before merge
520
<<<<<<< HEAD
16035364   Benjamin Renard   First commit
521
			    $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
5de62950   Nathanael Jourdane   Improve the VOTab...
522
523
			    'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
                            'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
16035364   Benjamin Renard   First commit
524
			  }
5de62950   Nathanael Jourdane   Improve the VOTab...
525

16035364   Benjamin Renard   First commit
526
		    break;
b02c37dd   Elena.Budnik   before merge
527
=======
f740e66b   Nathanael Jourdane   Improve the VOTab...
528

57bf8841   Elena.Budnik   correct mydataPar...
529
				$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
f740e66b   Nathanael Jourdane   Improve the VOTab...
530
531
532
				'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
                            'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);

16035364   Benjamin Renard   First commit
533
			  }
f740e66b   Nathanael Jourdane   Improve the VOTab...
534

16035364   Benjamin Renard   First commit
535
		    break;
f740e66b   Nathanael Jourdane   Improve the VOTab...
536

b02c37dd   Elena.Budnik   before merge
537
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
5de62950   Nathanael Jourdane   Improve the VOTab...
538
		     case 'myData' :
16035364   Benjamin Renard   First commit
539
			    $info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
16035364   Benjamin Renard   First commit
540
541
542
543
544
545
546
547
548
549
550
551
			    break;

                    case 'myDataParam' :

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

5de62950   Nathanael Jourdane   Improve the VOTab...
552

16035364   Benjamin Renard   First commit
553
554
555
556
557
558
559
                        if ($isLeaf) {
                            $isParameter = true;
                            $info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
                            $isSpectra = $child->getAttribute('plottype') === 'Spectra';
                        }

                        if ($child->hasAttribute('desc')) {
57bf8841   Elena.Budnik   correct mydataPar...
560
561
                            $globalStart = substr($child->getAttribute('desc'), 0, 19);
                            $globalStop =  substr($child->getAttribute('desc'), 20);
16035364   Benjamin Renard   First commit
562
563
                        }

5de62950   Nathanael Jourdane   Improve the VOTab...
564
                        $childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
16035364   Benjamin Renard   First commit
565
                        'globalStart' => $globalStart, 'globalStop' => $globalStop,
5de62950   Nathanael Jourdane   Improve the VOTab...
566
                        'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf,
16035364   Benjamin Renard   First commit
567
568
569
                        'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

                        break;
5de62950   Nathanael Jourdane   Improve the VOTab...
570
                    default:
16035364   Benjamin Renard   First commit
571
		}
5de62950   Nathanael Jourdane   Improve the VOTab...
572

16035364   Benjamin Renard   First commit
573
		if (!$specialNode && !$skip) {
5de62950   Nathanael Jourdane   Improve the VOTab...
574
		       if ($child->hasAttribute('desc'))
16035364   Benjamin Renard   First commit
575
			    $info = $child->getAttribute('desc');
5de62950   Nathanael Jourdane   Improve the VOTab...
576
			$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
16035364   Benjamin Renard   First commit
577
578
579
580
                                                    'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
		}
	      }
		// if $childrenToReturn we have to return []
5de62950   Nathanael Jourdane   Improve the VOTab...
581
		 if ($childrenToReturn == null) {
16035364   Benjamin Renard   First commit
582
583
584
585
586
587
588
			$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
		 }
        }

      return  $childrenToReturn;
 }

5de62950   Nathanael Jourdane   Improve the VOTab...
589
    public  function saveTree($obj)
16035364   Benjamin Renard   First commit
590
591
    {
            $paramMgr = new ParamMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
592
            return $paramMgr->saveTree($obj);
16035364   Benjamin Renard   First commit
593
594
    }

5de62950   Nathanael Jourdane   Improve the VOTab...
595
596
    public  function doNothing($obj)
    {
16035364   Benjamin Renard   First commit
597
        return array("res" => 'ok');
5de62950   Nathanael Jourdane   Improve the VOTab...
598

16035364   Benjamin Renard   First commit
599
600
    }

5de62950   Nathanael Jourdane   Improve the VOTab...
601
602
    public  function deleteFromTree($obj)
    {
16035364   Benjamin Renard   First commit
603
604
        $paramMgr = new ParamMgr();
        return $paramMgr->deleteFromTree($obj);
5de62950   Nathanael Jourdane   Improve the VOTab...
605

16035364   Benjamin Renard   First commit
606
607
608
609
    }

/*
*  temporary object fromUpload
5de62950   Nathanael Jourdane   Improve the VOTab...
610
*/
16035364   Benjamin Renard   First commit
611
    public  function getUploadedObject($name, $format, $nodeType)
5de62950   Nathanael Jourdane   Improve the VOTab...
612
613
    {
            switch ($nodeType)
16035364   Benjamin Renard   First commit
614
            {
5de62950   Nathanael Jourdane   Improve the VOTab...
615
616
                case 'timeTable' :
                        $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
617
                        break;
5de62950   Nathanael Jourdane   Improve the VOTab...
618
619
                case 'myDataParam' :
                        $objectMgr = new FilesMgr();
16035364   Benjamin Renard   First commit
620
621
622
623
624
                        break;
                default:
                        return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
            }
            return  $objectMgr -> getUploadedObject($name, $format, true);
aa94fd24   elena   Merge with last svn
625

5de62950   Nathanael Jourdane   Improve the VOTab...
626
    }
16035364   Benjamin Renard   First commit
627
628

/*
5de62950   Nathanael Jourdane   Improve the VOTab...
629
630
631
632
633
*  fill ascii file into grid
*/
    public  function getAsciiFile($obj)
    {
            $objectMgr = new FilesMgr();
16035364   Benjamin Renard   First commit
634
635
            return  $objectMgr -> getAsciiFile($obj->fileName);
    }
5de62950   Nathanael Jourdane   Improve the VOTab...
636
637
638
639

    public  function getMyParamInfo($object)
    {
            $objectMgr = new FilesMgr();
16035364   Benjamin Renard   First commit
640
            return  $objectMgr -> getParamInfo($object);
5de62950   Nathanael Jourdane   Improve the VOTab...
641
    }
16035364   Benjamin Renard   First commit
642
643

/*
5de62950   Nathanael Jourdane   Improve the VOTab...
644
645
646
647
*  temporary object from Search
*/
    public  function getTmpObject($folderId, $name, $nodeType) {

aa94fd24   elena   Merge with last svn
648

16035364   Benjamin Renard   First commit
649
	    switch ($nodeType) {
5de62950   Nathanael Jourdane   Improve the VOTab...
650
651
652
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
			   break;
d18b535d   elena   catalog draft + c...
653
		 case 'catalog' :
5de62950   Nathanael Jourdane   Improve the VOTab...
654
655
			   $objectMgr = new CatalogMgr();
			   break;
16035364   Benjamin Renard   First commit
656
657
658
659
		  default:
			    return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
              }
	      return  $objectMgr -> getTmpObject($folderId, $name, true);
aa94fd24   elena   Merge with last svn
660

16035364   Benjamin Renard   First commit
661
    }
16035364   Benjamin Renard   First commit
662

5de62950   Nathanael Jourdane   Improve the VOTab...
663
664
665

    public  function getObject($id, $nodeType) {

16035364   Benjamin Renard   First commit
666
667
	    switch ($nodeType) {
		  case 'myDataParam':
5de62950   Nathanael Jourdane   Improve the VOTab...
668
669
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($nodeType);
16035364   Benjamin Renard   First commit
670
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
671
		  case 'timeTable' :
16035364   Benjamin Renard   First commit
672
		  case 'sharedtimeTable' :
5de62950   Nathanael Jourdane   Improve the VOTab...
673
674
			   $objectMgr = new TimeTableMgr();
			   break;
048b4d77   elena   catalogs +
675
		  case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
676
          case 'sharedcatalog' :
5de62950   Nathanael Jourdane   Improve the VOTab...
677
678
679
			   $objectMgr = new CatalogMgr();
			   break;
		  case 'condition' :
16035364   Benjamin Renard   First commit
680
		  case 'request' :
5de62950   Nathanael Jourdane   Improve the VOTab...
681
682
			   $objectMgr = new RequestMgr($nodeType);
			   break;
16035364   Benjamin Renard   First commit
683
684
685
686
687
		  case 'bkgWorks' :
		  	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		  	return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
			   break;
		  case 'myData' :
5de62950   Nathanael Jourdane   Improve the VOTab...
688
			   $objectMgr = new FilesMgr();
16035364   Benjamin Renard   First commit
689
690
691
692
693
694
695
696
697
698
			   break;
		  default:
			    return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> getObject($id, $nodeType);
    }
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
5de62950   Nathanael Jourdane   Improve the VOTab...
699
700
701
702
703
704
705
    public  function deleteObject($obj) {

	    switch ($obj->nodeType) {

		  case 'myDataParam' :
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
b02c37dd   Elena.Budnik   before merge
706
707
708
709
710
711
712
713
714
<<<<<<< HEAD
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
			   break;
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
			   break;
=======
16035364   Benjamin Renard   First commit
715
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
716
717
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
718
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
719
720
721
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
			   break;
b02c37dd   Elena.Budnik   before merge
722
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
5de62950   Nathanael Jourdane   Improve the VOTab...
723
		  case 'condition' :
16035364   Benjamin Renard   First commit
724
		  case 'request' :
5de62950   Nathanael Jourdane   Improve the VOTab...
725
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
726
727
728
729
			   break;
		  case 'alias' :
		  	   $objectMgr = new AliasMgr();
		  	   $obj->id = substr($obj->id,strlen('alias_'));
5de62950   Nathanael Jourdane   Improve the VOTab...
730
		  	   break;
16035364   Benjamin Renard   First commit
731
732
733
		  case 'bkgWorks' :
		  	   require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		  	   return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);
aa94fd24   elena   Merge with last svn
734

16035364   Benjamin Renard   First commit
735
736
737
738
739
740
741
742
743
744
745
746
747
		  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 }
*/
5de62950   Nathanael Jourdane   Improve the VOTab...
748
749
    public  function renameObject($obj) {

16035364   Benjamin Renard   First commit
750
	    switch ($obj->nodeType) {
5de62950   Nathanael Jourdane   Improve the VOTab...
751

16035364   Benjamin Renard   First commit
752
		  case 'myDataParam' :
5de62950   Nathanael Jourdane   Improve the VOTab...
753
754
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
b02c37dd   Elena.Budnik   before merge
755
<<<<<<< HEAD
16035364   Benjamin Renard   First commit
756
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
757
758
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
d18b535d   elena   catalog draft + c...
759
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
760
761
762
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
			   break;
b02c37dd   Elena.Budnik   before merge
763
=======
16035364   Benjamin Renard   First commit
764
			   break;
f740e66b   Nathanael Jourdane   Improve the VOTab...
765
766
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
d18b535d   elena   catalog draft + c...
767
			   break;
f740e66b   Nathanael Jourdane   Improve the VOTab...
768
769
770
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
			   break;
b02c37dd   Elena.Budnik   before merge
771
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
5de62950   Nathanael Jourdane   Improve the VOTab...
772
773
774
		  case 'condition' :
		  case 'request' :
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
775
776
			   break;
		  case 'alias' :
5de62950   Nathanael Jourdane   Improve the VOTab...
777
778
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
779
780
781
782
783
784
785
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

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

5de62950   Nathanael Jourdane   Improve the VOTab...
786
/*
16035364   Benjamin Renard   First commit
787
788
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
5de62950   Nathanael Jourdane   Improve the VOTab...
789
790
    public  function createObject($obj, $folder) {

16035364   Benjamin Renard   First commit
791
792
	    switch ($obj->nodeType) {

5de62950   Nathanael Jourdane   Improve the VOTab...
793
		  case 'myDataParam' :
16035364   Benjamin Renard   First commit
794
		  case 'derivedParam' :
5de62950   Nathanael Jourdane   Improve the VOTab...
795
                        if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
16035364   Benjamin Renard   First commit
796
797
                             $this->amdaStat->addTask('create', $this->user, null);

5de62950   Nathanael Jourdane   Improve the VOTab...
798
799
800
801
802
803
804
                        $objectMgr = new DerivedParamMgr($obj->nodeType);
                        break;
		  case 'timeTable' :
                        $objectMgr = new TimeTableMgr();
			   break;
		  case 'catalog' :
                        $objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
805
806
			   break;
		  case 'condition' :
5de62950   Nathanael Jourdane   Improve the VOTab...
807
808
809
		  case 'request' :
			   $objectMgr = new RequestMgr($obj->nodeType);
			   break;
16035364   Benjamin Renard   First commit
810
		  case 'alias' :
5de62950   Nathanael Jourdane   Improve the VOTab...
811
812
			    $objectMgr = new AliasMgr();
			    break;
16035364   Benjamin Renard   First commit
813
814
815
816
817
818
819
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

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

5de62950   Nathanael Jourdane   Improve the VOTab...
820
/*
16035364   Benjamin Renard   First commit
821
822
823
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
    public  function modifyObject($obj) {
16035364   Benjamin Renard   First commit
824

5de62950   Nathanael Jourdane   Improve the VOTab...
825
826
827
828
829
830
831
832
	    switch ($obj->nodeType) {

		  case 'myDataParam' :
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
b02c37dd   Elena.Budnik   before merge
833
834
835
836
837
838
<<<<<<< HEAD
			   break;
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
			   break;
=======
16035364   Benjamin Renard   First commit
839
			   break;
5de62950   Nathanael Jourdane   Improve the VOTab...
840
841
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
842
			   break;
b02c37dd   Elena.Budnik   before merge
843
>>>>>>> ac59cf4f59a141f969f1fc7eeb2880c1d4790f4a
5de62950   Nathanael Jourdane   Improve the VOTab...
844
		  case 'condition' :
16035364   Benjamin Renard   First commit
845
		  case 'request' :
5de62950   Nathanael Jourdane   Improve the VOTab...
846
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
847
848
849
850
851
852
			   break;
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
              }

	    return  $objectMgr -> modifyObject($obj);
5de62950   Nathanael Jourdane   Improve the VOTab...
853
    }
16035364   Benjamin Renard   First commit
854
855
856
857
858
859
860
861
862
863
/*
 * {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...
864
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
865
866
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
867
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
868
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
869
870
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
871
872
873
874
875
876
877
878
879
880
881
882
883
884
			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
885

16035364   Benjamin Renard   First commit
886
887
888
    public  function getJobs()
    {
    	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
5de62950   Nathanael Jourdane   Improve the VOTab...
889
    	return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
16035364   Benjamin Renard   First commit
890
891
892
893
894
895
896
897
898
899
900
901
902
    }


	/* 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);
		}
5de62950   Nathanael Jourdane   Improve the VOTab...
903
904


16035364   Benjamin Renard   First commit
905
906
907
908
909
910
911
912
		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();
5de62950   Nathanael Jourdane   Improve the VOTab...
913
914

        //TODO error handling
16035364   Benjamin Renard   First commit
915
916
        if (($res = $dd -> ddCheckUser()) != 0)
		{
5de62950   Nathanael Jourdane   Improve the VOTab...
917
			if ($res == 156)
16035364   Benjamin Renard   First commit
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
				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');
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
935

16035364   Benjamin Renard   First commit
936
        $this->user = $dd->user;
5de62950   Nathanael Jourdane   Improve the VOTab...
937

16035364   Benjamin Renard   First commit
938
939
		return array('success' => true, 'userHost' => $dd -> getIPclient());
	}
5de62950   Nathanael Jourdane   Improve the VOTab...
940

16035364   Benjamin Renard   First commit
941
942
943
	private function executeRequest($obj, $function)
	{
		$res = $this->checkUser($obj);
5de62950   Nathanael Jourdane   Improve the VOTab...
944

16035364   Benjamin Renard   First commit
945
946
		if (!$res['success'])
			return $res;
5de62950   Nathanael Jourdane   Improve the VOTab...
947

16035364   Benjamin Renard   First commit
948
		$requestManager = new RequestManagerClass();
5de62950   Nathanael Jourdane   Improve the VOTab...
949

16035364   Benjamin Renard   First commit
950
951
952
953
954
		try {
			$res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj);
		} catch (Exception $e) {
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
		}
5de62950   Nathanael Jourdane   Improve the VOTab...
955

16035364   Benjamin Renard   First commit
956
957
		return $res;
	}
5de62950   Nathanael Jourdane   Improve the VOTab...
958
959
960

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
961
962
*/
    public  function execute($node, $obj)
5de62950   Nathanael Jourdane   Improve the VOTab...
963
	{
16035364   Benjamin Renard   First commit
964
965
966
967
968
969
		require_once(INTEGRATION_SRC_DIR."RequestManager.php");
		if (isset($obj->action))
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
		else
			return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
    }
5de62950   Nathanael Jourdane   Improve the VOTab...
970

16035364   Benjamin Renard   First commit
971
/*
a0b3d64e   Benjamin Renard   Derived parameter...
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
 * 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);
5de62950   Nathanael Jourdane   Improve the VOTab...
987

a0b3d64e   Benjamin Renard   Derived parameter...
988
989
		if (!$res['success'])
			return $res;
5de62950   Nathanael Jourdane   Improve the VOTab...
990

a0b3d64e   Benjamin Renard   Derived parameter...
991
992
993
994
995
996
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
    	return array("success" => true);
   }
5de62950   Nathanael Jourdane   Improve the VOTab...
997

a0b3d64e   Benjamin Renard   Derived parameter...
998
/*
e6e5b259   Benjamin Renard   Add kill plot req...
999
 * kill plot process
16035364   Benjamin Renard   First commit
1000
 */
5de62950   Nathanael Jourdane   Improve the VOTab...
1001

e6e5b259   Benjamin Renard   Add kill plot req...
1002
    public function killPlotRequest()
5de62950   Nathanael Jourdane   Improve the VOTab...
1003
    {
e6e5b259   Benjamin Renard   Add kill plot req...
1004
1005
    	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
    	return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
16035364   Benjamin Renard   First commit
1006
1007
1008
1009
1010
1011
1012
1013
1014
    }

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

        if ($this->amdaStat->success)
            $this->amdaStat->addTask('ttoper', $this->user, null);
5de62950   Nathanael Jourdane   Improve the VOTab...
1015

16035364   Benjamin Renard   First commit
1016
1017
1018
1019
1020
1021
        $objectMgr = new TimeTableMgr();

    return  $objectMgr -> merge($obj);

    }

5de62950   Nathanael Jourdane   Improve the VOTab...
1022

16035364   Benjamin Renard   First commit
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
/*
 * 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;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1036

f9c8b272   elena   edit catalog
1037
        public function initTTCache($isCatalog = false, $nparams)
16035364   Benjamin Renard   First commit
1038
        {
048b4d77   elena   catalogs +
1039
1040
        	if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
        	else              $cacheMgr = new CatalogCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1041

f9c8b272   elena   edit catalog
1042
        	return $cacheMgr->initTTCache($nparams);
16035364   Benjamin Renard   First commit
1043
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1044
1045


16035364   Benjamin Renard   First commit
1046
1047
        public function initTTCacheFromTT($id, $type)
        {
169f14d2   Benjamin Renard   Add shared object...
1048
        	if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
048b4d77   elena   catalogs +
1049
        	else $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1050

16035364   Benjamin Renard   First commit
1051
1052
        	return $cacheMgr->initFromTT($id, $type);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1053

9d412dda   elena   catalog tmp and r...
1054
        public function initForChart($id, $name, $isTmpObject, $type)
86263051   elena   visu second draft
1055
        {
169f14d2   Benjamin Renard   Add shared object...
1056
        	if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1057

9d412dda   elena   catalog tmp and r...
1058
        	return $objMgr->initForChart($id, $name, $isTmpObject, $type);
86263051   elena   visu second draft
1059
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1060

d18b535d   elena   catalog draft + c...
1061
        public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
16035364   Benjamin Renard   First commit
1062
        {
d18b535d   elena   catalog draft + c...
1063
			if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1064

d18b535d   elena   catalog draft + c...
1065
			else              $cacheMgr = new CatalogCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1066
1067
1068



16035364   Benjamin Renard   First commit
1069
1070
        	return $cacheMgr->initFromTmpObject($folderId, $name);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1071

16035364   Benjamin Renard   First commit
1072
1073
1074
1075
1076
        public function initTTCacheFromUploadedFile($name, $format)
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->initFromUploadedFile($name, $format);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1077

16035364   Benjamin Renard   First commit
1078
1079
        public function readTTCacheIntervals($o)
        {
169f14d2   Benjamin Renard   Add shared object...
1080
        	if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
d18b535d   elena   catalog draft + c...
1081
        	else $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1082

16035364   Benjamin Renard   First commit
1083
1084
        	return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1085

86263051   elena   visu second draft
1086
1087
	 public function readIntervalsForChart($o)
        {
169f14d2   Benjamin Renard   Add shared object...
1088
        	if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1089
1090


9d412dda   elena   catalog tmp and r...
1091
        	return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT);
86263051   elena   visu second draft
1092
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1093

16035364   Benjamin Renard   First commit
1094
1095
1096
1097
1098
        public function saveTTCacheIntervalsInTT($o)
        {
        	$cacheMgr = new TimeTableCacheMgr();
            return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1099

16035364   Benjamin Renard   First commit
1100
1101
        public function addTTCacheInterval($o)
        {
f9c8b272   elena   edit catalog
1102
1103
          	if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
          	else $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1104

16035364   Benjamin Renard   First commit
1105
1106
            return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1107

70aabdee   elena   catalog draft
1108
        public function removeTTCacheIntervalFromId($id, $isCatalog = false)
16035364   Benjamin Renard   First commit
1109
        {
70aabdee   elena   catalog draft
1110
1111
        	if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
        	else $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1112

16035364   Benjamin Renard   First commit
1113
1114
        	return $cacheMgr->removeIntervalFromId($id);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1115

16035364   Benjamin Renard   First commit
1116
1117
        public function modifyTTCacheInterval($o)
        {
f9c8b272   elena   edit catalog
1118
        	if ($o->isCatalog) {
5de62950   Nathanael Jourdane   Improve the VOTab...
1119

f9c8b272   elena   edit catalog
1120
1121
			$cacheMgr = new CatalogCacheMgr();
		return $cacheMgr->modifyIntervalFromId($o);
5de62950   Nathanael Jourdane   Improve the VOTab...
1122

f9c8b272   elena   edit catalog
1123
1124
		}
          	else $cacheMgr = new TimeTableCacheMgr();
5de62950   Nathanael Jourdane   Improve the VOTab...
1125

16035364   Benjamin Renard   First commit
1126
1127
        	return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1128

16035364   Benjamin Renard   First commit
1129
1130
1131
1132
1133
        public function operationTTCacheIntervals($extendTime, $shiftTime)
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->operationIntervals($extendTime, $shiftTime);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1134

16035364   Benjamin Renard   First commit
1135
1136
1137
1138
1139
        public function mergeTTCacheIntervals()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->mergeIntervals();
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1140

16035364   Benjamin Renard   First commit
1141
1142
1143
1144
1145
        public function getTTCacheStatistics()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->getStatistics();
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1146

16035364   Benjamin Renard   First commit
1147
1148
1149
1150
1151
        public function getTTCacheStatus()
        {
        	$cacheMgr = new TimeTableCacheMgr();
        	return $cacheMgr->getStatus();
        }
aa94fd24   elena   Merge with last svn
1152

16035364   Benjamin Renard   First commit
1153
1154
/*
 * Send a feedback
5de62950   Nathanael Jourdane   Improve the VOTab...
1155
 *
16035364   Benjamin Renard   First commit
1156
1157
1158
1159
1160
1161
 */
        public function sendFeedback($feed)
        {
            $feedMgr = new FeedbackMgr();
            return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1162

16035364   Benjamin Renard   First commit
1163
1164
/*
 * Save state
5de62950   Nathanael Jourdane   Improve the VOTab...
1165
 *
16035364   Benjamin Renard   First commit
1166
1167
1168
1169
1170
1171
 */
        public function saveState($datas)
        {
            $myStateMgr = new StateMgr();
            return $myStateMgr->saveState($datas);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1172

16035364   Benjamin Renard   First commit
1173
1174
/*
 * Load state
5de62950   Nathanael Jourdane   Improve the VOTab...
1175
1176
 *
 */
16035364   Benjamin Renard   First commit
1177
        public function loadState($o)
5de62950   Nathanael Jourdane   Improve the VOTab...
1178
        {
16035364   Benjamin Renard   First commit
1179
1180
1181
                $myStateMgr = new StateMgr();
                return $myStateMgr->loadState();
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1182
1183

/*
16035364   Benjamin Renard   First commit
1184
1185
1186
 * SAMP
 */
        public function sendToSAMP($o)
5de62950   Nathanael Jourdane   Improve the VOTab...
1187
        {
16035364   Benjamin Renard   First commit
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
                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;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1200

16035364   Benjamin Renard   First commit
1201
1202
1203
1204
1205
1206
1207
/*
 * HST Images
 */
        public function getHstImagesUrl($o)
        {
                if ($this->amdaStat->success)
                    $this->amdaStat->addTask('images', $this->user, null);
5de62950   Nathanael Jourdane   Improve the VOTab...
1208

16035364   Benjamin Renard   First commit
1209
1210
1211
1212
1213
1214
                $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);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1215

16035364   Benjamin Renard   First commit
1216
1217
        public function getAPISImagesUrl($o)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1218
                if ($this->amdaStat->success)
16035364   Benjamin Renard   First commit
1219
                    $this->amdaStat->addTask('images', $this->user, null);
5de62950   Nathanael Jourdane   Improve the VOTab...
1220

16035364   Benjamin Renard   First commit
1221
                $apisMgr = new APISMgr();
b7796276   Benjamin Renard   Migration to supp...
1222
                $res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);
16035364   Benjamin Renard   First commit
1223
1224

                return $res;
5de62950   Nathanael Jourdane   Improve the VOTab...
1225
        }
16035364   Benjamin Renard   First commit
1226
1227
1228
1229
1230
/*
 * Filters
 */
        public function loadFilterList($o)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1231
                $filtersMgr = new FiltersMgr();
16035364   Benjamin Renard   First commit
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
                $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;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1245

16035364   Benjamin Renard   First commit
1246
1247
        public function saveFilter($o)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1248
                $filtersMgr = new FiltersMgr();
16035364   Benjamin Renard   First commit
1249
1250
                return $filtersMgr->save($o);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1251

16035364   Benjamin Renard   First commit
1252
1253
        public function createFilter($o)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1254
                $filtersMgr = new FiltersMgr();
16035364   Benjamin Renard   First commit
1255
1256
                return $filtersMgr->create($o);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1257

16035364   Benjamin Renard   First commit
1258
1259
1260
1261
1262
1263
        public function destroyFilter($o)
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->delete($o);
                return;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1264

16035364   Benjamin Renard   First commit
1265
1266
1267
1268
1269
1270
        public function getCrtFilterId()
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->getCrtId();
                return $res;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1271

16035364   Benjamin Renard   First commit
1272
1273
        public function getCrtFilterResult()
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1274
                $filtersMgr = new FiltersMgr();
16035364   Benjamin Renard   First commit
1275
1276
                return $filtersMgr->getCrtResult();
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1277

16035364   Benjamin Renard   First commit
1278
1279
        public function setCrtFilterId($o)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1280
                $filtersMgr = new FiltersMgr();
16035364   Benjamin Renard   First commit
1281
1282
                return $filtersMgr->setCrtId($o->id);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1283

16035364   Benjamin Renard   First commit
1284
1285
1286
1287
1288
1289
        public function resetFilter()
        {
                $filtersMgr = new FiltersMgr();
                $res = $filtersMgr->reset();
                return $res;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1290

16035364   Benjamin Renard   First commit
1291
1292
1293
1294
1295
1296
1297
1298
	public function logout($isGuest)
	{
                if ($isGuest) {
                    $guestMgr = new Guest($this->user);
                    $guestMgr->deleteGuest();
                }
                else {
                    $myBaseMgr = new BaseManager();
5de62950   Nathanael Jourdane   Improve the VOTab...
1299
1300
1301
                    $myBaseMgr->delSimuFiles('mysimudata');
		    $myBaseMgr->delSimuFiles('mywsrdata');

18d4a11e   Benjamin Renard   Save and load plo...
1302
                    $this->cleanUserWS();
5de62950   Nathanael Jourdane   Improve the VOTab...
1303
                 }
16035364   Benjamin Renard   First commit
1304
		return;
5de62950   Nathanael Jourdane   Improve the VOTab...
1305
	}
16035364   Benjamin Renard   First commit
1306
1307
1308

        public function getInfo($obj)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1309
                if (file_exists(HELPPATH.$obj->name))
16035364   Benjamin Renard   First commit
1310
                {
5de62950   Nathanael Jourdane   Improve the VOTab...
1311
                        $content = file_get_contents(HELPPATH.$obj->name);
16035364   Benjamin Renard   First commit
1312
1313
1314
                        return  array('success' => true, 'result' => $content);
                }
                return array('success' => false);
5de62950   Nathanael Jourdane   Improve the VOTab...
1315
1316
1317

        }

16035364   Benjamin Renard   First commit
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
        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);
5de62950   Nathanael Jourdane   Improve the VOTab...
1337
1338

            return  $res;
16035364   Benjamin Renard   First commit
1339
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1340
1341

    //$obj = array of IDs
16035364   Benjamin Renard   First commit
1342
1343
1344
1345
1346
1347
1348
1349
        public function addRun($obj)
        {
            $myBestRunsMgr = new BestRunsMgr();
            $myBestRunsMgr->init();
            $myBestRunsMgr->addRuns($obj);

            $res =  array('success' => true,'addedRuns' => $obj);
        return $res;
5de62950   Nathanael Jourdane   Improve the VOTab...
1350
        }
16035364   Benjamin Renard   First commit
1351
1352
1353
        //AKKA - New action to clean user WS
        public function cleanUserWS()
        {
70aabdee   elena   catalog draft
1354
          	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
e82af71b   elena   catalog draft
1355
         	return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
16035364   Benjamin Renard   First commit
1356
1357
1358
1359
        }

        public function deleteSpecialInfo($name)
        {
5de62950   Nathanael Jourdane   Improve the VOTab...
1360
             if (file_exists(USERDIR.$name))
16035364   Benjamin Renard   First commit
1361
1362
1363
                                    unlink(USERDIR.$name);
             return array('success' => true);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1364

488b1401   Benjamin Renard   Interactive multi...
1365
        public function interactivePlot($obj, $multiPlotState)
9f08f4eb   Benjamin Renard   Zoom in interacti...
1366
1367
        {
        	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
488b1401   Benjamin Renard   Interactive multi...
1368
1369
1370
1371
1372
        	$inputobj = (Object)array(
        		'action' => $obj,
        		'multiPlotState' => $multiPlotState
        	);
        	return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
9f08f4eb   Benjamin Renard   Zoom in interacti...
1373
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1374

ced82260   Benjamin Renard   Get initial plot ...
1375
1376
1377
1378
1379
1380
1381
1382
1383
        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);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1384

7ac3ce50   Benjamin Renard   First implementat...
1385
1386
1387
1388
1389
1390
1391
1392
1393
        public function getParamInfo($obj)
        {
        	require_once(INTEGRATION_SRC_DIR."RequestManager.php");
        	$inputobj = (Object)array(
        			'paramId' => $obj->paramId,
        			'type' => 'param_info'
        	);
        	return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1394

169f14d2   Benjamin Renard   Add shared object...
1395
1396
1397
1398
1399
1400
        public function getSharedObjectFolders($obj)
        {
        	$mgr = new SharedObjectsMgr();
        	$folders = $mgr->getFolders($obj->type);
        	return array('success' => true, 'folders' => $folders);
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1401

169f14d2   Benjamin Renard   Add shared object...
1402
1403
1404
1405
1406
1407
1408
1409
        public function shareObjects($obj)
        {
        	$mgr = new SharedObjectsMgr();
        	switch ($obj->type) {
        		case 'timeTable' :
        		case 'catalog' :
        			$src_object_path = USERTTDIR.$obj->object->id.".xml";
        			break;
5de62950   Nathanael Jourdane   Improve the VOTab...
1410

169f14d2   Benjamin Renard   Add shared object...
1411
1412
1413
        		default:
        			return array('success' => false, 'message' => 'Unknown object type');
        	}
5de62950   Nathanael Jourdane   Improve the VOTab...
1414

169f14d2   Benjamin Renard   Add shared object...
1415
1416
1417
        	$result = $mgr->add($obj->type, $obj->name, $obj->folder, $src_object_path, $obj->description, $this->user);
        	if (!$result['success'])
        		return $result;
5de62950   Nathanael Jourdane   Improve the VOTab...
1418

169f14d2   Benjamin Renard   Add shared object...
1419
1420
1421
        	$mgr->updateTree();
        	return $result;
        }
5de62950   Nathanael Jourdane   Improve the VOTab...
1422

169f14d2   Benjamin Renard   Add shared object...
1423
1424
1425
1426
1427
1428
        public function isSharedObjectNameAlreadyUsed($obj)
        {
        	$mgr = new SharedObjectsMgr();
        	$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
        	return array('success' => true, 'alreadyUsed' => $alreadyUsed);
        }
3fc0b658   Nathanael Jourdane   Add EPN-TAP modul...
1429

67a4e0da   Nathanael Jourdane   Add a function to...
1430
1431
1432
1433
1434
1435
		public function epnTapGetGranules($table_name, $access_url, $filter, $select, $limit, $offset) {
			return (new EpnTapMgr)->getGranules($table_name, $access_url, $filter, $select, $limit, $offset);
		}

		public function epnTapGetNbRows($table_name, $access_url, $filter) {
			return (new EpnTapMgr)->getNbRows($table_name, $access_url, $filter);
3fc0b658   Nathanael Jourdane   Add EPN-TAP modul...
1436
		}
16035364   Benjamin Renard   First commit
1437
1438
}
?>