Blame view

src/Request/ParamsRequestImpl/ParamsRequestDataClass.php 7.32 KB
22521f1c   Benjamin Renard   First commit
1
2
3
<?php

/**
3493f196   Benjamin Renard   Add request to ge...
4
5
6
7
8
9
10
11
12
 * @class ParamsRequestTypeEnumClass
 * @brief Enumerate for request type
 * @details
 */
abstract class ParamsRequestTypeEnumClass
{
	const UNKNOWN = "";
	const XMLREQUEST = "XMLREQUEST";
	const PARAMGEN   = "PARAMGEN";
cd28a380   Benjamin Renard   Generate param in...
13
	const PARAMSINFOGEN   = "PARAMSINFOGEN";
3493f196   Benjamin Renard   Add request to ge...
14
15
16
}

/**
22521f1c   Benjamin Renard   First commit
17
18
19
20
21
22
 * @class ParamsRequestDataClass
 * @brief Data for a params request. Inherits from ProcessRequestDataClass
 * @details
 */
class ParamsRequestDataClass extends ProcessRequestDataClass
{
3493f196   Benjamin Renard   Add request to ge...
23
	private $requestType           = ParamsRequestTypeEnumClass::XMLREQUEST;
8c57155b   Benjamin Renard   Integration for t...
24
	private $requestNodes          = array();
22521f1c   Benjamin Renard   First commit
25
	private $compilationPath       = "";
944199fe   Benjamin Renard   Use table definit...
26
	private $localBasePath         = "";
22521f1c   Benjamin Renard   First commit
27
28
	private $waitingResults        = array();
	private $processParamsToCreate = array();
944199fe   Benjamin Renard   Use table definit...
29
	private $localParamsToCreate   = array();
ffc5cb81   Elena.Budnik   temporary commit
30
	private $localParamsToCreateAndCopy   = array();
b3343120   Benjamin Renard   Check parameters ...
31
	private $paramTimeRestriction  = array();
22521f1c   Benjamin Renard   First commit
32
	private $paramsToCopy          = array();
3493f196   Benjamin Renard   Add request to ge...
33
	private $paramId               = "";
59eb1b9c   Elena.Budnik   new ama stat
34
	private $datasetId             = array();
92a8e6b0   Elena.Budnik   temporary commot
35
	private $task                  = "";
22521f1c   Benjamin Renard   First commit
36
37
38
39

	function __construct()
	{
		parent::__construct();
22521f1c   Benjamin Renard   First commit
40
41
42
43
44
45
46
47
48
49
50
	}

	public function getCompilationPath()
	{
		return $this->compilationPath;
	}

	public function setCompilationPath($compilationPath)
	{
		$this->compilationPath = $compilationPath;
	}
944199fe   Benjamin Renard   Use table definit...
51
52
53
54
55
56
57
58
59
60
	
	public function getLocalBasePath()
	{
		return $this->localBasePath;
	}
	
	public function setLocalBasePath($localBasePath)
	{
		$this->localBasePath = $localBasePath;
	}
22521f1c   Benjamin Renard   First commit
61

3493f196   Benjamin Renard   Add request to ge...
62
63
64
65
66
67
68
69
70
71
	public function getRequestType()
	{
		return $this->requestType;
	}
	
	public function setRequestType($requestType)
	{
		$this->requestType = $requestType;
	}
	
92a8e6b0   Elena.Budnik   temporary commot
72
73
74
75
76
77
78
79
	public function getTask()
	{
		return $this->task;
	}
	
	public function setTask($task)
	{
		$this->task = $task;
92a8e6b0   Elena.Budnik   temporary commot
80
	}
70e82c1f   Benjamin Renard   Fix doPlot
81

7d14181a   Benjamin Renard   Fix multi-request...
82
	public function addRequestNode($request_index)
22521f1c   Benjamin Renard   First commit
83
	{
8c57155b   Benjamin Renard   Integration for t...
84
		$newRequestNode = new RequestNodeClass();
7d14181a   Benjamin Renard   Fix multi-request...
85
		$this->requestNodes[$request_index] = $newRequestNode;
8c57155b   Benjamin Renard   Integration for t...
86
87
88
89
90
91
		return $newRequestNode;
	}
	
