Blame view

php/classes/AmdaAction.php 43.1 KB
16035364   Benjamin Renard   First commit
1
2
3
<?php
/**
 * @class AmdaAction
aa94fd24   elena   Merge with last svn
4
 * @version $Id: AmdaAction.php 2976 2015-07-01 15:05:40Z benjamin $
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
5
 * @brief
16035364   Benjamin Renard   First commit
6
 */
10200969   Roipoussiere   Remove whitespace...
7
class AmdaAction
735c653b   Elena.Budnik   rank at observato...
8
{
10200969   Roipoussiere   Remove whitespace...
9
	private $xmlFiles  = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
735c653b   Elena.Budnik   rank at observato...
10
										'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
10200969   Roipoussiere   Remove whitespace...
11
12
										'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
										'myData' => 'Files.xml',
735c653b   Elena.Budnik   rank at observato...
13
14
15
16
17
										'request' => 'Request.xml', 'condition' => 'Request.xml',
										'bkgWorks' => 'jobs.xml');

	private $user, $amdaStat;

10200969   Roipoussiere   Remove whitespace...
18
19
	public function __construct()
	{
735c653b   Elena.Budnik   rank at observato...
20
21
22
23
24
		$dd = new UserMgr();
		$this->user = $dd->user;
		if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
					$this->amdaStat = new AmdaStats($dd->user);
	}
16035364   Benjamin Renard   First commit
25

10200969   Roipoussiere   Remove whitespace...
26
	private function getUrlDirs($url)
735c653b   Elena.Budnik   rank at observato...
27
28
29
	{
		//TODO replace by ftp php class methods: ftp_nlist() etc
		require_once "simple_html_dom.php";
10200969   Roipoussiere   Remove whitespace...
30
31

		$url = html_entity_decode($url);
735c653b   Elena.Budnik   rank at observato...
32
		$trimmed_url = trim($url);
10200969   Roipoussiere   Remove whitespace...
33
		if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1)
735c653b   Elena.Budnik   rank at observato...
34
		{
10200969   Roipoussiere   Remove whitespace...
35
			if (file_exists("temp.html")) unlink("temp.html");
735c653b   Elena.Budnik   rank at observato...
36
			exec("wget -O temp.html ".$url);
10200969   Roipoussiere   Remove whitespace...
37

735c653b   Elena.Budnik   rank at observato...
38
39
			$html = file_get_html('temp.html');
			$dirs = $html->find('a[href]');
10200969   Roipoussiere   Remove whitespace...
40
			foreach ($dirs as $dir)
735c653b   Elena.Budnik   rank at observato...
41
			{
6acb8d2a   Elena.Budnik   checkRequest in R...
42
43
				$name =  $dir->innertext; //$dir->href;
				$isLeaf = strrpos($name, "/") !== strlen($name) - 1;
10200969   Roipoussiere   Remove whitespace...
44
				$childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name, 'nodeType' => 'url', 'leaf' => $isLeaf);
735c653b   Elena.Budnik   rank at observato...
45
			}
10200969   Roipoussiere   Remove whitespace...
46

735c653b   Elena.Budnik   rank at observato...
47
		}
10200969   Roipoussiere   Remove whitespace...
48
49
50

		return $childrenToReturn;

735c653b   Elena.Budnik   rank at observato...
51
	}
10200969   Roipoussiere   Remove whitespace...
52

16035364   Benjamin Renard   First commit
53
54
/*****************************************************************
*                           PUBLIC FUNCTIONS
10200969   Roipoussiere   Remove whitespace...
55
56
*****************************************************************/

