Blame view

php/classes/AmdaAction.php 50.6 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
192
193
							if ($isLeaf) {
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('intervals').'<br/>';
								$info .= '<b>ID:</b> '. $child->getAttribute('xml:id');
							}
735c653b   Elena.Budnik   rank at observato...
194
						break;
10200969   Roipoussiere   Remove whitespace...
195

735c653b   Elena.Budnik   rank at observato...
196
197
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
198
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
199
200
201
							{
								$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...
202
203
								$info .= '<b>Description:</b> '.$child->getAttribute('description').'<br/>';
								$info .= '<b>ID:</b> ' . $child->getAttribute('xml:id');
8b6bb092   Elena.Budnik   icones if rank is...
204
							} 
735c653b   Elena.Budnik   rank at observato...
205
206
						break;
						case 'derivedParam':
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
207
208
  							$info = $child->getAttribute('buildchain').'<br/>';
							                                        
dfa8db4f   Hacene SI HADJ MOHAND   correcting derive...
209
210
							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
211
212
   							$samplingMode = $child->getAttribute('sampling_mode');
 						  	if($samplingMode == 'timestep'){
1cfbb4ac   Furkan   10931 - Done
213
      								$info .= 'Sampling: '.$child->getAttribute('timestep').' sec';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
214
   							}else if($samplingMode == 'refparam'){
09a0cb29   Hacene SI HADJ MOHAND   us ok
215
      								$info .= 'Reference Parameter: '.$child->getAttribute('reference_param');
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
216
			 	 			}			
0fea5567   Benjamin Renard   First step for re...
217

8ba47f72   Benjamin Renard   rest actualisatio...
218
219
220
221
222
223
224
							if ($child->hasAttribute('dim_1')) {
								$dim_1 = $child->getAttribute('dim_1');
							}
					                if ($child->hasAttribute('dim_2')) {
                                                                $dim_2 = $child->getAttribute('dim_2');
                                                        }

735c653b   Elena.Budnik   rank at observato...
225
226
227
228
							if ($isLeaf) $isParameter = true;
						break;

						case 'localParam':
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
229
							
735c653b   Elena.Budnik   rank at observato...
230
231
232
233
234
235
							$globalStart = null;
							$globalStop = null;
							$timeRestriction = false;
							$specialNode = true;
							$isParameter = false;
							$needsArgs = false;
10200969   Roipoussiere   Remove whitespace...
236
							$isSpectra = false;
dc9e2c14   Elena.Budnik   init + message + ...
237
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
238
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
239
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
240

10200969   Roipoussiere   Remove whitespace...
241
242
							if ($child->hasAttribute('desc'))
							{
735c653b   Elena.Budnik   rank at observato...
243
								$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
244

c57c57c9   Elena.Budnik   info message depe...
245
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
67bd6ed6   Elena.Budnik   rm 8375
246
247
248
249
250
251
252
                                    $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
253
254
                                        $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
255
256
257
258
                                    } else {
                                        $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
                                    }
                                    
a7316784   Elena.Budnik   add LastUpdate to...
259
260
261
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
262
								}
735c653b   Elena.Budnik   rank at observato...
263
							}
10200969   Roipoussiere   Remove whitespace...
264

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

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

cbbbdc34   Elena.Budnik   param description...
269
270
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description')."<br/>".$units;
0fea5567   Benjamin Renard   First step for re...
271
								else
cbbbdc34   Elena.Budnik   param description...
272
273
									$info = $units;
							}
71b9368c   Benjamin Renard   Fix bug with tool...
274
275
276
277
							else {
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description');
							}
0fea5567   Benjamin Renard   First step for re...
278

f29c5e66   Elena.Budnik   plot only option
279
							if ($child->tagName == 'parameter') {
735c653b   Elena.Budnik   rank at observato...
280
								$isParameter = true;
67bd6ed6   Elena.Budnik   rm 8375
281
282
                                if ($child->hasAttribute('TemplatedParameter'))
                                    $needsArgs = true;
2fa56f95   Benjamin Renard   Predefined templa...
283

b0f72ee0   Erdogan Furkan   #10557 For now
284
285
								if ($child->hasAttribute('PredefinedTemplatedParameter'))
									$predefinedArgs = true;
67bd6ed6   Elena.Budnik   rm 8375
286
                                    
c57c57c9   Elena.Budnik   info message depe...
287
								if ($child->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
288
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
289
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
290
								}
0fea5567   Benjamin Renard   First step for re...
291

f29c5e66   Elena.Budnik   plot only option
292
293
294
295
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
296
								}
3afe4f59   Benjamin Renard   Add datasets time...
297
298
299
300

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

735c653b   Elena.Budnik   rank at observato...
303
304
305
306
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
307

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

f29c5e66   Elena.Budnik   plot only option
313
314
315
316
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->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->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
322
323
324
325
326

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

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

f29c5e66   Elena.Budnik   plot only option
331
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
332
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
333
334
										$needsArgs = true;
										$isSpectra = true;
dc9e2c14   Elena.Budnik   init + message + ...
335
336
										if (strpos($child->getAttribute('name'),'2D') !== false)
											$is2dSpectra = true;
735c653b   Elena.Budnik   rank at observato...
337
								}
c57c57c9   Elena.Budnik   info message depe...
338
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
339
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
340
								}
10200969   Roipoussiere   Remove whitespace...
341
342
							}

f31bea1c   Benjamin Renard   wip for save plot
343

