Commit 0dd42438d6599f845c28367a5e87c81c2707294f

Authored by Benjamin Renard
1 parent 90f366ce

WS getDataset without resampling #7170

src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -186,6 +186,7 @@ class IHMParamManagerClass @@ -186,6 +186,7 @@ class IHMParamManagerClass
186 186
187 //check templated parameter 187 //check templated parameter
188 $real_param_id = $paramId; 188 $real_param_id = $paramId;
  189 + $paramPath = "";
189 if ($this->templateParamsManager->isTemplatedParam($paramId)) { 190 if ($this->templateParamsManager->isTemplatedParam($paramId)) {
190 $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink); 191 $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink);
191 $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs); 192 $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs);
@@ -202,7 +203,7 @@ class IHMParamManagerClass @@ -202,7 +203,7 @@ class IHMParamManagerClass
202 203
203 $this->addLinkedLocalParams($paramId, $paramsData, $templateArgs); 204 $this->addLinkedLocalParams($paramId, $paramsData, $templateArgs);
204 205
205 - return array("id" => $real_param_id, "indexes" => $indexes, "calib_infos" => $calib_infos); 206 + return array("id" => $real_param_id, "indexes" => $indexes, "calib_infos" => $calib_infos, "path" => $paramPath);
206 } 207 }
207 208
208 /* 209 /*
src/InputOutput/WSImpl/Params/DownloadImpl/WSInputOutputParamsDownloadClass.php
@@ -40,6 +40,9 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -40,6 +40,9 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
40 $outputsNode = $requestNode->getOutputsNode(); 40 $outputsNode = $requestNode->getOutputsNode();
41 $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD); 41 $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD);
42 42
  43 + // hash is used to be sure to have a unique file name for two differents requests
  44 + $hash = "";
  45 +
43 switch (strtoupper($input->timeformat)) 46 switch (strtoupper($input->timeformat))
44 { 47 {
45 case 'ISO08601' : 48 case 'ISO08601' :
@@ -51,6 +54,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -51,6 +54,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
51 default : 54 default :
52 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO); 55 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO);
53 } 56 }
  57 + $hash .= $input->timeformat;
54 58
55 switch ($input->fileformat) 59 switch ($input->fileformat)
56 { 60 {
@@ -77,7 +81,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -77,7 +81,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
77 //add params to output 81 //add params to output
78 $resultFile = WSInputOutputClass::getService(); 82 $resultFile = WSInputOutputClass::getService();
79 $isFirst = true; 83 $isFirst = true;
80 - 84 +
81 foreach ($input->list as $param) 85 foreach ($input->list as $param)
82 { 86 {
83 $paramInfo = $this->paramManager->addExistingParam($param->paramid, $this->paramsData/*, $param->template_args*/); 87 $paramInfo = $this->paramManager->addExistingParam($param->paramid, $this->paramsData/*, $param->template_args*/);
@@ -86,14 +90,14 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -86,14 +90,14 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
86 $downloadNode->addParam($paramInfo['id'],$paramInfo['indexes'],$paramInfo['calib_infos']); 90 $downloadNode->addParam($paramInfo['id'],$paramInfo['indexes'],$paramInfo['calib_infos']);
87 $paramsNode->addParam($paramInfo['id']); 91 $paramsNode->addParam($paramInfo['id']);
88 92
89 - if ( WSInputOutputClass::getService() == WSConfigClass::DATASET && $isFirst) 93 + if ( (WSInputOutputClass::getService() == WSConfigClass::DATASET) && $isFirst)
90 { 94 {
91 - $resultFile .= "_".$this->getDatasetIdFromParamInfo($param->paramid); 95 + $resultFile .= "_".$input->file_info;
92 $isFirst = false; 96 $isFirst = false;
93 } 97 }
94 elseif ( WSInputOutputClass::getService() != WSConfigClass::DATASET ) 98 elseif ( WSInputOutputClass::getService() != WSConfigClass::DATASET )
95 { 99 {
96 - $resultFile .= "_".$paramInfo['id']; 100 + $resultFile .= "_".$input->file_info;
97 if (!empty($paramInfo['indexes'])) 101 if (!empty($paramInfo['indexes']))
98 foreach ($paramInfo['indexes'] as $index) 102 foreach ($paramInfo['indexes'] as $index)
99 $resultFile .= "_".$index; 103 $resultFile .= "_".$index;
@@ -105,7 +109,13 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -105,7 +109,13 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
105 { 109 {
106 $downloadNode->setSamplingTime($input->sampling); 110 $downloadNode->setSamplingTime($input->sampling);
107 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE); 111 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE);
108 - } 112 + $hash .= $input->sampling;
  113 + }
  114 + else if ($input->ref_sampling_param)
  115 + {
  116 + $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_REFPARAM);
  117 + $hash .= $input->ref_sampling_param;
  118 + }
109 else { 119 else {
110 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_PER_PARAMETER_PER_INTERVAL); 120 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_PER_PARAMETER_PER_INTERVAL);
111 } 121 }
@@ -123,7 +133,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -123,7 +133,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
123 $resultFilePrefix = "output-"; 133 $resultFilePrefix = "output-";
124 } 134 }
125 135
126 - $resultFile .= "_".date("Ymd\THis", strtotime($input->startDate))."_".date("Ymd\THis",strtotime($input->stopDate)); 136 + $resultFile .= '_' . md5($hash) . "_".date("Ymd\THis", strtotime($input->startDate))."_".date("Ymd\THis",strtotime($input->stopDate));
127 137
128 $this->paramsData->addWaitingResult(WSInputOutputClass::getService(), $resultFile.$extension); 138 $this->paramsData->addWaitingResult(WSInputOutputClass::getService(), $resultFile.$extension);
129 139
@@ -179,18 +189,6 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -179,18 +189,6 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
179 return $result; 189 return $result;
180 } 190 }
181 191
182 - protected function getDatasetIdFromParamInfo($paramId)  
183 - {  
184 - $paramInfoFilePath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml";  
185 - $dom = new DomDocument("1.0");  
186 -  
187 - $dom->load($paramInfoFilePath);  
188 -  
189 - return $dom->getElementsByTagName("dataset_id")->item(0)->nodeValue;  
190 -  
191 -  
192 - }  
193 -  
194 /* 192 /*
195 * @brief method to marshall the result of a download request 193 * @brief method to marshall the result of a download request
196 */ 194 */