Blame view

php/classes/AmdaAction.php 52.3 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',
2e7079bb   Benjamin Renard   First implementat...
13
										'request' => 'Request.xml', 'condition' => 'Request.xml', 'download' => 'Request.xml', 'statistic' => 'Request.xml',
735c653b   Elena.Budnik   rank at observato...
14
15
16
17
										'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;
735c653b   Elena.Budnik   rank at observato...
64
65
		$remoteBase = false;
		$isRemoteDataSet = false;
16035364   Benjamin Renard   First commit
66

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

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

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

10200969   Roipoussiere   Remove whitespace...
77
78
		if ($node == 'root' && !$remoteBase)
		{
e57cb025   Benjamin Renard   Fix most of error...
79
80
81
82
83
84
85
86
87
88
89
90
			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...
91
92
		}
		else
735c653b   Elena.Budnik   rank at observato...
93
94
95
		{
			$Dom = new DomDocument("1.0");

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

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

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

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

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

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

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

					$specialNode = false;
					$isParameter = false;
					$isAddable =  false;
					$isSimulation = false;
735c653b   Elena.Budnik   rank at observato...
155
					$rank = null;
e57cb025   Benjamin Renard   Fix most of error...
156
					$skip = FALSE;
698494ac   Benjamin Renard   Add tooltip for s...
157
					$last_update = 0;
735c653b   Elena.Budnik   rank at observato...
158

10200969   Roipoussiere   Remove whitespace...
159
					switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
160
					{
10200969   Roipoussiere   Remove whitespace...
161
						case 'bkgWorks':
735c653b   Elena.Budnik   rank at observato...
162
							$specialNode = true;
84db3b67   Nathanael Jourdane   Improve job toolt...
163
164
165
166
167
168
							$childrenToReturn[] = [
								'text'     => $name,
								'id'       => $id,
								'nodeType' => $nodeType,
								'leaf'     => $isLeaf,
								'pid'      => $child->getAttribute('pid'),
b4bca467   Nathanael Jourdane   job tooltip: use ...
169
								'status'   => $child->getAttribute('status'),
84db3b67   Nathanael Jourdane   Improve job toolt...
170
								'jobType'  => $child->getAttribute('jobType'),
4711b5b4   Erdogan Furkan   Done
171
								'start'	   => $child->getAttribute('start'),
812bc03d   Nathanael Jourdane   update job info o...
172
								'info'     => $child->getAttribute('info')
84db3b67   Nathanael Jourdane   Improve job toolt...
173
							];
b4bca467   Nathanael Jourdane   job tooltip: use ...
174
							break;
33519521   Benjamin Renard   Fix saved request...
175

f569bae5   Benjamin Renard   Save download
176
						case 'download':
735c653b   Elena.Budnik   rank at observato...
177
						case 'condition':
33519521   Benjamin Renard   Fix saved request...
178
						case 'request':
2e7079bb   Benjamin Renard   First implementat...
179
						case 'statistic':
638db58d   Benjamin Renard   RequestMgr constr...
180
							$objectMgr = new RequestMgr($nodeType);
33519521   Benjamin Renard   Fix saved request...
181
							$info = $objectMgr->getObjectInfo($id);
698494ac   Benjamin Renard   Add tooltip for s...
182
183
184
185
							$obj_info = $objectMgr->getObject($id);
							if (!empty($obj_info) && !empty($obj_info->last_update)) {
								$last_update = $obj_info->last_update;
							}
f569bae5   Benjamin Renard   Save download
186
							break;
8b6bb092   Elena.Budnik   icones if rank is...
187
						
735c653b   Elena.Budnik   rank at observato...
188
						case 'timeTable':
10200969   Roipoussiere   Remove whitespace...
189
						case 'catalog':
8dec1016   Benjamin Renard   Add TT and catalo...
190
191
							if ($isLeaf) {
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('intervals').'<br/>';
533ea933   Benjamin Renard   Show description ...
192
								$objectMgr = new TimeTableMgr();
6a679a7f   Erdogan Furkan   #11478 - Infobulle
193
						
533ea933   Benjamin Renard   Show description ...
194
								$obj_info = $objectMgr->getObject($id, $nodeType);
6a679a7f   Erdogan Furkan   #11478 - Infobulle
195
196
197
198

								if($nodeType == "catalog")
									$info .='<b>Nb columns:</b> '.$obj_info['nbParam']. '<br/>';
								
533ea933   Benjamin Renard   Show description ...
199
200
201
202
								if (!empty($obj_info) && !empty($obj_info['description'])) {
									$info .= '<b>Description:</b> '. $obj_info['description'] . '<br/>';
								}

8dec1016   Benjamin Renard   Add TT and catalo...
203
								$info .= '<b>ID:</b> '. $child->getAttribute('xml:id');
533ea933   Benjamin Renard   Show description ...
204

8dec1016   Benjamin Renard   Add TT and catalo...
205
							}
735c653b   Elena.Budnik   rank at observato...
206
						break;
10200969   Roipoussiere   Remove whitespace...
207

735c653b   Elena.Budnik   rank at observato...
208
209
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
210
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
211
212
213
							{
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('nbIntervals').'<br/>';
								$info .= '<b>Shared by:</b> '.$child->getAttribute('sharedBy').' ('.$child->getAttribute('sharedDate').')<br/>';
8dec1016   Benjamin Renard   Add TT and catalo...
214
215
								$info .= '<b>Description:</b> '.$child->getAttribute('description').'<br/>';
								$info .= '<b>ID:</b> ' . $child->getAttribute('xml:id');
8b6bb092   Elena.Budnik   icones if rank is...
216
							} 
735c653b   Elena.Budnik   rank at observato...
217
218
						break;
						case 'derivedParam':
533ea933   Benjamin Renard   Show description ...
219
  							$info = '<b>Expression:</b> '. $child->getAttribute('buildchain').'<br/>';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
220
							                                        
dfa8db4f   Hacene SI HADJ MOHAND   correcting derive...
221
222
							if($child->hasAttribute('units') && $child->getAttribute('units') != 'undefined' && $child->getAttribute('units') != '')
                                                                                                                                                  $info .= 'Units: '.$child->getAttribute('units').'<br/>';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
223
224
   							$samplingMode = $child->getAttribute('sampling_mode');
 						  	if($samplingMode == 'timestep'){
533ea933   Benjamin Renard   Show description ...
225
      								$info .= '<b>Sampling:</b> '.$child->getAttribute('timestep').' sec'.'<br/>';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
226
   							}else if($samplingMode == 'refparam'){
533ea933   Benjamin Renard   Show description ...
227
      								$info .= '<b>Reference Parameter:</b> '.$child->getAttribute('reference_param').'<br/>';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
228
			 	 			}			
0fea5567   Benjamin Renard   First step for re...
229

8ba47f72   Benjamin Renard   rest actualisatio...
230
231
232
233
234
							if ($child->hasAttribute('dim_1')) {
								$dim_1 = $child->getAttribute('dim_1');
							}
					                if ($child->hasAttribute('dim_2')) {
                                                                $dim_2 = $child->getAttribute('dim_2');
533ea933   Benjamin Renard   Show description ...
235

8ba47f72   Benjamin Renard   rest actualisatio...
236
237
                                                        }

533ea933   Benjamin Renard   Show description ...
238
239
240
241
242
243
244
245
							$objectMgr = new DerivedParamMgr($nodeType);
							$obj_info = $objectMgr->getObject($child->getAttribute('xml:id')) ;
							if (!empty($obj_info) && array_key_exists('description', $obj_info) && ($obj_info['description'] != "undefined")) {
								$info .= '<b>Description:</b> '. $obj_info['description'].'<br/>';
							}

							$info .= '<b>ID:</b> '. $child->getAttribute('xml:id');

735c653b   Elena.Budnik   rank at observato...
246
247
248
249
							if ($isLeaf) $isParameter = true;
						break;

						case 'localParam':
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
250
							
735c653b   Elena.Budnik   rank at observato...
251
252
253
254
255
256
							$globalStart = null;
							$globalStop = null;
							$timeRestriction = false;
							$specialNode = true;
							$isParameter = false;
							$needsArgs = false;
10200969   Roipoussiere   Remove whitespace...
257
							$isSpectra = false;
dc9e2c14   Elena.Budnik   init + message + ...
258
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
259
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
260
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
261

10200969   Roipoussiere   Remove whitespace...
262
263
							if ($child->hasAttribute('desc'))
							{
735c653b   Elena.Budnik   rank at observato...
264
								$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
265

c57c57c9   Elena.Budnik   info message depe...
266
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
67bd6ed6   Elena.Budnik   rm 8375
267
268
269
270
271
272
273
                                    $dataStart = $child->getAttribute('dataStart');
                                    // check UTC format
                                    if ( !preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/', $dataStart ) ) {
                                        if ( $dataStart == "MissionDependent" )
                                            $info .= "<br/>Time Range : depending on mission selection"; 
                                        else 
                                            $info .= "<br/>Time Range : undefined"; 
3a8eaaff   Hacene SI HADJ MOHAND   resolue
274
275
                                        $child->setAttribute('dataStart', date("Y-m-d\TH:i:s.u\Z", strtotime(' -1 day')));
                                        $child->setAttribute('dataStop', date("Y-m-d\TH:i:s.u\Z", time()));                                        
67bd6ed6   Elena.Budnik   rm 8375
276
277
278
279
                                    } else {
                                        $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
                                    }
                                    
a7316784   Elena.Budnik   add LastUpdate to...
280
281
282
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
283
								}
735c653b   Elena.Budnik   rank at observato...
284
							}
10200969   Roipoussiere   Remove whitespace...
285

cbbbdc34   Elena.Budnik   param description...
286
							if ($child->hasAttribute('units')) {
0fea5567   Benjamin Renard   First step for re...
287

cbbbdc34   Elena.Budnik   param description...
288
								$units = $child->getAttribute('units');
0fea5567   Benjamin Renard   First step for re...
289

cbbbdc34   Elena.Budnik   param description...
290
291
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description')."<br/>".$units;
0fea5567   Benjamin Renard   First step for re...
292
								else
cbbbdc34   Elena.Budnik   param description...
293
294
									$info = $units;
							}
71b9368c   Benjamin Renard   Fix bug with tool...
295
296
297
298
							else {
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description');
							}
0fea5567   Benjamin Renard   First step for re...
299

f29c5e66   Elena.Budnik   plot only option
300
							if ($child->tagName == 'parameter') {
735c653b   Elena.Budnik   rank at observato...
301
								$isParameter = true;
641a1a72   Benjamin Renard   Add the possibili...
302
                                if ($child->hasAttribute('template'))
67bd6ed6   Elena.Budnik   rm 8375
303
                                    $needsArgs = true;
2fa56f95   Benjamin Renard   Predefined templa...
304

641a1a72   Benjamin Renard   Add the possibili...
305
								if ($child->hasAttribute('predefined'))
b0f72ee0   Erdogan Furkan   #10557 For now
306
									$predefinedArgs = true;
67bd6ed6   Elena.Budnik   rm 8375
307
                                    
c57c57c9   Elena.Budnik   info message depe...
308
								if ($child->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
309
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
310
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
311
								}
0fea5567   Benjamin Renard   First step for re...
312

f29c5e66   Elena.Budnik   plot only option
313
314
315
316
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
317
								}
3afe4f59   Benjamin Renard   Add datasets time...
318
319
320
321

								if ($child->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
322
							}
10200969   Roipoussiere   Remove whitespace...
323

735c653b   Elena.Budnik   rank at observato...
324
325
326
327
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
328

c57c57c9   Elena.Budnik   info message depe...
329
								if ($child->parentNode->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
330
									$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
331
332
									$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
								}
0fea5567   Benjamin Renard   First step for re...
333

f29c5e66   Elena.Budnik   plot only option
334
335
336
337
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
338
								}