735c653b   Elena.Budnik   rank at observato...
57
58
59
60
	/*
	*   $obj = { id: node.id,  nodeType: node.nodeType }
	*/
	public function getTree($obj) {
735c653b   Elena.Budnik   rank at observato...
61
		$node = $obj->node;
10200969   Roipoussiere   Remove whitespace...
62

735c653b   Elena.Budnik   rank at observato...
63
		$nodeType = $obj->nodeType;
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;
10200969   Roipoussiere   Remove whitespace...
132

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

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

					$specialNode = false;
					$isParameter = false;
					$isAddable =  false;
					$isSimulation = false;
0ead0129   Benjamin Renard   Modify save plot ...
154
					$plotTabs = FALSE;
735c653b   Elena.Budnik   rank at observato...
155
					$rank = null;
e57cb025   Benjamin Renard   Fix most of error...
156
					$skip = FALSE;
735c653b   Elena.Budnik   rank at observato...
157

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

						case 'condition':
638db58d   Benjamin Renard   RequestMgr constr...
175
							$objectMgr = new RequestMgr($nodeType);
10200969   Roipoussiere   Remove whitespace...
176
177
							$info = $objectMgr->getObject($id)->expression;
						break;
735c653b   Elena.Budnik   rank at observato...
178

10200969   Roipoussiere   Remove whitespace...
179
						case 'request':
638db58d   Benjamin Renard   RequestMgr constr...
180
						$objectMgr = new RequestMgr($nodeType);
10200969   Roipoussiere   Remove whitespace...
181
						$objplot = $objectMgr->getObject($id);
f31bea1c   Benjamin Renard   wip for save plot
182
183
184
185
186
187
188
						if (isset($objplot->name)) {
							$info = $objplot->name;
						}
						else {
							$info = $id;
						}

3efc6401   Benjamin Renard   Set icons for plo...
189
190
						$isLeaf = isset($objplot->tabs);
						if ($isLeaf) {
0ead0129   Benjamin Renard   Modify save plot ...
191
							$plotTabs = array();
f31bea1c   Benjamin Renard   wip for save plot
192
193
							foreach ($objplot->tabs as $index => $tab) {
								$plotTabs[$index] = array(
0c99c4b7   Benjamin Renard   Implements plot t...
194
									"name" => (!empty($tab->{'tab-name'})) ? $tab->{'tab-name'} : "Plot ".($index+1),
f31bea1c   Benjamin Renard   wip for save plot
195
196
									"id" => $tab->id,
								);
735c653b   Elena.Budnik   rank at observato...
197
198
							}
						}
0ead0129   Benjamin Renard   Modify save plot ...
199
200
						else
							$plotTabs = FALSE;
10200969   Roipoussiere   Remove whitespace...
201
						break;
735c653b   Elena.Budnik   rank at observato...
202

10200969   Roipoussiere   Remove whitespace...
203
						case 'alias':
735c653b   Elena.Budnik   rank at observato...
204
205
							$info = $id;
							$id = 'alias_'.$id;
cbbbdc34   Elena.Budnik   param description...
206
207
208
209
210
211
212
213
							$component_info = array();
							if ($child->hasAttribute("index1"))
								$component_info["index1"] = $child->getAttribute('index1');
							if ($child->hasAttribute("index2"))
								$component_info["index2"] = $child->getAttribute('index2');

							if ($child->hasAttribute("parentId"))
								$component_info["parentId"] = $child->getAttribute("parentId");
0fea5567   Benjamin Renard   First step for re...
214

cbbbdc34   Elena.Budnik   param description...
215
216
							if ($child->hasAttribute("iconCls"))
								$iconCls = $child->getAttribute("iconCls");
0fea5567   Benjamin Renard   First step for re...
217

10200969   Roipoussiere   Remove whitespace...
218
							if ($isLeaf) $isParameter = true;
0fea5567   Benjamin Renard   First step for re...
219

735c653b   Elena.Budnik   rank at observato...
220
221
222
						break;

						case 'timeTable':
10200969   Roipoussiere   Remove whitespace...
223
						case 'catalog':
735c653b   Elena.Budnik   rank at observato...
224
225
							if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
						break;
10200969   Roipoussiere   Remove whitespace...
226

735c653b   Elena.Budnik   rank at observato...
227
228
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
229
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
230
231
232
233
234
235
236
237
							{
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('nbIntervals').'<br/>';
								$info .= '<b>Shared by:</b> '.$child->getAttribute('sharedBy').' ('.$child->getAttribute('sharedDate').')<br/>';
								$info .= '<b>Description:</b> '.$child->getAttribute('description');
							}
						break;
						case 'derivedParam':
							$info = $child->getAttribute('buildchain');
0fea5567   Benjamin Renard   First step for re...
238

8ba47f72   Benjamin Renard   rest actualisatio...
239
240
241
242
243
244
245
							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...
246
247
248
249
250
251
252
253
254
255
256
							if ($isLeaf) $isParameter = true;
						break;

						case 'localParam':

							$globalStart = null;
							$globalStop = null;
							$timeRestriction = false;
							$specialNode = true;
							$isParameter = false;
							$needsArgs = false;
10200969   Roipoussiere   Remove whitespace...
257
							$isSpectra = false;
dc9e2c14   Elena.Budnik   init + message + ...
258
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
259
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
260
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
261

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

c57c57c9   Elena.Budnik   info message depe...
266
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
10200969   Roipoussiere   Remove whitespace...
267
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
0fea5567   Benjamin Renard   First step for re...
268

a7316784   Elena.Budnik   add LastUpdate to...
269
270
271
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
272
								}
