Commit c0535e834f9229275e4b7a0d3f02bfc7d35fd9b8

Authored by Benjamin Renard
1 parent 97a69b20

Use units and yTitle definition for a derived parameter (#5672)

src/InputOutput/IHMImpl/Params/DataMiningImpl/IHMInputOutputParamsDataMiningClass.php
@@ -38,7 +38,7 @@ class IHMInputOutputParamsDataMiningClass extends IHMInputOutputParamsAbstractCl @@ -38,7 +38,7 @@ class IHMInputOutputParamsDataMiningClass extends IHMInputOutputParamsAbstractCl
38 //create a derived param for the expression 38 //create a derived param for the expression
39 $this->paramManager->addProcessParam($paramId, $expressionInfo["expression"], $input->expression, 39 $this->paramManager->addProcessParam($paramId, $expressionInfo["expression"], $input->expression,
40 $expressionInfo['params'], $input->sampling, 40 $expressionInfo['params'], $input->sampling,
41 - $input->gap,time(),$this->paramsData); 41 + $input->gap,time(),"","",$this->paramsData);
42 42
43 //add derived param to output 43 //add derived param to output
44 $paramsNode->addParam($paramId); 44 $paramsNode->addParam($paramId);
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -39,9 +39,9 @@ class IHMParamManagerClass @@ -39,9 +39,9 @@ class IHMParamManagerClass
39 /* 39 /*
40 * @brief Add a process parameter 40 * @brief Add a process parameter
41 */ 41 */
42 - public function addProcessParam($paramId,$expression,$expression_info,$params,$sampling,$gap,$dateModif,$paramsData)  
43 - {  
44 - $paramsData->addProcessParamToCreate($paramId, $expression, $expression_info, $params, $sampling, $gap,$dateModif); 42 + public function addProcessParam($paramId,$expression,$expression_info,$params,$sampling,$gap,$dateModif,$units,$ytitle,$paramsData)
  43 + {
  44 + $paramsData->addProcessParamToCreate($paramId, $expression, $expression_info, $params, $sampling, $gap,$dateModif, $units, $ytitle);
45 45
46 foreach ($params as $param) { 46 foreach ($params as $param) {
47 $template_args = NULL; 47 $template_args = NULL;
@@ -202,7 +202,8 @@ class IHMParamManagerClass @@ -202,7 +202,8 @@ class IHMParamManagerClass
202 //create a process param for the derived parameter 202 //create a process param for the derived parameter
203 $this->addProcessParam($paramId, $expressionInfo["expression"], $res["param"]["expression"], 203 $this->addProcessParam($paramId, $expressionInfo["expression"], $res["param"]["expression"],
204 $expressionInfo['params'], $res["param"]["timestep"], 204 $expressionInfo['params'], $res["param"]["timestep"],
205 - 0,$res["param"]["dateModif"],$paramsData); 205 + 0,$res["param"]["dateModif"],!empty($res["param"]["info"]["units"]) ? $res["param"]["info"]["units"] : "",
  206 + !empty($res["param"]["info"]["yTitle"]) ? $res["param"]["info"]["yTitle"] : "", $paramsData);
206 207
207 return array("id" => $paramId, "indexes" => array(), "calib_infos" => array()); 208 return array("id" => $paramId, "indexes" => array(), "calib_infos" => array());
208 } 209 }
src/InputOutput/IHMImpl/Tools/IHMUserParamLoaderClass.php
@@ -19,7 +19,10 @@ class IHMUserParamLoaderClass @@ -19,7 +19,10 @@ class IHMUserParamLoaderClass
19 19
20 //additional info for derived parameter 20 //additional info for derived parameter
21 private static $infoDerivedUnitsNode = 'units'; 21 private static $infoDerivedUnitsNode = 'units';
  22 + private static $infoDerivedYTitleNode = 'ytitle';
22 private static $infoDerivedDescriptionNode = 'description'; 23 private static $infoDerivedDescriptionNode = 'description';
  24 +
  25 + private static $infoDerivedUndefined = 'undefined';
23 26
24 //uploaded parameters in manager file 27 //uploaded parameters in manager file
25 private static $mgrUploadedNode = 'mydataList'; 28 private static $mgrUploadedNode = 'mydataList';
@@ -255,6 +258,7 @@ class IHMUserParamLoaderClass @@ -255,6 +258,7 @@ class IHMUserParamLoaderClass
255 258
256 $result = array( 259 $result = array(
257 "units" => "", 260 "units" => "",
  261 + "yTitle" => "",
258 "description" => "" 262 "description" => ""
259 ); 263 );
260 264
@@ -268,8 +272,21 @@ class IHMUserParamLoaderClass @@ -268,8 +272,21 @@ class IHMUserParamLoaderClass
268 272
269 //get parameter units 273 //get parameter units
270 $unitsNodes = $dom->getElementsByTagName(self::$infoDerivedUnitsNode); 274 $unitsNodes = $dom->getElementsByTagName(self::$infoDerivedUnitsNode);
271 - if (count($unitsNodes) > 0) 275 + if (count($unitsNodes) > 0) {
272 $result["units"] = $unitsNodes->item(0)->nodeValue; 276 $result["units"] = $unitsNodes->item(0)->nodeValue;
  277 + if ($result["units"] == self::$infoDerivedUndefined) {
  278 + $result["units"] = "";
  279 + }
  280 + }
  281 +
  282 + //get parameter y title
  283 + $yTitleNodes = $dom->getElementsByTagName(self::$infoDerivedYTitleNode);
  284 + if (count($yTitleNodes) > 0) {
  285 + $result["yTitle"] = $yTitleNodes->item(0)->nodeValue;
  286 + if ($result["yTitle"] == self::$infoDerivedUndefined) {
  287 + $result["yTitle"] = "";
  288 + }
  289 + }
273 290
274 //get parameter description 291 //get parameter description
275 $descNodes = $dom->getElementsByTagName(self::$infoDerivedDescriptionNode); 292 $descNodes = $dom->getElementsByTagName(self::$infoDerivedDescriptionNode);
@@ -361,4 +378,4 @@ class IHMUserParamLoaderClass @@ -361,4 +378,4 @@ class IHMUserParamLoaderClass
361 378
362 return $result; 379 return $result;
363 } 380 }
364 -}  
365 \ No newline at end of file 381 \ No newline at end of file
  382 +}