	public function getRequestNodes()
	{
		return $this->requestNodes;
22521f1c   Benjamin Renard   First commit
92
93
	}

98881737   Benjamin Renard   Add post processi...
94
95
96
97
98
	public function getWaitingResults()
	{
		return $this->waitingResults;
	}
	
22521f1c   Benjamin Renard   First commit
99
100
101
102
103
104
105
106
107
108
	public function getWaitingResult($key)
	{
		return $this->waitingResults[$key];
	}

	public function addWaitingResult($key, $result)
	{
		$this->waitingResults[$key] = $result;
	}

3493f196   Benjamin Renard   Add request to ge...
109
110
111
112
113
114
115
116
117
118
	public function getParamId()
	{
		return $this->paramId;
	}
	
	public function setParamId($paramId)
	{
		$this->paramId = $paramId;
	}
	
22521f1c   Benjamin Renard   First commit
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	public function getParamsToCopy()
	{
		return $this->paramsToCopy;
	}

	public function addParamToCopy($paramId,$paramFilePath)
	{
		$this->paramsToCopy[$paramId] = $paramFilePath;
	}

	public function getProcessParamsToCreate()
	{
		return $this->processParamsToCreate;
	}
59eb1b9c   Elena.Budnik   new ama stat
133
134
135
136
137
138
139
140
141
142
143
	
	public function getDatasetForStat()
	{
		return $this->datasetId;
	}
	
	public function addDatasetForStat($dsId)
	{
		$this->datasetId[] = $dsId;
	}
	
b1a5ee3c   Erdogan Furkan   Integration part ...
144
	public function addProcessParamToCreate($paramId, $expression, $expression_info, $getParams, $sampling_mode, $sampling_step, $ref_param, $gap, $dateModif, $units, $ytitle, $status)
22521f1c   Benjamin Renard   First commit
145
146
147
	{
		$newParam = new ParamNodeClass();
		$newParam->setId($paramId);
c0535e83   Benjamin Renard   Use units and yTi...
148
149
150
151
152
153
154
155
156
		if (!empty($units)) {
			$newParam->getInfo()->setUnits($units);
		}
		if (!empty($ytitle)) {
			$newParam->getInfo()->setShortName($ytitle);
		}
		else {
			$newParam->getInfo()->setShortName($paramId);
		}
b1a5ee3c   Erdogan Furkan   Integration part ...
157
158
159
160
161
		if (!empty($status)) {
			foreach ($status as $def) {
				$newParam->getInfo()->addStatus($def["min"], $def["max"], $def["name"], $def["color"]);
			}
		}
4c975261   Benjamin Renard   Add modif. time f...
162
163
164
165
166
167
168
169
170
171
172
173
		switch ($sampling_mode) {
			case 'refparam':
				$newParam->setReferenceParameter($ref_param);
				$amdaParamNode = $newParam->addParamGet(ParamGetTypeEnum::AMDAPARAM);
				$amdaParamNode->setParamName($ref_param);
				break;
			default:
				$newParam->setSampling($sampling_step);
				if (isset($gap) && ($gap > 0))
					$newParam->setGap($gap);
				break;
		}
22521f1c   Benjamin Renard   First commit
174
175
176
		foreach ($getParams as $getParam)
		{
			$amdaParamNode = $newParam->addParamGet(ParamGetTypeEnum::AMDAPARAM);
e4545ed5   Benjamin Renard   Implement templat...
177
178
179
180
			if (array_key_exists('template_args', $getParam))
				$amdaParamNode->setParamName($getParam['fullparamid']);
			else
				$amdaParamNode->setParamName($getParam['paramid']);
22521f1c   Benjamin Renard   First commit
181
		}
a04159d9   Benjamin Renard   Define common lib...
182
		$newParam->setProcess($expression, $expression_info, true);
22521f1c   Benjamin Renard   First commit
183
		$newParam->setOutput();
ffc5cb81   Elena.Budnik   temporary commit
184

286f7924   Benjamin Renard   Derived parameter...
185
		$this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
52c1e291   Benjamin Renard   Generate TT and c...
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
	}

