Blame view

src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php 3.74 KB
01ff2cc6   elena   catalog draft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?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)
	{
		/*
e4cf87dc   Elena.Budnik   params with args ...
18
19
20
21
22
		   {"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"}]'
01ff2cc6   elena   catalog draft
23
		 */
5e00164f   Benjamin Renard   Merge modificatio...
24
25
26
		$requestNode = $this->paramsData->addRequestNode();

		$paramsNode = $requestNode->getParamsNode();
01ff2cc6   elena   catalog draft
27
28

		//unmarshall time definition
49311864   Benjamin Renard   Fix a bug with ti...
29
		$this->unmarshallTimeDefinition($input, 0);
01ff2cc6   elena   catalog draft
30
31

		//unmarshall statistic output definition
5e00164f   Benjamin Renard   Merge modificatio...
32
		$outputsNode = $requestNode->getOutputsNode();
01ff2cc6   elena   catalog draft
33
34
35
36
		$catalogNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::STATISTIC);
		$catalogNode->setTimeFormat(RequestOutputStatisticTimeFormatEnum::ISO);
		$catalogNode->setFileFormat(RequestOutputStatisticFileFormatEnum::XML);
		
e4cf87dc   Elena.Budnik   params with args ...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
		$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'};
				}
			}
		}
ecdabbec   elena   index for statistics
53
                
e4cf87dc   Elena.Budnik   params with args ...
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
		foreach ($paramFunctionAssociation as $param => $functions) 
		{	
			// template parameter
			if ($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);
			}
		} 
01ff2cc6   elena   catalog draft
84
85
86

 		$resultFile = "result_".$this->requestID;
		$this->paramsData->addWaitingResult(STATISTICS_RESULT_FILE_KEY, $resultFile);
e4cf87dc   Elena.Budnik   params with args ...
87
 
01ff2cc6   elena   catalog draft
88
89
90
		$postProcessCmd  = "mv statistic-*";
		$postProcessCmd .= " ".$resultFile.".xml";
 
01ff2cc6   elena   catalog draft
91
92
93
94
95
96
97
98
99
100
101
102
		$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);
	}
}
5e00164f   Benjamin Renard   Merge modificatio...
103
?>