10200969   Roipoussiere   Remove whitespace...
273

c57c57c9   Elena.Budnik   info message depe...
274
								if ($child->getAttribute('dataStart') == 'depending on mission') {
735c653b   Elena.Budnik   rank at observato...
275
									$info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
276
								}
0fea5567   Benjamin Renard   First step for re...
277

f29c5e66   Elena.Budnik   plot only option
278
279
280
281
// 								if ($child->getAttribute('restriction') > 1) {
// 									$restricted  = $child->getAttribute('restriction');
// 									$info .= "<br/><b>Time Restriction</b>: -$restricted days";
// 								}
735c653b   Elena.Budnik   rank at observato...
282
							}
10200969   Roipoussiere   Remove whitespace...
283

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

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

cbbbdc34   Elena.Budnik   param description...
288
289
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description')."<br/>".$units;
0fea5567   Benjamin Renard   First step for re...
290
								else
cbbbdc34   Elena.Budnik   param description...
291
292
									$info = $units;
							}
0fea5567   Benjamin Renard   First step for re...
293

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

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

f29c5e66   Elena.Budnik   plot only option
302
303
304
305
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
306
								}
f29c5e66   Elena.Budnik   plot only option
307
308
309
// 								if ($child->parentNode->getAttribute('restriction') > 1 ) {
// 									$timeRestriction = true;
// 								}
735c653b   Elena.Budnik   rank at observato...
310
							}
10200969   Roipoussiere   Remove whitespace...
311

735c653b   Elena.Budnik   rank at observato...
312
313
314
315
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
316

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

f29c5e66   Elena.Budnik   plot only option
322
323
324
325
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
326
								}
f29c5e66   Elena.Budnik   plot only option
327
328
329
// 								if ($child->parentNode->parentNode->getAttribute('restriction') > 1) {
// 									$timeRestriction = true;
// 								}
735c653b   Elena.Budnik   rank at observato...
330
331
332
333
334

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

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

f29c5e66   Elena.Budnik   plot only option
339
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
340
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
341
342
										$needsArgs = true;
										$isSpectra = true;
dc9e2c14   Elena.Budnik   init + message + ...
343
344
										if (strpos($child->getAttribute('name'),'2D') !== false)
											$is2dSpectra = true;
735c653b   Elena.Budnik   rank at observato...
345
								}
c57c57c9   Elena.Budnik   info message depe...
346
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
347
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
348
								}
10200969   Roipoussiere   Remove whitespace...
349
350
							}

f31bea1c   Benjamin Renard   wip for save plot
351

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

661293d7   Elena.Budnik   parse ## and @@ i...
356
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
357
358
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
dc9e2c14   Elena.Budnik   init + message + ...
359
360
									'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra,
									'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
735c653b   Elena.Budnik   rank at observato...
361
							}
c57c57c9   Elena.Budnik   info message depe...
362
							else {
c57c57c9   Elena.Budnik   info message depe...
363
								if ($child->tagName == 'mission' || $child->tagName == 'observatory') {
735c653b   Elena.Budnik   rank at observato...
364
365
									$rank = $child->getAttribute('rank');
								}
0fea5567   Benjamin Renard   First step for re...
366

acf87705   Elena.Budnik   bug in disable param
367
368
								$disable = $child->hasAttribute('group');

c57c57c9   Elena.Budnik   info message depe...
369
								if ($disable) {
acf87705   Elena.Budnik   bug in disable param
370
									if ($child->getAttribute("group") !== "TBD") {
c57c57c9   Elena.Budnik   info message depe...
371
372
											$info .=  "<br/><b>Restricted Access</b>";
										}
10200969   Roipoussiere   Remove whitespace...
373
									else {
c57c57c9   Elena.Budnik   info message depe...
374
										$info .=  "<br/><b>Sorry! Not finished yet...</b>";
735c653b   Elena.Budnik   rank at observato...
375
									}
0fea5567   Benjamin Renard   First step for re...
376
								}
acf87705   Elena.Budnik   bug in disable param
377
378
379
								else {
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
380
381
								}

10200969   Roipoussiere   Remove whitespace...
382
383
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
735c653b   Elena.Budnik   rank at observato...
384
385
386
387
							}
						break;

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

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

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

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

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

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

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

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

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

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

							$isSpectra = false;

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

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

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

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

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

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

