Commit e4cf87dcec6fbf599e2b41b55d109a4187eda537

Authored by Elena.Budnik
1 parent ddb6bf06

params with args processing

src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php
... ... @@ -15,7 +15,11 @@ class IHMInputOutputParamsStatisticsClass extends IHMInputOutputParamsAbstractCl
15 15 protected function unmarshallRequest($input)
16 16 {
17 17 /*
18   - {"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"}]'
  18 + {"id":"",
  19 + "timesrc":"TimeTable","name":"test",
  20 + "created":null,"description":"first","objName":"","objFormat":"","folderId":"","nbIntervals":0,"cacheToken":"",
  21 + "parameter":[{"param":"imf_gsm","function":"min","template_args":"{}"},{"param":"imf_mag","function":"max","template_args":"{}"}],
  22 + "timeTables":[{"id":"sharedtt_26"},{"id":"sharedtt_27"}],"leaf":true,"nodeType":"catalog"}]'
19 23 */
20 24 $requestNode = $this->paramsData->addRequestNode();
21 25  
... ... @@ -30,26 +34,60 @@ class IHMInputOutputParamsStatisticsClass extends IHMInputOutputParamsAbstractCl
30 34 $catalogNode->setTimeFormat(RequestOutputStatisticTimeFormatEnum::ISO);
31 35 $catalogNode->setFileFormat(RequestOutputStatisticFileFormatEnum::XML);
32 36  
33   - // parse parameters / functions array
34   - foreach ($input->parameter as $obj) {
35   - $paramFunctionAssociation[$obj->param][] = $obj->function;
36   - }
37   -
38   - foreach ($paramFunctionAssociation as $param => $functions) {
  37 + $paramTemplateArgs = array(count($input->parameter), count($input->parameter));
  38 + $paramTemplateIndex = array(count($input->parameter), count($input->parameter));
  39 +
  40 + // parse parameters / functions array
  41 + foreach ($input->parameter as $obj)
  42 + {
  43 + $paramFunctionAssociation[$obj->paramid][] = $obj->function;
  44 + // parse template args and indices for template params
  45 + $array = (array) $obj->template_args;
  46 + if (!empty ($array)) {
  47 + $paramTemplateArgs[$obj->paramid][$obj->function] = $obj->template_args;
  48 + if (($obj->{'dim1-index'} != '*') && ($obj->{'dim1-index'} != '')) {
  49 + $paramTemplateIndex[$obj->paramid][$obj->function] = $obj->{'dim1-index'};
  50 + }
  51 + }
  52 + }
39 53  
40   - $paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData);
41   - $paramsNode->addParam($paramInfo['id']);
42   - $outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
43   - foreach ($functions as $function) $outputParamNode->addFunction($function);
44   - }
  54 + foreach ($paramFunctionAssociation as $param => $functions)
  55 + {
  56 + // template parameter
  57 + if ($paramTemplateArgs[$param])
  58 + {
  59 + foreach ($functions as $function)
  60 + {
  61 + $templateArgs = $paramTemplateArgs[$param][$function];
  62 + $paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData, $templateArgs);
  63 + $paramsNode->addParam($paramInfo['id']);
  64 + if ($paramTemplateIndex[$param][$function] != null)
  65 + {
  66 + $paramInfo['indexes'] = array();
  67 + $paramInfo['indexes'][] = $paramTemplateIndex[$param][$function];
  68 + }
  69 + $outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
  70 + $outputParamNode->addFunction($function);
  71 + }
  72 + }
  73 + // normal parameter
  74 + else
  75 + {
  76 + $paramInfo = $this->paramManager->addExistingParam($param, $this->paramsData);
  77 + $paramsNode->addParam($paramInfo['id']);
  78 + $outputParamNode = $catalogNode->addParam($paramInfo['id'],$paramInfo['indexes']);
  79 +
  80 + foreach ($functions as $function)
  81 + $outputParamNode->addFunction($function);
  82 + }
  83 + }
45 84  
46 85 $resultFile = "result_".$this->requestID;
47 86 $this->paramsData->addWaitingResult(STATISTICS_RESULT_FILE_KEY, $resultFile);
48   -//
  87 +
49 88 $postProcessCmd = "mv statistic-*";
50 89 $postProcessCmd .= " ".$resultFile.".xml";
51 90  
52   -//
53 91 $this->paramsData->setPostCmd($postProcessCmd);
54 92 return $this->paramsData;
55 93 }
... ...