src/Request/ParamsRequestImpl/ParamsRequestDataClass.php
@@ -117,10 +117,19 @@ class ParamsRequestDataClass extends ProcessRequestDataClass @@ -117,10 +117,19 @@ class ParamsRequestDataClass extends ProcessRequestDataClass
117 return $this->processParamsToCreate; 117 return $this->processParamsToCreate;
118 } 118 }
119 119
120 - public function addProcessParamToCreate($paramId, $expression, $expression_info, $getParams, $sampling, $gap, $dateModif) 120 + public function addProcessParamToCreate($paramId, $expression, $expression_info, $getParams, $sampling, $gap, $dateModif, $units, $ytitle)
121 { 121 {
122 $newParam = new ParamNodeClass(); 122 $newParam = new ParamNodeClass();
123 $newParam->setId($paramId); 123 $newParam->setId($paramId);
  124 + if (!empty($units)) {
  125 + $newParam->getInfo()->setUnits($units);
  126 + }
  127 + if (!empty($ytitle)) {
  128 + $newParam->getInfo()->setShortName($ytitle);
  129 + }
  130 + else {
  131 + $newParam->getInfo()->setShortName($paramId);
  132 + }
124 $newParam->setSampling($sampling); 133 $newParam->setSampling($sampling);
125 if (isset($gap) && ($gap > 0)) 134 if (isset($gap) && ($gap > 0))
126 $newParam->setGap($gap); 135 $newParam->setGap($gap);