3afe4f59   Benjamin Renard   Add datasets time...
339
340
341
342

								if ($child->parentNode->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
343
344
345
346
347

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

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

f29c5e66   Elena.Budnik   plot only option
352
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
353
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
354
355
										$needsArgs = true;
										$isSpectra = true;
dc9e2c14   Elena.Budnik   init + message + ...
356
357
										if (strpos($child->getAttribute('name'),'2D') !== false)
											$is2dSpectra = true;
735c653b   Elena.Budnik   rank at observato...
358
								}
c57c57c9   Elena.Budnik   info message depe...
359
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
360
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
361
								}
10200969   Roipoussiere   Remove whitespace...
362
363
							}

f31bea1c   Benjamin Renard   wip for save plot
364

c57c57c9   Elena.Budnik   info message depe...
365
							if ($isParameter) {
735c653b   Elena.Budnik   rank at observato...
366
367
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);
c3b20775   Elena.Budnik   not show ID for p...
368
369
								
                                if (! ($child->parentNode->hasAttribute('group') || $child->parentNode->parentNode->hasAttribute('group'))) $info .= '</br><i>ID : '.$id.'</i>';
661293d7   Elena.Budnik   parse ## and @@ i...
370
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
371
372
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
dc9e2c14   Elena.Budnik   init + message + ...
373
									'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra,
2fa56f95   Benjamin Renard   Predefined templa...
374
									'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'predefinedArgs' => $predefinedArgs, 'help' => $help, 'notyet' => $not_yet);
735c653b   Elena.Budnik   rank at observato...
375
							}
c57c57c9   Elena.Budnik   info message depe...
376
							else {
8b6bb092   Elena.Budnik   icones if rank is...
377
								if ($child->hasAttribute('rank')) {
735c653b   Elena.Budnik   rank at observato...
378
379
									$rank = $child->getAttribute('rank');
								}
0fea5567   Benjamin Renard   First step for re...
380

3afe4f59   Benjamin Renard   Add datasets time...
381
382
383
384
								if ($child->hasAttribute("timeRestriction")) {
									$timeRestriction = $child->getAttribute("timeRestriction");
								}
								$disable = TRUE;
acf87705   Elena.Budnik   bug in disable param
385

222e562d   Benjamin Renard   Give the possibil...
386
387
388
389
390
								$hideIfRestricted = FALSE;
								if ($child->hasAttribute("hideIfRestricted") && ($child->getAttribute("hideIfRestricted") == "1")) {
									$hideIfRestricted = TRUE;
								}

3afe4f59   Benjamin Renard   Add datasets time...
391
								if ($child->hasAttribute('group')) {
c3976709   Elena.Budnik   rm 7589 + clean u...
392
393
									if ($child->getAttribute("group") === "TBD") {
											$info .=  "<br/><b>Under Testing</b>";
3afe4f59   Benjamin Renard   Add datasets time...
394
									}
1c2f5368   Elena.Budnik   message for TimeR...
395
									else {	
3afe4f59   Benjamin Renard   Add datasets time...
396
397
										if (!empty($timeRestriction)) {
											$disable = FALSE;
3a8eaaff   Hacene SI HADJ MOHAND   resolue
398
											$formattedTimeRestriction = date("Y-m-d\TH:i:s.u\Z",strtotime($timeRestriction)+1);
1c2f5368   Elena.Budnik   message for TimeR...
399
400
401
402
											$info .= "<br/><b>After $formattedTimeRestriction data are restricted to group ".$child->getAttribute('group')."</b>";
										}
										else {
                                            $info .= "<br/><b>Restricted Access : Group ".$child->getAttribute('group')."</b>";
3afe4f59   Benjamin Renard   Add datasets time...
403
										}
735c653b   Elena.Budnik   rank at observato...
404
									}
0fea5567   Benjamin Renard   First step for re...
405
								}
acf87705   Elena.Budnik   bug in disable param
406
								else {
3afe4f59   Benjamin Renard   Add datasets time...
407
									$disable = FALSE;
acf87705   Elena.Budnik   bug in disable param
408
409
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
410
								}
222e562d   Benjamin Renard   Give the possibil...
411
								$visible = !($disable && $hideIfRestricted);
735c653b   Elena.Budnik   rank at observato...
412

698494ac   Benjamin Renard   Add tooltip for s...
413
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'last_update' => $last_update,
222e562d   Benjamin Renard   Give the possibil...
414
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'visible' => $visible, 'rank' => $rank, 'timeRestriction' => $timeRestriction);
735c653b   Elena.Budnik   rank at observato...
415
416
417
418
							}
						break;

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