a0f13ed1   Elena.Budnik   small format + ti...
478
479
480
481
482
483
							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...
484

a0f13ed1   Elena.Budnik   small format + ti...
485
486
487
488
489
490
							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...
491

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

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

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

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

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

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

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

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

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

						case 'myDataParam' :

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

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

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

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

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

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

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

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
3a420953   Benjamin Renard   Merge branch 'mas...
600
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, 'tabs' => $plotTabs,
0fea5567   Benjamin Renard   First step for re...
601
													'component_info' => isset($component_info) ? $component_info : NULL,
cbbbdc34   Elena.Budnik   param description...
602
													'iconCls' => isset($iconCls) ? $iconCls : NULL );
735c653b   Elena.Budnik   rank at observato...
603
604
605
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
606
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
607
				{
735c653b   Elena.Budnik   rank at observato...
608
609
610
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
611
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
612
	}
16035364   Benjamin Renard   First commit
613

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

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

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

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

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

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

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

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

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

10200969   Roipoussiere   Remove whitespace...
739
740
741
742

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

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

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

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

16035364   Benjamin Renard   First commit
817
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
818
819
820
821
822
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
823
			   break;
10200969   Roipoussiere   Remove whitespace...
824
825
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
826
			   break;
10200969   Roipoussiere   Remove whitespace...
827
828
		  case 'condition' :
		  case 'request' :
0c99c4b7   Benjamin Renard   Implements plot t...
829
                  case 'plottab' :
10200969   Roipoussiere   Remove whitespace...
830
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
831
832
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
833
834
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
835
836
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
837
		}
16035364   Benjamin Renard   First commit
838

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

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

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


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

16035364   Benjamin Renard   First commit
949
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
950
		{
e5ab198f   Nathanael Jourdane   simple getStatus
951
			$dd = new WSUserMgr();
fcdd1349   Elena.Budnik   merge with master
952
			$dd->init($obj->username,$obj->password,$obj->sessionID, false);
735c653b   Elena.Budnik   rank at observato...
953
		}
a21497cc   Elena.Budnik   redmine #5645
954
		else {
16035364   Benjamin Renard   First commit
955
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
956
957
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
958
959

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

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

6acb8d2a   Elena.Budnik   checkRequest in R...
967
		if ($dd->user == 'impex')
16035364   Benjamin Renard   First commit
968
969
970
		{
			//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
971
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
972
		}
32bb889b   Elena.Budnik   #5532 to process ...
973
		else {
0fea5567   Benjamin Renard   First step for re...
974
			// check disk space
2c7f2cb6   Benjamin Renard   Remove old log fi...
975
976
977
978
979
980
			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...
981
		}
10200969   Roipoussiere   Remove whitespace...
982

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

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

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

32bb889b   Elena.Budnik   #5532 to process ...
991
992
993
		// 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...
994
995
				$function == FunctionTypeEnumClass::PARAMSGEN ||
				$function == FunctionTypeEnumClass::PARAMSINFOGEN )