c57c57c9   Elena.Budnik   info message depe...
344
							if ($isParameter) {
735c653b   Elena.Budnik   rank at observato...
345
346
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);
c3b20775   Elena.Budnik   not show ID for p...
347
348
								
                                if (! ($child->parentNode->hasAttribute('group') || $child->parentNode->parentNode->hasAttribute('group'))) $info .= '</br><i>ID : '.$id.'</i>';
661293d7   Elena.Budnik   parse ## and @@ i...
349
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
350
351
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
dc9e2c14   Elena.Budnik   init + message + ...
352
									'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra,
2fa56f95   Benjamin Renard   Predefined templa...
353
									'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'predefinedArgs' => $predefinedArgs, 'help' => $help, 'notyet' => $not_yet);
735c653b   Elena.Budnik   rank at observato...
354
							}
c57c57c9   Elena.Budnik   info message depe...
355
							else {
8b6bb092   Elena.Budnik   icones if rank is...
356
								if ($child->hasAttribute('rank')) {
735c653b   Elena.Budnik   rank at observato...
357
358
									$rank = $child->getAttribute('rank');
								}
0fea5567   Benjamin Renard   First step for re...
359

3afe4f59   Benjamin Renard   Add datasets time...
360
361
362
363
								if ($child->hasAttribute("timeRestriction")) {
									$timeRestriction = $child->getAttribute("timeRestriction");
								}
								$disable = TRUE;
acf87705   Elena.Budnik   bug in disable param
364

222e562d   Benjamin Renard   Give the possibil...
365
366
367
368
369
								$hideIfRestricted = FALSE;
								if ($child->hasAttribute("hideIfRestricted") && ($child->getAttribute("hideIfRestricted") == "1")) {
									$hideIfRestricted = TRUE;
								}

3afe4f59   Benjamin Renard   Add datasets time...
370
								if ($child->hasAttribute('group')) {
c3976709   Elena.Budnik   rm 7589 + clean u...
371
372
									if ($child->getAttribute("group") === "TBD") {
											$info .=  "<br/><b>Under Testing</b>";
3afe4f59   Benjamin Renard   Add datasets time...
373
									}
1c2f5368   Elena.Budnik   message for TimeR...
374
									else {	
3afe4f59   Benjamin Renard   Add datasets time...
375
376
										if (!empty($timeRestriction)) {
											$disable = FALSE;
3a8eaaff   Hacene SI HADJ MOHAND   resolue
377
											$formattedTimeRestriction = date("Y-m-d\TH:i:s.u\Z",strtotime($timeRestriction)+1);
1c2f5368   Elena.Budnik   message for TimeR...
378
379
380
381
											$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...
382
										}
735c653b   Elena.Budnik   rank at observato...
383
									}
0fea5567   Benjamin Renard   First step for re...
384
								}
acf87705   Elena.Budnik   bug in disable param
385
								else {
3afe4f59   Benjamin Renard   Add datasets time...
386
									$disable = FALSE;
acf87705   Elena.Budnik   bug in disable param
387
388
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
389
								}
222e562d   Benjamin Renard   Give the possibil...
390
								$visible = !($disable && $hideIfRestricted);
735c653b   Elena.Budnik   rank at observato...
391

698494ac   Benjamin Renard   Add tooltip for s...
392
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'last_update' => $last_update,
222e562d   Benjamin Renard   Give the possibil...
393
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'visible' => $visible, 'rank' => $rank, 'timeRestriction' => $timeRestriction);
735c653b   Elena.Budnik   rank at observato...
394
395
396
397
							}
						break;

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

bf74fc2d   Elena.Budnik   IMPEX
399
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
400
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
401
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
402
403

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
404
405
406
407
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
408
409

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
410
							{
10200969   Roipoussiere   Remove whitespace...
411
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
412
								{
10200969   Roipoussiere   Remove whitespace...
413
414
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
415
								}
10200969   Roipoussiere   Remove whitespace...
416
								else
735c653b   Elena.Budnik   rank at observato...
417
418
419
420
421
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
422
423

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
424
425
426
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
427

bf74fc2d   Elena.Budnik   IMPEX
428
429
							if ( $child->tagName == 'parameter')
							{
abb54096   Elena.Budnik   time interval by ...
430
								if ($child->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
431
									{
abb54096   Elena.Budnik   time interval by ...
432
433
										$globalStart = $child->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
434
435
									}
							}
10200969   Roipoussiere   Remove whitespace...
436

bf74fc2d   Elena.Budnik   IMPEX
437
438
							if ( $child->tagName == 'component')
							{
abb54096   Elena.Budnik   time interval by ...
439
								if ($child->parentNode->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
440
									{
abb54096   Elena.Budnik   time interval by ...
441
442
										$globalStart = $child->parentNode->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
443
444
									}
							}
10200969   Roipoussiere   Remove whitespace...
445

735c653b   Elena.Budnik   rank at observato...
446
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
447
448

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
449
450
451
452
453
454
455
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
456
457
458
459
460
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
461
							{
10200969   Roipoussiere   Remove whitespace...
462
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
463
464
465
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
466
467
								default:
							}
10200969   Roipoussiere   Remove whitespace...
468

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

10200969   Roipoussiere   Remove whitespace...
471
472
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
473
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
474
475
476
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
477
478
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
479
							}
10200969   Roipoussiere   Remove whitespace...
480

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

10200969   Roipoussiere   Remove whitespace...
483
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
484
							{
10200969   Roipoussiere   Remove whitespace...
485
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
486
							}
0fea5567   Benjamin Renard   First step for re...
487

a0f13ed1   Elena.Budnik   small format + ti...
488
489
							if ($child->tagName == 'parameter'){
								if ($child->parentNode->hasAttribute('dataStart')){
3a8eaaff   Hacene SI HADJ MOHAND   resolue
490
491
									$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...
492
493
								}
							}
735c653b   Elena.Budnik   rank at observato...
494

a0f13ed1   Elena.Budnik   small format + ti...
495
496
							if ( $child->tagName == 'component'){
								if ($child->parentNode->parentNode->hasAttribute('dataStart')){
3a8eaaff   Hacene SI HADJ MOHAND   resolue
497
498
									$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...
499
500
								}
							}
0fea5567   Benjamin Renard   First step for re...
501

10200969   Roipoussiere   Remove whitespace...
502
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
503
							{
10200969   Roipoussiere   Remove whitespace...
504
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
505
506
507
508
509
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
510
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
511
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
512
								}
bf74fc2d   Elena.Budnik   IMPEX
513
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
514
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
515
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
516
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
517
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => isset($component_info) ? $component_info : NULL);
bf74fc2d   Elena.Budnik   IMPEX
518
								else
10200969   Roipoussiere   Remove whitespace...
519
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
520
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
521
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
522
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
523
							}