bf74fc2d   Elena.Budnik   IMPEX
420
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
421
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
422
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
423
424

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
425
426
427
428
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
429
430

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
431
							{
10200969   Roipoussiere   Remove whitespace...
432
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
433
								{
10200969   Roipoussiere   Remove whitespace...
434
435
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
436
								}
10200969   Roipoussiere   Remove whitespace...
437
								else
735c653b   Elena.Budnik   rank at observato...
438
439
440
441
442
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
443
444

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
445
446
447
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
448

bf74fc2d   Elena.Budnik   IMPEX
449
450
							if ( $child->tagName == 'parameter')
							{
abb54096   Elena.Budnik   time interval by ...
451
								if ($child->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
452
									{
abb54096   Elena.Budnik   time interval by ...
453
454
										$globalStart = $child->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
455
456
									}
							}
10200969   Roipoussiere   Remove whitespace...
457

bf74fc2d   Elena.Budnik   IMPEX
458
459
							if ( $child->tagName == 'component')
							{
abb54096   Elena.Budnik   time interval by ...
460
								if ($child->parentNode->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
461
									{
abb54096   Elena.Budnik   time interval by ...
462
463
										$globalStart = $child->parentNode->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
464
465
									}
							}
10200969   Roipoussiere   Remove whitespace...
466

735c653b   Elena.Budnik   rank at observato...
467
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
468
469

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
470
471
472
473
474
475
476
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
477
478
479
480
481
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
482
							{
10200969   Roipoussiere   Remove whitespace...
483
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
484
485
486
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
487
488
								default:
							}
10200969   Roipoussiere   Remove whitespace...
489

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

10200969   Roipoussiere   Remove whitespace...
492
493
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
494
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
495
496
497
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
498
499
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
500
							}
10200969   Roipoussiere   Remove whitespace...
501

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

10200969   Roipoussiere   Remove whitespace...
504
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
505
							{
10200969   Roipoussiere   Remove whitespace...
506
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
507
							}
0fea5567   Benjamin Renard   First step for re...
508

a0f13ed1   Elena.Budnik   small format + ti...
509
510
							if ($child->tagName == 'parameter'){
								if ($child->parentNode->hasAttribute('dataStart')){
3a8eaaff   Hacene SI HADJ MOHAND   resolue
511
512
									$globalStart = date('Y-m-d\TH:i:s.u\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s.u\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
a0f13ed1   Elena.Budnik   small format + ti...
513
514
								}
							}
735c653b   Elena.Budnik   rank at observato...
515

a0f13ed1   Elena.Budnik   small format + ti...
516
517
							if ( $child->tagName == 'component'){
								if ($child->parentNode->parentNode->hasAttribute('dataStart')){
3a8eaaff   Hacene SI HADJ MOHAND   resolue
518
519
									$globalStart = date('Y-m-d\TH:i:s.u\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s.u\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
a0f13ed1   Elena.Budnik   small format + ti...
520
521
								}
							}
0fea5567   Benjamin Renard   First step for re...
522

10200969   Roipoussiere   Remove whitespace...
523
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
524
							{
10200969   Roipoussiere   Remove whitespace...
525
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
526
527
528
529
530
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
531
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
532
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
533
								}
bf74fc2d   Elena.Budnik   IMPEX
534
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
535
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
536
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
537
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
538
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => isset($component_info) ? $component_info : NULL);
bf74fc2d   Elena.Budnik   IMPEX
539
								else
10200969   Roipoussiere   Remove whitespace...
540
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
541
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
542
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
543
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
544
							}
10200969   Roipoussiere   Remove whitespace...
545
546
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
547
								$restricted = FALSE;
0fea5567   Benjamin Renard   First step for re...
548

735c653b   Elena.Budnik   rank at observato...
549
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
550
								{
735c653b   Elena.Budnik   rank at observato...
551
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
552
								}
735c653b   Elena.Budnik   rank at observato...
553
								else
6657f68b   Elena.Budnik   monitor impex ser...
554
								{
735c653b   Elena.Budnik   rank at observato...
555
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
556
								}
10200969   Roipoussiere   Remove whitespace...
557

735c653b   Elena.Budnik   rank at observato...
558
559
560
561
562
563
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
564
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
565
566
567
568
569
570
571
572
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

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

735c653b   Elena.Budnik   rank at observato...
574
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
575
576
577
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
578
						break;
10200969   Roipoussiere   Remove whitespace...
579
580
581

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
582
583
584
585
586
587
588
589
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
590
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
591
							$sampling = null;
0fea5567   Benjamin Renard   First step for re...
592
							if ($child->hasAttribute('minsampling'))
19dcd963   Elena.Budnik   redmine #4903 : s...
593
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
594
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
595
596

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
597
598
599
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
600
601
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
602
603
604
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
605
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
606
607
608
609
610
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
611
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
612
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
613
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
614
615
616
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
b0f72ee0   Erdogan Furkan   #10557 For now
617
618
						
						case 'specialParam':
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
619
620
621
							$specialNode=TRUE;
							$isParameter=($child->tagName == 'parameter');
							$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'isParameter' => $isParameter, 'needsArgs' => $isParameter, 'leaf' => $isParameter);
b0f72ee0   Erdogan Furkan   #10557 For now
622
623
							break;
						
10200969   Roipoussiere   Remove whitespace...
624
						default:
735c653b   Elena.Budnik   rank at observato...
625
					}
10200969   Roipoussiere   Remove whitespace...
626
627

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
628
					{
10200969   Roipoussiere   Remove whitespace...
629
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
630
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
631
632

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
633
634
635
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
636
637

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
2048f5bc   Benjamin Renard   Fix save & edit plot
638
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2,
0fea5567   Benjamin Renard   First step for re...
639
													'component_info' => isset($component_info) ? $component_info : NULL,
698494ac   Benjamin Renard   Add tooltip for s...
640
													'iconCls' => isset($iconCls) ? $iconCls : NULL, 'last_update' => $last_update );
735c653b   Elena.Budnik   rank at observato...
641
642
643
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
644
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
645
				{
735c653b   Elena.Budnik   rank at observato...
646
647
648
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
649
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
650
	}
16035364   Benjamin Renard   First commit
651

0dc31ba8   Elena.Budnik   remoteParamManage...
652
653
654
	/*
	*  add Remote Parameter to user RemoteParams.xml
	*  send request to DDServer to AddVi if Vi doesn't exist
0fea5567   Benjamin Renard   First step for re...
655
	*  create Remote Parameter Description
0dc31ba8   Elena.Budnik   remoteParamManage...
656
	*/
10200969   Roipoussiere   Remove whitespace...
657
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
658
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
659
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
660
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
661

2b8ea2a7   Elena.Budnik   RemoteParamManage...
662
663
		if ($res['success'])
			return $paramMgr->saveTree($obj);
0fea5567   Benjamin Renard   First step for re...
664
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
665
			return $res;
735c653b   Elena.Budnik   rank at observato...
666
	}
0fea5567   Benjamin Renard   First step for re...
667

