Blame view

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

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

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

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

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

f29c5e66   Elena.Budnik   plot only option
244
							if ($child->tagName == 'parameter') {
735c653b   Elena.Budnik   rank at observato...
245
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
246

c57c57c9   Elena.Budnik   info message depe...
247
								if ($child->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
248
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
249
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
250
								}
f29c5e66   Elena.Budnik   plot only option
251
252
253
254
255
									
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
256
								}
f29c5e66   Elena.Budnik   plot only option
257
258
259
// 								if ($child->parentNode->getAttribute('restriction') > 1 ) {
// 									$timeRestriction = true;
// 								}
735c653b   Elena.Budnik   rank at observato...
260
							}
10200969   Roipoussiere   Remove whitespace...
261

735c653b   Elena.Budnik   rank at observato...
262
263
264
265
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
266

c57c57c9   Elena.Budnik   info message depe...
267
								if ($child->parentNode->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
268
									$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
269
270
									$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
								}
f29c5e66   Elena.Budnik   plot only option
271
272
273
274
275
								
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
276
								}
f29c5e66   Elena.Budnik   plot only option
277
278
279
// 								if ($child->parentNode->parentNode->getAttribute('restriction') > 1) {
// 									$timeRestriction = true;
// 								}
735c653b   Elena.Budnik   rank at observato...
280
281
282
283
284

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

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

f29c5e66   Elena.Budnik   plot only option
289
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
290
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
291
292
										$needsArgs = true;
										$isSpectra = true;
735c653b   Elena.Budnik   rank at observato...
293
								}
c57c57c9   Elena.Budnik   info message depe...
294
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
295
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
296
								}
10200969   Roipoussiere   Remove whitespace...
297
298
							}

c57c57c9   Elena.Budnik   info message depe...
299
							if ($isParameter) {
735c653b   Elena.Budnik   rank at observato...
300
301
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);
10200969   Roipoussiere   Remove whitespace...
302

661293d7   Elena.Budnik   parse ## and @@ i...
303
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
304
305
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
1c007ca2   Elena.Budnik   vector icon for M...
306
									'leaf' => $isLeaf, 'isParameter' => $isParameter,
735c653b   Elena.Budnik   rank at observato...
307
308
									'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
							}
c57c57c9   Elena.Budnik   info message depe...
309
							else {
c57c57c9   Elena.Budnik   info message depe...
310
								if ($child->tagName == 'mission' || $child->tagName == 'observatory') {
735c653b   Elena.Budnik   rank at observato...
311
312
									$rank = $child->getAttribute('rank');
								}
c57c57c9   Elena.Budnik   info message depe...
313
								
acf87705   Elena.Budnik   bug in disable param
314
315
								$disable = $child->hasAttribute('group');

c57c57c9   Elena.Budnik   info message depe...
316
								if ($disable) {
acf87705   Elena.Budnik   bug in disable param
317
									if ($child->getAttribute("group") !== "TBD") {
c57c57c9   Elena.Budnik   info message depe...
318
319
											$info .=  "<br/><b>Restricted Access</b>";
										}
10200969   Roipoussiere   Remove whitespace...
320
									else {
c57c57c9   Elena.Budnik   info message depe...
321
										$info .=  "<br/><b>Sorry! Not finished yet...</b>";
735c653b   Elena.Budnik   rank at observato...
322
									}
acf87705   Elena.Budnik   bug in disable param
323
324
325
326
								} 
								else {
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
327
328
								}

10200969   Roipoussiere   Remove whitespace...
329
330
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
735c653b   Elena.Budnik   rank at observato...
331
332
333
334
							}
						break;

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