10200969   Roipoussiere   Remove whitespace...
524
525
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
526
								$restricted = FALSE;
0fea5567   Benjamin Renard   First step for re...
527

735c653b   Elena.Budnik   rank at observato...
528
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
529
								{
735c653b   Elena.Budnik   rank at observato...
530
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
531
								}
735c653b   Elena.Budnik   rank at observato...
532
								else
6657f68b   Elena.Budnik   monitor impex ser...
533
								{
735c653b   Elena.Budnik   rank at observato...
534
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
535
								}
10200969   Roipoussiere   Remove whitespace...
536

735c653b   Elena.Budnik   rank at observato...
537
538
539
540
541
542
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
543
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
544
545
546
547
548
549
550
551
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

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

735c653b   Elena.Budnik   rank at observato...
553
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
554
555
556
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
557
						break;
10200969   Roipoussiere   Remove whitespace...
558
559
560

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
561
562
563
564
565
566
567
568
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
569
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
570
							$sampling = null;
0fea5567   Benjamin Renard   First step for re...
571
							if ($child->hasAttribute('minsampling'))
19dcd963   Elena.Budnik   redmine #4903 : s...
572
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
573
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
574
575

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
576
577
578
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
579
580
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
581
582
583
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
584
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
585
586
587
588
589
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
590
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
591
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
592
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
593
594
595
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
b0f72ee0   Erdogan Furkan   #10557 For now
596
597
						
						case 'specialParam':
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
598
599
600
							$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
601
602
							break;
						
10200969   Roipoussiere   Remove whitespace...
603
						default:
735c653b   Elena.Budnik   rank at observato...
604
					}
10200969   Roipoussiere   Remove whitespace...
605
606

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
607
					{
10200969   Roipoussiere   Remove whitespace...
608
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
609
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
610
611

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
612
613
614
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
615
616

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
2048f5bc   Benjamin Renard   Fix save & edit plot
617
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2,
0fea5567   Benjamin Renard   First step for re...
618
													'component_info' => isset($component_info) ? $component_info : NULL,
698494ac   Benjamin Renard   Add tooltip for s...
619
													'iconCls' => isset($iconCls) ? $iconCls : NULL, 'last_update' => $last_update );
735c653b   Elena.Budnik   rank at observato...
620
621
622
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
623
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
624
				{
735c653b   Elena.Budnik   rank at observato...
625
626
627
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
628
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
629
	}
16035364   Benjamin Renard   First commit
630

0dc31ba8   Elena.Budnik   remoteParamManage...
631
632
633
	/*
	*  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...
634
	*  create Remote Parameter Description
0dc31ba8   Elena.Budnik   remoteParamManage...
635
	*/
10200969   Roipoussiere   Remove whitespace...
636
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
637
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
638
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
639
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
640

2b8ea2a7   Elena.Budnik   RemoteParamManage...
641
642
		if ($res['success'])
			return $paramMgr->saveTree($obj);
0fea5567   Benjamin Renard   First step for re...
643
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
644
			return $res;
735c653b   Elena.Budnik   rank at observato...
645
	}
0fea5567   Benjamin Renard   First step for re...
646

0dc31ba8   Elena.Budnik   remoteParamManage...
647
648
649
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
650
651
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
652
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
653
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
654

2b8ea2a7   Elena.Budnik   RemoteParamManage...
655
656
		if ($res['success'])
			return $paramMgr->deleteFromTree($obj);
0fea5567   Benjamin Renard   First step for re...
657
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
658
			return $res;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
659
	}
0fea5567   Benjamin Renard   First step for re...
660

0dc31ba8   Elena.Budnik   remoteParamManage...
661
662
663
664
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
665