32bb889b   Elena.Budnik   #5532 to process ...
996
		{
7ac3e07e   Elena.Budnik   do not check user...
997
998
999
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
8ba47f72   Benjamin Renard   rest actualisatio...
1000

16035364   Benjamin Renard   First commit
1001
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
1002
		try {
e57cb025   Benjamin Renard   Fix most of error...
1003
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
1004
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
1005
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
1006
		}
16035364   Benjamin Renard   First commit
1007
1008
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1009
1010
1011

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
1012
*/
735c653b   Elena.Budnik   rank at observato...
1013
1014
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
1015
1016
1017
1018
		// 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
1019
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
1020
1021
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
1022
1023
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
1024

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

16035364   Benjamin Renard   First commit
1029
/*
a0b3d64e   Benjamin Renard   Derived parameter...
1030
1031
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1032
1033
	public function compilParam($obj)
	{
bf776dc8   Benjamin Renard   working
1034
//error_log(print_r($obj,TRUE));
735c653b   Elena.Budnik   rank at observato...
1035
1036
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
1037

8ba47f72   Benjamin Renard   rest actualisatio...
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049

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




a0b3d64e   Benjamin Renard   Derived parameter...
1050
1051
1052
/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1053
1054
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
1055
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
1056

a0b3d64e   Benjamin Renard   Derived parameter...
1057
1058
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
1059

a0b3d64e   Benjamin Renard   Derived parameter...
1060
1061
1062
1063
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
1064
1065
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
1066

a0b3d64e   Benjamin Renard   Derived parameter...
1067
/*
e6e5b259   Benjamin Renard   Add kill plot req...
1068
 * kill plot process
16035364   Benjamin Renard   First commit
1069
 */
10200969   Roipoussiere   Remove whitespace...
1070

735c653b   Elena.Budnik   rank at observato...
1071
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
1072
	{
735c653b   Elena.Budnik   rank at observato...
1073
1074
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
1075
1076
1077
1078

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

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

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

10200969   Roipoussiere   Remove whitespace...
1089

16035364   Benjamin Renard   First commit
1090
1091
1092
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
1093
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
1094
1095
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1096
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1097

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

735c653b   Elena.Budnik   rank at observato...
1101
1102
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1103

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

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


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

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

0fea5567   Benjamin Renard   First step for re...
1121
	public function initObjectCacheFromCatalog($id, $type)
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
1122
1123
1124
1125
1126
1127
1128
        {
                $cacheMgr = new TimeTableCacheMgr();

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


e1fdab74   Hacene SI HADJ MOHAND   starting
1129
1130
1131
1132
1133
1134
1135
1136
         public function initObjectCacheFromTimeTable($id, $nbParams)
        {
                $cacheMgr = new CatalogCacheMgr();

                return $cacheMgr->initFromTimeTable($id, $nbParams);
        }


8be9a1a8   Benjamin Renard   Fix catalog visu
1137
	public function initForChart($id, $folderId, $name, $isTmpObject, $type)
735c653b   Elena.Budnik   rank at observato...
1138
	{
e1fd05b4   Elena.Budnik   visu from cacheCat
1139
1140
		if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
			return array('success' => true, 'cache' => $id);
0fea5567   Benjamin Renard   First step for re...
1141

735c653b   Elena.Budnik   rank at observato...
1142
		if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
10200969   Roipoussiere   Remove whitespace...
1143

8be9a1a8   Benjamin Renard   Fix catalog visu
1144
		return $objMgr->initForChart($id, $folderId, $name, $isTmpObject, $type);
735c653b   Elena.Budnik   rank at observato...
1145
	}
10200969   Roipoussiere   Remove whitespace...
1146

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

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

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

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

e57cb025   Benjamin Renard   Fix most of error...
1167
		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...
1168
	}
10200969   Roipoussiere   Remove whitespace...
1169

735c653b   Elena.Budnik   rank at observato...
1170
1171
	public function readIntervalsForChart($o)
	{
e57cb025   Benjamin Renard   Fix most of error...
1172
		if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) {
0fea5567   Benjamin Renard   First step for re...
1173

e1fd05b4   Elena.Budnik   visu from cacheCat
1174
1175
				if ($o->fromPlugin && $o->id == 'cacheCat') {
					$objMgr = new CatalogCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1176

e1fd05b4   Elena.Budnik   visu from cacheCat
1177
1178
					return $objMgr->getIntervals();
				}
0fea5567   Benjamin Renard   First step for re...
1179

e1fd05b4   Elena.Budnik   visu from cacheCat
1180
1181
				$objMgr = new CatalogMgr();
		}
10200969   Roipoussiere   Remove whitespace...
1182

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

735c653b   Elena.Budnik   rank at observato...
1186
1187
1188
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1189
		return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
735c653b   Elena.Budnik   rank at observato...
1190
	}
10200969   Roipoussiere   Remove whitespace...
1191

342b20ca   Benjamin Renard   Fix inheritence b...
1192
	public function addCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1193
1194
1195
1196
1197
1198
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

735c653b   Elena.Budnik   rank at observato...
1200
1201
1202
1203
1204
1205
1206
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

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

342b20ca   Benjamin Renard   Fix inheritence b...
1208
	public function modifyCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1209
	{
10200969   Roipoussiere   Remove whitespace...
1210
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1211
		{
f9c8b272   elena   edit catalog
1212
			$cacheMgr = new CatalogCacheMgr();
f9c8b272   elena   edit catalog
1213
		}
735c653b   Elena.Budnik   rank at observato...
1214
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1215

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

735c653b   Elena.Budnik   rank at observato...
1219
1220
1221
1222
1223
	public function operationTTCacheIntervals($extendTime, $shiftTime)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1224

735c653b   Elena.Budnik   rank at observato...
1225
1226
1227
1228
1229
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1230

0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1231
	public function getTTCacheStatistics($obj)
735c653b   Elena.Budnik   rank at observato...
1232
	{
0fea5567   Benjamin Renard   First step for re...
1233
                if($obj->name == "timeTableUi"){
0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1234
1235
1236
1237
1238
1239
				$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...
1240
1241
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1242

735c653b   Elena.Budnik   rank at observato...
1243
1244
1245
1246
1247
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1248

16035364   Benjamin Renard   First commit
1249
1250
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1251
 *
16035364   Benjamin Renard   First commit
1252
 */
735c653b   Elena.Budnik   rank at observato...
1253
1254
1255
1256
1257
	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...
1258

16035364   Benjamin Renard   First commit
1259
1260
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1261
 *
16035364   Benjamin Renard   First commit
1262
 */
735c653b   Elena.Budnik   rank at observato...
1263
1264
1265
1266
1267
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1268

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

/*
16035364   Benjamin Renard   First commit
1280
1281
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1282
1283
1284
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1285
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1286

735c653b   Elena.Budnik   rank at observato...
1287
1288
1289
1290
1291
1292
		$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...
1293

735c653b   Elena.Budnik   rank at observato...
1294
1295
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1296
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1297
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1298

735c653b   Elena.Budnik   rank at observato...
1299
1300
1301
1302
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1303
	}
16035364   Benjamin Renard   First commit
1304
1305
1306
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1307
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1308
	{
10200969   Roipoussiere   Remove whitespace...
1309
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1310
1311
1312
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1313

735c653b   Elena.Budnik   rank at observato...
1314
1315
1316
1317
1318
1319
1320
1321
1322
	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...
1323

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

735c653b   Elena.Budnik   rank at observato...
1330
1331
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1332
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1333
1334
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1335

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

735c653b   Elena.Budnik   rank at observato...
1343
1344
1345
1346
1347
1348
1349
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

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

fdf1413b   Elena.Budnik   TT download
1356
1357
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1358
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1359
1360
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1361

fdf1413b   Elena.Budnik   TT download
1362
1363
1364
1365
1366
1367
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1368

16035364   Benjamin Renard   First commit
1369
1370
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1371
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1372
		{
fdf1413b   Elena.Budnik   TT download
1373
1374
1375
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1376
		else
735c653b   Elena.Budnik   rank at observato...
1377
		{
fdf1413b   Elena.Budnik   TT download
1378
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1379
		}
16035364   Benjamin Renard   First commit
1380
		return;
10200969   Roipoussiere   Remove whitespace...
1381
	}
16035364   Benjamin Renard   First commit
1382

fdf1413b   Elena.Budnik   TT download
1383
1384
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1385
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1386
		{
10200969   Roipoussiere   Remove whitespace...
1387
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1388
1389
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1390
1391
1392
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1393
1394
1395
1396
1397
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1398

fdf1413b   Elena.Budnik   TT download
1399
1400
1401
1402
1403
	public function convertWS()
	{
		$dd = new UserMgr();
		return $dd->convertWS();
	}
16035364   Benjamin Renard   First commit
1404

fdf1413b   Elena.Budnik   TT download
1405
1406
1407
1408
1409
1410
	// $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...
1411
1412

		return  $res;
fdf1413b   Elena.Budnik   TT download
1413
	}
10200969   Roipoussiere   Remove whitespace...
1414
1415

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1416
1417
1418
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1419

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

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

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

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

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

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

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

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

fdf1413b   Elena.Budnik   TT download
1468
1469
	public function interactivePlot($obj, $multiPlotState)
	{
fdf1413b   Elena.Budnik   TT download
1470
1471
1472
1473
1474
1475
		$inputobj = (Object)array(
			'action' => $obj,
			'multiPlotState' => $multiPlotState
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1476

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

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

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

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

bf776dc8   Benjamin Renard   working
1521
		}
0fea5567   Benjamin Renard   First step for re...
1522
		return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
bf776dc8   Benjamin Renard   working
1523
	}
0fea5567   Benjamin Renard   First step for re...
1524

bf776dc8   Benjamin Renard   working
1525
1526
1527
1528
1529
1530
	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...
1531
		}elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
bf776dc8   Benjamin Renard   working
1532
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
		/* 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...
1559

10200969   Roipoussiere   Remove whitespace...
1560

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

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

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

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

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

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

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

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

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

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

0bda97f3   Benjamin Renard   Fix SAMP export f...
1638
1639
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1640
1641
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
16035364   Benjamin Renard   First commit
1642
1643
}
?>