Blame view

php/classes/AmdaAction.php 45.4 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;
0fea5567   Benjamin Renard   First step for re...
64

735c653b   Elena.Budnik   rank at observato...
65
66
		$remoteBase = false;
		$isRemoteDataSet = false;
16035364   Benjamin Renard   First commit
67

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

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

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

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

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

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

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

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

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

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

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

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

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

f569bae5   Benjamin Renard   Save download
173
						case 'download':
735c653b   Elena.Budnik   rank at observato...
174
						case 'condition':
33519521   Benjamin Renard   Fix saved request...
175
						case 'request':
2e7079bb   Benjamin Renard   First implementat...
176
						case 'statistic':
638db58d   Benjamin Renard   RequestMgr constr...
177
							$objectMgr = new RequestMgr($nodeType);
33519521   Benjamin Renard   Fix saved request...
178
							$info = $objectMgr->getObjectInfo($id);
698494ac   Benjamin Renard   Add tooltip for s...
179
180
181
182
							$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
183
							break;
8b6bb092   Elena.Budnik   icones if rank is...
184
						
735c653b   Elena.Budnik   rank at observato...
185
						case 'timeTable':
10200969   Roipoussiere   Remove whitespace...
186
						case 'catalog':
735c653b   Elena.Budnik   rank at observato...
187
188
							if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
						break;
10200969   Roipoussiere   Remove whitespace...
189

735c653b   Elena.Budnik   rank at observato...
190
191
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
192
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
193
194
195
196
							{
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('nbIntervals').'<br/>';
								$info .= '<b>Shared by:</b> '.$child->getAttribute('sharedBy').' ('.$child->getAttribute('sharedDate').')<br/>';
								$info .= '<b>Description:</b> '.$child->getAttribute('description');
8b6bb092   Elena.Budnik   icones if rank is...
197
							} 
735c653b   Elena.Budnik   rank at observato...
198
199
						break;
						case 'derivedParam':
09a0cb29   Hacene SI HADJ MOHAND   us ok
200
                                                        error_log("child");
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
201
202
  							$info = $child->getAttribute('buildchain').'<br/>';
							                                        
09a0cb29   Hacene SI HADJ MOHAND   us ok
203
204
							if($child->hasAttribute('units') && $child->getAttribute('units') != 'undefined')
                                                             $info .= 'Units: '.$child->getAttribute('units').'<br/>';
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
205
206
   							$samplingMode = $child->getAttribute('sampling_mode');
 						  	if($samplingMode == 'timestep'){
09a0cb29   Hacene SI HADJ MOHAND   us ok
207
      								$info .= 'Sampling Time: '.$child->getAttribute('timestep');
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
208
   							}else if($samplingMode == 'refparam'){
09a0cb29   Hacene SI HADJ MOHAND   us ok
209
      								$info .= 'Reference Parameter: '.$child->getAttribute('reference_param');
5f42fc77   Hacene SI HADJ MOHAND   get attributes ko
210
			 	 			}			
0fea5567   Benjamin Renard   First step for re...
211

8ba47f72   Benjamin Renard   rest actualisatio...
212
213
214
215
216
217
218
							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...
219
220
221
222
223
224
225
226
227
228
229
							if ($isLeaf) $isParameter = true;
						break;

						case 'localParam':

							$globalStart = null;
							$globalStop = null;
							$timeRestriction = false;
							$specialNode = true;
							$isParameter = false;
							$needsArgs = false;
10200969   Roipoussiere   Remove whitespace...
230
							$isSpectra = false;
dc9e2c14   Elena.Budnik   init + message + ...
231
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
232
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
233
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
234

10200969   Roipoussiere   Remove whitespace...
235
236
							if ($child->hasAttribute('desc'))
							{
735c653b   Elena.Budnik   rank at observato...
237
								$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
238

c57c57c9   Elena.Budnik   info message depe...
239
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
67bd6ed6   Elena.Budnik   rm 8375
240
241
242
243
244
245
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"; 
                                        $child->setAttribute('dataStart', date("Y-m-d\TH:i:s\Z", strtotime(' -1 day')));
                                        $child->setAttribute('dataStop', date("Y-m-d\TH:i:s\Z", time()));                                        
                                    } else {
                                        $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
                                    }
                                    
a7316784   Elena.Budnik   add LastUpdate to...
253
254
255
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
256
								}
735c653b   Elena.Budnik   rank at observato...
257
							}