0dc31ba8   Elena.Budnik   remoteParamManage...
666
667
668
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
669
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
670
	{
5f8bd1f5   Nathanaël Jourdane   Fix Windows-files...
671
672
673
		$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...
674
		$isTTCat = FALSE;
10200969   Roipoussiere   Remove whitespace...
675
		switch ($nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
676
		{
10200969   Roipoussiere   Remove whitespace...
677
678
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
42e2e019   Benjamin Renard   Next step for cac...
679
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
680
				break;
10200969   Roipoussiere   Remove whitespace...
681
682
683
684
685
			case 'myDataParam' :
				$objectMgr = new FilesMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
42e2e019   Benjamin Renard   Next step for cac...
686
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
687
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
688
689
690
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
42e2e019   Benjamin Renard   Next step for cac...
691
692
693
694
695
696
		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
697
                                        'timeformat' => 'YYYY-MM-DDThh:mm:ss.u',
42e2e019   Benjamin Renard   Next step for cac...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
					'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
720
		return  $objectMgr->getUploadedObject($name, $format, true);
10200969   Roipoussiere   Remove whitespace...
721
	}
16035364   Benjamin Renard   First commit
722

0dc31ba8   Elena.Budnik   remoteParamManage...
723
724
725
	/*
	*  fill ascii file into grid
	*/
10200969   Roipoussiere   Remove whitespace...
726
727
728
	public  function getAsciiFile($obj)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
729
		return  $objectMgr->getAsciiFile($obj->fileName);
735c653b   Elena.Budnik   rank at observato...
730
	}
10200969   Roipoussiere   Remove whitespace...
731
732
733
734

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

0dc31ba8   Elena.Budnik   remoteParamManage...
738
739
740
	/*
	*  get temporary object from Search
	*/
10200969   Roipoussiere   Remove whitespace...
741
742
743
	public  function getTmpObject($folderId, $name, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
744
		{
10200969   Roipoussiere   Remove whitespace...
745
746
747
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
748
			case 'catalog' :
10200969   Roipoussiere   Remove whitespace...
749
750
				$objectMgr = new CatalogMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
751
752
753
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
754
		return  $objectMgr->getTmpObject($folderId, $name, true);
fdf1413b   Elena.Budnik   TT download
755
	}
735c653b   Elena.Budnik   rank at observato...
756

10200969   Roipoussiere   Remove whitespace...
757
758
759
760

	public  function getObject($id, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
761
762
		{
			case 'myDataParam':
10200969   Roipoussiere   Remove whitespace...
763
764
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($nodeType);
735c653b   Elena.Budnik   rank at observato...
765
				break;
10200969   Roipoussiere   Remove whitespace...
766
			case 'timeTable' :
735c653b   Elena.Budnik   rank at observato...
767
			case 'sharedtimeTable' :
10200969   Roipoussiere   Remove whitespace...
768
769
				$objectMgr = new TimeTableMgr();
				break;
735c653b   Elena.Budnik   rank at observato...
770
771
			case 'catalog' :
			case 'sharedcatalog' :
10200969   Roipoussiere   Remove whitespace...
772
773
774
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
775
			case 'request' :
f569bae5   Benjamin Renard   Save download
776
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
777
			case 'statistic':
10200969   Roipoussiere   Remove whitespace...
778
779
				$objectMgr = new RequestMgr($nodeType);
				break;
0fea5567   Benjamin Renard   First step for re...
780
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
781
782
783
				return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
				break;
			case 'myData' :
10200969   Roipoussiere   Remove whitespace...
784
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
785
				break;
10200969   Roipoussiere   Remove whitespace...
786
			default:
735c653b   Elena.Budnik   rank at observato...
787
788
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
789
		return  $objectMgr->getObject($id, $nodeType);
fdf1413b   Elena.Budnik   TT download
790
	}
10200969   Roipoussiere   Remove whitespace...
791

16035364   Benjamin Renard   First commit
792
793
794
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
795
796
797
798
799
800
801
	public  function deleteObject($obj)
	{
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
802
				break;
10200969   Roipoussiere   Remove whitespace...
803
804
805
806
807
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
735c653b   Elena.Budnik   rank at observato...
808
				break;
10200969   Roipoussiere   Remove whitespace...
809
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
810
			case 'request' :
f569bae5   Benjamin Renard   Save download
811
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
812
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
813
				$objectMgr = new RequestMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
814
815
816
817
				break;
			case 'alias' :
				$objectMgr = new AliasMgr();
				$obj->id = substr($obj->id,strlen('alias_'));
10200969   Roipoussiere   Remove whitespace...
818
				break;
735c653b   Elena.Budnik   rank at observato...
819
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
820
821
822
				return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);

			case 'myData' :
16035364   Benjamin Renard   First commit
823
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
824
825
826
827
828
829
				break;
			default:
					return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> deleteObject($obj);
	}
16035364   Benjamin Renard   First commit
830
831
832
833

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

16035364   Benjamin Renard   First commit
839
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
840
841
842
843
844
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
845
			   break;
10200969   Roipoussiere   Remove whitespace...
846
847
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
848
			   break;
10200969   Roipoussiere   Remove whitespace...
849
850
		  case 'condition' :
		  case 'request' :
f569bae5   Benjamin Renard   Save download
851
		  case 'download' :
2e7079bb   Benjamin Renard   First implementat...
852
		  case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
853
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
854
855
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
856
857
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
858
859
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
860
		}
16035364   Benjamin Renard   First commit
861

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

10200969   Roipoussiere   Remove whitespace...
865
/*
16035364   Benjamin Renard   First commit
866
867
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
868
869
870
	public  function createObject($obj, $folder)
	{
		switch ($obj->nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
871
		{
10200969   Roipoussiere   Remove whitespace...
872
			case 'myDataParam' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
873
			case 'derivedParam' :
10200969   Roipoussiere   Remove whitespace...
874
				if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
875
						$this->amdaStat->addTask($this->user, 'create', null);
10200969   Roipoussiere   Remove whitespace...
876
				$objectMgr = new DerivedParamMgr($obj->nodeType);
8ba47f72   Benjamin Renard   rest actualisatio...
877
                 	break;
10200969   Roipoussiere   Remove whitespace...
878
879
880
881
882
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
883
			   break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
884
			case 'condition' :
10200969   Roipoussiere   Remove whitespace...
885
			case 'request' :
f569bae5   Benjamin Renard   Save download
886
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
887
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
888
889
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
890
			case 'alias' :
10200969   Roipoussiere   Remove whitespace...
891
892
				$objectMgr = new AliasMgr();
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
893
894
895
896
897
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> createObject($obj, $folder);
	}
16035364   Benjamin Renard   First commit
898

10200969   Roipoussiere   Remove whitespace...
899
/*
16035364   Benjamin Renard   First commit
900
901
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
902
	public  function modifyObject($obj)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
903
	{
10200969   Roipoussiere   Remove whitespace...
904
905
906
907
908
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
909
				break;
10200969   Roipoussiere   Remove whitespace...
910
911
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
912
				break;
10200969   Roipoussiere   Remove whitespace...
913
914
915
916
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
917
			case 'request' :
f569bae5   Benjamin Renard   Save download
918
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
919
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
920
				$objectMgr = new RequestMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
921
922
923
924
925
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> modifyObject($obj);
10200969   Roipoussiere   Remove whitespace...
926
	}
16035364   Benjamin Renard   First commit
927
928
929
930
931
932
933
934
935
936
/*
 * {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...
937
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
938
939
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
940
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
941
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
942
943
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
944
945
			case 'condition' :
			case 'request' :
f569bae5   Benjamin Renard   Save download
946
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
947
			case 'statistic' :
16035364   Benjamin Renard   First commit
948
949
950
951
952
953
954
955
956
957
				$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...
958
*   Get running jobs
16035364   Benjamin Renard   First commit
959
*/
bae6f5da   Nathanael Jourdane   bugFix fileName f...
960
	public function getJobs($obj = null)
6acb8d2a   Elena.Budnik   checkRequest in R...
961
	{
812bc03d   Nathanael Jourdane   update job info o...
962
		$obj = (object) array();
10200969   Roipoussiere   Remove whitespace...
963
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
6acb8d2a   Elena.Budnik   checkRequest in R...
964
	}
16035364   Benjamin Renard   First commit
965
966
967
968
969
970
971


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

16035364   Benjamin Renard   First commit
977
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
978
		{
e5ab198f   Nathanael Jourdane   simple getStatus
979
			$dd = new WSUserMgr();
039d19ac   Benjamin Renard   Fix getParameter ...
980
			$dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false);
735c653b   Elena.Budnik   rank at observato...
981
		}
