RequestOutputDownloadNodeClass.php
8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
174
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
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
295
296
297
<?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
{
const UNKNOWN = "";
const ISO = "ISO";
const DDTIME = "DD";
const TIMESTAMP = "DOUBLE";
}
abstract class RequestOutputDownloadFileFormatEnum
{
const UNKNOWN = "";
const ASCII = "ASCII";
const VOTABLE = "VOT";
const CDF = "CDF";
const JSON = "JSON";
}
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);
}
public function addIndex($index = "")
{
if ($this->indexExist($index))
return $this->getIndex($index);
$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_INDEX);
$node->setValue($index);
$this->addChild($node);
return $node;
}
public function getIndex($index)
{
$indexNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_INDEX);
foreach ($indexNodes as $indexNode)
if ($indexNode->getValue() == $index)
return $indexNode;
return NULL;
}
public function indexExist($index)
{
return ($this->getIndex($index) != NULL);
}
public function addCalibInfo($calibInfo)
{
if ($this->calibInfoExist($calibInfo))
return $this->getCalibInfo($calibInfo);
$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_CALIB);
$node->setValue($calibInfo);
$this->addChild($node);
return $node;
}
public function getCalibInfo($calibInfo)
{
$calibNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_CALIB);
foreach ($calibNodes as $calibNode)
if ($calibNode->getValue() == $calibInfo)
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));
}
}
}
/**
* @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()
{
$node = $this->getChildInstanceByName(REQUESTOUTPUTDOWNLOAD_FILENAME);
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);
}
public function addParam($id = "", $indexes = NULL, $calib_infos = NULL)
{
$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);
return $node;
}
public function getParam($id)
{
$nodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_NAME);
foreach ($nodes as $node)
if ($node->getId() == $id)
return $node;
return NULL;
}
public function addPostProcessing($process = "")
{
$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
if ($node == NULL)
{
$node = new RequestOutputPostProcessingNodeClass();
$this->addChild($node);
}
if ($process != "")
$node->addPostProcessing($process);
return $node;
}
public function isPostProcessing($process)
{
$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
if ($node == NULL)
return false;
return $node->isPostProcessing($process);
}
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);
}
}
?>