10200969   Roipoussiere   Remove whitespace...
258

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

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

cbbbdc34   Elena.Budnik   param description...
263
264
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description')."<br/>".$units;
0fea5567   Benjamin Renard   First step for re...
265
								else
cbbbdc34   Elena.Budnik   param description...
266
267
									$info = $units;
							}
71b9368c   Benjamin Renard   Fix bug with tool...
268
269
270
271
							else {
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description');
							}
0fea5567   Benjamin Renard   First step for re...
272

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

				if ($child->hasAttribute('PredefinedTemplatedParameter'))
					$predefinedArgs = true;
67bd6ed6   Elena.Budnik   rm 8375
280
                                    
c57c57c9   Elena.Budnik   info message depe...
281
								if ($child->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
282
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
283
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
284
								}
0fea5567   Benjamin Renard   First step for re...
285

f29c5e66   Elena.Budnik   plot only option
286
287
288
289
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
290
								}
3afe4f59   Benjamin Renard   Add datasets time...
291
292
293
294

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

735c653b   Elena.Budnik   rank at observato...
297
298
299
300
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
301

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

f29c5e66   Elena.Budnik   plot only option
307
308
309
310
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
311
								}
3afe4f59   Benjamin Renard   Add datasets time...
312
313
314
315

								if ($child->parentNode->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
316
317
318
319
320

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

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

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

f31bea1c   Benjamin Renard   wip for save plot
337

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

3afe4f59   Benjamin Renard   Add datasets time...
354
355
356
357
								if ($child->hasAttribute("timeRestriction")) {
									$timeRestriction = $child->getAttribute("timeRestriction");
								}
								$disable = TRUE;
acf87705   Elena.Budnik   bug in disable param
358

3afe4f59   Benjamin Renard   Add datasets time...
359
								if ($child->hasAttribute('group')) {
c3976709   Elena.Budnik   rm 7589 + clean u...
360
361
									if ($child->getAttribute("group") === "TBD") {
											$info .=  "<br/><b>Under Testing</b>";
3afe4f59   Benjamin Renard   Add datasets time...
362
									}
1c2f5368   Elena.Budnik   message for TimeR...
363
									else {	
3afe4f59   Benjamin Renard   Add datasets time...
364
365
										if (!empty($timeRestriction)) {
											$disable = FALSE;
1c2f5368   Elena.Budnik   message for TimeR...
366
367
368
369
370
											$formattedTimeRestriction = date("Y-m-d\TH:i:s\Z",strtotime($timeRestriction)+1);
											$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...
371
										}
735c653b   Elena.Budnik   rank at observato...
372
									}
0fea5567   Benjamin Renard   First step for re...
373
								}
acf87705   Elena.Budnik   bug in disable param
374
								else {
3afe4f59   Benjamin Renard   Add datasets time...
375
									$disable = FALSE;
acf87705   Elena.Budnik   bug in disable param
376
377
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
378
379
								}

698494ac   Benjamin Renard   Add tooltip for s...
380
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'last_update' => $last_update,
3afe4f59   Benjamin Renard   Add datasets time...
381
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank, 'timeRestriction' => $timeRestriction);
735c653b   Elena.Budnik   rank at observato...
382
383
384
385
							}
						break;

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