a21497cc   Elena.Budnik   redmine #5645
982
		else {
16035364   Benjamin Renard   First commit
983
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
984
985
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
986
987

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

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

98c5bd44   Benjamin Renard   Introduce anonymo...
995
		if ($dd->user == WSConfigClass::getAnonymousUserName())
16035364   Benjamin Renard   First commit
996
997
998
		{
			//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
999
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
1000
		}
32bb889b   Elena.Budnik   #5532 to process ...
1001
		else {
0fea5567   Benjamin Renard   First step for re...
1002
			// check disk space
2c7f2cb6   Benjamin Renard   Remove old log fi...
1003
1004
1005
1006
1007
1008
			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...
1009
		}
10200969   Roipoussiere   Remove whitespace...
1010

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

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

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

32bb889b   Elena.Budnik   #5532 to process ...
1019
1020
1021
		// 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...
1022
1023
				$function == FunctionTypeEnumClass::PARAMSGEN ||
				$function == FunctionTypeEnumClass::PARAMSINFOGEN )
32bb889b   Elena.Budnik   #5532 to process ...
1024
		{
7ac3e07e   Elena.Budnik   do not check user...
1025
1026
1027
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
8ba47f72   Benjamin Renard   rest actualisatio...
1028

16035364   Benjamin Renard   First commit
1029
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
1030
		try {
e57cb025   Benjamin Renard   Fix most of error...
1031
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
1032
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
1033
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
1034
		}
16035364   Benjamin Renard   First commit
1035
1036
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1037
1038
1039

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
1040
*/
735c653b   Elena.Budnik   rank at observato...
1041
1042
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
1043
1044
1045
1046
		// 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
1047
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
1048
1049
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
1050
1051
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
1052

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

16035364   Benjamin Renard   First commit
1057
/*
a0b3d64e   Benjamin Renard   Derived parameter...
1058
1059
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1060
1061
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
1062
1063
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
1064

8ba47f72   Benjamin Renard   rest actualisatio...
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076

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




a0b3d64e   Benjamin Renard   Derived parameter...
1077
1078
1079
/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1080
1081
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
1082
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
1083

a0b3d64e   Benjamin Renard   Derived parameter...
1084
1085
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
1086

a0b3d64e   Benjamin Renard   Derived parameter...
1087
1088
1089
1090
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
1091
1092
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
1093

a0b3d64e   Benjamin Renard   Derived parameter...
1094
/*
e6e5b259   Benjamin Renard   Add kill plot req...
1095
 * kill plot process
16035364   Benjamin Renard   First commit
1096
 */
10200969   Roipoussiere   Remove whitespace...
1097

735c653b   Elena.Budnik   rank at observato...
1098
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
1099
	{
735c653b   Elena.Budnik   rank at observato...
1100
1101
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
1102
1103
1104
1105

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

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

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

10200969   Roipoussiere   Remove whitespace...
1116

16035364   Benjamin Renard   First commit
1117
1118
1119
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
1120
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
1121
1122
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1123
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1124

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

735c653b   Elena.Budnik   rank at observato...
1128
1129
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1130

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

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


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

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

0fea5567   Benjamin Renard   First step for re...
1148
	public function initObjectCacheFromCatalog($id, $type)
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
1149
1150
1151
1152
1153
1154
        {
                $cacheMgr = new TimeTableCacheMgr();

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

19eca0a6   Hacene SI HADJ MOHAND   ok
1155
1156
1157
1158
        public function initObjectCacheFromTimeTable($id, $type, $nparams)
        {
                $cacheMgr = new CatalogCacheMgr();

ceac8bd0   Hacene SI HADJ MOHAND   us ok
1159
                return $cacheMgr->initFromTimeTable($id, $nparams, $type);
19eca0a6   Hacene SI HADJ MOHAND   ok
1160
1161
        }

0fea5567   Benjamin Renard   First step for re...
1162
	public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1163
	{
10200969   Roipoussiere   Remove whitespace...
1164
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1165
1166
1167
1168
		else  $cacheMgr = new CatalogCacheMgr();

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

0fea5567   Benjamin Renard   First step for re...
1170
	public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1171
	{
901ba3f3   Elena.Budnik   upload catalog
1172
1173
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1174
1175
		return $cacheMgr->initFromUploadedFile($name, $format);
	}
10200969   Roipoussiere   Remove whitespace...
1176

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

e57cb025   Benjamin Renard   Fix most of error...
1182
		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...
1183
	}
10200969   Roipoussiere   Remove whitespace...
1184

735c653b   Elena.Budnik   rank at observato...
1185
1186
	public function readIntervalsForChart($o)
	{
1a0151a5   Benjamin Renard   wip
1187
		$objMgr = new CatalogCacheMgr(TRUE);
b0720b91   Benjamin Renard   Finalize catalog ...
1188
		$objMgr->initFromObject($o->id, $o->type);
1a0151a5   Benjamin Renard   wip
1189
		return $objMgr->getIntervalsForChart();
735c653b   Elena.Budnik   rank at observato...
1190
	}
10200969   Roipoussiere   Remove whitespace...
1191

735c653b   Elena.Budnik   rank at observato...
1192
1193
1194
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1195
		return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
735c653b   Elena.Budnik   rank at observato...
1196
	}
10200969   Roipoussiere   Remove whitespace...
1197

342b20ca   Benjamin Renard   Fix inheritence b...
1198
	public function addCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1199
1200
1201
1202
1203
1204
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

735c653b   Elena.Budnik   rank at observato...
1206
1207
1208
1209
1210
1211
1212
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

342b20ca   Benjamin Renard   Fix inheritence b...
1214
	public function modifyCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1215
	{
10200969   Roipoussiere   Remove whitespace...
1216
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1217
		{
f9c8b272   elena   edit catalog
1218
			$cacheMgr = new CatalogCacheMgr();
f9c8b272   elena   edit catalog
1219
		}
735c653b   Elena.Budnik   rank at observato...
1220
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1221

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

f3e15e49   Erdogan Furkan   #10700 - Done
1225
	public function operationTTCacheIntervals($extendTime, $shiftTime, $isCat)
735c653b   Elena.Budnik   rank at observato...
1226
	{
f3e15e49   Erdogan Furkan   #10700 - Done
1227
1228
1229
1230
1231
1232
		if($isCat){
			$cacheMgr = new CatalogCacheMgr();
		}
		else{
			$cacheMgr = new TimeTableCacheMgr();
		}
735c653b   Elena.Budnik   rank at observato...
1233
1234
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1235

735c653b   Elena.Budnik   rank at observato...
1236
1237
1238
1239
1240
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1241

0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1242
	public function getTTCacheStatistics($obj)
735c653b   Elena.Budnik   rank at observato...
1243
	{
0fea5567   Benjamin Renard   First step for re...
1244
                if($obj->name == "timeTableUi"){
0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1245
1246
1247
1248
1249
1250
				$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...
1251
1252
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1253

735c653b   Elena.Budnik   rank at observato...
1254
1255
1256
1257
1258
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1259

16035364   Benjamin Renard   First commit
1260
1261
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1262
 *
16035364   Benjamin Renard   First commit
1263
 */
735c653b   Elena.Budnik   rank at observato...
1264
1265
1266
1267
1268
	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...
1269

16035364   Benjamin Renard   First commit
1270
1271
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1272
 *
16035364   Benjamin Renard   First commit
1273
 */
735c653b   Elena.Budnik   rank at observato...
1274
1275
1276
1277
1278
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1279

16035364   Benjamin Renard   First commit
1280
1281
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1282
1283
 *
 */
735c653b   Elena.Budnik   rank at observato...
1284
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1285
	{
735c653b   Elena.Budnik   rank at observato...
1286
1287
1288
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1289
1290

/*
16035364   Benjamin Renard   First commit
1291
1292
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1293
1294
1295
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1296
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1297

735c653b   Elena.Budnik   rank at observato...
1298
1299
1300
1301
1302
1303
		$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...
1304

735c653b   Elena.Budnik   rank at observato...
1305
1306
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1307
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1308
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1309

735c653b   Elena.Budnik   rank at observato...
1310
1311
1312
1313
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1314
	}
16035364   Benjamin Renard   First commit
1315
1316
1317
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1318
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1319
	{
10200969   Roipoussiere   Remove whitespace...
1320
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1321
1322
1323
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1324

735c653b   Elena.Budnik   rank at observato...
1325
1326
1327
1328
1329
1330
1331
1332
1333
	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...
1334

735c653b   Elena.Budnik   rank at observato...
1335
1336
	public function saveFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1337
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1338
1339
		return $filtersMgr->save($o);
	}
10200969   Roipoussiere   Remove whitespace...
1340

735c653b   Elena.Budnik   rank at observato...
1341
1342
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1343
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1344
1345
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1346

735c653b   Elena.Budnik   rank at observato...
1347
1348
1349
1350
1351
1352
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1353

735c653b   Elena.Budnik   rank at observato...
1354
1355
1356
1357
1358
1359
1360
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1361
1362
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1363
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1364
1365
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1366

fdf1413b   Elena.Budnik   TT download
1367
1368
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1369
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1370
1371
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1372

fdf1413b   Elena.Budnik   TT download
1373
1374
1375
1376
1377
1378
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1379

16035364   Benjamin Renard   First commit
1380
1381
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1382
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1383
		{
fdf1413b   Elena.Budnik   TT download
1384
1385
1386
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1387
		else
735c653b   Elena.Budnik   rank at observato...
1388
		{
fdf1413b   Elena.Budnik   TT download
1389
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1390
		}
16035364   Benjamin Renard   First commit
1391
		return;
10200969   Roipoussiere   Remove whitespace...
1392
	}
16035364   Benjamin Renard   First commit
1393

fdf1413b   Elena.Budnik   TT download
1394
1395
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1396
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1397
		{
10200969   Roipoussiere   Remove whitespace...
1398
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1399
1400
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1401
1402
1403
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1404
1405
1406
1407
1408
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1409

fdf1413b   Elena.Budnik   TT download
1410
1411
1412
1413
1414
1415
	// $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...
1416
1417

		return  $res;
fdf1413b   Elena.Budnik   TT download
1418
	}
10200969   Roipoussiere   Remove whitespace...
1419
1420

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1421
1422
1423
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1424

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1435
1436
1437
1438
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
278185de   Benjamin Renard   Upload catalog fr...
1439
		$this->rrmdir(USERDIR.'TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1440
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1441
1442

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

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

fdf1413b   Elena.Budnik   TT download
1450
1451
1452
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1453
1454
			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
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
					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...
1468
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1469
1470
1471
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1472

46c5751e   Benjamin Renard   Cleanup
1473
	public function interactivePlot($obj)
fdf1413b   Elena.Budnik   TT download
1474
	{
fdf1413b   Elena.Budnik   TT download
1475
1476
		$inputobj = (Object)array(
			'action' => $obj,
fdf1413b   Elena.Budnik   TT download
1477
1478
1479
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1480

735c653b   Elena.Budnik   rank at observato...
1481
1482
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1483
1484
1485
1486
1487
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1488

735c653b   Elena.Budnik   rank at observato...
1489
1490
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1491
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1492
1493
1494
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1495

735c653b   Elena.Budnik   rank at observato...
1496
1497
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1498
1499
1500
1501
1502
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1503

735c653b   Elena.Budnik   rank at observato...
1504
1505
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
2fa56f95   Benjamin Renard   Predefined templa...
1506
				'predefinedArgs' => !empty($obj->predefinedArgs),
bf74fc2d   Elena.Budnik   IMPEX
1507
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1508
1509
1510
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
bf776dc8   Benjamin Renard   working
1511
	public function getDerivedParamInfo($obj)
0fea5567   Benjamin Renard   First step for re...
1512
	{
bf776dc8   Benjamin Renard   working
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
                 $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...
1525

bf776dc8   Benjamin Renard   working
1526
		}
0fea5567   Benjamin Renard   First step for re...
1527
		return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
bf776dc8   Benjamin Renard   working
1528
	}
0fea5567   Benjamin Renard   First step for re...
1529

22d8d756   Hacene SI HADJ MOHAND   resolu
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
       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
1550
1551
1552
1553
1554
1555
	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...
1556
		}elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
bf776dc8   Benjamin Renard   working
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
		/* 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...
1584

10200969   Roipoussiere   Remove whitespace...
1585

bf776dc8   Benjamin Renard   working
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
			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...
1600

bf776dc8   Benjamin Renard   working
1601
1602
1603
1604
1605
1606
1607
			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...
1608
				'relatedDim'=>'dim' . ($j+1),
bf776dc8   Benjamin Renard   working
1609
1610
1611
1612
1613
1614
1615
1616
1617
				'name'=>'component' . ($j+1),
				'units'=>"",
				'variable'=>"",
				'channels'=>$compts,
				'minmax'=>""
				);

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

bf776dc8   Benjamin Renard   working
1619
1620
1621
1622
1623
1624
                  $data=array(
				'dimensions'=>$dims,
				'tables'=>$tables
			     );
		return array('success'=>true,'data'=>$data);
                }
0fea5567   Benjamin Renard   First step for re...
1625

bf776dc8   Benjamin Renard   working
1626
	}
735c653b   Elena.Budnik   rank at observato...
1627
1628
1629
1630
1631
1632
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1633

735c653b   Elena.Budnik   rank at observato...
1634
1635
1636
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1637
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1638
1639
1640
1641
1642
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1643

735c653b   Elena.Budnik   rank at observato...
1644
1645
1646
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1647

735c653b   Elena.Budnik   rank at observato...
1648
1649
1650
		$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...
1651

735c653b   Elena.Budnik   rank at observato...
1652
1653
1654
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1655

735c653b   Elena.Budnik   rank at observato...
1656
1657
1658
1659
1660
1661
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1662

0bda97f3   Benjamin Renard   Fix SAMP export f...
1663
1664
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1665
1666
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
2fa56f95   Benjamin Renard   Predefined templa...
1667
1668
1669
1670
1671
1672
1673
1674
1675

	public function parseTemplatedParam($paramTemplateId)
	{
		$args = (Object)array(
			'paramId' => $paramTemplateId,
			'type' => 'param_parse_template'
		);
		return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO);
	}
3d95b0a6   furkan   Adding the Delete...
1676
1677
1678
1679
1680
1681

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

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

ce347c54   Erdogan Furkan   Done.
1683
	public function addColumn($id, $name, $type, $size, $description, $status){
42c4ccd3   Erdogan Furkan   #9660 - Done
1684
		$cacheMgr = new CatalogCacheMgr();
ce347c54   Erdogan Furkan   Done.
1685
		return $cacheMgr->addColumn($id,$name, $type,$size,$description, $status);
42c4ccd3   Erdogan Furkan   #9660 - Done
1686
1687
1688
1689
1690
1691
1692
	}

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

ce347c54   Erdogan Furkan   Done.
1693
	public function editColumn($id, $name, $type, $size,$description, $status){
42c4ccd3   Erdogan Furkan   #9660 - Done
1694
		$cacheMgr = new CatalogCacheMgr();
ce347c54   Erdogan Furkan   Done.
1695
		return $cacheMgr->editColumn($id,$name, $type,$size,$description, $status);
42c4ccd3   Erdogan Furkan   #9660 - Done
1696
	}
851cf2f0   Erdogan Furkan   For now
1697
1698
1699

	public function getNodeValues($data,&$transformed){
		$iconCls = "task-folder";
851cf2f0   Erdogan Furkan   For now
1700
		foreach ($data as $parameter => $value) {
4f728fd9   Erdogan Furkan   For now 2
1701
			if(is_array($value) && !$value['modified']){
851cf2f0   Erdogan Furkan   For now
1702
1703
1704
1705
1706
1707
1708
				$child = [
					"parameter" => $parameter,
					"value" => "",
					"iconCls" => $iconCls,
					"expanded" => false,
					"children" => []
				];
4f728fd9   Erdogan Furkan   For now 2
1709

851cf2f0   Erdogan Furkan   For now
1710
1711
1712
				$this->getNodeValues($value,$child['children']);
				$transformed[] = $child;
			}
4f728fd9   Erdogan Furkan   For now 2
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
			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
1724
1725
1726
1727
1728
			else{
				$child =[
					"parameter" => $parameter,
					"value" => $value,
					"iconCls" => "task",
4f728fd9   Erdogan Furkan   For now 2
1729
1730
1731
					"leaf" => true,
					"modified" => false,
					"default" =>$value
851cf2f0   Erdogan Furkan   For now
1732
				];
851cf2f0   Erdogan Furkan   For now
1733
1734
1735
1736
				$transformed[] = $child;
			}
		}
	}
4f728fd9   Erdogan Furkan   For now 2
1737
1738
	public function getDefaultValueConfigs(){
		if (file_exists(DATAPATH.'defaultValuesConfig.json'))
b1dc2eb3   Erdogan Furkan   More modifications
1739
			return array('success' => true , 'configs' => json_decode(file_get_contents(DATAPATH.'defaultValuesConfig.json'), true));
4f728fd9   Erdogan Furkan   For now 2
1740
		else
b1dc2eb3   Erdogan Furkan   More modifications
1741
			return array('success' => false , 'configs' => array(), 'message'=>'Error : No default value configs file.');
4f728fd9   Erdogan Furkan   For now 2
1742
1743
1744
	}

	public function getDefaultValueLinks(){
b1dc2eb3   Erdogan Furkan   More modifications
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
		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
1759
	}
851cf2f0   Erdogan Furkan   For now
1760

4f728fd9   Erdogan Furkan   For now 2
1761
	public function getDefaultValueTree($isTree=TRUE){
851cf2f0   Erdogan Furkan   For now
1762
1763
		$childrenToReturn = array();
		$children = [];
b1dc2eb3   Erdogan Furkan   More modifications
1764
		if (!file_exists(DATAPATH.'defaultValues.json')) 
a2b8ec19   Benjamin Renard   Fix userDefaults....
1765
			return array('success' => false , 'defaultValues' => array(), 'message'=>'Defaultvalues file not found.');
b1dc2eb3   Erdogan Furkan   More modifications
1766
1767
1768
1769
		$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....
1770
1771
1772
1773
1774
1775
		$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
1776
1777
1778
1779
1780
1781

		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
1782
			}
b1dc2eb3   Erdogan Furkan   More modifications
1783
1784
1785
1786
			if($isTree)
				$results = array("value" => $value, "modified" => true, "defaultValue" => $results);
			else
				$results = $value;
851cf2f0   Erdogan Furkan   For now
1787
		}
b1dc2eb3   Erdogan Furkan   More modifications
1788
1789
1790
1791
		
		if($isTree){
			$this->getNodeValues($json_o,$children);
			return [ "text" => ".", "children" => $children ];
851cf2f0   Erdogan Furkan   For now
1792
		}
b1dc2eb3   Erdogan Furkan   More modifications
1793
1794

		return array('success' => true , 'defaultValues' => $json_o);
851cf2f0   Erdogan Furkan   For now
1795
	}
239d9f8f   Erdogan Furkan   First Working ver...
1796
1797
1798

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

239d9f8f   Erdogan Furkan   First Working ver...
1802
1803
1804
1805
		file_put_contents(USERDIR.'userDefaults.json',$json_user);

		return array('success' => true);
	}
16035364   Benjamin Renard   First commit
1806
1807
}
?>