IHMInputOutputParamsStatisticsClass.php
3.74 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
<?php
define ("STATISTICS_RESULT_FILE_KEY", "statistic");
/**
* @class IHMInputOutputParamsStatisticsClass
* @brief Implementation of IHMInputOutputParamsAbstractClass to treat catalog generation request
* @details
*/
class IHMInputOutputParamsStatisticsClass extends IHMInputOutputParamsAbstractClass
{
/*
* @brief method to unmarshall a catalog generation request
*/
protected function unmarshallRequest($input)
{
/*
{"id":"",
"timesrc":"TimeTable","name":"test",
"created":null,"description":"first","objName":"","objFormat":"","folderId":"","nbIntervals":0,"cacheToken":"",
"parameter":[{"param":"imf_gsm","function":"min","template_args":"{}"},{"param":"imf_mag","function":"max","template_args":"{}"}],
"timeTables":[{"id":"sharedtt_26"},{"id":"sharedtt_27"}],"leaf":true,"nodeType":"catalog"}]'
*/
$requestNode = $this->paramsData->addRequestNode(0);
$paramsNode = $requestNode->getParamsNode();
//unmarshall time definition
$this->unmarshallTimeDefinition($input, 0);
//unmarshall statistic output definition
$outputsNode = $requestNode->getOutputsNode();
$catalogNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::STATISTIC);
$catalogNode->setTimeFormat(RequestOutputStatisticTimeFormatEnum::ISO);
$catalogNode->setFileFormat(RequestOutputStatisticFileFormatEnum::XML);
$paramTemplateArgs = array(count($input->parameter), count($input->parameter));
$paramTemplateIndex = array(count($input->parameter), count($input->parameter));
// parse parameters / functions array
foreach ($input->parameter as $obj)
{
$paramFunctionAssociation[$obj->paramid][] = $obj->function;
// parse template args and indices for template params
$array = (array) $obj->template_args;
if (!empty ($array)) {
$paramTemplateArgs[$obj->paramid][$obj->function] = $obj->template_args;
if (($obj->{'dim1-index'} != '*') && ($obj->{'dim1-index'} != '')) {
$paramTemplateIndex[$obj->paramid][$obj->function] = $obj->{'dim1-index'};
}
}
}
foreach ($paramFunctionAssociation as $param => $functions)
{
// template parameter
if (!empty($paramTemplateArgs[$param]))
{
foreach ($functions as $function)
{
$templateArgs = $paramTemplateArgs[$param][$function];
$paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData, $templateArgs);
$paramsNode->addParam($paramInfo['id']);
if ($paramTemplateIndex[$param][$function] != null)
{
$paramInfo['indexes'] = array();
$paramInfo['indexes'][] = $paramTemplateIndex[$param][$function];
}
$outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
$outputParamNode->addFunction($function);
}
}
// normal parameter
else
{
$paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData);
$paramsNode->addParam($paramInfo['id']);
$outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
foreach ($functions as $function)
$outputParamNode->addFunction($function);
}
}
$resultFile = "result_".$this->requestID;
$this->paramsData->addWaitingResult(STATISTICS_RESULT_FILE_KEY, $resultFile);
$postProcessCmd = "mv statistic-*";
$postProcessCmd .= " ".$resultFile.".xml";
$this->paramsData->setPostCmd($postProcessCmd);
return $this->paramsData;
}
/*
* @brief method to marshall the result of a catalog generation request
*/
protected function marshallResult($data)
{
return $this->commonMarshallResult($data,STATISTICS_RESULT_FILE_KEY);
}
}
?>