Blame view

php/classes/AmdaAction.php 36.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 $
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
5
 * @brief
16035364   Benjamin Renard   First commit
6
 */
10200969   Roipoussiere   Remove whitespace...
7
class AmdaAction
735c653b   Elena.Budnik   rank at observato...
8
{
10200969   Roipoussiere   Remove whitespace...
9
	private $xmlFiles  = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
735c653b   Elena.Budnik   rank at observato...
10
										'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
10200969   Roipoussiere   Remove whitespace...
11
12
										'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
										'myData' => 'Files.xml',
735c653b   Elena.Budnik   rank at observato...
13
14
15
16
17
										'request' => 'Request.xml', 'condition' => 'Request.xml',
										'bkgWorks' => 'jobs.xml');

	private $user, $amdaStat;

10200969   Roipoussiere   Remove whitespace...
18
19
	public function __construct()
	{
735c653b   Elena.Budnik   rank at observato...
20
21
22
23
24
		$dd = new UserMgr();
		$this->user = $dd->user;
		if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
					$this->amdaStat = new AmdaStats($dd->user);
	}
16035364   Benjamin Renard   First commit
25

10200969   Roipoussiere   Remove whitespace...
26
	private function getUrlDirs($url)
735c653b   Elena.Budnik   rank at observato...
27
28
29
	{
		//TODO replace by ftp php class methods: ftp_nlist() etc
		require_once "simple_html_dom.php";
10200969   Roipoussiere   Remove whitespace...
30
31

		$url = html_entity_decode($url);
735c653b   Elena.Budnik   rank at observato...
32
		$trimmed_url = trim($url);
10200969   Roipoussiere   Remove whitespace...
33
		if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1)
735c653b   Elena.Budnik   rank at observato...
34
		{
10200969   Roipoussiere   Remove whitespace...
35
			if (file_exists("temp.html")) unlink("temp.html");
735c653b   Elena.Budnik   rank at observato...
36
			exec("wget -O temp.html ".$url);
10200969   Roipoussiere   Remove whitespace...
37

735c653b   Elena.Budnik   rank at observato...
38
39
			$html = file_get_html('temp.html');
			$dirs = $html->find('a[href]');
10200969   Roipoussiere   Remove whitespace...
40
			foreach ($dirs as $dir)
735c653b   Elena.Budnik   rank at observato...
41
			{
6acb8d2a   Elena.Budnik   checkRequest in R...
42
43
				$name =  $dir->innertext; //$dir->href;
				$isLeaf = strrpos($name, "/") !== strlen($name) - 1;
10200969   Roipoussiere   Remove whitespace...
44
				$childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name, 'nodeType' => 'url', 'leaf' => $isLeaf);
735c653b   Elena.Budnik   rank at observato...
45
			}
10200969   Roipoussiere   Remove whitespace...
46

735c653b   Elena.Budnik   rank at observato...
47
		}
10200969   Roipoussiere   Remove whitespace...
48
49
50

		return $childrenToReturn;

735c653b   Elena.Budnik   rank at observato...
51
	}
10200969   Roipoussiere   Remove whitespace...
52

16035364   Benjamin Renard   First commit
53
54
/*****************************************************************
*                           PUBLIC FUNCTIONS
10200969   Roipoussiere   Remove whitespace...
55
56
*****************************************************************/

