Blame view

php/classes/AmdaAction.php 37.5 KB
16035364   Benjamin Renard   First commit
1
2
3
<?php
/**
 * @class AmdaAction
aa94fd24   elena   Merge with last svn
4
 * @version $Id: AmdaAction.php 2976 2015-07-01 15:05:40Z benjamin $
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;
dc9e2c14   Elena.Budnik   init + message + ...
221
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
222
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
223
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
224

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

c57c57c9   Elena.Budnik   info message depe...
229
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
10200969   Roipoussiere   Remove whitespace...
230
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
a7316784   Elena.Budnik   add LastUpdate to...
231
232
233
234
									
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
235
								}
10200969   Roipoussiere   Remove whitespace...
236

c57c57c9   Elena.Budnik   info message depe...
237
								if ($child->getAttribute('dataStart') == 'depending on mission') {
735c653b   Elena.Budnik   rank at observato...
238
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
239
								}
a7316784   Elena.Budnik   add LastUpdate to...
240
	
f29c5e66   Elena.Budnik   plot only option
241
242
243
244
// 								if ($child->getAttribute('restriction') > 1) {
// 									$restricted  = $child->getAttribute('restriction');
// 									$info .= "<br/><b>Time Restriction</b>: -$restricted days";
// 								}
735c653b   Elena.Budnik   rank at observato...
245
							}
10200969   Roipoussiere   Remove whitespace...
246

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

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

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

735c653b   Elena.Budnik   rank at observato...
267
268
269
270
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
271

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

f29c5e66   Elena.Budnik   plot only option
294
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
295
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
296
297
										$needsArgs = true;
										$isSpectra = true;
dc9e2c14   Elena.Budnik   init + message + ...
298
299
										if (strpos($child->getAttribute('name'),'2D') !== false)
											$is2dSpectra = true;
735c653b   Elena.Budnik   rank at observato...
300
								}
c57c57c9   Elena.Budnik   info message depe...
301
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
302
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
303
								}
10200969   Roipoussiere   Remove whitespace...
304
305
							}

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

661293d7   Elena.Budnik   parse ## and @@ i...
310
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
311
312
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
dc9e2c14   Elena.Budnik   init + message + ...
313
314
									'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra,
									'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
735c653b   Elena.Budnik   rank at observato...
315
							}
c57c57c9   Elena.Budnik   info message depe...
316
							else {
c57c57c9   Elena.Budnik   info message depe...
317
								if ($child->tagName == 'mission' || $child->tagName == 'observatory') {
735c653b   Elena.Budnik   rank at observato...
318
319
									$rank = $child->getAttribute('rank');
								}
c57c57c9   Elena.Budnik   info message depe...
320
								
acf87705   Elena.Budnik   bug in disable param
321
322
								$disable = $child->hasAttribute('group');

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

10200969   Roipoussiere   Remove whitespace...
336
337
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
735c653b   Elena.Budnik   rank at observato...
338
339
340
341
							}
						break;

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

bf74fc2d   Elena.Budnik   IMPEX
343
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
344
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
345
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
346
347

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
348
349
350
351
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
352
353

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
354
							{
10200969   Roipoussiere   Remove whitespace...
355
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
356
								{
10200969   Roipoussiere   Remove whitespace...
357
358
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
359
								}
10200969   Roipoussiere   Remove whitespace...
360
								else
735c653b   Elena.Budnik   rank at observato...
361
362
363
364
365
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
366
367

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
368
369
370
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
371

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

bf74fc2d   Elena.Budnik   IMPEX
381
382
							if ( $child->tagName == 'component')
							{
abb54096   Elena.Budnik   time interval by ...
383
								if ($child->parentNode->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
384
									{
abb54096   Elena.Budnik   time interval by ...
385
386
										$globalStart = $child->parentNode->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
387
388
									}
							}
10200969   Roipoussiere   Remove whitespace...
389

735c653b   Elena.Budnik   rank at observato...
390
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
391
392

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
393
394
395
396
397
398
399
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
400
401
402
403
404
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
405
							{
10200969   Roipoussiere   Remove whitespace...
406
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
407
408
409
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
410
411
								default:
							}
10200969   Roipoussiere   Remove whitespace...
412

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

10200969   Roipoussiere   Remove whitespace...
415
416
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
417
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
418
419
420
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
421
422
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
423
							}
10200969   Roipoussiere   Remove whitespace...
424

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

10200969   Roipoussiere   Remove whitespace...
427
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
428
							{
10200969   Roipoussiere   Remove whitespace...
429
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
430
							}
a0f13ed1   Elena.Budnik   small format + ti...
431
432
433
434
435
436
437
							
							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...
438

a0f13ed1   Elena.Budnik   small format + ti...
439
440
441
442
443
444
445
							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...
446
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
447
							{
10200969   Roipoussiere   Remove whitespace...
448
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
449
450
451
452
453
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

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

735c653b   Elena.Budnik   rank at observato...
481
482
483
484
485
486
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
487
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
488
489
490
491
492
493
494
495
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

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

735c653b   Elena.Budnik   rank at observato...
497
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
498
499
500
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
501
						break;
10200969   Roipoussiere   Remove whitespace...
502
503
504

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
505
506
507
508
509
510
511
512
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
513
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
514
515
516
							$sampling = null;
							if ($child->hasAttribute('minsampling')) 
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
517
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
518
519

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
520
521
522
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
523
524
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
525
526
527
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
528
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
529
530
531
532
533
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
534
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
535
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
536
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
537
538
539
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
10200969   Roipoussiere   Remove whitespace...
540
						default:
735c653b   Elena.Budnik   rank at observato...
541
					}
10200969   Roipoussiere   Remove whitespace...
542
543

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
544
					{
10200969   Roipoussiere   Remove whitespace...
545
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
546
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
547
548

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
549
550
551
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
552
553

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

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

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

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

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

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

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

10200969   Roipoussiere   Remove whitespace...
660
661
662
663

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

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

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

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

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

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

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

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

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


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

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

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

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

6acb8d2a   Elena.Budnik   checkRequest in R...
886
		if ($dd->user == 'impex')
16035364   Benjamin Renard   First commit
887
888
889
		{
			//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
890
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
891
		}
32bb889b   Elena.Budnik   #5532 to process ...
892
		else {
a21497cc   Elena.Budnik   redmine #5645
893
			// check disk space 
2c7f2cb6   Benjamin Renard   Remove old log fi...
894
895
896
897
898
899
			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...
900
		}
10200969   Roipoussiere   Remove whitespace...
901

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

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

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

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

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

16035364   Benjamin Renard   First commit
946
/*
a0b3d64e   Benjamin Renard   Derived parameter...
947
948
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
949
950
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
951
952
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
953
954
955
956

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

a0b3d64e   Benjamin Renard   Derived parameter...
961
962
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
963

a0b3d64e   Benjamin Renard   Derived parameter...
964
965
966
967
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
968
969
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
970

a0b3d64e   Benjamin Renard   Derived parameter...
971
/*
e6e5b259   Benjamin Renard   Add kill plot req...
972
 * kill plot process
16035364   Benjamin Renard   First commit
973
 */
