Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php 8.12 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

require_once("RequestOutputPostProcessingNodeClass.php");

define ("REQUESTOUTPUTDOWNLOAD_NAME", "download");
define ("REQUESTOUTPUTDOWNLOAD_TIMEFORMAT", "timeFormat");
define ("REQUESTOUTPUTDOWNLOAD_FILEFORMAT", "fileFormat");
define ("REQUESTOUTPUTDOWNLOAD_FILENAME", "fileName");
define ("REQUESTOUTPUTDOWNLOAD_SAMPLING", "timeResolution");
define ("REQUESTOUTPUTDOWNLOAD_STRUCTURE", "outputStructure");
define ("REQUESTOUTPUTDOWNLOAD_PRECISION", "precision");

define ("REQUESTOUTPUTDOWNLOADPARAM_NAME", "param");
define ("REQUESTOUTPUTDOWNLOADPARAM_ID", "id");
define ("REQUESTOUTPUTDOWNLOADPARAM_INDEX", "index");
define ("REQUESTOUTPUTDOWNLOADPARAM_CALIB", "calibration_info");

abstract class RequestOutputDownloadTimeFormatEnum
{
d6410187   Benjamin Renard   Complete download...
20
21
22
23
	const UNKNOWN   = "";
	const ISO       = "ISO";
	const DDTIME    = "DD";
	const TIMESTAMP = "DOUBLE";
22521f1c   Benjamin Renard   First commit
24
25
26
27
28
29
30
}

abstract class RequestOutputDownloadFileFormatEnum
{
	const UNKNOWN = "";
	const ASCII   = "ASCII";
	const VOTABLE = "VOT";
d6410187   Benjamin Renard   Complete download...
31
32
	const CDF     = "CDF";
	const JSON    = "JSON";
22521f1c   Benjamin Renard   First commit
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
}

abstract class RequestOutputDownloadStructureEnum
{
	const UNKNOWN                             = "";
	const ONE_FILE                            = "one-file";
	const ONE_FILE_REFPARAM                   = "one-file-refparam";
	const ONE_FILE_PER_INTERVAL               = "one-file-per-interval";
	const ONE_FILE_PER_INTERVAL_REFPARAM      = "one-file-per-interval-refparam";
	const ONE_FILE_PER_PARAMETER_PER_INTERVAL = "one-file-per-parameter-per-interval";
}

class RequestOutputDownloadParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTDOWNLOADPARAM_NAME);
	}

	public function setId($id)
	{
		$this->setAttribute(REQUESTOUTPUTDOWNLOADPARAM_ID, $id);
	}

	public function getId()
	{
		return $this->getAttribute(REQUESTOUTPUTDOWNLOADPARAM_ID);
	}

966bd5f8   Benjamin Renard   Add request to ge...
62
	public function addIndex($index = "")
22521f1c   Benjamin Renard   First commit
63
64
	{
		if ($this->indexExist($index))
966bd5f8   Benjamin Renard   Add request to ge...
65
			return $this->getIndex($index);
22521f1c   Benjamin Renard   First commit
66
67
68
69

		$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_INDEX);
		$node->setValue($index);
		$this->addChild($node);
966bd5f8   Benjamin Renard   Add request to ge...
70
		return $node;
22521f1c   Benjamin Renard   First commit
71
72
	}

966bd5f8   Benjamin Renard   Add request to ge...
73
	public function getIndex($index)
22521f1c   Benjamin Renard   First commit
74
75
	{
		$indexNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_INDEX);
966bd5f8   Benjamin Renard   Add request to ge...
76
	
22521f1c   Benjamin Renard   First commit
77
		foreach ($indexNodes as $indexNode)
966bd5f8   Benjamin Renard   Add request to ge...
78
79
80
81
82
83
84
85
86
			if ($indexNode->getValue() == $index)
				return $indexNode;
	
		return NULL;
	}
	
	public function indexExist($index)
	{
		return ($this->getIndex($index) != NULL);
22521f1c   Benjamin Renard   First commit
87
88
89
90
91
	}

	public function addCalibInfo($calibInfo)
	{
		if ($this->calibInfoExist($calibInfo))
966bd5f8   Benjamin Renard   Add request to ge...
92
			return $this->getCalibInfo($calibInfo);
22521f1c   Benjamin Renard   First commit
93
94
95
96

		$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_CALIB);
		$node->setValue($calibInfo);
		$this->addChild($node);
966bd5f8   Benjamin Renard   Add request to ge...
97
		return $node;
22521f1c   Benjamin Renard   First commit
98
99
	}

966bd5f8   Benjamin Renard   Add request to ge...
100
	public function getCalibInfo($calibInfo)
22521f1c   Benjamin Renard   First commit
101
102
	{
		$calibNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_CALIB);
966bd5f8   Benjamin Renard   Add request to ge...
103
		
22521f1c   Benjamin Renard   First commit
104
105
		foreach ($calibNodes as $calibNode)
		if ($calibNode->getValue() == $calibInfo)
966bd5f8   Benjamin Renard   Add request to ge...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
			return $calibNode;
		
		return NULL;
	}
	
	public function calibInfoExist($calibInfo)
	{
		return ($this->getCalibInfo($calibInfo) != NULL);
	}
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTDOWNLOADPARAM_ID));
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTDOWNLOADPARAM_INDEX) as $indexXmlNode) {
			$this->addIndex($this->getXmlNodeValue($indexXmlNode));
		}
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTDOWNLOADPARAM_CALIB) as $calibInfoXmlNode) {
			$this->addCalibInfo($this->getXmlNodeValue($calibInfoXmlNode));
		}