	public function addTTCatParamToCreate($paramId, $ttCatFilePath, $isShared, $dateModif, $units, $ytitle, $status, $flag = "")
	{
		$newParam = new ParamNodeClass();
		$newParam->setId($paramId);
		if (!empty($units)) {
			$newParam->getInfo()->setUnits($units);
		}
		if (!empty($ytitle)) {
			$newParam->getInfo()->setShortName($ytitle);
		}
		else {
			$newParam->getInfo()->setShortName($paramId);
		}
		if (!empty($status)) {
			foreach ($status as $def) {
				$newParam->getInfo()->addStatus($def["min"], $def["max"], $def["name"], $def["color"]);
			}
		}
		$constantGetNode = $newParam->addParamGet(ParamGetTypeEnum::CONSTANT);
		$constantParamNode = $constantGetNode->addConstant();
		$constantParamNode->setSampling(1);
		$process = "#ttcat_to_param(\$constant_1_".$constantParamNode->getType()."_";
		$process .= $constantParamNode->getConstValue()."_".$constantParamNode->getDim1()."_".$constantParamNode->getDim2().";".$ttCatFilePath;
		if (!empty($flag)) {
			$process .= ";".$flag;
		}
		$process .= ")";
		$newParam->setProcess($process, "Transform Time Table or Catalog to a parameter", !$isShared);
		$newParam->setOutput();

		$this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
22521f1c   Benjamin Renard   First commit
219
	}
944199fe   Benjamin Renard   Use table definit...
220
221
222
223
224
225
	
	public function getLocalParamsToCreate()
	{
		return $this->localParamsToCreate;
	}
	
ffc5cb81   Elena.Budnik   temporary commit
226
227
228
229
230
	public function getLocalParamsToCreateAndCopy()
	{
		return $this->localParamsToCreateAndCopy;
	}	
	
b1a5ee3c   Erdogan Furkan   Integration part ...
231
	public function addLocalParamToCreate($paramId, $viId, $realVarId, $minSampling, $maxSampling, $type, $size, $fillValue, $dateModif, $status, $isImpex = false)
944199fe   Benjamin Renard   Use table definit...
232
233
234
235
	{
		$newParam = new ParamNodeClass();
		$newParam->setId($paramId);
		
e99d9ed4   Benjamin Renard   Support fillValue...
236
237
238
239
		$infoNode = $newParam->getInfo();
                if (isset($fillValue)) {
                    $infoNode->setFillVal($fillValue);
                }
944199fe   Benjamin Renard   Use table definit...
240
241
242
243
		
		$localParamNode = $newParam->addParamGet(ParamGetTypeEnum::LOCALBASE);
		$localParamNode->setVIId($viId);
		
e8ff4ba7   Elena.Budnik   integration of as...
244
		$localParamNode->addLocalParam($realVarId, $minSampling, $maxSampling, $type, $size);
944199fe   Benjamin Renard   Use table definit...
245
		
e9165342   Benjamin Renard   Write data mining...
246
		$newParam->setProcess("","");
944199fe   Benjamin Renard   Use table definit...
247
		$newParam->setOutput();
b1a5ee3c   Erdogan Furkan   Integration part ...
248
249
250
251
252
253

		if (!empty($status)) {
			foreach ($status as $def) {
				$newParam->getInfo()->addStatus($def["min"], $def["max"], $def["name"], $def["color"]);
			}
		}
ffc5cb81   Elena.Budnik   temporary commit
254
255
256
257
258
259
260
261
262
		
		if ($isImpex) 
		{			
			$this->localParamsToCreateAndCopy[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
		}
		else
		{
			$this->localParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
		}
944199fe   Benjamin Renard   Use table definit...
263
264
265
		
		return $newParam;
	}
b3343120   Benjamin Renard   Check parameters ...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

	public function addParamTimeRestriction($paramId, $timeRestriction)
	{
		if (array_key_exists($paramId, $this->paramTimeRestriction)) {
			if (strtotime($timeRestriction) > strtotime($this->paramTimeRestriction[$paramId])) {
				return;
			}
		}
		$this->paramTimeRestriction[$paramId] = $timeRestriction;
	}

	public function getParamsTimeRestrictions()
	{
		return $this->paramTimeRestriction;
	}
22521f1c   Benjamin Renard   First commit
281
282
}

e9165342   Benjamin Renard   Write data mining...
283
?>