0dc31ba8   Elena.Budnik   remoteParamManage...
668
669
670
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
671
672
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
673
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
674
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
675

2b8ea2a7   Elena.Budnik   RemoteParamManage...
676
677
		if ($res['success'])
			return $paramMgr->deleteFromTree($obj);
0fea5567   Benjamin Renard   First step for re...
678
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
679
			return $res;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
680
	}
0fea5567   Benjamin Renard   First step for re...
681

0dc31ba8   Elena.Budnik   remoteParamManage...
682
683
684
685
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
686

0dc31ba8   Elena.Budnik   remoteParamManage...
687
688
689
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
690
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
691
	{
5f8bd1f5   Nathanaël Jourdane   Fix Windows-files...
692
693
694
		$fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name)));
		file_put_contents(USERTEMPDIR . $name, $fileContent);

42e2e019   Benjamin Renard   Next step for cac...
695
		$isTTCat = FALSE;
10200969   Roipoussiere   Remove whitespace...
696
		switch ($nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
697
		{
10200969   Roipoussiere   Remove whitespace...
698
699
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
42e2e019   Benjamin Renard   Next step for cac...
700
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
701
				break;
10200969   Roipoussiere   Remove whitespace...
702
703
704
705
706
			case 'myDataParam' :
				$objectMgr = new FilesMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
42e2e019   Benjamin Renard   Next step for cac...
707
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
708
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
709
710
711
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
42e2e019   Benjamin Renard   Next step for cac...
712
713
714
715
716
717
		if ($isTTCat) {
			//Pre-process: convert to INTERNAL format if needed
			if (($format == 'ASCII') || ($format == 'VOT')) {
				$result = $this->executeRequest((Object) array(
					'compression' => 'none',
					'fileformat' => 'internal',
217e6c35   Hacene SI HADJ MOHAND   affichage oki
718
                                        'timeformat' => 'YYYY-MM-DDThh:mm:ss.u',
42e2e019   Benjamin Renard   Next step for cac...
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
					'sendToSamp' => FALSE,
					'list' => array(
						(Object) array(
							'path' => USERTEMPDIR . $name,
							'format' => $format,
							'name' => pathinfo($name, PATHINFO_FILENAME),
						)
					),
				), FunctionTypeEnumClass::TTCONVERT);
				if (!$result['success']) {
					return array("error" => "Error during file conversion");
				}
				$name = basename($result['download']);
				$convertedFile = USERDIR.'/DOWNLOAD.TEMP/'.$name;
				if (!file_exists($convertedFile)) {
					return array("error" => "Error during file conversion");
				}

				$format = 'internal';
				rename($convertedFile, USERTEMPDIR . '/' . $name);
			}
		}
bf74fc2d   Elena.Budnik   IMPEX
741
		return  $objectMgr->getUploadedObject($name, $format, true);
10200969   Roipoussiere   Remove whitespace...
742
	}
16035364   Benjamin Renard   First commit
743

0dc31ba8   Elena.Budnik   remoteParamManage...
744
745
746
	/*
	*  fill ascii file into grid
	*/
10200969   Roipoussiere   Remove whitespace...
747
748
749
	public  function getAsciiFile($obj)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
750
		return  $objectMgr->getAsciiFile($obj->fileName);
735c653b   Elena.Budnik   rank at observato...
751
	}
10200969   Roipoussiere   Remove whitespace...
752
753
754
755

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

0dc31ba8   Elena.Budnik   remoteParamManage...
759
760
761
	/*
	*  get temporary object from Search
	*/
10200969   Roipoussiere   Remove whitespace...
762
763
764
	public  function getTmpObject($folderId, $name, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
765
		{
10200969   Roipoussiere   Remove whitespace...
766
767
768
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
769
			case 'catalog' :
10200969   Roipoussiere   Remove whitespace...
770
771
				$objectMgr = new CatalogMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
772
773
774
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
775
		return  $objectMgr->getTmpObject($folderId, $name, true);
fdf1413b   Elena.Budnik   TT download
776
	}
735c653b   Elena.Budnik   rank at observato...
777

10200969   Roipoussiere   Remove whitespace...
778
779
780
781

	public  function getObject($id, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
782
783
		{
			case 'myDataParam':
10200969   Roipoussiere   Remove whitespace...
784
785
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($nodeType);
735c653b   Elena.Budnik   rank at observato...
786
				break;
10200969   Roipoussiere   Remove whitespace...
787
			case 'timeTable' :
735c653b   Elena.Budnik   rank at observato...
788
			case 'sharedtimeTable' :
10200969   Roipoussiere   Remove whitespace...
789
790
				$objectMgr = new TimeTableMgr();
				break;
735c653b   Elena.Budnik   rank at observato...
791
792
			case 'catalog' :
			case 'sharedcatalog' :
10200969   Roipoussiere   Remove whitespace...
793
794
795
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
796
			case 'request' :
f569bae5   Benjamin Renard   Save download
797
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
798
			case 'statistic':
10200969   Roipoussiere   Remove whitespace...
799
800
				$objectMgr = new RequestMgr($nodeType);
				break;
0fea5567   Benjamin Renard   First step for re...
801
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
802
803
804
				return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
				break;
			case 'myData' :
10200969   Roipoussiere   Remove whitespace...
805
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
806
				break;
10200969   Roipoussiere   Remove whitespace...
807
			default:
735c653b   Elena.Budnik   rank at observato...
808
809
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
810
		return  $objectMgr->getObject($id, $nodeType);
fdf1413b   Elena.Budnik   TT download
811
	}
10200969   Roipoussiere   Remove whitespace...
812

16035364   Benjamin Renard   First commit
813
814
815
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
816
817
818
819
820
821
822
	public  function deleteObject($obj)
	{
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
823
				break;
10200969   Roipoussiere   Remove whitespace...
824
825
826
827
828
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
735c653b   Elena.Budnik   rank at observato...
829
				break;
10200969   Roipoussiere   Remove whitespace...
830
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
831
			case 'request' :
f569bae5   Benjamin Renard   Save download
832
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
833
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
834
				$objectMgr = new RequestMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
835
836
837
838
				break;
			case 'alias' :
				$objectMgr = new AliasMgr();
				$obj->id = substr($obj->id,strlen('alias_'));
10200969   Roipoussiere   Remove whitespace...
839
				break;
735c653b   Elena.Budnik   rank at observato...
840
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
841
842
843
				return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);

			case 'myData' :
16035364   Benjamin Renard   First commit
844
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
845
846
847
848
849
850
				break;
			default:
					return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> deleteObject($obj);
	}
16035364   Benjamin Renard   First commit
851
852
853
854

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

16035364   Benjamin Renard   First commit
860
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
861
862
863
864
865
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
866
			   break;
10200969   Roipoussiere   Remove whitespace...
867
868
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
869
			   break;
10200969   Roipoussiere   Remove whitespace...
870
871
		  case 'condition' :
		  case 'request' :
f569bae5   Benjamin Renard   Save download
872
		  case 'download' :
2e7079bb   Benjamin Renard   First implementat...
873
		  case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
874
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
875
876
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
877
878
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
879
880
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
881
		}
16035364   Benjamin Renard   First commit
882

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