10200969   Roipoussiere   Remove whitespace...
974

735c653b   Elena.Budnik   rank at observato...
975
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
976
	{
735c653b   Elena.Budnik   rank at observato...
977
978
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
979
980
981
982

/*
 * merge time tables
 */
10200969   Roipoussiere   Remove whitespace...
983
	public  function merge($obj)
735c653b   Elena.Budnik   rank at observato...
984
985
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
986
			$this->amdaStat->addTask( $this->user, 'ttoper', null);
10200969   Roipoussiere   Remove whitespace...
987

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

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

10200969   Roipoussiere   Remove whitespace...
993

16035364   Benjamin Renard   First commit
994
995
996
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
997
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
998
999
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1000
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1001

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

735c653b   Elena.Budnik   rank at observato...
1005
1006
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1007

735c653b   Elena.Budnik   rank at observato...
1008
1009
1010
1011
	public function initTTCache($isCatalog = false, $nparams)
	{
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else              $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1012

735c653b   Elena.Budnik   rank at observato...
1013
1014
		return $cacheMgr->initTTCache($nparams);
	}
10200969   Roipoussiere   Remove whitespace...
1015
1016


735c653b   Elena.Budnik   rank at observato...
1017
1018
1019
1020
	public function initTTCacheFromTT($id, $type)
	{
		if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1021

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

735c653b   Elena.Budnik   rank at observato...
1025
1026
	public function initForChart($id, $name, $isTmpObject, $type)
	{
e1fd05b4   Elena.Budnik   visu from cacheCat
1027
1028
1029
		if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
			return array('success' => true, 'cache' => $id);
			
735c653b   Elena.Budnik   rank at observato...
1030
		if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
10200969   Roipoussiere   Remove whitespace...
1031

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

735c653b   Elena.Budnik   rank at observato...
1035
1036
	public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
	{
10200969   Roipoussiere   Remove whitespace...
1037
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1038
1039
1040
1041
		else  $cacheMgr = new CatalogCacheMgr();

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

901ba3f3   Elena.Budnik   upload catalog
1043
	public function initTTCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1044
	{
901ba3f3   Elena.Budnik   upload catalog
1045
1046
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1047

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

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

e57cb025   Benjamin Renard   Fix most of error...
1056
		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...
1057
	}
10200969   Roipoussiere   Remove whitespace...
1058

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

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

735c653b   Elena.Budnik   rank at observato...
1075
1076
1077
1078
1079
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
	}
10200969   Roipoussiere   Remove whitespace...
1080

735c653b   Elena.Budnik   rank at observato...
1081
1082
1083
1084
1085
1086
1087
	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...
1088

735c653b   Elena.Budnik   rank at observato...
1089
1090
1091
1092
1093
1094
1095
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

735c653b   Elena.Budnik   rank at observato...
1097
1098
	public function modifyTTCacheInterval($o)
	{
10200969   Roipoussiere   Remove whitespace...
1099
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1100
		{
f9c8b272   elena   edit catalog
1101
			$cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1102
			return $cacheMgr->modifyIntervalFromId($o);
f9c8b272   elena   edit catalog
1103
		}
735c653b   Elena.Budnik   rank at observato...
1104
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1105

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

735c653b   Elena.Budnik   rank at observato...
1109
1110
1111
1112
1113
	public function operationTTCacheIntervals($extendTime, $shiftTime)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1114

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

735c653b   Elena.Budnik   rank at observato...
1121
1122
1123
1124
1125
	public function getTTCacheStatistics()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1126

735c653b   Elena.Budnik   rank at observato...
1127
1128
1129
1130
1131
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1132

16035364   Benjamin Renard   First commit
1133
1134
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1135
 *
16035364   Benjamin Renard   First commit
1136
 */
735c653b   Elena.Budnik   rank at observato...
1137
1138
1139
1140
1141
	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...
1142

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

16035364   Benjamin Renard   First commit
1153
1154
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1155
1156
 *
 */
735c653b   Elena.Budnik   rank at observato...
1157
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1158
	{
735c653b   Elena.Budnik   rank at observato...
1159
1160
1161
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1162
1163

/*
16035364   Benjamin Renard   First commit
1164
1165
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1166
1167
1168
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1169
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1170

735c653b   Elena.Budnik   rank at observato...
1171
1172
1173
1174
1175
1176
		$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...
1177

735c653b   Elena.Budnik   rank at observato...
1178
1179
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1180
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1181
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1182

735c653b   Elena.Budnik   rank at observato...
1183
1184
1185
1186
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1187
	}
16035364   Benjamin Renard   First commit
1188
1189
1190
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1191
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1192
	{
10200969   Roipoussiere   Remove whitespace...
1193
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1194
1195
1196
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1197

735c653b   Elena.Budnik   rank at observato...
1198
1199
1200
1201
1202
1203
1204
1205
1206
	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...
1207

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

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

735c653b   Elena.Budnik   rank at observato...
1220
1221
1222
1223
1224
1225
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1226

735c653b   Elena.Budnik   rank at observato...
1227
1228
1229
1230
1231
1232
1233
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1234
1235
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1236
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1237
1238
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1239

fdf1413b   Elena.Budnik   TT download
1240
1241
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1242
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1243
1244
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1245

fdf1413b   Elena.Budnik   TT download
1246
1247
1248
1249
1250
1251
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1252

16035364   Benjamin Renard   First commit
1253
1254
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1255
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1256
		{
fdf1413b   Elena.Budnik   TT download
1257
1258
1259
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1260
		else
735c653b   Elena.Budnik   rank at observato...
1261
		{
fdf1413b   Elena.Budnik   TT download
1262
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1263
		}
16035364   Benjamin Renard   First commit
1264
		return;
10200969   Roipoussiere   Remove whitespace...
1265
	}
16035364   Benjamin Renard   First commit
1266

fdf1413b   Elena.Budnik   TT download
1267
1268
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1269
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1270
		{
10200969   Roipoussiere   Remove whitespace...
1271
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1272
1273
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1274
1275
1276
		return array('success' => false);
	}

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

fdf1413b   Elena.Budnik   TT download
1283
1284
1285
1286
1287
	public function convertWS()
	{
		$dd = new UserMgr();
		return $dd->convertWS();
	}
16035364   Benjamin Renard   First commit
1288

fdf1413b   Elena.Budnik   TT download
1289
1290
1291
1292
1293
1294
	// $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...
1295
1296

		return  $res;
fdf1413b   Elena.Budnik   TT download
1297
	}
10200969   Roipoussiere   Remove whitespace...
1298
1299

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1300
1301
1302
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1303

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1314
1315
1316
1317
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1318
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1319
1320

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

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

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

fdf1413b   Elena.Budnik   TT download
1351
1352
	public function interactivePlot($obj, $multiPlotState)
	{
fdf1413b   Elena.Budnik   TT download
1353
1354
1355
1356
1357
1358
		$inputobj = (Object)array(
			'action' => $obj,
			'multiPlotState' => $multiPlotState
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1359

735c653b   Elena.Budnik   rank at observato...
1360
1361
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1362
1363
1364
1365
1366
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1367

735c653b   Elena.Budnik   rank at observato...
1368
1369
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1370
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1371
1372
1373
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1374

735c653b   Elena.Budnik   rank at observato...
1375
1376
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1377
1378
1379
1380
1381
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1382

735c653b   Elena.Budnik   rank at observato...
1383
1384
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1385
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1386
1387
1388
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1389

735c653b   Elena.Budnik   rank at observato...
1390
1391
1392
1393
1394
1395
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1396

735c653b   Elena.Budnik   rank at observato...
1397
1398
1399
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1400
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1401
1402
1403
1404
1405
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1406

735c653b   Elena.Budnik   rank at observato...
1407
1408
1409
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1410

735c653b   Elena.Budnik   rank at observato...
1411
1412
1413
		$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...
1414

735c653b   Elena.Budnik   rank at observato...
1415
1416
1417
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1418

735c653b   Elena.Budnik   rank at observato...
1419
1420
1421
1422
1423
1424
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1425

0bda97f3   Benjamin Renard   Fix SAMP export f...
1426
1427
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1428
1429
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
16035364   Benjamin Renard   First commit
1430
1431
}
?>