Commit 0dd42438d6599f845c28367a5e87c81c2707294f
1 parent
90f366ce
Exists in
master
and in
54 other branches
WS getDataset without resampling #7170
Showing
2 changed files
with
18 additions
and
19 deletions
Show diff stats
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
... | ... | @@ -186,6 +186,7 @@ class IHMParamManagerClass |
186 | 186 | |
187 | 187 | //check templated parameter |
188 | 188 | $real_param_id = $paramId; |
189 | + $paramPath = ""; | |
189 | 190 | if ($this->templateParamsManager->isTemplatedParam($paramId)) { |
190 | 191 | $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink); |
191 | 192 | $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs); |
... | ... | @@ -202,7 +203,7 @@ class IHMParamManagerClass |
202 | 203 | |
203 | 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 | 40 | $outputsNode = $requestNode->getOutputsNode(); |
41 | 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 | 46 | switch (strtoupper($input->timeformat)) |
44 | 47 | { |
45 | 48 | case 'ISO08601' : |
... | ... | @@ -51,6 +54,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
51 | 54 | default : |
52 | 55 | $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO); |
53 | 56 | } |
57 | + $hash .= $input->timeformat; | |
54 | 58 | |
55 | 59 | switch ($input->fileformat) |
56 | 60 | { |
... | ... | @@ -77,7 +81,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
77 | 81 | //add params to output |
78 | 82 | $resultFile = WSInputOutputClass::getService(); |
79 | 83 | $isFirst = true; |
80 | - | |
84 | + | |
81 | 85 | foreach ($input->list as $param) |
82 | 86 | { |
83 | 87 | $paramInfo = $this->paramManager->addExistingParam($param->paramid, $this->paramsData/*, $param->template_args*/); |
... | ... | @@ -86,14 +90,14 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
86 | 90 | $downloadNode->addParam($paramInfo['id'],$paramInfo['indexes'],$paramInfo['calib_infos']); |
87 | 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 | 96 | $isFirst = false; |
93 | 97 | } |
94 | 98 | elseif ( WSInputOutputClass::getService() != WSConfigClass::DATASET ) |
95 | 99 | { |
96 | - $resultFile .= "_".$paramInfo['id']; | |
100 | + $resultFile .= "_".$input->file_info; | |
97 | 101 | if (!empty($paramInfo['indexes'])) |
98 | 102 | foreach ($paramInfo['indexes'] as $index) |
99 | 103 | $resultFile .= "_".$index; |
... | ... | @@ -105,7 +109,13 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
105 | 109 | { |
106 | 110 | $downloadNode->setSamplingTime($input->sampling); |
107 | 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 | 119 | else { |
110 | 120 | $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_PER_PARAMETER_PER_INTERVAL); |
111 | 121 | } |
... | ... | @@ -123,7 +133,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
123 | 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 | 138 | $this->paramsData->addWaitingResult(WSInputOutputClass::getService(), $resultFile.$extension); |
129 | 139 | |
... | ... | @@ -179,18 +189,6 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass |
179 | 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 | 193 | * @brief method to marshall the result of a download request |
196 | 194 | */ |
... | ... |