Commit 684f43c27c8f7224ae686ba3b99ee3f070b19417

Authored by Elena.Budnik
2 parents 3e0cf0aa 52859c27

Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_Integration

src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
... ... @@ -23,7 +23,7 @@ class IHMParamManagerClass
23 23 /*
24 24 * @brief Add an existing parameter
25 25 */
26   - public function addExistingParam($param, $paramsData, $templateArgs = NULL)
  26 + public function addExistingParam($param, $paramsData, $templateArgs = NULL, $tableLink = NULL)
27 27 {
28 28 if ($this->isDerivedParam($param))
29 29 return $this->addDerivedParam($param,$paramsData);
... ... @@ -32,7 +32,7 @@ class IHMParamManagerClass
32 32 else if ($this->isImpexParam($param))
33 33 return $this->addImpexParam($param,$paramsData,$templateArgs);
34 34 else
35   - return $this->addLocalParam($param,$paramsData,$templateArgs);
  35 + return $this->addLocalParam($param,$paramsData,$templateArgs, $tableLink);
36 36 return "";
37 37 }
38 38  
... ... @@ -82,7 +82,7 @@ class IHMParamManagerClass
82 82 /*
83 83 * @brief Add a local parameter
84 84 */
85   - private function addLocalParam($param, $paramsData, $templateArgs)
  85 + private function addLocalParam($param, $paramsData, $templateArgs, $tableLink)
86 86 {
87 87 //local parameter
88 88 $indexes = array();
... ... @@ -101,9 +101,8 @@ class IHMParamManagerClass
101 101 //check templated parameter
102 102 $real_param_id = $paramId;
103 103 if ($this->templateParamsManager->isTemplatedParam($paramId)) {
104   - $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs);
  104 + $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink);
105 105 $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs);
106   -
107 106 if (empty($paramPath) || !file_exists($paramPath))
108 107 throw new Exception('Cannot generate parameter template file '.$paramId);
109 108 }
... ... @@ -485,7 +484,11 @@ class IHMParamManagerClass
485 484 'max' => $dim1_max,
486 485 'relateddim' => 0,
487 486 );
488   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
  487 + $tableLink = array(
  488 + 'paramid' => $paramInfo['id'],
  489 + 'relateddim' => 1,
  490 + );
  491 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
489 492 if ($dim2_index != '*') {
490 493 $paramInfo['indexes'][] = $dim2_index;
491 494 }
... ... @@ -497,7 +500,11 @@ class IHMParamManagerClass
497 500 'max' => $dim2_max,
498 501 'relateddim' => 1,
499 502 );
500   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
  503 + $tableLink = array(
  504 + 'paramid' => $paramInfo['id'],
  505 + 'relateddim' => 0,
  506 + );
  507 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
501 508 if ($dim1_index != '*') {
502 509 $paramInfo['indexes'][] = $dim1_index;
503 510 }
... ...
src/InputOutput/IHMImpl/Tools/IHMParamTemplateClass.php
... ... @@ -138,7 +138,7 @@ class IHMParamTemplateClass
138 138 /*
139 139 * @brief Generate parameter file from template
140 140 */
141   - public function generateTemplatedParamFile($param_id, $template_args) {
  141 + public function generateTemplatedParamFile($param_id, $template_args, $table_link = NULL) {
142 142 $templatePath = $this->getTemplatePath($param_id);
143 143 if (empty($templatePath))
144 144 return "";
... ... @@ -177,6 +177,38 @@ class IHMParamTemplateClass
177 177 }
178 178 fclose($templateHandle);
179 179 fclose($dstHandle);
  180 +
  181 + if (isset($table_link)) {
  182 + //Inject table link
  183 + $xml = new DOMDocument();
  184 + $xml->preserveWhiteSpace = TRUE;
  185 + $xml->load($dstFilePath);
  186 +
  187 + $infoNodes = $xml->documentElement->getElementsByTagName('info');
  188 + if ($infoNodes->length == 0) {
  189 + $infoNode = $xml->createElement('info');
  190 + $infoNode = $xml->documentElement->insertBefore($infoNode, $xml->documentElement->firstChild);
  191 + }
  192 + else {
  193 + $infoNode = $infoNodes->item(0);
  194 + }
  195 +
  196 + $tableNodes = $infoNode->getElementsByTagName('table');
  197 + if ($tableNodes->length == 0) {
  198 + $tableNode = $xml->createElement('table');
  199 + $tableNode = $infoNode->appendChild($tableNode);
  200 + }
  201 + else {
  202 + $tableNode = $tableNodes->item(0);
  203 + }
  204 +
  205 + $linkTableNode = $xml->createElement('linkTable');
  206 + $linkTableNode->setAttribute('originParamId', $table_link['paramid']);
  207 + $linkTableNode->setAttribute('originTableDim', $table_link['relateddim']);
  208 + $tableNode->appendChild($linkTableNode);
  209 +
  210 + $xml->save($dstFilePath);
  211 + }
180 212  
181 213 $dateModifTemplate = filemtime($templatePath);
182 214 touch($dstFilePath, $dateModifTemplate);
... ...