bf74fc2d   Elena.Budnik   IMPEX
336
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
337
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
338
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
339
340

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
341
342
343
344
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
345
346

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
347
							{
10200969   Roipoussiere   Remove whitespace...
348
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
349
								{
10200969   Roipoussiere   Remove whitespace...
350
351
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
352
								}
10200969   Roipoussiere   Remove whitespace...
353
								else
735c653b   Elena.Budnik   rank at observato...
354
355
356
357
358
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
359
360

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
361
362
363
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
364

bf74fc2d   Elena.Budnik   IMPEX
365
366
							if ( $child->tagName == 'parameter')
							{
abb54096   Elena.Budnik   time interval by ...
367
								if ($child->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
368
									{
abb54096   Elena.Budnik   time interval by ...
369
370
										$globalStart = $child->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
371
372
									}
							}
10200969   Roipoussiere   Remove whitespace...
373

bf74fc2d   Elena.Budnik   IMPEX
374
375
							if ( $child->tagName == 'component')
							{
abb54096   Elena.Budnik   time interval by ...
376
								if ($child->parentNode->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
377
									{
abb54096   Elena.Budnik   time interval by ...
378
379
										$globalStart = $child->parentNode->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
380
381
									}
							}
10200969   Roipoussiere   Remove whitespace...
382

735c653b   Elena.Budnik   rank at observato...
383
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
384
385

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
386
387
388
389
390
391
392
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
393
394
395
396
397
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
398
							{
10200969   Roipoussiere   Remove whitespace...
399
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
400
401
402
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
403
404
								default:
							}
10200969   Roipoussiere   Remove whitespace...
405

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

10200969   Roipoussiere   Remove whitespace...
408
409
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
410
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
411
412
413
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
414
415
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
416
							}
10200969   Roipoussiere   Remove whitespace...
417

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

10200969   Roipoussiere   Remove whitespace...
420
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
421
							{
10200969   Roipoussiere   Remove whitespace...
422
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
423
							}
a0f13ed1   Elena.Budnik   small format + ti...
424
425
426
427
428
429
430
							
							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...
431

a0f13ed1   Elena.Budnik   small format + ti...
432
433
434
435
436
437
438
							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...
439
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
440
							{
10200969   Roipoussiere   Remove whitespace...
441
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
442
443
444
445
446
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
447
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
448
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
449
								}
bf74fc2d   Elena.Budnik   IMPEX
450
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
451
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
452
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
453
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
454
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => isset($component_info) ? $component_info : NULL);
bf74fc2d   Elena.Budnik   IMPEX
455
								else
10200969   Roipoussiere   Remove whitespace...
456
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
457
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
458
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
459
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
460
							}
10200969   Roipoussiere   Remove whitespace...
461
462
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
463
								$restricted = FALSE;
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
464
								
735c653b   Elena.Budnik   rank at observato...
465
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
466
								{
735c653b   Elena.Budnik   rank at observato...
467
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
468
								}
735c653b   Elena.Budnik   rank at observato...
469
								else
6657f68b   Elena.Budnik   monitor impex ser...
470
								{
735c653b   Elena.Budnik   rank at observato...
471
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
472
								}
10200969   Roipoussiere   Remove whitespace...
473

735c653b   Elena.Budnik   rank at observato...
474
475
476
477
478
479
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
480
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
481
482
483
484
485
486
487
488
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

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

735c653b   Elena.Budnik   rank at observato...
490
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
491
492
493
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
494
						break;
10200969   Roipoussiere   Remove whitespace...
495
496
497

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
498
499
500
501
502
503
504
505
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
506
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
507
508
509
							$sampling = null;
							if ($child->hasAttribute('minsampling')) 
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
510
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
511
512

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
513
514
515
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
516
517
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
518
519
520
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
521
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
522
523
524
525
526
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
527
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
528
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
529
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
530
531
532
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
10200969   Roipoussiere   Remove whitespace...
533
						default:
735c653b   Elena.Budnik   rank at observato...
534
					}