10200969   Roipoussiere   Remove whitespace...
886
/*
16035364   Benjamin Renard   First commit
887
888
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
889
890
891
	public  function createObject($obj, $folder)
	{
		switch ($obj->nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
892
		{
10200969   Roipoussiere   Remove whitespace...
893
			case 'myDataParam' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
894
			case 'derivedParam' :
10200969   Roipoussiere   Remove whitespace...
895
				if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
896
						$this->amdaStat->addTask($this->user, 'create', null);
10200969   Roipoussiere   Remove whitespace...
897
				$objectMgr = new DerivedParamMgr($obj->nodeType);
8ba47f72   Benjamin Renard   rest actualisatio...
898
                 	break;
10200969   Roipoussiere   Remove whitespace...
899
900
901
902
903
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
904
			   break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
905
			case 'condition' :
10200969   Roipoussiere   Remove whitespace...
906
			case 'request' :
f569bae5   Benjamin Renard   Save download
907
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
908
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
909
910
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
911
			case 'alias' :
10200969   Roipoussiere   Remove whitespace...
912
913
				$objectMgr = new AliasMgr();
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
914
915
916
917
918
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> createObject($obj, $folder);
	}
16035364   Benjamin Renard   First commit
919

10200969   Roipoussiere   Remove whitespace...
920
/*
16035364   Benjamin Renard   First commit
921
922
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
923
	public  function modifyObject($obj)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
924
	{
10200969   Roipoussiere   Remove whitespace...
925
926
927
928
929
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
930
				break;
10200969   Roipoussiere   Remove whitespace...
931
932
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
933
				break;
10200969   Roipoussiere   Remove whitespace...
934
935
936
937
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
938
			case 'request' :
f569bae5   Benjamin Renard   Save download
939
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
940
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
941
				$objectMgr = new RequestMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
942
943
944
945
946
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> modifyObject($obj);
10200969   Roipoussiere   Remove whitespace...
947
	}
16035364   Benjamin Renard   First commit
948
949
950
951
952
953
954
955
956
957
/*
 * {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...
958
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
959
960
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
961
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
962
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
963
964
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
965
966
			case 'condition' :
			case 'request' :
f569bae5   Benjamin Renard   Save download
967
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
968
			case 'statistic' :
16035364   Benjamin Renard   First commit
969
970
971
972
973
974
975
976
977
978
				$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...
979
*   Get running jobs
16035364   Benjamin Renard   First commit
980
*/
bae6f5da   Nathanael Jourdane   bugFix fileName f...
981
	public function getJobs($obj = null)
6acb8d2a   Elena.Budnik   checkRequest in R...
982
	{
812bc03d   Nathanael Jourdane   update job info o...
983
		$obj = (object) array();
10200969   Roipoussiere   Remove whitespace...
984
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
6acb8d2a   Elena.Budnik   checkRequest in R...
985
	}
16035364   Benjamin Renard   First commit
986
987
988
989
990
991
992


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

16035364   Benjamin Renard   First commit
998
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
999
		{
e5ab198f   Nathanael Jourdane   simple getStatus
1000
			$dd = new WSUserMgr();
039d19ac   Benjamin Renard   Fix getParameter ...
1001
			$dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false);
735c653b   Elena.Budnik   rank at observato...
1002
		}
