Commit dcdacd5ccff1da0a0ce95efb79b4e759d734986b

Authored by Benjamin Renard
1 parent 2c0e1b9a

Fill plot type in plot manager for My Data parameters (#4903)

src/InputOutput/IHMImpl/ParamInfo/IHMInputOutputParamInfoClass.php
@@ -8,8 +8,9 @@ @@ -8,8 +8,9 @@
8 class IHMInputOutputParamInfoClass implements InputOutputInterface 8 class IHMInputOutputParamInfoClass implements InputOutputInterface
9 { 9 {
10 private $paramInfoData = null; 10 private $paramInfoData = null;
  11 + private $paramMgr = null;
11 private $paramTemplateMgr = null; 12 private $paramTemplateMgr = null;
12 - private $paramImpexMgr = null; 13 + private $paramImpexMgr = null;
13 14
14 /* 15 /*
15 * @brief Constructor 16 * @brief Constructor
@@ -17,6 +18,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface @@ -17,6 +18,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface
17 function __construct() 18 function __construct()
18 { 19 {
19 $this->paramTemplateMgr = new IHMParamTemplateClass(); 20 $this->paramTemplateMgr = new IHMParamTemplateClass();
  21 + $this->paramMgr = new IHMParamManagerClass();
20 } 22 }
21 23
22 /* 24 /*
@@ -33,20 +35,44 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface @@ -33,20 +35,44 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface
33 35
34 if (!isset($input->paramId) || empty($input->paramId)) 36 if (!isset($input->paramId) || empty($input->paramId))
35 throw new Exception("Param info request need a param id as argument"); 37 throw new Exception("Param info request need a param id as argument");
36 -  
37 - if ($this->paramTemplateMgr->isTemplatedParam($input->paramId)) 38 +
  39 + if ($this->paramMgr->isUploadedParam($input->paramId)) {
  40 + $userParameterLoader = new IHMUserParamLoaderClass();
  41 +
  42 + //get uploaded parameter info
  43 + $info = $userParameterLoader->getUploadedParameterFromName($input->paramId);
  44 + if ($info['success'] && ($info["param"]["info"]["plotType"] == 'Spectra')) {
  45 + $plot_init = array(
  46 + 'panel' => array(
  47 + 'plotType' => 'timePlot',
  48 + ),
  49 + 'draw' => array(
  50 + 'type' => 'spectro',
  51 + 'spectro-yaxis' => 'y-left',
  52 + ),
  53 + );
  54 + $this->paramInfoData->setInternalPlotInit($plot_init);
  55 + }
  56 + }
  57 + else if ($this->paramTemplateMgr->isTemplatedParam($input->paramId)) {
38 //Use param template file 58 //Use param template file
39 $paramFilePath = $this->paramTemplateMgr->getTemplatePath($input->paramId); 59 $paramFilePath = $this->paramTemplateMgr->getTemplatePath($input->paramId);
40 - else  
41 - $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml";  
42 -  
43 - if (!file_exists("$paramFilePath"))  
44 - throw new Exception("Cannot find parameter definition file"); 60 + if (!file_exists($paramFilePath))
  61 + throw new Exception("Cannot find parameter definition file");
  62 +
  63 + $this->paramInfoData->setFilePath($paramFilePath);
  64 + }
  65 + else {
  66 + //Direct access to the parameter file
  67 + $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml";
  68 + if (!file_exists($paramFilePath))
  69 + throw new Exception("Cannot find parameter definition file");
45 70
46 - $this->paramInfoData->setFilePath($paramFilePath); 71 + $this->paramInfoData->setFilePath($paramFilePath);
  72 + }
47 break; 73 break;
48 74
49 - case 'impex_plot_init' : 75 + case 'impex_plot_init' :
50 76
51 $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXPLOTINIT); 77 $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXPLOTINIT);
52 78
@@ -159,7 +185,14 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface @@ -159,7 +185,14 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface
159 } 185 }
160 186
161 private function getOutputPlotInit($data, &$result) { 187 private function getOutputPlotInit($data, &$result) {
162 - if (($data->getResult() != NULL) && ($data->getResult()->getName() == "plot") && (count($data->getResult()->getChildren()) >= 1)) { 188 + $internal_info = $data->getInternalPlotInit();
  189 + if (isset($internal_info)) {
  190 + $result = array(
  191 + "success" => true,
  192 + "data" => $internal_info
  193 + );
  194 + }
  195 + else if (($data->getResult() != NULL) && ($data->getResult()->getName() == "plot") && (count($data->getResult()->getChildren()) >= 1)) {
163 $result_data = array(); 196 $result_data = array();
164 197
165 $panelNodes = $data->getResult()->getChildren(); 198 $panelNodes = $data->getResult()->getChildren();
@@ -510,4 +543,4 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface @@ -510,4 +543,4 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface
510 } 543 }
511 } 544 }
512 545
513 -?>  
514 \ No newline at end of file 546 \ No newline at end of file
  547 +?>
src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php
@@ -458,7 +458,6 @@ class IHMJobsManagerClass { @@ -458,7 +458,6 @@ class IHMJobsManagerClass {
458 $resPath = glob(USERWORKINGDIR . $job->getAttribute('folder') . '/' . $job->getAttribute('result') . '*')[0]; 458 $resPath = glob(USERWORKINGDIR . $job->getAttribute('folder') . '/' . $job->getAttribute('result') . '*')[0];
459 459
460 if($job->getAttribute('jobType') == 'condition') { 460 if($job->getAttribute('jobType') == 'condition') {
461 - error_log('resPath: ' . $resPath);  
462 $resXml = new DomDocument(); 461 $resXml = new DomDocument();
463 $resXml->load($resPath); 462 $resXml->load($resPath);
464 $infos['nb intervals'] = $resXml->getElementsByTagName('nbIntervals')->item(0)->nodeValue; 463 $infos['nb intervals'] = $resXml->getElementsByTagName('nbIntervals')->item(0)->nodeValue;
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -66,7 +66,7 @@ class IHMParamManagerClass @@ -66,7 +66,7 @@ class IHMParamManagerClass
66 /* 66 /*
67 * @brief Detect if it's a uploaded parameter 67 * @brief Detect if it's a uploaded parameter
68 */ 68 */
69 - private function isUploadedParam($param) 69 + public function isUploadedParam($param)
70 { 70 {
71 return preg_match("#^wsd_#",$param); 71 return preg_match("#^wsd_#",$param);
72 } 72 }
src/Request/ParamInfoRequestClass.php
@@ -13,7 +13,7 @@ class ParamInfoRequestClass extends RequestAbstractClass @@ -13,7 +13,7 @@ class ParamInfoRequestClass extends RequestAbstractClass
13 { 13 {
14 if (!isset($this->requestData)) 14 if (!isset($this->requestData))
15 return false; 15 return false;
16 - 16 +
17 if ($this->requestData->getType() == ParamInfoTypeEnumClass::PLOTINIT 17 if ($this->requestData->getType() == ParamInfoTypeEnumClass::PLOTINIT
18 || $this->requestData->getType() == ParamInfoTypeEnumClass::IMPEXPLOTINIT) { 18 || $this->requestData->getType() == ParamInfoTypeEnumClass::IMPEXPLOTINIT) {
19 //Force load of node files to init the NodeFactory 19 //Force load of node files to init the NodeFactory
@@ -30,7 +30,6 @@ class ParamInfoRequestClass extends RequestAbstractClass @@ -30,7 +30,6 @@ class ParamInfoRequestClass extends RequestAbstractClass
30 */ 30 */
31 public function run() 31 public function run()
32 { 32 {
33 -  
34 if ($this->requestData->getType() == ParamInfoTypeEnumClass::IMPEXINFO) 33 if ($this->requestData->getType() == ParamInfoTypeEnumClass::IMPEXINFO)
35 { 34 {
36 $this->requestData->setSuccess(true); 35 $this->requestData->setSuccess(true);
@@ -44,30 +43,38 @@ class ParamInfoRequestClass extends RequestAbstractClass @@ -44,30 +43,38 @@ class ParamInfoRequestClass extends RequestAbstractClass
44 $this->requestData->setResult($result); 43 $this->requestData->setResult($result);
45 return $this->requestData->getSuccess(); 44 return $this->requestData->getSuccess();
46 } 45 }
  46 +
  47 + $filePath = $this->requestData->getFilePath();
  48 + if (!empty($filePath)) {
  49 + //Load info from a XML file
  50 + $dom = new DOMDocument("1.0","UTF-8");
  51 + $dom->preserveWhiteSpace = false;
  52 + $dom->formatOutput = true;
47 53
48 - $dom = new DOMDocument("1.0","UTF-8");  
49 - $dom->preserveWhiteSpace = false;  
50 - $dom->formatOutput = true;  
51 -  
52 - $res = @$dom->load($this->requestData->getFilePath()); 54 + $res = @$dom->load($this->requestData->getFilePath());
53 55
54 - $this->requestData->setSuccess(false); 56 + $this->requestData->setSuccess(false);
55 57
56 - if (!$res) {  
57 - $this->requestData->setLastErrorMessage("Cannot load file".$this->requestData->getFilePath());  
58 - return false;  
59 - } 58 + if (!$res) {
  59 + $this->requestData->setLastErrorMessage("Cannot load file".$this->requestData->getFilePath());
  60 + return false;
  61 + }
60 62
61 - switch ($this->requestData->getType()) {  
62 - case ParamInfoTypeEnumClass::IMPEXPLOTINIT :  
63 - case ParamInfoTypeEnumClass::PLOTINIT :  
64 - $this->runFromParamFile($dom);  
65 - break;  
66 - case ParamInfoTypeEnumClass::PARAMINFO :  
67 - $this->runFromParamInfoFile($dom);  
68 - break;  
69 - default :  
70 - $this->requestData->setLastErrorMessage("Unknown ParamInfo type "); 63 + switch ($this->requestData->getType()) {
  64 + case ParamInfoTypeEnumClass::IMPEXPLOTINIT :
  65 + case ParamInfoTypeEnumClass::PLOTINIT :
  66 + $this->runFromParamFile($dom);
  67 + break;
  68 + case ParamInfoTypeEnumClass::PARAMINFO :
  69 + $this->runFromParamInfoFile($dom);
  70 + break;
  71 + default :
  72 + $this->requestData->setLastErrorMessage("Unknown ParamInfo type ");
  73 + }
  74 + }
  75 + else {
  76 + //Use some internal info - Nothing to do
  77 + $this->requestData->setSuccess(true);
71 } 78 }
72 79
73 return $this->requestData->getSuccess(); 80 return $this->requestData->getSuccess();
src/Request/ParamInfoRequestDataClass.php
@@ -26,6 +26,7 @@ class ParamInfoRequestDataClass extends RequestDataClass @@ -26,6 +26,7 @@ class ParamInfoRequestDataClass extends RequestDataClass
26 private $templateInfo = NULL; 26 private $templateInfo = NULL;
27 private $type = ParamInfoTypeEnumClass::UNKNOWN; 27 private $type = ParamInfoTypeEnumClass::UNKNOWN;
28 private $result = NULL; 28 private $result = NULL;
  29 + private $internalPlotInit = NULL;
29 30
30 public function getFilePath() 31 public function getFilePath()
31 { 32 {
@@ -37,6 +38,16 @@ class ParamInfoRequestDataClass extends RequestDataClass @@ -37,6 +38,16 @@ class ParamInfoRequestDataClass extends RequestDataClass
37 $this->filePath = $filePath; 38 $this->filePath = $filePath;
38 } 39 }
39 40
  41 + public function setInternalPlotInit($plotInit)
  42 + {
  43 + $this->internalPlotInit = $plotInit;
  44 + }
  45 +
  46 + public function getInternalPlotInit()
  47 + {
  48 + return $this->internalPlotInit;
  49 + }
  50 +
40 public function getType() 51 public function getType()
41 { 52 {
42 return $this->type; 53 return $this->type;
@@ -78,4 +89,4 @@ class ParamInfoRequestDataClass extends RequestDataClass @@ -78,4 +89,4 @@ class ParamInfoRequestDataClass extends RequestDataClass
78 } 89 }
79 } 90 }
80 91
81 -?>  
82 \ No newline at end of file 92 \ No newline at end of file
  93 +?>