Blame view

src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php 2.57 KB
01ff2cc6   elena   catalog draft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?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"},{"param":"imf_mag","function":"max"}],"timeTables":[{"id":"sharedtt_26"},{"id":"sharedtt_27"}],"leaf":true,"nodeType":"catalog"}]'
		 */
5e00164f   Benjamin Renard   Merge modificatio...
20
21
22
		$requestNode = $this->paramsData->addRequestNode();

		$paramsNode = $requestNode->getParamsNode();
01ff2cc6   elena   catalog draft
23
24

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

		//unmarshall statistic output definition
5e00164f   Benjamin Renard   Merge modificatio...
28
		$outputsNode = $requestNode->getOutputsNode();
01ff2cc6   elena   catalog draft
29
30
31
32
33
34
35
36
37
38
		$catalogNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::STATISTIC);
		$catalogNode->setTimeFormat(RequestOutputStatisticTimeFormatEnum::ISO);
		$catalogNode->setFileFormat(RequestOutputStatisticFileFormatEnum::XML);
		
		// parse parameters / functions array                       
                foreach ($input->parameter as $obj) { 
                   $paramFunctionAssociation[$obj->param][] = $obj->function;                
                }
                
                foreach ($paramFunctionAssociation as $param => $functions) {
ecdabbec   elena   index for statistics
39
                
bf27ba04   Benjamin Renard   Add templated par...
40
                     $paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData);                     			
e4545ed5   Benjamin Renard   Implement templat...
41
						$paramsNode->addParam($paramInfo['id']);                     
ecdabbec   elena   index for statistics
42
43
                     $outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
                     foreach ($functions as $function) $outputParamNode->addFunction($function);                     
01ff2cc6   elena   catalog draft
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                } 

 		$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);
	}
}
5e00164f   Benjamin Renard   Merge modificatio...
65
?>