735c653b   Elena.Budnik   rank at observato...
57
58
59
60
	/*
	*   $obj = { id: node.id,  nodeType: node.nodeType }
	*/
	public function getTree($obj) {
735c653b   Elena.Budnik   rank at observato...
61
		$node = $obj->node;
10200969   Roipoussiere   Remove whitespace...
62

735c653b   Elena.Budnik   rank at observato...
63
		$nodeType = $obj->nodeType;
a0f13ed1   Elena.Budnik   small format + ti...
64
		
735c653b   Elena.Budnik   rank at observato...
65
66
		$remoteBase = false;
		$isRemoteDataSet = false;
16035364   Benjamin Renard   First commit
67

10200969   Roipoussiere   Remove whitespace...
68
		if ($nodeType == 'url')
735c653b   Elena.Budnik   rank at observato...
69
		{
10200969   Roipoussiere   Remove whitespace...
70
			$url = $node == 'root' ? $obj->baseId : $node;
735c653b   Elena.Budnik   rank at observato...
71
72
			return  $this->getUrlDirs($url);
		}
16035364   Benjamin Renard   First commit
73

e57cb025   Benjamin Renard   Fix most of error...
74
		if (isset($obj->baseId)) $remoteBase = true;
16035364   Benjamin Renard   First commit
75

735c653b   Elena.Budnik   rank at observato...
76
		if ($node == 'root' && $remoteBase)  $node = $obj->baseId;
16035364   Benjamin Renard   First commit
77

10200969   Roipoussiere   Remove whitespace...
78
79
		if ($node == 'root' && !$remoteBase)
		{
e57cb025   Benjamin Renard   Fix most of error...
80
81
82
83
84
85
86
87
88
89
90
91
			if (file_exists(DATAPATH.$nodeType.'.json')) {
				$json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
				if (empty($json_o)) {
					$childrenToReturn = array();
				}
				else {
					$childrenToReturn = $json_o->nodes;
				}
			}
			else {
				$childrenToReturn = array();
			}
10200969   Roipoussiere   Remove whitespace...
92
93
		}
		else
735c653b   Elena.Budnik   rank at observato...
94
95
96
		{
			$Dom = new DomDocument("1.0");

10200969   Roipoussiere   Remove whitespace...
97
			switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
98
99
100
101
102
			{
				case 'sharedtimeTable':
				case 'sharedcatalog':
					$xmlName = SHAREDPATH.'/SharedObjectTree.xml';
					break;
10200969   Roipoussiere   Remove whitespace...
103
				case 'bkgWorks':
84db3b67   Nathanael Jourdane   Improve job toolt...
104
					// data/<user>/JOBS/jobs.xml
735c653b   Elena.Budnik   rank at observato...
105
106
107
					$xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
					break;
				case 'source':
10200969   Roipoussiere   Remove whitespace...
108
109
110
111
					$xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
					break;
				case 'destination':
					$xmlName = USERWSDIR.'RemoteParams.xml';
735c653b   Elena.Budnik   rank at observato...
112
					break;
735c653b   Elena.Budnik   rank at observato...
113
114
115
				default:
					$xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
			}
16035364   Benjamin Renard   First commit
116

a0f13ed1   Elena.Budnik   small format + ti...
117
			if ($remoteBase){
735c653b   Elena.Budnik   rank at observato...
118
				$nodeType = 'remoteParam';
10200969   Roipoussiere   Remove whitespace...
119
120
			}

e57cb025   Benjamin Renard   Fix most of error...
121
			@$Dom->load($xmlName);
10200969   Roipoussiere   Remove whitespace...
122

a0f13ed1   Elena.Budnik   small format + ti...
123
			if ($node == "myRemoteSimuData-treeRootNode") $node = "myRemoteData-treeRootNode";
10200969   Roipoussiere   Remove whitespace...
124

735c653b   Elena.Budnik   rank at observato...
125
			$nodeToOpen = $Dom->getElementById($node);
e57cb025   Benjamin Renard   Fix most of error...
126
			$children = empty($nodeToOpen->childNodes) ? array() : $nodeToOpen->childNodes;
16035364   Benjamin Renard   First commit
127

10200969   Roipoussiere   Remove whitespace...
128
129
			foreach ($children as $child)
				if ($child->nodeType == XML_ELEMENT_NODE)
735c653b   Elena.Budnik   rank at observato...
130
131
				{
					$isLeaf = true;
10200969   Roipoussiere   Remove whitespace...
132

735c653b   Elena.Budnik   rank at observato...
133
					if ($child->hasChildNodes())
10200969   Roipoussiere   Remove whitespace...
134
135
						foreach ($child->childNodes as $grandChild)
							if ($grandChild -> nodeType == XML_ELEMENT_NODE)
735c653b   Elena.Budnik   rank at observato...
136
137
138
139
140
141
							{
									$isLeaf = false;
									break;
							}
					if ($child->tagName == 'folder')  $isLeaf = false;

10200969   Roipoussiere   Remove whitespace...
142
143
					//TODO MAKE PROPERLY  as function of nodetype !!!!
					$info = '';
735c653b   Elena.Budnik   rank at observato...
144
					$id =  $child->getAttribute('xml:id');
10200969   Roipoussiere   Remove whitespace...
145
					$name = $child->getAttribute('name');
735c653b   Elena.Budnik   rank at observato...
146
					$help = $child->getAttribute('att');
735c653b   Elena.Budnik   rank at observato...
147
148
149
150
151
152

					$specialNode = false;
					$isParameter = false;
					$isAddable =  false;
					$isSimulation = false;
					$rank = null;
e57cb025   Benjamin Renard   Fix most of error...
153
					$skip = FALSE;
735c653b   Elena.Budnik   rank at observato...
154

10200969   Roipoussiere   Remove whitespace...
155
					switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
156
					{
10200969   Roipoussiere   Remove whitespace...
157
						case 'bkgWorks':
735c653b   Elena.Budnik   rank at observato...
158
							$specialNode = true;
84db3b67   Nathanael Jourdane   Improve job toolt...
159
160
161
162
163
164
							$childrenToReturn[] = [
								'text'     => $name,
								'id'       => $id,
								'nodeType' => $nodeType,
								'leaf'     => $isLeaf,
								'pid'      => $child->getAttribute('pid'),
b4bca467   Nathanael Jourdane   job tooltip: use ...
165
								'status'   => $child->getAttribute('status'),
84db3b67   Nathanael Jourdane   Improve job toolt...
166
								'jobType'  => $child->getAttribute('jobType'),
812bc03d   Nathanael Jourdane   update job info o...
167
								'info'     => $child->getAttribute('info')
84db3b67   Nathanael Jourdane   Improve job toolt...
168
							];
b4bca467   Nathanael Jourdane   job tooltip: use ...
169
							break;
735c653b   Elena.Budnik   rank at observato...
170
171
172

						case 'condition':
							$objectMgr = new RequestMgr();
10200969   Roipoussiere   Remove whitespace...
173
174
							$info = $objectMgr->getObject($id)->expression;
						break;
735c653b   Elena.Budnik   rank at observato...
175

10200969   Roipoussiere   Remove whitespace...
176
						case 'request':
735c653b   Elena.Budnik   rank at observato...
177
						$objectMgr = new RequestMgr();
10200969   Roipoussiere   Remove whitespace...
178
179
180
						$objplot = $objectMgr->getObject($id);
						for ($i=0; $i < count($objplot->children); $i++)
						{
812bc03d   Nathanael Jourdane   update job info o...
181
							for ($j=0; $j < count($objplot->children[$i]->children); $j++) {
367f7ed0   Nathanael Jourdane   jobs tooltip: dis...
182
								$info = $info.' . '.$objplot->children[$i]->children[$j]->name;
735c653b   Elena.Budnik   rank at observato...
183
184
							}
						}
10200969   Roipoussiere   Remove whitespace...
185
						break;
735c653b   Elena.Budnik   rank at observato...
186

10200969   Roipoussiere   Remove whitespace...
187
						case 'alias':
735c653b   Elena.Budnik   rank at observato...
188
189
							$info = $id;
							$id = 'alias_'.$id;
10200969   Roipoussiere   Remove whitespace...
190
							if ($isLeaf) $isParameter = true;
735c653b   Elena.Budnik   rank at observato...
191
192
193
						break;

						case 'timeTable':
10200969   Roipoussiere   Remove whitespace...
194
						case 'catalog':
735c653b   Elena.Budnik   rank at observato...
195
196
							if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
						break;
10200969   Roipoussiere   Remove whitespace...
197

735c653b   Elena.Budnik   rank at observato...
198
199
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
200
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
							{
								$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;
						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;
10200969   Roipoussiere   Remove whitespace...
220
							$isSpectra = false;
735c653b   Elena.Budnik   rank at observato...
221
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
222
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
223

10200969   Roipoussiere   Remove whitespace...
224
225
							if ($child->hasAttribute('desc'))
							{
735c653b   Elena.Budnik   rank at observato...
226
								$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
227
228
229
230

								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop'))
								{
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
231
								}
10200969   Roipoussiere   Remove whitespace...
232

735c653b   Elena.Budnik   rank at observato...
233
234
235
								if ($child->getAttribute('dataStart') == 'depending on mission')
								{
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
236
237
238
								}

								if ($child->getAttribute('restriction') > 1)
735c653b   Elena.Budnik   rank at observato...
239
240
241
242
243
								{
									$restricted  = $child->getAttribute('restriction');
									$info .= "<br/><b>Time Restriction</b>: -$restricted days";
								}
							}
10200969   Roipoussiere   Remove whitespace...
244

735c653b   Elena.Budnik   rank at observato...
245
246
							if ($child->hasAttribute('units')) $info = $child->getAttribute('units');

10200969   Roipoussiere   Remove whitespace...
247
							if ($child->tagName == 'parameter')
735c653b   Elena.Budnik   rank at observato...
248
249
250
251
252
253
254
							{
								$isParameter = true;
								$isScatter = true;

								if ($child->parentNode->hasAttribute('dataStart'))
								{
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
255
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
256
257
258
259
260
								}

								if ($child->parentNode->getAttribute('restriction') > 1 )
								{
									$timeRestriction = true;
10200969   Roipoussiere   Remove whitespace...
261
262
263

								}
								/*------------------- to show not tested parameters ------*/
735c653b   Elena.Budnik   rank at observato...
264
								if ($child->getAttribute('tbd'))
10200969   Roipoussiere   Remove whitespace...
265
266
									$info .= "<br/><b>Not tested yet</b>";
								/*------------------- --------------------------------------*/
735c653b   Elena.Budnik   rank at observato...
267
							}
10200969   Roipoussiere   Remove whitespace...
268

735c653b   Elena.Budnik   rank at observato...
269
270
271
272
273
274
275
276
277
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
								$isScatter = true;

								if ($child->parentNode->parentNode->hasAttribute('dataStart'))
								{
									$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
278
279
									$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
								}
735c653b   Elena.Budnik   rank at observato...
280
281
282

								if ($child->parentNode->parentNode->getAttribute('restriction') > 1)
								{
10200969   Roipoussiere   Remove whitespace...
283
284
									$timeRestriction = true;
								}
735c653b   Elena.Budnik   rank at observato...
285
286
287
288
289

								if ($child->hasAttribute("index1"))
									$component_info["index1"] = $child->getAttribute('index1');
								if ($child->hasAttribute("index2"))
									$component_info["index2"] = $child->getAttribute('index2');
10200969   Roipoussiere   Remove whitespace...
290

735c653b   Elena.Budnik   rank at observato...
291
292
								$component_info["parentId"] = $child->parentNode->getAttribute('xml:id');
							}
10200969   Roipoussiere   Remove whitespace...
293

735c653b   Elena.Budnik   rank at observato...
294
							if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
10200969   Roipoussiere   Remove whitespace...
295
296

							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type'))
735c653b   Elena.Budnik   rank at observato...
297
							{
10200969   Roipoussiere   Remove whitespace...
298
								if ($child->getAttribute('display_type') == 'spectrogram')
735c653b   Elena.Budnik   rank at observato...
299
								{
10200969   Roipoussiere   Remove whitespace...
300
301
										$needsArgs = true;
										$isSpectra = true;
735c653b   Elena.Budnik   rank at observato...
302
303
										$isScatter = false;
								}
10200969   Roipoussiere   Remove whitespace...
304
305
								elseif ($child->getAttribute('display_type') == 'stackplot')
								{
735c653b   Elena.Budnik   rank at observato...
306
307
308
										$isStack = true;
										$isScatter = false;
								}
10200969   Roipoussiere   Remove whitespace...
309
310
311
							}

							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
312
							{
735c653b   Elena.Budnik   rank at observato...
313
314
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);
10200969   Roipoussiere   Remove whitespace...
315
316

								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
317
318
319
320
321
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
									'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
									'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
							}
10200969   Roipoussiere   Remove whitespace...
322
							else
735c653b   Elena.Budnik   rank at observato...
323
							{
10200969   Roipoussiere   Remove whitespace...
324
								if ($child->tagName == 'mission' || $child->tagName == 'observatory')
735c653b   Elena.Budnik   rank at observato...
325
326
327
328
329
330
331
332
								{
									$disable = $child->hasAttribute('restriction');
									$rank = $child->getAttribute('rank');
								}
								else
								{
									$disable = $child->hasAttribute('restriction');
								}
10200969   Roipoussiere   Remove whitespace...
333

735c653b   Elena.Budnik   rank at observato...
334
335
336
								if ($disable)
								{
									if ($disable == 1) {
abda054b   Elena.Budnik   correct message
337
										$info .=  "<br/><b>Sorry ! Not finished yet...</b>";
735c653b   Elena.Budnik   rank at observato...
338
									}
10200969   Roipoussiere   Remove whitespace...
339
340
									else {
										$disable = false;
735c653b   Elena.Budnik   rank at observato...
341
342
343
									}
								}

10200969   Roipoussiere   Remove whitespace...
344
345
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
735c653b   Elena.Budnik   rank at observato...
346
347
348
349
							}
						break;

						case 'remoteSimuParam' :
10200969   Roipoussiere   Remove whitespace...
350

bf74fc2d   Elena.Budnik   IMPEX
351
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
352
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
353
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
354
355

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
356
357
358
359
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
360
361

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
362
							{
10200969   Roipoussiere   Remove whitespace...
363
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
364
								{
10200969   Roipoussiere   Remove whitespace...
365
366
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
367
								}
10200969   Roipoussiere   Remove whitespace...
368
								else
735c653b   Elena.Budnik   rank at observato...
369
370
371
372
373
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
374
375

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
376
377
378
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
379

bf74fc2d   Elena.Budnik   IMPEX
380
381
							if ( $child->tagName == 'parameter')
							{
a0f13ed1   Elena.Budnik   small format + ti...
382
								if ($child->parentNode->hasAttribute('dataStart'))
bf74fc2d   Elena.Budnik   IMPEX
383
									{
a0f13ed1   Elena.Budnik   small format + ti...
384
385
										$globalStart = $child->parentNode->getAttribute('dataStart');
										$globalStop = $child->parentNode->getAttribute('dataStop');
bf74fc2d   Elena.Budnik   IMPEX
386
387
									}
							}
10200969   Roipoussiere   Remove whitespace...
388

bf74fc2d   Elena.Budnik   IMPEX
389
390
391
392
393
							if ( $child->tagName == 'component')
							{
								if ($child->parentNode->parentNode->hasAttribute('dataStart'))
									{
										$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
394
										$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
bf74fc2d   Elena.Budnik   IMPEX
395
396
									}
							}
10200969   Roipoussiere   Remove whitespace...
397

735c653b   Elena.Budnik   rank at observato...
398
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
399
400

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
401
402
403
404
405
406
407
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
408
409
410
411
412
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
413
							{
10200969   Roipoussiere   Remove whitespace...
414
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
415
416
417
418
419
								case 'THEMIS' :
									$rank = 5;
									break;
								case 'MAPSKP' :
									$rank = 9;
10200969   Roipoussiere   Remove whitespace...
420
									break;
735c653b   Elena.Budnik   rank at observato...
421
422
								default:
							}
10200969   Roipoussiere   Remove whitespace...
423

735c653b   Elena.Budnik   rank at observato...
424
425
							$info = $child->getAttribute('desc');

10200969   Roipoussiere   Remove whitespace...
426
427
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
428
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
429
430
431
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
432
433
							{
								$isParameter = true;
10200969   Roipoussiere   Remove whitespace...
434
								$isScatter = true;
735c653b   Elena.Budnik   rank at observato...
435
							}
10200969   Roipoussiere   Remove whitespace...
436

9a63b7f6   Elena.Budnik   needsArgs to Simu...
437
							$needsArgs =  $child->getAttribute('needsArgs');
735c653b   Elena.Budnik   rank at observato...
438
439

							if (($child->tagName == 'parameter' && $child->hasChildNodes()) || $needsArgs) $isScatter = false;
10200969   Roipoussiere   Remove whitespace...
440
441

							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
442
							{
10200969   Roipoussiere   Remove whitespace...
443
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
444
							}
a0f13ed1   Elena.Budnik   small format + ti...
445
446
447
448
449
450
451
							
							if ($child->tagName == 'parameter'){
								if ($child->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
735c653b   Elena.Budnik   rank at observato...
452

a0f13ed1   Elena.Budnik   small format + ti...
453
454
455
456
457
458
459
							if ( $child->tagName == 'component'){
								if ($child->parentNode->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
							
10200969   Roipoussiere   Remove whitespace...
460
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
461
							{
10200969   Roipoussiere   Remove whitespace...
462
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
463
464
465
466
467
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
468
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
469
470
									$isScatter = false;
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
471
								}
bf74fc2d   Elena.Budnik   IMPEX
472
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
473
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
474
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
475
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
bf74fc2d   Elena.Budnik   IMPEX
476
477
										'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
								else
10200969   Roipoussiere   Remove whitespace...
478
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
479
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
480
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
bf74fc2d   Elena.Budnik   IMPEX
481
										'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
482
							}
10200969   Roipoussiere   Remove whitespace...
483
484
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
485
								$restricted = FALSE;
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
486
								
735c653b   Elena.Budnik   rank at observato...
487
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
488
								{
735c653b   Elena.Budnik   rank at observato...
489
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
490
								}
735c653b   Elena.Budnik   rank at observato...
491
								else
6657f68b   Elena.Budnik   monitor impex ser...
492
								{
735c653b   Elena.Budnik   rank at observato...
493
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
494
								}
10200969   Roipoussiere   Remove whitespace...
495

735c653b   Elena.Budnik   rank at observato...
496
497
498
499
500
501
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
502
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
503
504
505
506
507
508
509
510
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

								$disable = $restricted || $nonavailable || $obsolete;
10200969   Roipoussiere   Remove whitespace...
511

735c653b   Elena.Budnik   rank at observato...
512
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
513
514
515
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
516
						break;
10200969   Roipoussiere   Remove whitespace...
517
518
519

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
520
521
522
523
524
525
526
527
528
529
530
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
							$isScatter = $size == 1;
							$mask = $child->getAttribute('mask');
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
531
532

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
533
534
535
536
537
538
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
539
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
540
541
542
543
544
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
545
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
546
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
10200969   Roipoussiere   Remove whitespace...
547
								'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
548
549
550
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
10200969   Roipoussiere   Remove whitespace...
551
						default:
735c653b   Elena.Budnik   rank at observato...
552
					}
10200969   Roipoussiere   Remove whitespace...
553
554

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
555
					{
10200969   Roipoussiere   Remove whitespace...
556
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
557
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
558
559

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
560
561
562
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
563
564

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
6657f68b   Elena.Budnik   monitor impex ser...
565
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
735c653b   Elena.Budnik   rank at observato...
566
567
568
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
569
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
570
				{
735c653b   Elena.Budnik   rank at observato...
571
572
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
735c653b   Elena.Budnik   rank at observato...
573
			}
16035364   Benjamin Renard   First commit
574
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
575
	}
16035364   Benjamin Renard   First commit
576

0dc31ba8   Elena.Budnik   remoteParamManage...
577
578
579
580
581
	/*
	*  add Remote Parameter to user RemoteParams.xml
	*  send request to DDServer to AddVi if Vi doesn't exist
	*  create Remote Parameter Description	
	*/
10200969   Roipoussiere   Remove whitespace...
582
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
583
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
584
		$paramMgr = new RemoteParamManager();
10200969   Roipoussiere   Remove whitespace...
585
		return $paramMgr->saveTree($obj);
735c653b   Elena.Budnik   rank at observato...
586
	}
0dc31ba8   Elena.Budnik   remoteParamManage...
587
588
589
590
	
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
591
592
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
593
		$paramMgr = new RemoteParamManager();
10200969   Roipoussiere   Remove whitespace...
594
		return $paramMgr->deleteFromTree($obj);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
595
	}
0dc31ba8   Elena.Budnik   remoteParamManage...
596
597
598
599
600
		
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
601

0dc31ba8   Elena.Budnik   remoteParamManage...
602
603
604
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
605
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
606
607
	{
		switch ($nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
608
		{
10200969   Roipoussiere   Remove whitespace...
609
610
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
611
				break;
10200969   Roipoussiere   Remove whitespace...
612
613
614
615
616
			case 'myDataParam' :
				$objectMgr = new FilesMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
617
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
618
619
620
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
621
		return  $objectMgr->getUploadedObject($name, $format, true);
10200969   Roipoussiere   Remove whitespace...
622
	}
16035364   Benjamin Renard   First commit
623

0dc31ba8   Elena.Budnik   remoteParamManage...
624
625
626
	/*
	*  fill ascii file into grid
	*/
10200969   Roipoussiere   Remove whitespace...
627
628
629
	public  function getAsciiFile($obj)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
630
		return  $objectMgr->getAsciiFile($obj->fileName);
735c653b   Elena.Budnik   rank at observato...
631
	}
10200969   Roipoussiere   Remove whitespace...
632
633
634
635

	public function getMyParamInfo($object)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
636
		return  $objectMgr->getParamInfo($object);
10200969   Roipoussiere   Remove whitespace...
637
	}
16035364   Benjamin Renard   First commit
638

0dc31ba8   Elena.Budnik   remoteParamManage...
639
640
641
	/*
	*  get temporary object from Search
	*/
10200969   Roipoussiere   Remove whitespace...
642
643
644
	public  function getTmpObject($folderId, $name, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
645
		{
10200969   Roipoussiere   Remove whitespace...
646
647
648
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
649
			case 'catalog' :
10200969   Roipoussiere   Remove whitespace...
650
651
				$objectMgr = new CatalogMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
652
653
654
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
655
		return  $objectMgr->getTmpObject($folderId, $name, true);
fdf1413b   Elena.Budnik   TT download
656
	}
735c653b   Elena.Budnik   rank at observato...
657

10200969   Roipoussiere   Remove whitespace...
658
659
660
661

	public  function getObject($id, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
662
663
		{
			case 'myDataParam':
10200969   Roipoussiere   Remove whitespace...
664
665
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($nodeType);
735c653b   Elena.Budnik   rank at observato...
666
				break;
10200969   Roipoussiere   Remove whitespace...
667
			case 'timeTable' :
735c653b   Elena.Budnik   rank at observato...
668
			case 'sharedtimeTable' :
10200969   Roipoussiere   Remove whitespace...
669
670
				$objectMgr = new TimeTableMgr();
				break;
735c653b   Elena.Budnik   rank at observato...
671
672
			case 'catalog' :
			case 'sharedcatalog' :
10200969   Roipoussiere   Remove whitespace...
673
674
675
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
676
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
677
678
				$objectMgr = new RequestMgr($nodeType);
				break;
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
679
			case 'bkgWorks' :	
735c653b   Elena.Budnik   rank at observato...
680
681
682
				return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
				break;
			case 'myData' :
10200969   Roipoussiere   Remove whitespace...
683
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
684
				break;
10200969   Roipoussiere   Remove whitespace...
685
			default:
735c653b   Elena.Budnik   rank at observato...
686
687
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
688
		return  $objectMgr->getObject($id, $nodeType);
fdf1413b   Elena.Budnik   TT download
689
	}
10200969   Roipoussiere   Remove whitespace...
690

16035364   Benjamin Renard   First commit
691
692
693
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
694
695
696
697
698
699
700
	public  function deleteObject($obj)
	{
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
701
				break;
10200969   Roipoussiere   Remove whitespace...
702
703
704
705
706
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
735c653b   Elena.Budnik   rank at observato...
707
				break;
10200969   Roipoussiere   Remove whitespace...
708
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
709
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
710
				$objectMgr = new RequestMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
711
712
713
714
				break;
			case 'alias' :
				$objectMgr = new AliasMgr();
				$obj->id = substr($obj->id,strlen('alias_'));
10200969   Roipoussiere   Remove whitespace...
715
				break;
735c653b   Elena.Budnik   rank at observato...
716
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
717
718
719
				return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);

			case 'myData' :
16035364   Benjamin Renard   First commit
720
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
721
722
723
724
725
726
				break;
			default:
					return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> deleteObject($obj);
	}
16035364   Benjamin Renard   First commit
727
728
729
730

/*
*   $obj = { id: node.id, old_name: node.text, name: value,  parent : node.parentNode.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
731
732
733
	public  function renameObject($obj)
	{
		switch ($obj->nodeType)
735c653b   Elena.Budnik   rank at observato...
734
		{
10200969   Roipoussiere   Remove whitespace...
735

16035364   Benjamin Renard   First commit
736
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
737
738
739
740
741
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
742
			   break;
10200969   Roipoussiere   Remove whitespace...
743
744
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
745
			   break;
10200969   Roipoussiere   Remove whitespace...
746
747
748
		  case 'condition' :
		  case 'request' :
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
749
750
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
751
752
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
753
754
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
755
		}
16035364   Benjamin Renard   First commit
756

735c653b   Elena.Budnik   rank at observato...
757
758
		return  $objectMgr -> renameObject($obj);
	}
16035364   Benjamin Renard   First commit
759

10200969   Roipoussiere   Remove whitespace...
760
/*
16035364   Benjamin Renard   First commit
761
762
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
763
764
765
	public  function createObject($obj, $folder)
	{
		switch ($obj->nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
766
		{
10200969   Roipoussiere   Remove whitespace...
767
			case 'myDataParam' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
768
			case 'derivedParam' :
10200969   Roipoussiere   Remove whitespace...
769
				if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
770
						$this->amdaStat->addTask('create', $this->user, null);
10200969   Roipoussiere   Remove whitespace...
771
772
773
774
775
776
777
				$objectMgr = new DerivedParamMgr($obj->nodeType);
				break;
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
778
			   break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
779
			case 'condition' :
10200969   Roipoussiere   Remove whitespace...
780
781
782
			case 'request' :
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
783
			case 'alias' :
10200969   Roipoussiere   Remove whitespace...
784
785
				$objectMgr = new AliasMgr();
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
786
787
788
789
790
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> createObject($obj, $folder);
	}
16035364   Benjamin Renard   First commit
791

10200969   Roipoussiere   Remove whitespace...
792
/*
16035364   Benjamin Renard   First commit
793
794
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
795
	public  function modifyObject($obj)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
796
	{
10200969   Roipoussiere   Remove whitespace...
797
798
799
800
801
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
802
				break;
10200969   Roipoussiere   Remove whitespace...
803
804
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
805
				break;
10200969   Roipoussiere   Remove whitespace...
806
807
808
809
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
810
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
811
				$objectMgr = new RequestMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
812
813
814
815
816
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> modifyObject($obj);
10200969   Roipoussiere   Remove whitespace...
817
	}
16035364   Benjamin Renard   First commit
818
819
820
821
822
823
824
825
826
827
/*
 * {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...
828
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
829
830
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
831
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
832
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
833
834
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
835
836
837
838
839
840
841
842
843
844
845
846
847
848
			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
*/
6acb8d2a   Elena.Budnik   checkRequest in R...
849
850
	public  function getJobs()
	{
812bc03d   Nathanael Jourdane   update job info o...
851
		$obj = (object) array();
10200969   Roipoussiere   Remove whitespace...
852
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
6acb8d2a   Elena.Budnik   checkRequest in R...
853
	}
16035364   Benjamin Renard   First commit
854
855
856
857
858
859
860


	/* AKKA-KERNEL-INT
	Move user check from RequestMgr.php to AmdaAction.php
	*/
	private function checkUser($obj)
	{
32bb889b   Elena.Budnik   #5532 to process ...
861
		if (defined('NEWKERNEL_DEBUG') && NEWKERNEL_DEBUG){
16035364   Benjamin Renard   First commit
862
863
864
			$this->user = NEWKERNEL_DEBUG_USER;
			return array('success' => true);
		}
10200969   Roipoussiere   Remove whitespace...
865

32bb889b   Elena.Budnik   #5532 to process ...
866
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID)) {
a21497cc   Elena.Budnik   redmine #5645
867
			   //$dd = new WSUserMgr();
16035364   Benjamin Renard   First commit
868
869
            //$dd->init($obj->username,$obj->password,$obj->sessionID);
			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support not implemented");
735c653b   Elena.Budnik   rank at observato...
870
		}
a21497cc   Elena.Budnik   redmine #5645
871
		else {
16035364   Benjamin Renard   First commit
872
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
873
874
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
875
876

		//TODO error handling
32bb889b   Elena.Budnik   #5532 to process ...
877
		if (($res = $dd->ddCheckUser()) != 0) {
10200969   Roipoussiere   Remove whitespace...
878
			if ($res == 156)
6acb8d2a   Elena.Budnik   checkRequest in R...
879
				return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!');
16035364   Benjamin Renard   First commit
880

735c653b   Elena.Budnik   rank at observato...
881
882
			return array('success' => false, 'message' => 'ddLogin error: '.$res);
		}
16035364   Benjamin Renard   First commit
883

32bb889b   Elena.Budnik   #5532 to process ...
884
		if ($dd->user == 'impex') {	
16035364   Benjamin Renard   First commit
885
			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
886
		}
32bb889b   Elena.Budnik   #5532 to process ...
887
		else {
a21497cc   Elena.Budnik   redmine #5645
888
			// check disk space 
6acb8d2a   Elena.Budnik   checkRequest in R...
889
			if ($dd->getWsSize() > DISK_QUOTA)
16035364   Benjamin Renard   First commit
890
				return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available');
735c653b   Elena.Budnik   rank at observato...
891
		}
10200969   Roipoussiere   Remove whitespace...
892

735c653b   Elena.Budnik   rank at observato...
893
		$this->user = $dd->user;
10200969   Roipoussiere   Remove whitespace...
894

32bb889b   Elena.Budnik   #5532 to process ...
895
		return array('success' => true, 'userHost' => $dd->getIPclient());
16035364   Benjamin Renard   First commit
896
	}
10200969   Roipoussiere   Remove whitespace...
897

6acb8d2a   Elena.Budnik   checkRequest in R...
898
	private function executeRequest($obj, $function)
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
899
	{ 
32bb889b   Elena.Budnik   #5532 to process ...
900
901
902
903
904
		// Check user if access to DD Server and / or possible 'space consuming' action
		if (  $function == FunctionTypeEnumClass::PARAMS ||
				$function == FunctionTypeEnumClass::ACTION ||
				$function == FunctionTypeEnumClass::PARAMSGEN )
		{
7ac3e07e   Elena.Budnik   do not check user...
905
906
907
908
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
		
16035364   Benjamin Renard   First commit
909
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
910
		try {
e57cb025   Benjamin Renard   Fix most of error...
911
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
912
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
913
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
914
		}
16035364   Benjamin Renard   First commit
915
916
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
917
918
919

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
920
*/
735c653b   Elena.Budnik   rank at observato...
921
922
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
923
924
925
926
		// just convert TT / Catalog
		if ($obj->nodeType == "download" &&  $obj->downloadSrc == "1")
			return $this->executeRequest($obj, FunctionTypeEnumClass::TTCONVERT);
		else if (isset($obj->action))
16035364   Benjamin Renard   First commit
927
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
928
929
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
930
931
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
932

16035364   Benjamin Renard   First commit
933
			return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
6acb8d2a   Elena.Budnik   checkRequest in R...
934
		}
fdf1413b   Elena.Budnik   TT download
935
	}
10200969   Roipoussiere   Remove whitespace...
936

16035364   Benjamin Renard   First commit
937
/*
a0b3d64e   Benjamin Renard   Derived parameter...
938
939
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
940
941
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
942
943
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
944
945
946
947

/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
948
949
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
950
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
951

a0b3d64e   Benjamin Renard   Derived parameter...
952
953
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
954

a0b3d64e   Benjamin Renard   Derived parameter...
955
956
957
958
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
959
960
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
961

a0b3d64e   Benjamin Renard   Derived parameter...
962
/*
e6e5b259   Benjamin Renard   Add kill plot req...
963
 * kill plot process
16035364   Benjamin Renard   First commit
964
 */
10200969   Roipoussiere   Remove whitespace...
965

735c653b   Elena.Budnik   rank at observato...
966
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
967
	{
735c653b   Elena.Budnik   rank at observato...
968
969
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
970
971
972
973

/*
 * merge time tables
 */
10200969   Roipoussiere   Remove whitespace...
974
	public  function merge($obj)
735c653b   Elena.Budnik   rank at observato...
975
976
977
	{
		if ($this->amdaStat->success)
			$this->amdaStat->addTask('ttoper', $this->user, null);
10200969   Roipoussiere   Remove whitespace...
978

735c653b   Elena.Budnik   rank at observato...
979
		$objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
980

735c653b   Elena.Budnik   rank at observato...
981
982
		return  $objectMgr -> merge($obj);
	}
16035364   Benjamin Renard   First commit
983

10200969   Roipoussiere   Remove whitespace...
984

16035364   Benjamin Renard   First commit
985
986
987
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
988
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
989
990
991
	{
		if ($this->amdaStat->success)
				$this->amdaStat->addTask('ttoper', $this->user, null);
16035364   Benjamin Renard   First commit
992

735c653b   Elena.Budnik   rank at observato...
993
994
		$objectMgr = new TimeTableMgr();
		$result = $objectMgr -> intersect($obj);
16035364   Benjamin Renard   First commit
995

735c653b   Elena.Budnik   rank at observato...
996
997
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
998

735c653b   Elena.Budnik   rank at observato...
999
1000
1001
1002
	public function initTTCache($isCatalog = false, $nparams)
	{
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else              $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1003

735c653b   Elena.Budnik   rank at observato...
1004
1005
		return $cacheMgr->initTTCache($nparams);
	}
10200969   Roipoussiere   Remove whitespace...
1006
1007


735c653b   Elena.Budnik   rank at observato...
1008
1009
1010
1011
	public function initTTCacheFromTT($id, $type)
	{
		if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1012

735c653b   Elena.Budnik   rank at observato...
1013
1014
		return $cacheMgr->initFromTT($id, $type);
	}
10200969   Roipoussiere   Remove whitespace...
1015

735c653b   Elena.Budnik   rank at observato...
1016
1017
	public function initForChart($id, $name, $isTmpObject, $type)
	{
e1fd05b4   Elena.Budnik   visu from cacheCat
1018
1019
1020
		if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
			return array('success' => true, 'cache' => $id);
			
735c653b   Elena.Budnik   rank at observato...
1021
		if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
10200969   Roipoussiere   Remove whitespace...
1022

735c653b   Elena.Budnik   rank at observato...
1023
1024
		return $objMgr->initForChart($id, $name, $isTmpObject, $type);
	}
10200969   Roipoussiere   Remove whitespace...
1025

735c653b   Elena.Budnik   rank at observato...
1026
1027
	public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
	{
10200969   Roipoussiere   Remove whitespace...
1028
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1029
1030
1031
1032
		else  $cacheMgr = new CatalogCacheMgr();

		return $cacheMgr->initFromTmpObject($folderId, $name);
	}
10200969   Roipoussiere   Remove whitespace...
1033

901ba3f3   Elena.Budnik   upload catalog
1034
	public function initTTCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1035
	{
901ba3f3   Elena.Budnik   upload catalog
1036
1037
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1038

735c653b   Elena.Budnik   rank at observato...
1039
1040
		return $cacheMgr->initFromUploadedFile($name, $format);
	}
10200969   Roipoussiere   Remove whitespace...
1041

735c653b   Elena.Budnik   rank at observato...
1042
1043
	public function readTTCacheIntervals($o)
	{
e57cb025   Benjamin Renard   Fix most of error...
1044
		if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1045
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1046

e57cb025   Benjamin Renard   Fix most of error...
1047
		return $cacheMgr->getIntervals($o->start,$o->limit,isset($o->sort) ? $o->sort : NULL, isset($o->filter) ? $o->filter : NULL);
735c653b   Elena.Budnik   rank at observato...
1048
	}
10200969   Roipoussiere   Remove whitespace...
1049

735c653b   Elena.Budnik   rank at observato...
1050
1051
	public function readIntervalsForChart($o)
	{
e57cb025   Benjamin Renard   Fix most of error...
1052
		if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) {
e1fd05b4   Elena.Budnik   visu from cacheCat
1053
1054
1055
1056
1057
1058
1059
1060
1061
				
				if ($o->fromPlugin && $o->id == 'cacheCat') {
					$objMgr = new CatalogCacheMgr();
					
					return $objMgr->getIntervals();
				}
				
				$objMgr = new CatalogMgr();
		}
10200969   Roipoussiere   Remove whitespace...
1062

735c653b   Elena.Budnik   rank at observato...
1063
1064
		return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT);
	}
10200969   Roipoussiere   Remove whitespace...
1065

735c653b   Elena.Budnik   rank at observato...
1066
1067
1068
1069
1070
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
	}
10200969   Roipoussiere   Remove whitespace...
1071

735c653b   Elena.Budnik   rank at observato...
1072
1073
1074
1075
1076
1077
1078
	public function addTTCacheInterval($o)
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

		return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
	}
10200969   Roipoussiere   Remove whitespace...
1079

735c653b   Elena.Budnik   rank at observato...
1080
1081
1082
1083
1084
1085
1086
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

		return $cacheMgr->removeIntervalFromId($id);
	}
10200969   Roipoussiere   Remove whitespace...
1087

735c653b   Elena.Budnik   rank at observato...
1088
1089
	public function modifyTTCacheInterval($o)
	{
10200969   Roipoussiere   Remove whitespace...
1090
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1091
		{
f9c8b272   elena   edit catalog
1092
			$cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1093
			return $cacheMgr->modifyIntervalFromId($o);
f9c8b272   elena   edit catalog
1094
		}
735c653b   Elena.Budnik   rank at observato...
1095
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1096

735c653b   Elena.Budnik   rank at observato...
1097
1098
		return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop);
	}
