From e4cf87dcec6fbf599e2b41b55d109a4187eda537 Mon Sep 17 00:00:00 2001 From: Elena.Budnik Date: Fri, 21 Apr 2017 16:21:09 +0200 Subject: [PATCH] params with args processing --- src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php b/src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php index 7c245bf..b2e267c 100644 --- a/src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php +++ b/src/InputOutput/IHMImpl/Params/StatisticsImpl/IHMInputOutputParamsStatisticsClass.php @@ -15,7 +15,11 @@ class IHMInputOutputParamsStatisticsClass extends IHMInputOutputParamsAbstractCl 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"}]' + {"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(); @@ -30,26 +34,60 @@ class IHMInputOutputParamsStatisticsClass extends IHMInputOutputParamsAbstractCl $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) { + $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'}; + } + } + } - $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); - } + 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); + } + } $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; } -- libgit2 0.21.2