Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputDownloadNodeClass.php 5.86 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
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
}

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;

		$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_INDEX);
		$node->setValue($index);
		$this->addChild($node);
	}

	public function indexExist($index)
	{
		$indexNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_INDEX);

		foreach ($indexNodes as $indexNode)
		if ($indexNode->getValue() == $index)
			return true;

		return false;
	}

	public function addCalibInfo($calibInfo)
	{
		if ($this->calibInfoExist($calibInfo))
			return;

		$node = new NodeClass(REQUESTOUTPUTDOWNLOADPARAM_CALIB);
		$node->setValue($calibInfo);
		$this->addChild($node);
	}

	public function calibInfoExist($calibInfo)
	{
		$calibNodes = $this->getChildrenByName(REQUESTOUTPUTDOWNLOADPARAM_CALIB);

		foreach ($calibNodes as $calibNode)
		if ($calibNode->getValue() == $calibInfo)
			return true;

		return false;
	}
}

/**
 * @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_FILEFORMAT);
		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, $calib_infos)
	{
		$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);
	}

	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);
		}

		$node->addPostProcessing($process);
	}

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

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
}

d6410187   Benjamin Renard   Complete download...
237
?>