10200969   Roipoussiere   Remove whitespace...
1099

735c653b   Elena.Budnik   rank at observato...
1100
1101
1102
1103
1104
	public function operationTTCacheIntervals($extendTime, $shiftTime)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1105

735c653b   Elena.Budnik   rank at observato...
1106
1107
1108
1109
1110
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1111

735c653b   Elena.Budnik   rank at observato...
1112
1113
1114
1115
1116
	public function getTTCacheStatistics()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1117

735c653b   Elena.Budnik   rank at observato...
1118
1119
1120
1121
1122
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1123

16035364   Benjamin Renard   First commit
1124
1125
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1126
 *
16035364   Benjamin Renard   First commit
1127
 */
735c653b   Elena.Budnik   rank at observato...
1128
1129
1130
1131
1132
	public function sendFeedback($feed)
	{
		$feedMgr = new FeedbackMgr();
		return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
	}
10200969   Roipoussiere   Remove whitespace...
1133

16035364   Benjamin Renard   First commit
1134
1135
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1136
 *
16035364   Benjamin Renard   First commit
1137
 */
735c653b   Elena.Budnik   rank at observato...
1138
1139
1140
1141
1142
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1143

16035364   Benjamin Renard   First commit
1144
1145
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1146
1147
 *
 */
735c653b   Elena.Budnik   rank at observato...
1148
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1149
	{
735c653b   Elena.Budnik   rank at observato...
1150
1151
1152
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1153
1154

/*
16035364   Benjamin Renard   First commit
1155
1156
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1157
1158
1159
1160
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
			$this->amdaStat->addTask('images', $this->user, null);
10200969   Roipoussiere   Remove whitespace...
1161

735c653b   Elena.Budnik   rank at observato...
1162
1163
1164
1165
1166
1167
		$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);
	}
10200969   Roipoussiere   Remove whitespace...
1168

735c653b   Elena.Budnik   rank at observato...
1169
1170
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1171
		if ($this->amdaStat->success)
735c653b   Elena.Budnik   rank at observato...
1172
			$this->amdaStat->addTask('images', $this->user, null);
10200969   Roipoussiere   Remove whitespace...
1173

735c653b   Elena.Budnik   rank at observato...
1174
1175
1176
1177
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1178
	}
16035364   Benjamin Renard   First commit
1179
1180
1181
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1182
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1183
	{
10200969   Roipoussiere   Remove whitespace...
1184
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1185
1186
1187
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1188

735c653b   Elena.Budnik   rank at observato...
1189
1190
1191
1192
1193
1194
1195
1196
1197
	public function loadFilters($o)
	{
		$filtersMgr = new FiltersMgr();
		if (isset($o->id))
			$res = $filtersMgr->loadFilter($o->id);
		else
			$res = $filtersMgr->loadAll();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1198

735c653b   Elena.Budnik   rank at observato...
1199
1200
	public function saveFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1201
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1202
1203
		return $filtersMgr->save($o);
	}
10200969   Roipoussiere   Remove whitespace...
1204

735c653b   Elena.Budnik   rank at observato...
1205
1206
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1207
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1208
1209
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1210

735c653b   Elena.Budnik   rank at observato...
1211
1212
1213
1214
1215
1216
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1217

735c653b   Elena.Budnik   rank at observato...
1218
1219
1220
1221
1222
1223
1224
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1225
1226
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1227
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1228
1229
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1230

fdf1413b   Elena.Budnik   TT download
1231
1232
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1233
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1234
1235
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1236

fdf1413b   Elena.Budnik   TT download
1237
1238
1239
1240
1241
1242
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1243

16035364   Benjamin Renard   First commit
1244
1245
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1246
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1247
		{
fdf1413b   Elena.Budnik   TT download
1248
1249
1250
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1251
		else
735c653b   Elena.Budnik   rank at observato...
1252
		{
fdf1413b   Elena.Budnik   TT download
1253
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1254
		}
16035364   Benjamin Renard   First commit
1255
		return;
10200969   Roipoussiere   Remove whitespace...
1256
	}
16035364   Benjamin Renard   First commit
1257

fdf1413b   Elena.Budnik   TT download
1258
1259
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1260
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1261
		{
10200969   Roipoussiere   Remove whitespace...
1262
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1263
1264
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1265
1266
1267
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1268
1269
1270
1271
1272
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1273

fdf1413b   Elena.Budnik   TT download
1274
1275
1276
1277
1278
	public function convertWS()
	{
		$dd = new UserMgr();
		return $dd->convertWS();
	}
16035364   Benjamin Renard   First commit
1279

fdf1413b   Elena.Budnik   TT download
1280
1281
1282
1283
1284
1285
	// $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);
10200969   Roipoussiere   Remove whitespace...
1286
1287

		return  $res;
fdf1413b   Elena.Budnik   TT download
1288
	}
10200969   Roipoussiere   Remove whitespace...
1289
1290

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1291
1292
1293
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1294

bf74fc2d   Elena.Budnik   IMPEX
1295
		$ok = $myBestRunsMgr->init();
10200969   Roipoussiere   Remove whitespace...
1296

bf74fc2d   Elena.Budnik   IMPEX
1297
1298
		if (!$ok)
			return array('success'=>false,'message'=>'cannot init addRun');
10200969   Roipoussiere   Remove whitespace...
1299

fdf1413b   Elena.Budnik   TT download
1300
		$myBestRunsMgr->addRuns($obj);
10200969   Roipoussiere   Remove whitespace...
1301

bf74fc2d   Elena.Budnik   IMPEX
1302
		return array('success'=>true,'addedRuns'=>$obj);
10200969   Roipoussiere   Remove whitespace...
1303
1304
	}

fdf1413b   Elena.Budnik   TT download
1305
1306
1307
1308
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1309
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1310
1311

		// delete impex params and data
bf74fc2d   Elena.Budnik   IMPEX
1312
1313
		$impexParamMgr = new ImpexParamManager();
		$impexParamMgr->deleteImpexStaff();
10200969   Roipoussiere   Remove whitespace...
1314

e57cb025   Benjamin Renard   Fix most of error...
1315
		$obj = (object) array();
fdf1413b   Elena.Budnik   TT download
1316
1317
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
	}
10200969   Roipoussiere   Remove whitespace...
1318

fdf1413b   Elena.Budnik   TT download
1319
1320
1321
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1322
1323
			foreach ($objects as $object) { // Recursively delete a directory that is not empty and directorys in directory
				if ($object != "." && $object != "..") {  // If object isn't a directory recall recursively this function
fdf1413b   Elena.Budnik   TT download
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
					if (filetype($dir."/".$object) == "dir")
						$this->rrmdir($dir."/".$object);
					else
						unlink($dir."/".$object);
				}
			}
			reset($objects);
			rmdir($dir);
		}
	}

	public function deleteSpecialInfo($name)
	{
10200969   Roipoussiere   Remove whitespace...
1337
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1338
1339
1340
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1341

fdf1413b   Elena.Budnik   TT download
1342
1343
	public function interactivePlot($obj, $multiPlotState)
	{
fdf1413b   Elena.Budnik   TT download
1344
1345
1346
1347
1348
1349
		$inputobj = (Object)array(
			'action' => $obj,
			'multiPlotState' => $multiPlotState
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1350

735c653b   Elena.Budnik   rank at observato...
1351
1352
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1353
1354
1355
1356
1357
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1358

735c653b   Elena.Budnik   rank at observato...
1359
1360
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1361
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1362
1363
1364
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1365

735c653b   Elena.Budnik   rank at observato...
1366
1367
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1368
1369
1370
1371
1372
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1373

735c653b   Elena.Budnik   rank at observato...
1374
1375
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1376
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1377
1378
1379
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1380

735c653b   Elena.Budnik   rank at observato...
1381
1382
1383
1384
1385
1386
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1387

735c653b   Elena.Budnik   rank at observato...
1388
1389
1390
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1391
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1392
1393
1394
1395
1396
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1397

735c653b   Elena.Budnik   rank at observato...
1398
1399
1400
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1401

735c653b   Elena.Budnik   rank at observato...
1402
1403
1404
		$result = $mgr->add($obj->type, $obj->name, $obj->folder, $src_object_path, $obj->description, $this->user);
		if (!$result['success'])
			return $result;
10200969   Roipoussiere   Remove whitespace...
1405

735c653b   Elena.Budnik   rank at observato...
1406
1407
1408
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1409

735c653b   Elena.Budnik   rank at observato...
1410
1411
1412
1413
1414
1415
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1416

0bda97f3   Benjamin Renard   Fix SAMP export f...
1417
1418
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1419
1420
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
16035364   Benjamin Renard   First commit
1421
1422
}
?>