10200969   Roipoussiere   Remove whitespace...
535
536

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
537
					{
10200969   Roipoussiere   Remove whitespace...
538
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
539
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
540
541

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
542
543
544
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
545
546

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
6657f68b   Elena.Budnik   monitor impex ser...
547
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
735c653b   Elena.Budnik   rank at observato...
548
549
550
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
551
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
552
				{
735c653b   Elena.Budnik   rank at observato...
553
554
555
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
556
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
557
	}
16035364   Benjamin Renard   First commit
558

0dc31ba8   Elena.Budnik   remoteParamManage...
559
560
561
562
563
	/*
	*  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...
564
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
565
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
566
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
567
568
569
570
571
572
		$res = $paramMgr->init();
		
		if ($res['success'])
			return $paramMgr->saveTree($obj);
		else 
			return $res;
735c653b   Elena.Budnik   rank at observato...
573
	}
0dc31ba8   Elena.Budnik   remoteParamManage...
574
575
576
577
	
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
578
579
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
580
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
581
582
583
584
585
586
		$res = $paramMgr->init();
		
		if ($res['success'])
			return $paramMgr->deleteFromTree($obj);
		else 
			return $res;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
587
	}
0dc31ba8   Elena.Budnik   remoteParamManage...
588
589
590
591
592
		
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
593

0dc31ba8   Elena.Budnik   remoteParamManage...
594
595
596
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
597
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
598
	{
5f8bd1f5   Nathanaël Jourdane   Fix Windows-files...
599
600
601
		$fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name)));
		file_put_contents(USERTEMPDIR . $name, $fileContent);

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

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

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

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

10200969   Roipoussiere   Remove whitespace...
653
654
655
656

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

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

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

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

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

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

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

10200969   Roipoussiere   Remove whitespace...
787
/*
16035364   Benjamin Renard   First commit
788
789
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
790
	public  function modifyObject($obj)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
791
	{
10200969   Roipoussiere   Remove whitespace...
792
793
794
795
796
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
797
				break;
10200969   Roipoussiere   Remove whitespace...
798
799
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
800
				break;
10200969   Roipoussiere   Remove whitespace...
801
802
803
804
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
805
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
806
				$objectMgr = new RequestMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
807
808
809
810
811
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> modifyObject($obj);
10200969   Roipoussiere   Remove whitespace...
812
	}
16035364   Benjamin Renard   First commit
813
814
815
816
817
818
819
820
821
822
/*
 * {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...
823
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
824
825
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
826
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
827
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
828
829
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
830
831
832
833
834
835
836
837
838
839
840
841
			case 'condition' :
			case 'request' :
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}

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

/*
bae6f5da   Nathanael Jourdane   bugFix fileName f...
842
*   Get running jobs
16035364   Benjamin Renard   First commit
843
*/
bae6f5da   Nathanael Jourdane   bugFix fileName f...
844
	public function getJobs($obj = null)
6acb8d2a   Elena.Budnik   checkRequest in R...
845
	{
812bc03d   Nathanael Jourdane   update job info o...
846
		$obj = (object) array();
10200969   Roipoussiere   Remove whitespace...
847
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
6acb8d2a   Elena.Budnik   checkRequest in R...
848
	}
16035364   Benjamin Renard   First commit
849
850
851
852
853
854
855


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

16035364   Benjamin Renard   First commit
861
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
862
		{
e5ab198f   Nathanael Jourdane   simple getStatus
863
			$dd = new WSUserMgr();
fcdd1349   Elena.Budnik   merge with master
864
			$dd->init($obj->username,$obj->password,$obj->sessionID, false);
735c653b   Elena.Budnik   rank at observato...
865
		}
a21497cc   Elena.Budnik   redmine #5645
866
		else {
16035364   Benjamin Renard   First commit
867
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
868
869
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
870
871

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

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

6acb8d2a   Elena.Budnik   checkRequest in R...
879
		if ($dd->user == 'impex')
16035364   Benjamin Renard   First commit
880
881
882
		{
			//if ($dd->getWsSize() > DISK_QUOTA * 100)
			//	error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
e5ab198f   Nathanael Jourdane   simple getStatus
883
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
884
		}
32bb889b   Elena.Budnik   #5532 to process ...
885
		else {
a21497cc   Elena.Budnik   redmine #5645
886
			// check disk space 
2c7f2cb6   Benjamin Renard   Remove old log fi...
887
888
889
890
891
892
			if ($dd->getWsSize() > DISK_QUOTA) {
				//Try to delete log files - cf. #6245
				if ($dd->getWsSize(TRUE) > DISK_QUOTA) {
					return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available');
				}
			}
735c653b   Elena.Budnik   rank at observato...
893
		}
10200969   Roipoussiere   Remove whitespace...
894

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

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

6acb8d2a   Elena.Budnik   checkRequest in R...
900
	private function executeRequest($obj, $function)
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
901
	{ 
32bb889b   Elena.Budnik   #5532 to process ...
902
903
904
905
906
		// 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...
907
908
909
910
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
		
16035364   Benjamin Renard   First commit
911
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
912
		try {
e57cb025   Benjamin Renard   Fix most of error...
913
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
914
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
915
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
916
		}
16035364   Benjamin Renard   First commit
917
918
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
919
920
921

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
922
*/
735c653b   Elena.Budnik   rank at observato...
923
924
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
925
926
927
928
		// 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
929
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
930
931
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
932
933
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
934

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

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

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

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

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

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

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

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

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

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

10200969   Roipoussiere   Remove whitespace...
986

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

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

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

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

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


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

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

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

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

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

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

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

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

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

e57cb025   Benjamin Renard   Fix most of error...
1049
		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...
1050
	}
10200969   Roipoussiere   Remove whitespace...
1051

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

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

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

735c653b   Elena.Budnik   rank at observato...
1074
1075
1076
1077
1078
1079
1080
	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...
1081

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

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

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

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

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

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

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

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

16035364   Benjamin Renard   First commit
1126
1127
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1128
 *
16035364   Benjamin Renard   First commit
1129
 */
735c653b   Elena.Budnik   rank at observato...
1130
1131
1132
1133
1134
	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...
1135

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

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

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

735c653b   Elena.Budnik   rank at observato...
1164
1165
1166
1167
1168
1169
		$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...
1170

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

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

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

735c653b   Elena.Budnik   rank at observato...
1191
1192
1193
1194
1195
1196
1197
1198
1199
	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...
1200

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

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

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

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

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

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

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

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1282
1283
1284
1285
1286
1287
	// $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...
1288
1289

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

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

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

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

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

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1321
1322
1323
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1324
1325
			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
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
					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...
1339
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1340
1341
1342
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1343

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

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

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

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

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

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

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

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

735c653b   Elena.Budnik   rank at observato...
1404
1405
1406
		$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...
1407

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

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

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