a21497cc   Elena.Budnik   redmine #5645
1003
		else {
16035364   Benjamin Renard   First commit
1004
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
1005
1006
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
1007
1008

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

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

98c5bd44   Benjamin Renard   Introduce anonymo...
1016
		if ($dd->user == WSConfigClass::getAnonymousUserName())
16035364   Benjamin Renard   First commit
1017
1018
1019
		{
			//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
1020
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
1021
		}
32bb889b   Elena.Budnik   #5532 to process ...
1022
		else {
0fea5567   Benjamin Renard   First step for re...
1023
			// check disk space
2c7f2cb6   Benjamin Renard   Remove old log fi...
1024
1025
1026
1027
1028
1029
			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...
1030
		}
10200969   Roipoussiere   Remove whitespace...
1031

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

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

6acb8d2a   Elena.Budnik   checkRequest in R...
1037
	private function executeRequest($obj, $function)
0fea5567   Benjamin Renard   First step for re...
1038
1039
	{

32bb889b   Elena.Budnik   #5532 to process ...
1040
1041
1042
		// Check user if access to DD Server and / or possible 'space consuming' action
		if (  $function == FunctionTypeEnumClass::PARAMS ||
				$function == FunctionTypeEnumClass::ACTION ||
8ba47f72   Benjamin Renard   rest actualisatio...
1043
1044
				$function == FunctionTypeEnumClass::PARAMSGEN ||
				$function == FunctionTypeEnumClass::PARAMSINFOGEN )
32bb889b   Elena.Budnik   #5532 to process ...
1045
		{
7ac3e07e   Elena.Budnik   do not check user...
1046
1047
1048
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
8ba47f72   Benjamin Renard   rest actualisatio...
1049

16035364   Benjamin Renard   First commit
1050
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
1051
		try {
e57cb025   Benjamin Renard   Fix most of error...
1052
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
1053
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
1054
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
1055
		}
16035364   Benjamin Renard   First commit
1056
1057
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1058
1059
1060

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
1061
*/
735c653b   Elena.Budnik   rank at observato...
1062
1063
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
1064
1065
1066
1067
		// 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
1068
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
1069
1070
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
1071
1072
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
1073

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

16035364   Benjamin Renard   First commit
1078
/*
a0b3d64e   Benjamin Renard   Derived parameter...
1079
1080
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1081
1082
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
1083
1084
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
1085

8ba47f72   Benjamin Renard   rest actualisatio...
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097

/*
 * Generate parameter info for display (e.g size)
 */
        public function generateParamInfo($obj)
        {
                return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSINFOGEN);
        }




a0b3d64e   Benjamin Renard   Derived parameter...
1098
1099
1100
/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1101
1102
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
1103
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
1104

a0b3d64e   Benjamin Renard   Derived parameter...
1105
1106
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
1107

a0b3d64e   Benjamin Renard   Derived parameter...
1108
1109
1110
1111
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
1112
1113
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
1114

a0b3d64e   Benjamin Renard   Derived parameter...
1115
/*
e6e5b259   Benjamin Renard   Add kill plot req...
1116
 * kill plot process
16035364   Benjamin Renard   First commit
1117
 */
10200969   Roipoussiere   Remove whitespace...
1118

735c653b   Elena.Budnik   rank at observato...
1119
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
1120
	{
735c653b   Elena.Budnik   rank at observato...
1121
1122
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
1123
1124
1125
1126

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

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

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

10200969   Roipoussiere   Remove whitespace...
1137

16035364   Benjamin Renard   First commit
1138
1139
1140
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
1141
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
1142
1143
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1144
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1145

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

735c653b   Elena.Budnik   rank at observato...
1149
1150
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1151

0fea5567   Benjamin Renard   First step for re...
1152
	public function initObjectCache($isCatalog = false, $nparams = 1)
735c653b   Elena.Budnik   rank at observato...
1153
1154
1155
	{
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else              $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1156

0fea5567   Benjamin Renard   First step for re...
1157
		return $cacheMgr->initObjectCache(array('nparams' => $nparams));
735c653b   Elena.Budnik   rank at observato...
1158
	}
10200969   Roipoussiere   Remove whitespace...
1159
1160


342b20ca   Benjamin Renard   Fix inheritence b...
1161
	public function initObjectCacheFromObject($id, $type)
735c653b   Elena.Budnik   rank at observato...
1162
1163
1164
	{
		if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1165

0fea5567   Benjamin Renard   First step for re...
1166
		return $cacheMgr->initFromObject($id, $type);
735c653b   Elena.Budnik   rank at observato...
1167
	}
10200969   Roipoussiere   Remove whitespace...
1168

0fea5567   Benjamin Renard   First step for re...
1169
	public function initObjectCacheFromCatalog($id, $type)
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
1170
1171
1172
1173
1174
1175
        {
                $cacheMgr = new TimeTableCacheMgr();

                return $cacheMgr->initFromCatalog($id, $type);
        }

19eca0a6   Hacene SI HADJ MOHAND   ok
1176
1177
1178
1179
        public function initObjectCacheFromTimeTable($id, $type, $nparams)
        {
                $cacheMgr = new CatalogCacheMgr();

ceac8bd0   Hacene SI HADJ MOHAND   us ok
1180
                return $cacheMgr->initFromTimeTable($id, $nparams, $type);
19eca0a6   Hacene SI HADJ MOHAND   ok
1181
1182
        }

0fea5567   Benjamin Renard   First step for re...
1183
	public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1184
	{
10200969   Roipoussiere   Remove whitespace...
1185
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1186
1187
1188
1189
		else  $cacheMgr = new CatalogCacheMgr();

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

0fea5567   Benjamin Renard   First step for re...
1191
	public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1192
	{
901ba3f3   Elena.Budnik   upload catalog
1193
1194
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1195
1196
		return $cacheMgr->initFromUploadedFile($name, $format);
	}
10200969   Roipoussiere   Remove whitespace...
1197

342b20ca   Benjamin Renard   Fix inheritence b...
1198
	public function readCacheIntervals($o)
735c653b   Elena.Budnik   rank at observato...
1199
	{
e57cb025   Benjamin Renard   Fix most of error...
1200
		if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1201
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1202

e57cb025   Benjamin Renard   Fix most of error...
1203
		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...
1204
	}
10200969   Roipoussiere   Remove whitespace...
1205

735c653b   Elena.Budnik   rank at observato...
1206
1207
	public function readIntervalsForChart($o)
	{
1a0151a5   Benjamin Renard   wip
1208
		$objMgr = new CatalogCacheMgr(TRUE);
64280af6   Erdogan Furkan   11477 - Done.
1209
1210
1211
1212
		if($o->type == 'uploaded')
			$objMgr->initFromUploadedFile($o->name, $o->format);
		else
			$objMgr->initFromObject($o->id, $o->type);
1a0151a5   Benjamin Renard   wip
1213
		return $objMgr->getIntervalsForChart();
735c653b   Elena.Budnik   rank at observato...
1214
	}
10200969   Roipoussiere   Remove whitespace...
1215

735c653b   Elena.Budnik   rank at observato...
1216
1217
1218
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1219
		return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
735c653b   Elena.Budnik   rank at observato...
1220
	}
10200969   Roipoussiere   Remove whitespace...
1221

342b20ca   Benjamin Renard   Fix inheritence b...
1222
	public function addCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1223
1224
1225
1226
1227
1228
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

735c653b   Elena.Budnik   rank at observato...
1230
1231
1232
1233
1234
1235
1236
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

342b20ca   Benjamin Renard   Fix inheritence b...
1238
	public function modifyCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1239
	{
10200969   Roipoussiere   Remove whitespace...
1240
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1241
		{
f9c8b272   elena   edit catalog
1242
			$cacheMgr = new CatalogCacheMgr();
f9c8b272   elena   edit catalog
1243
		}
735c653b   Elena.Budnik   rank at observato...
1244
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1245

342b20ca   Benjamin Renard   Fix inheritence b...
1246
		return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->data);
735c653b   Elena.Budnik   rank at observato...
1247
	}
10200969   Roipoussiere   Remove whitespace...
1248

f3e15e49   Erdogan Furkan   #10700 - Done
1249
	public function operationTTCacheIntervals($extendTime, $shiftTime, $isCat)
735c653b   Elena.Budnik   rank at observato...
1250
	{
f3e15e49   Erdogan Furkan   #10700 - Done
1251
1252
1253
1254
1255
1256
		if($isCat){
			$cacheMgr = new CatalogCacheMgr();
		}
		else{
			$cacheMgr = new TimeTableCacheMgr();
		}
735c653b   Elena.Budnik   rank at observato...
1257
1258
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1259

735c653b   Elena.Budnik   rank at observato...
1260
1261
1262
1263
1264
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1265

0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1266
	public function getTTCacheStatistics($obj)
735c653b   Elena.Budnik   rank at observato...
1267
	{
0fea5567   Benjamin Renard   First step for re...
1268
                if($obj->name == "timeTableUi"){
0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1269
1270
1271
1272
1273
1274
				$cacheMgr = new TimeTableCacheMgr();
                 }elseif($obj->name == "catalogUI"){
                      $cacheMgr = new CatalogCacheMgr();
                 }else{
                      return array('success' => false, 'message' => 'unkown type: '.$obj->name);
               }
735c653b   Elena.Budnik   rank at observato...
1275
1276
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1277

735c653b   Elena.Budnik   rank at observato...
1278
1279
1280
1281
1282
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1283

16035364   Benjamin Renard   First commit
1284
1285
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1286
 *
16035364   Benjamin Renard   First commit
1287
 */
735c653b   Elena.Budnik   rank at observato...
1288
1289
1290
1291
1292
	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...
1293

16035364   Benjamin Renard   First commit
1294
1295
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1296
 *
16035364   Benjamin Renard   First commit
1297
 */
735c653b   Elena.Budnik   rank at observato...
1298
1299
1300
1301
1302
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1303

16035364   Benjamin Renard   First commit
1304
1305
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1306
1307
 *
 */
735c653b   Elena.Budnik   rank at observato...
1308
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1309
	{
735c653b   Elena.Budnik   rank at observato...
1310
1311
1312
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1313
1314

/*
16035364   Benjamin Renard   First commit
1315
1316
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1317
1318
1319
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1320
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1321

735c653b   Elena.Budnik   rank at observato...
1322
1323
1324
1325
1326
1327
		$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...
1328

735c653b   Elena.Budnik   rank at observato...
1329
1330
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1331
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1332
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1333

735c653b   Elena.Budnik   rank at observato...
1334
1335
1336
1337
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1338
	}
16035364   Benjamin Renard   First commit
1339
1340
1341
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1342
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1343
	{
10200969   Roipoussiere   Remove whitespace...
1344
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1345
1346
1347
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1348

735c653b   Elena.Budnik   rank at observato...
1349
1350
1351
1352
1353
1354
1355
1356
1357
	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...
1358

735c653b   Elena.Budnik   rank at observato...
1359
1360
	public function saveFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1361
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1362
1363
		return $filtersMgr->save($o);
	}
10200969   Roipoussiere   Remove whitespace...
1364

735c653b   Elena.Budnik   rank at observato...
1365
1366
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1367
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1368
1369
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1370

735c653b   Elena.Budnik   rank at observato...
1371
1372
1373
1374
1375
1376
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1377

735c653b   Elena.Budnik   rank at observato...
1378
1379
1380
1381
1382
1383
1384
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1385
1386
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1387
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1388
1389
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1390

fdf1413b   Elena.Budnik   TT download
1391
1392
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1393
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1394
1395
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1396

fdf1413b   Elena.Budnik   TT download
1397
1398
1399
1400
1401
1402
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1403

16035364   Benjamin Renard   First commit
1404
1405
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1406
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1407
		{
fdf1413b   Elena.Budnik   TT download
1408
1409
1410
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1411
		else
735c653b   Elena.Budnik   rank at observato...
1412
		{
fdf1413b   Elena.Budnik   TT download
1413
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1414
		}
16035364   Benjamin Renard   First commit
1415
		return;
10200969   Roipoussiere   Remove whitespace...
1416
	}
16035364   Benjamin Renard   First commit
1417

fdf1413b   Elena.Budnik   TT download
1418
1419
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1420
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1421
		{
10200969   Roipoussiere   Remove whitespace...
1422
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1423
1424
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1425
1426
1427
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1428
1429
1430
1431
1432
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1433

0f9ec8f6   Benjamin Renard   Add reset passwor...
1434
1435
1436
1437
1438
1439
1440
1441
    public function resetPwd($obj)
    {
        $dd = new UserMgr();
        $crt_pwd = $obj->crtpwd;
        $new_pwd = $obj->newpwd;
		return $dd->resetPwd($crt_pwd, $new_pwd);
    }

fdf1413b   Elena.Budnik   TT download
1442
1443
1444
1445
1446
1447
	// $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...
1448
1449

		return  $res;
fdf1413b   Elena.Budnik   TT download
1450
	}
10200969   Roipoussiere   Remove whitespace...
1451
1452

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1453
1454
1455
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1456

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1467
1468
1469
1470
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
278185de   Benjamin Renard   Upload catalog fr...
1471
		$this->rrmdir(USERDIR.'TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1472
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1473
1474

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

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

fdf1413b   Elena.Budnik   TT download
1482
1483
1484
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1485
1486
			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
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
					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...
1500
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1501
1502
1503
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1504

46c5751e   Benjamin Renard   Cleanup
1505
	public function interactivePlot($obj)
fdf1413b   Elena.Budnik   TT download
1506
	{
fdf1413b   Elena.Budnik   TT download
1507
1508
		$inputobj = (Object)array(
			'action' => $obj,
fdf1413b   Elena.Budnik   TT download
1509
1510
1511
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1512

735c653b   Elena.Budnik   rank at observato...
1513
1514
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1515
1516
1517
1518
1519
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1520

735c653b   Elena.Budnik   rank at observato...
1521
1522
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1523
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1524
1525
1526
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1527

735c653b   Elena.Budnik   rank at observato...
1528
1529
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1530
1531
1532
1533
1534
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1535

735c653b   Elena.Budnik   rank at observato...
1536
1537
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
2fa56f95   Benjamin Renard   Predefined templa...
1538
				'predefinedArgs' => !empty($obj->predefinedArgs),
bf74fc2d   Elena.Budnik   IMPEX
1539
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1540
1541
1542
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
bf776dc8   Benjamin Renard   working
1543
	public function getDerivedParamInfo($obj)
0fea5567   Benjamin Renard   First step for re...
1544
	{
bf776dc8   Benjamin Renard   working
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
                 $dom = new DomDocument("1.0");
                 $xmlName=USERWSDIR.$this->xmlFiles['derivedParam'];
		 @$dom->load($xmlName);
		 $params=$dom->getElementsByTagName("param");
		 foreach($params as $param)
		 {
                        if($param->hasAttribute("name") && ("ws_" . ($param->getAttribute("name")))==$obj->paramId)
		        {
                         $dim_1=$param->getAttribute("dim_1");
			 $dim_2=$param->getAttribute("dim_2");
		   	 return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId);
		  	}
0fea5567   Benjamin Renard   First step for re...
1557

bf776dc8   Benjamin Renard   working
1558
		}
0fea5567   Benjamin Renard   First step for re...
1559
		return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
bf776dc8   Benjamin Renard   working
1560
	}
0fea5567   Benjamin Renard   First step for re...
1561

22d8d756   Hacene SI HADJ MOHAND   resolu
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
       public function getMyDataParamInfo($obj)
        {
                 $dom = new DomDocument("1.0");
                 $xmlName=USERWSDIR.$this->xmlFiles['derivedParam'];
                 @$dom->load($xmlName);
                 $params=$dom->getElementsByTagName("mydata");
                 foreach($params as $param)
                 {
                        if($param->hasAttribute("name") && ("wsd_" . ($param->getAttribute("name")))==$obj->paramId)
                        {
                         $dim_1=$param->getAttribute("size");
                         $dim_2=1;
                         return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId);
                        }

                }
                return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
        }


bf776dc8   Benjamin Renard   working
1582
1583
1584
1585
1586
1587
	public function createDerivedParamInfo($dim_1,$dim_2,$paramId)
	{
		/* case of constant */
		if($dim_1*$dim_2==1)
		{
		return array('success'=>false,'msg'=>"dim1=1 dim2=1 no arguments for this parameter");
0fea5567   Benjamin Renard   First step for re...
1588
		}elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
bf776dc8   Benjamin Renard   working
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
		/* case of vector */
                {

	        $dims=array(
				'dim1'=>$dim_1,
				'dim2'=>$dim_2
			      );

		$compts=array();

		for($i=0;$i<($dim_1*$dim_2);++$i)
			{

			$c=array(

				'index_1'=>($dim_1>$dim_2)?(string)$i:"",
				'index_2'=>($dim_1<$dim_2)?$i:"",
				'name'=>$paramId.'('.$i.')'
				);
			array_push($compts,$c);

			}

		$data=array(
				'dimensions'=>$dims,
				'components'=>$compts
			    );
0fea5567   Benjamin Renard   First step for re...
1616

10200969   Roipoussiere   Remove whitespace...
1617

bf776dc8   Benjamin Renard   working
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
			return array('success'=>true,'data'=>$data);
		}else
		/* case of spectro*/
		{
		  $sizes=array($dim_1,$dim_2);
		  $dims=array(
				'dim1'=>$dim_1,
				'dim2'=>$dim_2
			      );
		$channels=array();
 		$tables=array();
		for($j=0;$j<count($sizes);$j++)
			{
		       $compts=array();
0fea5567   Benjamin Renard   First step for re...
1632

bf776dc8   Benjamin Renard   working
1633
1634
1635
1636
1637
1638
1639
			for($i=0;$i<$sizes[$j];$i++)
				{
				$c=array('min'=>'L' . $i,'max'=>'L' . ($i+1));
				array_push($compts,$c);
				}

			$tab=array(
0fea5567   Benjamin Renard   First step for re...
1640
				'relatedDim'=>'dim' . ($j+1),
bf776dc8   Benjamin Renard   working
1641
1642
1643
1644
1645
1646
1647
1648
1649
				'name'=>'component' . ($j+1),
				'units'=>"",
				'variable'=>"",
				'channels'=>$compts,
				'minmax'=>""
				);

			array_push($tables,$tab);
			}
0fea5567   Benjamin Renard   First step for re...
1650

bf776dc8   Benjamin Renard   working
1651
1652
1653
1654
1655
1656
                  $data=array(
				'dimensions'=>$dims,
				'tables'=>$tables
			     );
		return array('success'=>true,'data'=>$data);
                }
0fea5567   Benjamin Renard   First step for re...
1657

bf776dc8   Benjamin Renard   working
1658
	}
735c653b   Elena.Budnik   rank at observato...
1659
1660
1661
1662
1663
1664
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1665

735c653b   Elena.Budnik   rank at observato...
1666
1667
1668
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1669
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1670
1671
1672
1673
1674
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1675

735c653b   Elena.Budnik   rank at observato...
1676
1677
1678
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1679

735c653b   Elena.Budnik   rank at observato...
1680
1681
1682
		$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...
1683

735c653b   Elena.Budnik   rank at observato...
1684
1685
1686
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1687

735c653b   Elena.Budnik   rank at observato...
1688
1689
1690
1691
1692
1693
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1694

0bda97f3   Benjamin Renard   Fix SAMP export f...
1695
1696
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1697
1698
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
2fa56f95   Benjamin Renard   Predefined templa...
1699
1700
1701
1702
1703
1704
1705
1706
1707

	public function parseTemplatedParam($paramTemplateId)
	{
		$args = (Object)array(
			'paramId' => $paramTemplateId,
			'type' => 'param_parse_template'
		);
		return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO);
	}
3d95b0a6   furkan   Adding the Delete...
1708
1709
1710
1711
1712
1713

	public function deleteColumn($id){
		$cacheMgr = new CatalogCacheMgr();

		return $cacheMgr->deleteColumn($id);
	}
42c4ccd3   Erdogan Furkan   #9660 - Done
1714

ce347c54   Erdogan Furkan   Done.
1715
	public function addColumn($id, $name, $type, $size, $description, $status){
42c4ccd3   Erdogan Furkan   #9660 - Done
1716
		$cacheMgr = new CatalogCacheMgr();
ce347c54   Erdogan Furkan   Done.
1717
		return $cacheMgr->addColumn($id,$name, $type,$size,$description, $status);
42c4ccd3   Erdogan Furkan   #9660 - Done
1718
1719
1720
1721
1722
1723
1724
	}

	public function getCatColumnInfo($id){
		$cacheMgr = new CatalogCacheMgr();
		return $cacheMgr->getCatColumnInfo($id);
	}

ce347c54   Erdogan Furkan   Done.
1725
	public function editColumn($id, $name, $type, $size,$description, $status){
42c4ccd3   Erdogan Furkan   #9660 - Done
1726
		$cacheMgr = new CatalogCacheMgr();
ce347c54   Erdogan Furkan   Done.
1727
		return $cacheMgr->editColumn($id,$name, $type,$size,$description, $status);
42c4ccd3   Erdogan Furkan   #9660 - Done
1728
	}
851cf2f0   Erdogan Furkan   For now
1729
1730
1731

	public function getNodeValues($data,&$transformed){
		$iconCls = "task-folder";
851cf2f0   Erdogan Furkan   For now
1732
		foreach ($data as $parameter => $value) {
4f728fd9   Erdogan Furkan   For now 2
1733
			if(is_array($value) && !$value['modified']){
851cf2f0   Erdogan Furkan   For now
1734
1735
1736
1737
1738
1739
1740
				$child = [
					"parameter" => $parameter,
					"value" => "",
					"iconCls" => $iconCls,
					"expanded" => false,
					"children" => []
				];
4f728fd9   Erdogan Furkan   For now 2
1741

851cf2f0   Erdogan Furkan   For now
1742
1743
1744
				$this->getNodeValues($value,$child['children']);
				$transformed[] = $child;
			}
4f728fd9   Erdogan Furkan   For now 2
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
			else if (is_array($value) && $value['modified']){
				$child =[
					"parameter" => $parameter,
					"value" => $value["value"],
					"iconCls" => "task",
					"leaf" => true,
					"modified" => $value["modified"],
					"default" => $value["defaultValue"]
				];
				$transformed[] = $child;
			}
851cf2f0   Erdogan Furkan   For now
1756
1757
1758
1759
1760
			else{
				$child =[
					"parameter" => $parameter,
					"value" => $value,
					"iconCls" => "task",
4f728fd9   Erdogan Furkan   For now 2
1761
1762
1763
					"leaf" => true,
					"modified" => false,
					"default" =>$value
851cf2f0   Erdogan Furkan   For now
1764
				];
851cf2f0   Erdogan Furkan   For now
1765
1766
1767
1768
				$transformed[] = $child;
			}
		}
	}
4f728fd9   Erdogan Furkan   For now 2
1769
1770
	public function getDefaultValueConfigs(){
		if (file_exists(DATAPATH.'defaultValuesConfig.json'))
b1dc2eb3   Erdogan Furkan   More modifications
1771
			return array('success' => true , 'configs' => json_decode(file_get_contents(DATAPATH.'defaultValuesConfig.json'), true));
4f728fd9   Erdogan Furkan   For now 2
1772
		else
b1dc2eb3   Erdogan Furkan   More modifications
1773
			return array('success' => false , 'configs' => array(), 'message'=>'Error : No default value configs file.');
4f728fd9   Erdogan Furkan   For now 2
1774
1775
1776
	}

	public function getDefaultValueLinks(){
b1dc2eb3   Erdogan Furkan   More modifications
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
		if (!file_exists(DATAPATH.'defaultValuesLinks.json'))
			return array('success' => false , 'links' => array(), 'message'=>'Error : No default value links file.');

		$json_links = json_decode(file_get_contents(DATAPATH.'defaultValuesLinks.json'), true);
		if (!file_exists(DATAPATH.'defaultValuesConfig.json'))
			return  array('success' => false , 'links' => array(), 'message'=>'Error : No default value configs file.');
			
		$json_configs= json_decode(file_get_contents(DATAPATH.'defaultValuesConfig.json'), true);
		foreach ($json_links as $parameter => &$links){
			if(!empty($links['store']))
				$links['store']= $json_configs[$links['store']];
		}
		return array('success' => true , 'links' => $json_links);
		
4f728fd9   Erdogan Furkan   For now 2
1791
	}
851cf2f0   Erdogan Furkan   For now
1792

4f728fd9   Erdogan Furkan   For now 2
1793
	public function getDefaultValueTree($isTree=TRUE){
851cf2f0   Erdogan Furkan   For now
1794
1795
		$childrenToReturn = array();
		$children = [];
b1dc2eb3   Erdogan Furkan   More modifications
1796
		if (!file_exists(DATAPATH.'defaultValues.json')) 
a2b8ec19   Benjamin Renard   Fix userDefaults....
1797
			return array('success' => false , 'defaultValues' => array(), 'message'=>'Defaultvalues file not found.');
b1dc2eb3   Erdogan Furkan   More modifications
1798
1799
1800
1801
		$json_o = json_decode(file_get_contents(DATAPATH.'defaultValues.json'), true);
		if (empty($json_o)) 
			return array('success' => false , 'defaultValues' => array(), 'message'=>'Error : defaultValues file empty.');

a2b8ec19   Benjamin Renard   Fix userDefaults....
1802
1803
1804
1805
1806
1807
		$json_user = array();
		if (file_exists(USERDIR.'userDefaults.json')) 
			$json_user = json_decode(file_get_contents(USERDIR.'userDefaults.json'), true);
		if (empty($json_user)) {
			$json_user = array();
		}
b1dc2eb3   Erdogan Furkan   More modifications
1808
1809
1810
1811
1812
1813

		foreach($json_user as $key => $value){
			$keys = explode(".", $key);
			$results = &$json_o; // Use a reference to update the original array
			foreach($keys as $parameter){
				$results = &$results[$parameter];
851cf2f0   Erdogan Furkan   For now
1814
			}
b1dc2eb3   Erdogan Furkan   More modifications
1815
1816
1817
1818
			if($isTree)
				$results = array("value" => $value, "modified" => true, "defaultValue" => $results);
			else
				$results = $value;
851cf2f0   Erdogan Furkan   For now
1819
		}
b1dc2eb3   Erdogan Furkan   More modifications
1820
1821
1822
1823
		
		if($isTree){
			$this->getNodeValues($json_o,$children);
			return [ "text" => ".", "children" => $children ];
851cf2f0   Erdogan Furkan   For now
1824
		}
b1dc2eb3   Erdogan Furkan   More modifications
1825
1826

		return array('success' => true , 'defaultValues' => $json_o);
851cf2f0   Erdogan Furkan   For now
1827
	}
239d9f8f   Erdogan Furkan   First Working ver...
1828
1829
1830

	public function setUserDefaultValues($data){
		$json_user = json_encode($data, true);
b1dc2eb3   Erdogan Furkan   More modifications
1831
1832
1833
		if (empty($json_user)) 
			return array('success' => false , 'message'=>'Error : No modifications to write.');

239d9f8f   Erdogan Furkan   First Working ver...
1834
1835
1836
1837
		file_put_contents(USERDIR.'userDefaults.json',$json_user);

		return array('success' => true);
	}
e995f4ad   Erdogan Furkan   Added codeTextAre...
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858

	public function getParametersList(){
		$xml = simplexml_load_string(file_get_contents(LocalData.'LocalParams.xml'));
		$parameters = [];
		if (empty($xml)) 
			return array();
		foreach($xml->xpath('//parameter') as $parameter) {
			$parameters[] = (string) $parameter->attributes('xml', true)['id'];
		}

		$xml_derived = simplexml_load_string(file_get_contents(USERDIR.'/WS/WsParams.xml'));
		if(empty($xml_derived))
			return $parameters;
		foreach($xml_derived->xpath('//param') as $param) {
			$parameters[] = "ws_".(string) $param->attributes()->name;
		}
		foreach($xml_derived->xpath('//mydata') as $param) {
			$parameters[] = "wsd_".(string) $param->attributes()->name;
		}
		return $parameters;
	}
16035364   Benjamin Renard   First commit
1859
1860
}
?>