bf74fc2d   Elena.Budnik   IMPEX
387
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
388
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
389
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
390
391

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
392
393
394
395
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
396
397

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
398
							{
10200969   Roipoussiere   Remove whitespace...
399
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
400
								{
10200969   Roipoussiere   Remove whitespace...
401
402
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
403
								}
10200969   Roipoussiere   Remove whitespace...
404
								else
735c653b   Elena.Budnik   rank at observato...
405
406
407
408
409
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
410
411

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
412
413
414
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
415

bf74fc2d   Elena.Budnik   IMPEX
416
417
							if ( $child->tagName == 'parameter')
							{
abb54096   Elena.Budnik   time interval by ...
418
								if ($child->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
419
									{
abb54096   Elena.Budnik   time interval by ...
420
421
										$globalStart = $child->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
422
423
									}
							}
10200969   Roipoussiere   Remove whitespace...
424

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

735c653b   Elena.Budnik   rank at observato...
434
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
435
436

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
437
438
439
440
441
442
443
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
444
445
446
447
448
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
449
							{
10200969   Roipoussiere   Remove whitespace...
450
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
451
452
453
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
454
455
								default:
							}
10200969   Roipoussiere   Remove whitespace...
456

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

10200969   Roipoussiere   Remove whitespace...
459
460
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
461
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
462
463
464
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
465
466
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
467
							}
10200969   Roipoussiere   Remove whitespace...
468

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

10200969   Roipoussiere   Remove whitespace...
471
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
472
							{
10200969   Roipoussiere   Remove whitespace...
473
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
474
							}
0fea5567   Benjamin Renard   First step for re...
475

a0f13ed1   Elena.Budnik   small format + ti...
476
477
478
479
480
481
							if ($child->tagName == 'parameter'){
								if ($child->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
735c653b   Elena.Budnik   rank at observato...
482

a0f13ed1   Elena.Budnik   small format + ti...
483
484
485
486
487
488
							if ( $child->tagName == 'component'){
								if ($child->parentNode->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
0fea5567   Benjamin Renard   First step for re...
489

10200969   Roipoussiere   Remove whitespace...
490
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
491
							{
10200969   Roipoussiere   Remove whitespace...
492
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
493
494
495
496
497
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
498
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
499
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
500
								}
bf74fc2d   Elena.Budnik   IMPEX
501
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
502
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
503
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
504
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
505
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => isset($component_info) ? $component_info : NULL);
bf74fc2d   Elena.Budnik   IMPEX
506
								else
10200969   Roipoussiere   Remove whitespace...
507
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
508
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
509
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
510
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
511
							}
10200969   Roipoussiere   Remove whitespace...
512
513
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
514
								$restricted = FALSE;
0fea5567   Benjamin Renard   First step for re...
515

735c653b   Elena.Budnik   rank at observato...
516
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
517
								{
735c653b   Elena.Budnik   rank at observato...
518
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
519
								}
735c653b   Elena.Budnik   rank at observato...
520
								else
6657f68b   Elena.Budnik   monitor impex ser...
521
								{
735c653b   Elena.Budnik   rank at observato...
522
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
523
								}
10200969   Roipoussiere   Remove whitespace...
524

735c653b   Elena.Budnik   rank at observato...
525
526
527
528
529
530
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

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

10200969   Roipoussiere   Remove whitespace...
531
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
532
533
534
535
536
537
538
539
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

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

735c653b   Elena.Budnik   rank at observato...
541
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
542
543
544
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
545
						break;
10200969   Roipoussiere   Remove whitespace...
546
547
548

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
549
550
551
552
553
554
555
556
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
557
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
558
							$sampling = null;
0fea5567   Benjamin Renard   First step for re...
559
							if ($child->hasAttribute('minsampling'))
19dcd963   Elena.Budnik   redmine #4903 : s...
560
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
561
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
562
563

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
564
565
566
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
567
568
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
569
570
571
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
572
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
573
574
575
576
577
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
578
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
579
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
580
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
581
582
583
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
10200969   Roipoussiere   Remove whitespace...
584
						default:
735c653b   Elena.Budnik   rank at observato...
585
					}
10200969   Roipoussiere   Remove whitespace...
586
587

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
588
					{
10200969   Roipoussiere   Remove whitespace...
589
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
590
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
591
592

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
593
594
595
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
596
597

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
2048f5bc   Benjamin Renard   Fix save & edit plot
598
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2,
0fea5567   Benjamin Renard   First step for re...
599
													'component_info' => isset($component_info) ? $component_info : NULL,
698494ac   Benjamin Renard   Add tooltip for s...
600
													'iconCls' => isset($iconCls) ? $iconCls : NULL, 'last_update' => $last_update );
735c653b   Elena.Budnik   rank at observato...
601
602
603
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
604
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
605
				{
735c653b   Elena.Budnik   rank at observato...
606
607
608
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
609
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
610
	}
16035364   Benjamin Renard   First commit
611

0dc31ba8   Elena.Budnik   remoteParamManage...
612
613
614
	/*
	*  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...
615
	*  create Remote Parameter Description
0dc31ba8   Elena.Budnik   remoteParamManage...
616
	*/
10200969   Roipoussiere   Remove whitespace...
617
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
618
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
619
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
620
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
621

2b8ea2a7   Elena.Budnik   RemoteParamManage...
622
623
		if ($res['success'])
			return $paramMgr->saveTree($obj);
0fea5567   Benjamin Renard   First step for re...
624
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
625
			return $res;
735c653b   Elena.Budnik   rank at observato...
626
	}
0fea5567   Benjamin Renard   First step for re...
627

0dc31ba8   Elena.Budnik   remoteParamManage...
628
629
630
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
631
632
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
633
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
634
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
635

2b8ea2a7   Elena.Budnik   RemoteParamManage...
636
637
		if ($res['success'])
			return $paramMgr->deleteFromTree($obj);
0fea5567   Benjamin Renard   First step for re...
638
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
639
			return $res;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
640
	}