22521f1c   Benjamin Renard   First commit
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
	}
}

/**
 * @class RequestOutputDownloadNodeClass
 * @brief Definition of a request download output node for AMDA_Kernel
 * @details
 */
class RequestOutputDownloadNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTDOWNLOAD_NAME);
	}

	public function setTimeFormat($type)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_TIMEFORMAT, true);
		$node->setValue($type);
	}

	public function getTimeFormat()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_TIMEFORMAT);
		return (($node == NULL) ? RequestOutputDownloadTimeFormatEnum::UNKNOWN : $node->getValue());
	}

	public function setFileFormat($type)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILEFORMAT, true);
		$node->setValue($type);
	}

	public function getFileFormat()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILEFORMAT);
		return (($node == NULL) ? RequestOutputDownloadFileFormatEnum::UNKNOWN : $node->getValue());
	}

	public function setFileName($name)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILENAME, true);
		$node->setValue($name);
	}

	public function getFileName()
	{
8c57155b   Benjamin Renard   Integration for t...
174
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILENAME);
22521f1c   Benjamin Renard   First commit
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
		return (($node == NULL) ? "" : $node->getValue());
	}

	public function setSamplingTime($sampling)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_SAMPLING, true);
		$node->setValue($sampling);
	}

	public function getSamplingTime()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_SAMPLING);
		return (($node == NULL) ? "" : $node->getValue());
	}

	public function setStructure($type)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_STRUCTURE, true);
		$node->setValue($type);
	}

	public function getStructure()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_STRUCTURE);
		return (($node == NULL) ? RequestOutputDownloadStructureEnum::UNKNOWN : $node->getValue());
	}

	public function setPrecision($precision)
	{
		$this->setAttribute(REQUESTOUTPUTDOWNLOAD_PRECISION, $precision);
	}

	public function getPrecision()
	{
		return $this->getAttribute(REQUESTOUTPUTDOWNLOAD_PRECISION);
	}

966bd5f8   Benjamin Renard   Add request to ge...
212
	public function addParam($id = "", $indexes = NULL, $calib_infos = NULL)
22521f1c   Benjamin Renard   First commit
213
214
215
216
217
218
219
220
221
222
223
224
225
226
	{
		$node = new RequestOutputDownloadParamNodeClass();
		$node->setId($id);
		if (isset($indexes))
		{
			foreach ($indexes as $index)
				$node->addIndex($index);
		}
		if (isset($calib_infos))
		{
			foreach ($calib_infos as $calib_info)
				$node->addCalibInfo($calib_infos);
		}
		$this->addChild($node);
966bd5f8   Benjamin Renard   Add request to ge...
227
		return $node;
22521f1c   Benjamin Renard   First commit
228
229
230
231
232
233
234
235
236
237
238
239
	}

	public function getParam($id)
	{
		$nodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_NAME);

		foreach ($nodes as $node)
		if ($node->getId() == $id)
			return $node;
		return NULL;
	}

966bd5f8   Benjamin Renard   Add request to ge...
240
	public function addPostProcessing($process = "")
22521f1c   Benjamin Renard   First commit
241
242
243
244
245
246
247
248
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
		if ($node == NULL)
		{
			$node = new RequestOutputPostProcessingNodeClass();
			$this->addChild($node);
		}

966bd5f8   Benjamin Renard   Add request to ge...
249
250
251
252
		if ($process != "")
			$node->addPostProcessing($process);
		
		return $node;
22521f1c   Benjamin Renard   First commit
253
254
255
256
257
258
259
260
261
262
263
	}

	public function isPostProcessing($process)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
966bd5f8   Benjamin Renard   Add request to ge...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
	
	public function loadFromNode($xmlNode)
	{
		$timeformatXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOAD_TIMEFORMAT);
		if (isset($timeformatXmlNode))
			$this->setTimeFormat($this->getXmlNodeValue($timeformatXmlNode));
		
		$fileformatXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOAD_FILEFORMAT);
		if (isset($fileformatXmlNode))
			$this->FileFormat($this->getXmlNodeValue($fileformatXmlNode));
		
		$filenameXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOAD_FILENAME);
		if (isset($filenameXmlNode))
			$this->setFileName($this->getXmlNodeValue($filenameXmlNode));
		
		$structureXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOAD_STRUCTURE);
		if (isset($structureXmlNode))
			$this->setStructure($this->getXmlNodeValue($structureXmlNode));
		
		$precisionXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOAD_PRECISION);
		if (isset($precisionXmlNode))
			$this->setPrecision($this->getXmlNodeValue($precisionXmlNode));
		
		$paramXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDOWNLOADPARAM_NAME);
		if (isset($paramXmlNode))
			$this->addParam()->loadFromNode($paramXmlNode);
		
		$postProcessingXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPOSTPROCESSING_NAME);
		if (isset($postProcessingXmlNode))
			$this->addPostProcessing()->loadFromNode($postProcessingXmlNode);
	}
22521f1c   Benjamin Renard   First commit
295
296
}

d6410187   Benjamin Renard   Complete download...
297
?>