0fea5567   Benjamin Renard   First step for re...
641

0dc31ba8   Elena.Budnik   remoteParamManage...
642
643
644
645
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
646

0dc31ba8   Elena.Budnik   remoteParamManage...
647
648
649
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
650
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
651
	{
5f8bd1f5   Nathanaël Jourdane   Fix Windows-files...
652
653
654
		$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...
655
		$isTTCat = FALSE;
10200969   Roipoussiere   Remove whitespace...
656
		switch ($nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
657
		{
10200969   Roipoussiere   Remove whitespace...
658
659
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
42e2e019   Benjamin Renard   Next step for cac...
660
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
661
				break;
10200969   Roipoussiere   Remove whitespace...
662
663
664
665
666
			case 'myDataParam' :
				$objectMgr = new FilesMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
42e2e019   Benjamin Renard   Next step for cac...
667
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
668
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
669
670
671
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
42e2e019   Benjamin Renard   Next step for cac...
672
673
674
675
676
677
		if ($isTTCat) {
			//Pre-process: convert to INTERNAL format if needed
			if (($format == 'ASCII') || ($format == 'VOT')) {
				$result = $this->executeRequest((Object) array(
					'compression' => 'none',
					'fileformat' => 'internal',
698c7971   Benjamin Renard   Fix regression in...
678
                                        'timeformat' => 'YYYY-MM-DDThh:mm:ss',
42e2e019   Benjamin Renard   Next step for cac...
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
					'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
701
		return  $objectMgr->getUploadedObject($name, $format, true);
10200969   Roipoussiere   Remove whitespace...
702
	}
16035364   Benjamin Renard   First commit
703

0dc31ba8   Elena.Budnik   remoteParamManage...
704
705
706
	/*
	*  fill ascii file into grid
	*/
10200969   Roipoussiere   Remove whitespace...
707
708
709
	public  function getAsciiFile($obj)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
710
		return  $objectMgr->getAsciiFile($obj->fileName);
735c653b   Elena.Budnik   rank at observato...
711
	}
10200969   Roipoussiere   Remove whitespace...
712
713
714
715

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

0dc31ba8   Elena.Budnik   remoteParamManage...
719
720
721
	/*
	*  get temporary object from Search
	*/
10200969   Roipoussiere   Remove whitespace...
722
723
724
	public  function getTmpObject($folderId, $name, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
725
		{
10200969   Roipoussiere   Remove whitespace...
726
727
728
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
729
			case 'catalog' :
10200969   Roipoussiere   Remove whitespace...
730
731
				$objectMgr = new CatalogMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
732
733
734
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
735
		return  $objectMgr->getTmpObject($folderId, $name, true);
fdf1413b   Elena.Budnik   TT download
736
	}
735c653b   Elena.Budnik   rank at observato...
737

10200969   Roipoussiere   Remove whitespace...
738
739
740
741

	public  function getObject($id, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
742
743
		{
			case 'myDataParam':
10200969   Roipoussiere   Remove whitespace...
744
745
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($nodeType);
735c653b   Elena.Budnik   rank at observato...
746
				break;
10200969   Roipoussiere   Remove whitespace...
747
			case 'timeTable' :
735c653b   Elena.Budnik   rank at observato...
748
			case 'sharedtimeTable' :
10200969   Roipoussiere   Remove whitespace...
749
750
				$objectMgr = new TimeTableMgr();
				break;
735c653b   Elena.Budnik   rank at observato...
751
752
			case 'catalog' :
			case 'sharedcatalog' :
10200969   Roipoussiere   Remove whitespace...
753
754
755
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
756
			case 'request' :
f569bae5   Benjamin Renard   Save download
757
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
758
			case 'statistic':
10200969   Roipoussiere   Remove whitespace...
759
760
				$objectMgr = new RequestMgr($nodeType);
				break;
0fea5567   Benjamin Renard   First step for re...
761
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
762
763
764
				return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
				break;
			case 'myData' :
10200969   Roipoussiere   Remove whitespace...
765
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
766
				break;
10200969   Roipoussiere   Remove whitespace...
767
			default:
735c653b   Elena.Budnik   rank at observato...
768
769
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
770
		return  $objectMgr->getObject($id, $nodeType);
fdf1413b   Elena.Budnik   TT download
771
	}
10200969   Roipoussiere   Remove whitespace...
772

16035364   Benjamin Renard   First commit
773
774
775
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
776
777
778
779
780
781
782
	public  function deleteObject($obj)
	{
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
783
				break;
10200969   Roipoussiere   Remove whitespace...
784
785
786
787
788
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
735c653b   Elena.Budnik   rank at observato...
789
				break;
10200969   Roipoussiere   Remove whitespace...
790
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
791
			case 'request' :
f569bae5   Benjamin Renard   Save download
792
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
793
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
794
				$objectMgr = new RequestMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
795
796
797
798
				break;
			case 'alias' :
				$objectMgr = new AliasMgr();
				$obj->id = substr($obj->id,strlen('alias_'));
10200969   Roipoussiere   Remove whitespace...
799
				break;
735c653b   Elena.Budnik   rank at observato...
800
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
801
802
803
				return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);

			case 'myData' :
16035364   Benjamin Renard   First commit
804
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
805
806
807
808
809
810
				break;
			default:
					return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> deleteObject($obj);
	}
16035364   Benjamin Renard   First commit
811
812
813
814

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

16035364   Benjamin Renard   First commit
820
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
821
822
823
824
825
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
826
			   break;
10200969   Roipoussiere   Remove whitespace...
827
828
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
829
			   break;
10200969   Roipoussiere   Remove whitespace...
830
831
		  case 'condition' :
		  case 'request' :
f569bae5   Benjamin Renard   Save download
832
		  case 'download' :
2e7079bb   Benjamin Renard   First implementat...
833
		  case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
834
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
835
836
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
837
838
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
839
840
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
841
		}
16035364   Benjamin Renard   First commit
842

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

10200969   Roipoussiere   Remove whitespace...
846
/*
16035364   Benjamin Renard   First commit
847
848
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
849
850
851
	public  function createObject($obj, $folder)
	{
		switch ($obj->nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
852
		{
10200969   Roipoussiere   Remove whitespace...
853
			case 'myDataParam' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
854
			case 'derivedParam' :
10200969   Roipoussiere   Remove whitespace...
855
				if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
856
						$this->amdaStat->addTask($this->user, 'create', null);
10200969   Roipoussiere   Remove whitespace...
857
				$objectMgr = new DerivedParamMgr($obj->nodeType);
8ba47f72   Benjamin Renard   rest actualisatio...
858
                 	break;
10200969   Roipoussiere   Remove whitespace...
859
860
861
862
863
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
864
			   break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
865
			case 'condition' :
10200969   Roipoussiere   Remove whitespace...
866
			case 'request' :
f569bae5   Benjamin Renard   Save download
867
			case 'download' :
2e7079bb   Benjamin Renard   First implementat...
868
			case 'statistic' :
10200969   Roipoussiere   Remove whitespace...
869
870
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
871
			case 'alias' :
10200969   Roipoussiere   Remove whitespace...
872
873
				$objectMgr = new AliasMgr();
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
874
875
876
877
878
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> createObject($obj, $folder);
	}
16035364   Benjamin Renard   First commit
879

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


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

16035364   Benjamin Renard   First commit
958
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
959
		{
e5ab198f   Nathanael Jourdane   simple getStatus
960
			$dd = new WSUserMgr();
039d19ac   Benjamin Renard   Fix getParameter ...
961
			$dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false);
735c653b   Elena.Budnik   rank at observato...
962
		}
a21497cc   Elena.Budnik   redmine #5645
963
		else {
16035364   Benjamin Renard   First commit
964
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
965
966
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
967
968

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

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

98c5bd44   Benjamin Renard   Introduce anonymo...
976
		if ($dd->user == WSConfigClass::getAnonymousUserName())
16035364   Benjamin Renard   First commit
977
978
979
		{
			//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
980
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
981
		}
32bb889b   Elena.Budnik   #5532 to process ...
982
		else {
0fea5567   Benjamin Renard   First step for re...
983
			// check disk space
2c7f2cb6   Benjamin Renard   Remove old log fi...
984
985
986
987
988
989
			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...
990
		}
10200969   Roipoussiere   Remove whitespace...
991

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

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

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

32bb889b   Elena.Budnik   #5532 to process ...
1000
1001
1002
		// 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...
1003
1004
				$function == FunctionTypeEnumClass::PARAMSGEN ||
				$function == FunctionTypeEnumClass::PARAMSINFOGEN )
32bb889b   Elena.Budnik   #5532 to process ...
1005
		{
7ac3e07e   Elena.Budnik   do not check user...
1006
1007
1008
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
8ba47f72   Benjamin Renard   rest actualisatio...
1009

16035364   Benjamin Renard   First commit
1010
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
1011
		try {
e57cb025   Benjamin Renard   Fix most of error...
1012
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
1013
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
1014
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
1015
		}
16035364   Benjamin Renard   First commit
1016
1017
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1018
1019
1020

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
1021
*/
735c653b   Elena.Budnik   rank at observato...
1022
1023
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
1024
1025
1026
1027
		// 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
1028
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
1029
1030
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
1031
1032
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
1033

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

16035364   Benjamin Renard   First commit
1038
/*
a0b3d64e   Benjamin Renard   Derived parameter...
1039
1040
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1041
1042
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
1043
1044
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
1045

8ba47f72   Benjamin Renard   rest actualisatio...
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057

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




a0b3d64e   Benjamin Renard   Derived parameter...
1058
1059
1060
/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1061
1062
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
1063
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
1064

a0b3d64e   Benjamin Renard   Derived parameter...
1065
1066
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
1067

a0b3d64e   Benjamin Renard   Derived parameter...
1068
1069
1070
1071
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
1072
1073
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
1074

a0b3d64e   Benjamin Renard   Derived parameter...
1075
/*
e6e5b259   Benjamin Renard   Add kill plot req...
1076
 * kill plot process
16035364   Benjamin Renard   First commit
1077
 */
10200969   Roipoussiere   Remove whitespace...
1078

735c653b   Elena.Budnik   rank at observato...
1079
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
1080
	{
735c653b   Elena.Budnik   rank at observato...
1081
1082
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
1083
1084
1085
1086

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

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

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

10200969   Roipoussiere   Remove whitespace...
1097

16035364   Benjamin Renard   First commit
1098
1099
1100
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
1101
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
1102
1103
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1104
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1105

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

735c653b   Elena.Budnik   rank at observato...
1109
1110
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1111

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

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


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

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

0fea5567   Benjamin Renard   First step for re...
1129
	public function initObjectCacheFromCatalog($id, $type)
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
1130
1131
1132
1133
1134
1135
        {
                $cacheMgr = new TimeTableCacheMgr();

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

19eca0a6   Hacene SI HADJ MOHAND   ok
1136
1137
1138
1139
        public function initObjectCacheFromTimeTable($id, $type, $nparams)
        {
                $cacheMgr = new CatalogCacheMgr();

ceac8bd0   Hacene SI HADJ MOHAND   us ok
1140
                return $cacheMgr->initFromTimeTable($id, $nparams, $type);
19eca0a6   Hacene SI HADJ MOHAND   ok
1141
1142
        }

0fea5567   Benjamin Renard   First step for re...
1143
	public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1144
	{
10200969   Roipoussiere   Remove whitespace...
1145
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1146
1147
1148
1149
		else  $cacheMgr = new CatalogCacheMgr();

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

0fea5567   Benjamin Renard   First step for re...
1151
	public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1152
	{
901ba3f3   Elena.Budnik   upload catalog
1153
1154
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1155
1156
		return $cacheMgr->initFromUploadedFile($name, $format);
	}
10200969   Roipoussiere   Remove whitespace...
1157

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

e57cb025   Benjamin Renard   Fix most of error...
1163
		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...
1164
	}
10200969   Roipoussiere   Remove whitespace...
1165

735c653b   Elena.Budnik   rank at observato...
1166
1167
	public function readIntervalsForChart($o)
	{
1a0151a5   Benjamin Renard   wip
1168
		$objMgr = new CatalogCacheMgr(TRUE);
b0720b91   Benjamin Renard   Finalize catalog ...
1169
		$objMgr->initFromObject($o->id, $o->type);
1a0151a5   Benjamin Renard   wip
1170
		return $objMgr->getIntervalsForChart();
735c653b   Elena.Budnik   rank at observato...
1171
	}
10200969   Roipoussiere   Remove whitespace...
1172

735c653b   Elena.Budnik   rank at observato...
1173
1174
1175
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1176
		return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
735c653b   Elena.Budnik   rank at observato...
1177
	}
10200969   Roipoussiere   Remove whitespace...
1178

342b20ca   Benjamin Renard   Fix inheritence b...
1179
	public function addCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1180
1181
1182
1183
1184
1185
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

735c653b   Elena.Budnik   rank at observato...
1187
1188
1189
1190
1191
1192
1193
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

342b20ca   Benjamin Renard   Fix inheritence b...
1195
	public function modifyCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1196
	{
10200969   Roipoussiere   Remove whitespace...
1197
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1198
		{
f9c8b272   elena   edit catalog
1199
			$cacheMgr = new CatalogCacheMgr();
f9c8b272   elena   edit catalog
1200
		}
735c653b   Elena.Budnik   rank at observato...
1201
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1202

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

735c653b   Elena.Budnik   rank at observato...
1206
1207
1208
1209
1210
	public function operationTTCacheIntervals($extendTime, $shiftTime)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1211

735c653b   Elena.Budnik   rank at observato...
1212
1213
1214
1215
1216
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1217

0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1218
	public function getTTCacheStatistics($obj)
735c653b   Elena.Budnik   rank at observato...
1219
	{
0fea5567   Benjamin Renard   First step for re...
1220
                if($obj->name == "timeTableUi"){
0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1221
1222
1223
1224
1225
1226
				$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...
1227
1228
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1229

735c653b   Elena.Budnik   rank at observato...
1230
1231
1232
1233
1234
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1235

16035364   Benjamin Renard   First commit
1236
1237
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1238
 *
16035364   Benjamin Renard   First commit
1239
 */
735c653b   Elena.Budnik   rank at observato...
1240
1241
1242
1243
1244
	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...
1245

16035364   Benjamin Renard   First commit
1246
1247
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1248
 *
16035364   Benjamin Renard   First commit
1249
 */
735c653b   Elena.Budnik   rank at observato...
1250
1251
1252
1253
1254
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1255

16035364   Benjamin Renard   First commit
1256
1257
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1258
1259
 *
 */
735c653b   Elena.Budnik   rank at observato...
1260
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1261
	{
735c653b   Elena.Budnik   rank at observato...
1262
1263
1264
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1265
1266

/*
16035364   Benjamin Renard   First commit
1267
1268
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1269
1270
1271
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1272
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1273

735c653b   Elena.Budnik   rank at observato...
1274
1275
1276
1277
1278
1279
		$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...
1280

735c653b   Elena.Budnik   rank at observato...
1281
1282
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1283
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1284
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1285

735c653b   Elena.Budnik   rank at observato...
1286
1287
1288
1289
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1290
	}
16035364   Benjamin Renard   First commit
1291
1292
1293
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1294
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1295
	{
10200969   Roipoussiere   Remove whitespace...
1296
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1297
1298
1299
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1300

735c653b   Elena.Budnik   rank at observato...
1301
1302
1303
1304
1305
1306
1307
1308
1309
	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...
1310

735c653b   Elena.Budnik   rank at observato...
1311
1312
	public function saveFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1313
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1314
1315
		return $filtersMgr->save($o);
	}
10200969   Roipoussiere   Remove whitespace...
1316

735c653b   Elena.Budnik   rank at observato...
1317
1318
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1319
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1320
1321
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1322

735c653b   Elena.Budnik   rank at observato...
1323
1324
1325
1326
1327
1328
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1329

735c653b   Elena.Budnik   rank at observato...
1330
1331
1332
1333
1334
1335
1336
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1337
1338
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1339
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1340
1341
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1342

fdf1413b   Elena.Budnik   TT download
1343
1344
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1345
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1346
1347
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1348

fdf1413b   Elena.Budnik   TT download
1349
1350
1351
1352
1353
1354
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1355

16035364   Benjamin Renard   First commit
1356
1357
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1358
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1359
		{
fdf1413b   Elena.Budnik   TT download
1360
1361
1362
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1363
		else
735c653b   Elena.Budnik   rank at observato...
1364
		{
fdf1413b   Elena.Budnik   TT download
1365
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1366
		}
16035364   Benjamin Renard   First commit
1367
		return;
10200969   Roipoussiere   Remove whitespace...
1368
	}
16035364   Benjamin Renard   First commit
1369

fdf1413b   Elena.Budnik   TT download
1370
1371
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1372
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1373
		{
10200969   Roipoussiere   Remove whitespace...
1374
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1375
1376
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1377
1378
1379
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1380
1381
1382
1383
1384
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1385

fdf1413b   Elena.Budnik   TT download
1386
1387
1388
1389
1390
1391
	// $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...
1392
1393

		return  $res;
fdf1413b   Elena.Budnik   TT download
1394
	}
10200969   Roipoussiere   Remove whitespace...
1395
1396

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1397
1398
1399
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1400

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1411
1412
1413
1414
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
278185de   Benjamin Renard   Upload catalog fr...
1415
		$this->rrmdir(USERDIR.'TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1416
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1417
1418

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

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

fdf1413b   Elena.Budnik   TT download
1426
1427
1428
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1429
1430
			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
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
					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...
1444
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1445
1446
1447
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1448

46c5751e   Benjamin Renard   Cleanup
1449
	public function interactivePlot($obj)
fdf1413b   Elena.Budnik   TT download
1450
	{
fdf1413b   Elena.Budnik   TT download
1451
1452
		$inputobj = (Object)array(
			'action' => $obj,
fdf1413b   Elena.Budnik   TT download
1453
1454
1455
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1456

735c653b   Elena.Budnik   rank at observato...
1457
1458
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1459
1460
1461
1462
1463
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1464

735c653b   Elena.Budnik   rank at observato...
1465
1466
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1467
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1468
1469
1470
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1471

735c653b   Elena.Budnik   rank at observato...
1472
1473
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1474
1475
1476
1477
1478
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1479

735c653b   Elena.Budnik   rank at observato...
1480
1481
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
2fa56f95   Benjamin Renard   Predefined templa...
1482
				'predefinedArgs' => !empty($obj->predefinedArgs),
bf74fc2d   Elena.Budnik   IMPEX
1483
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1484
1485
1486
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
bf776dc8   Benjamin Renard   working
1487
	public function getDerivedParamInfo($obj)
0fea5567   Benjamin Renard   First step for re...
1488
	{
bf776dc8   Benjamin Renard   working
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
                 $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...
1501

bf776dc8   Benjamin Renard   working
1502
		}
0fea5567   Benjamin Renard   First step for re...
1503
		return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
bf776dc8   Benjamin Renard   working
1504
	}
0fea5567   Benjamin Renard   First step for re...
1505

22d8d756   Hacene SI HADJ MOHAND   resolu
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
       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
1526
1527
1528
1529
1530
1531
	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...
1532
		}elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
bf776dc8   Benjamin Renard   working
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
		/* 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...
1560

10200969   Roipoussiere   Remove whitespace...
1561

bf776dc8   Benjamin Renard   working
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
			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...
1576

bf776dc8   Benjamin Renard   working
1577
1578
1579
1580
1581
1582
1583
			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...
1584
				'relatedDim'=>'dim' . ($j+1),
bf776dc8   Benjamin Renard   working
1585
1586
1587
1588
1589
1590
1591
1592
1593
				'name'=>'component' . ($j+1),
				'units'=>"",
				'variable'=>"",
				'channels'=>$compts,
				'minmax'=>""
				);

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

bf776dc8   Benjamin Renard   working
1595
1596
1597
1598
1599
1600
                  $data=array(
				'dimensions'=>$dims,
				'tables'=>$tables
			     );
		return array('success'=>true,'data'=>$data);
                }
0fea5567   Benjamin Renard   First step for re...
1601

bf776dc8   Benjamin Renard   working
1602
	}
735c653b   Elena.Budnik   rank at observato...
1603
1604
1605
1606
1607
1608
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1609

735c653b   Elena.Budnik   rank at observato...
1610
1611
1612
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1613
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1614
1615
1616
1617
1618
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1619

735c653b   Elena.Budnik   rank at observato...
1620
1621
1622
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1623

735c653b   Elena.Budnik   rank at observato...
1624
1625
1626
		$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...
1627

735c653b   Elena.Budnik   rank at observato...
1628
1629
1630
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1631

735c653b   Elena.Budnik   rank at observato...
1632
1633
1634
1635
1636
1637
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1638

0bda97f3   Benjamin Renard   Fix SAMP export f...
1639
1640
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1641
1642
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
2fa56f95   Benjamin Renard   Predefined templa...
1643
1644
1645
1646
1647
1648
1649
1650
1651

	public function parseTemplatedParam($paramTemplateId)
	{
		$args = (Object)array(
			'paramId' => $paramTemplateId,
			'type' => 'param_parse_template'
		);
		return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO);
	}
16035364   Benjamin Renard   First commit
1652
1653
}
?>