Commit ffc5cb816f6e1c869e840b47a7a89824e447abc0
1 parent
e4cf87dc
Exists in
master
and in
66 other branches
temporary commit
Showing
14 changed files
with
615 additions
and
52 deletions
Show diff stats
src/InputOutput/IHMImpl/Config/IHMConfigClass.php
@@ -50,7 +50,11 @@ class IHMConfigClass | @@ -50,7 +50,11 @@ class IHMConfigClass | ||
50 | private static $userParamMgrFile = "WsParams.xml"; | 50 | private static $userParamMgrFile = "WsParams.xml"; |
51 | 51 | ||
52 | private static $userName; | 52 | private static $userName; |
53 | - | 53 | + |
54 | + private static $userHost; | ||
55 | + | ||
56 | + public static $remoteDataDir = "/home/budnik/RemoteDataCenter/MAJ/"; | ||
57 | + | ||
54 | public static function setUserName($userName) | 58 | public static function setUserName($userName) |
55 | { | 59 | { |
56 | self::$userName = $userName; | 60 | self::$userName = $userName; |
@@ -60,7 +64,17 @@ class IHMConfigClass | @@ -60,7 +64,17 @@ class IHMConfigClass | ||
60 | { | 64 | { |
61 | return self::$userName; | 65 | return self::$userName; |
62 | } | 66 | } |
67 | + | ||
68 | + public static function setUserHost($userHost) | ||
69 | + { | ||
70 | + self::$userHost = $userHost; | ||
71 | + } | ||
63 | 72 | ||
73 | + public static function getUserHost() | ||
74 | + { | ||
75 | + return self::$userHost; | ||
76 | + } | ||
77 | + | ||
64 | public static function getUserPath() | 78 | public static function getUserPath() |
65 | { | 79 | { |
66 | $userPath = IHM_SRC_DIR.self::$dataDir.self::$userName.'/'; | 80 | $userPath = IHM_SRC_DIR.self::$dataDir.self::$userName.'/'; |
@@ -198,6 +212,14 @@ class IHMConfigClass | @@ -198,6 +212,14 @@ class IHMConfigClass | ||
198 | return $localBasePath; | 212 | return $localBasePath; |
199 | } | 213 | } |
200 | 214 | ||
215 | + public static function getRemoteParamsFile() | ||
216 | + { | ||
217 | + $remoteBasePath = self::getUserPath().self::$wsDir; | ||
218 | + | ||
219 | + | ||
220 | + return $remoteBasePath.'RemoteParams.xml'; | ||
221 | + } | ||
222 | + | ||
201 | public static function getRequestPath() | 223 | public static function getRequestPath() |
202 | { | 224 | { |
203 | $requestPath = self::getUserPath().self::$requestDir; | 225 | $requestPath = self::getUserPath().self::$requestDir; |
src/InputOutput/IHMImpl/IHMInputOutputClass.php
@@ -12,9 +12,10 @@ class IHMInputOutputClass implements InputOutputInterface | @@ -12,9 +12,10 @@ class IHMInputOutputClass implements InputOutputInterface | ||
12 | /* | 12 | /* |
13 | * @brief Constructor | 13 | * @brief Constructor |
14 | */ | 14 | */ |
15 | - function __construct($userName) | 15 | + function __construct($userName, $userHost) |
16 | { | 16 | { |
17 | IHMConfigClass::setUserName($userName); | 17 | IHMConfigClass::setUserName($userName); |
18 | + IHMConfigClass::setUserHost($userHost); | ||
18 | } | 19 | } |
19 | 20 | ||
20 | /* | 21 | /* |
src/InputOutput/IHMImpl/ParamInfo/IHMInputOutputParamInfoClass.php
@@ -9,6 +9,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -9,6 +9,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
9 | { | 9 | { |
10 | private $paramInfoData = null; | 10 | private $paramInfoData = null; |
11 | private $paramTemplateMgr = null; | 11 | private $paramTemplateMgr = null; |
12 | + private $paramImpexMgr = null; | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * @brief Constructor | 15 | * @brief Constructor |
@@ -27,6 +28,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -27,6 +28,7 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
27 | 28 | ||
28 | switch ($input->type) { | 29 | switch ($input->type) { |
29 | case 'plot_init' : | 30 | case 'plot_init' : |
31 | + | ||
30 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PLOTINIT); | 32 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PLOTINIT); |
31 | 33 | ||
32 | if (!isset($input->paramId) || empty($input->paramId)) | 34 | if (!isset($input->paramId) || empty($input->paramId)) |
@@ -37,13 +39,35 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -37,13 +39,35 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
37 | $paramFilePath = $this->paramTemplateMgr->getTemplatePath($input->paramId); | 39 | $paramFilePath = $this->paramTemplateMgr->getTemplatePath($input->paramId); |
38 | else | 40 | else |
39 | $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml"; | 41 | $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml"; |
42 | + | ||
43 | + if (!file_exists("$paramFilePath")) | ||
44 | + throw new Exception("Cannot find parameter definition file"); | ||
45 | + | ||
46 | + $this->paramInfoData->setFilePath($paramFilePath); | ||
47 | + break; | ||
40 | 48 | ||
41 | - if (!file_exists($paramFilePath)) | 49 | + case 'impex_plot_init' : |
50 | + | ||
51 | + $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXPLOTINIT); | ||
52 | + | ||
53 | + if (!isset($input->paramId) || empty($input->paramId)) | ||
54 | + throw new Exception("Param info request need a param id as argument"); | ||
55 | + | ||
56 | + if (!$this->paramImpexMgr) | ||
57 | + { | ||
58 | + $this->paramImpexMgr = new IHMImpexParamClass(); | ||
59 | + } | ||
60 | + | ||
61 | + $paramFilePath = $this->paramImpexMgr->getParamInfoPlotPath($input->paramId); | ||
62 | + | ||
63 | + if (!$paramFilePath || !file_exists($paramFilePath)) | ||
42 | throw new Exception("Cannot find parameter definition file"); | 64 | throw new Exception("Cannot find parameter definition file"); |
43 | 65 | ||
44 | $this->paramInfoData->setFilePath($paramFilePath); | 66 | $this->paramInfoData->setFilePath($paramFilePath); |
45 | break; | 67 | break; |
68 | + | ||
46 | case 'param_info' : | 69 | case 'param_info' : |
70 | + | ||
47 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PARAMINFO); | 71 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PARAMINFO); |
48 | 72 | ||
49 | if (!isset($input->paramId) || empty($input->paramId)) | 73 | if (!isset($input->paramId) || empty($input->paramId)) |
@@ -61,8 +85,31 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -61,8 +85,31 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
61 | 85 | ||
62 | $this->paramInfoData->setFilePath($paramInfoFilePath); | 86 | $this->paramInfoData->setFilePath($paramInfoFilePath); |
63 | break; | 87 | break; |
88 | + | ||
89 | + case 'impex_param_info' : | ||
90 | + | ||
91 | + $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXINFO); | ||
92 | + if (!isset($input->paramId) || empty($input->paramId)) | ||
93 | + throw new Exception("Param info request need a param id as argument"); | ||
94 | + | ||
95 | + if (!$this->paramImpexMgr) | ||
96 | + { | ||
97 | + $this->paramImpexMgr = new IHMImpexParamClass(); | ||
98 | + } | ||
99 | + $this->paramImpexMgr->setParamTemplateListFilePath($input->paramId); | ||
100 | + $templatedParams = $this->paramImpexMgr->getParamTemplates(); | ||
101 | + | ||
102 | + $simRegion = $this->paramImpexMgr->getSimulationRegion($input->paramId); | ||
103 | + | ||
104 | + // No SimulationRuns (LESIA) | ||
105 | + if ($simRegion == "UNKNOWN") | ||
106 | + $simRegion = $this->paramImpexMgr->getResourceID($input->paramId); | ||
107 | + | ||
108 | + $this->paramInfoData->setTemplateInfo($templatedParams[$simRegion]); | ||
109 | + | ||
110 | + break; | ||
64 | default : | 111 | default : |
65 | - throw new Exception("Para info request type '".$input->type."' not yet implemented"); | 112 | + throw new Exception("Param info request type '".$input->type."' not yet implemented"); |
66 | } | 113 | } |
67 | 114 | ||
68 | $this->paramInfoData->setParamId($input->paramId); | 115 | $this->paramInfoData->setParamId($input->paramId); |
@@ -80,10 +127,18 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -80,10 +127,18 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
80 | $result = array("success" => false, "message" => "Cannot get plot init"); | 127 | $result = array("success" => false, "message" => "Cannot get plot init"); |
81 | $this->getOutputPlotInit($data, $result); | 128 | $this->getOutputPlotInit($data, $result); |
82 | break; | 129 | break; |
130 | + case ParamInfoTypeEnumClass::IMPEXPLOTINIT : | ||
131 | + $result = array("success" => false, "message" => "Cannot get impex plot init"); | ||
132 | + $this->getOutputPlotInit($data, $result); | ||
133 | + break; | ||
83 | case ParamInfoTypeEnumClass::PARAMINFO : | 134 | case ParamInfoTypeEnumClass::PARAMINFO : |
84 | $result = array("success" => false, "message" => "Cannot get param info"); | 135 | $result = array("success" => false, "message" => "Cannot get param info"); |
85 | $this->getOutputParamInfo($data, $result); | 136 | $this->getOutputParamInfo($data, $result); |
86 | break; | 137 | break; |
138 | + case ParamInfoTypeEnumClass::IMPEXINFO : | ||
139 | + $result = array("success" => false, "message" => "Cannot get impex param info"); | ||
140 | + $this->getOutputParamInfo($data, $result); | ||
141 | + break; | ||
87 | default: | 142 | default: |
88 | //Nothing ToDo | 143 | //Nothing ToDo |
89 | } | 144 | } |
src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php
@@ -52,7 +52,8 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas | @@ -52,7 +52,8 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas | ||
52 | $downloadNode->setFileFormat(RequestOutputDownloadFileFormatEnum::ASCII); | 52 | $downloadNode->setFileFormat(RequestOutputDownloadFileFormatEnum::ASCII); |
53 | $formatExtension = ".txt"; | 53 | $formatExtension = ".txt"; |
54 | break; | 54 | break; |
55 | - case "vot" : | 55 | + case "vot" : |
56 | + case "VOT" : | ||
56 | $downloadNode->setFileFormat(RequestOutputDownloadFileFormatEnum::VOTABLE); | 57 | $downloadNode->setFileFormat(RequestOutputDownloadFileFormatEnum::VOTABLE); |
57 | $formatExtension = ".vot"; | 58 | $formatExtension = ".vot"; |
58 | break; | 59 | break; |
@@ -65,7 +66,7 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas | @@ -65,7 +66,7 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas | ||
65 | $formatExtension = ".json"; | 66 | $formatExtension = ".json"; |
66 | break; | 67 | break; |
67 | default : | 68 | default : |
68 | - throw new Exception('File format not implemented.'); | 69 | + throw new Exception('File format '.$input->fileformat.' not implemented.'); |
69 | } | 70 | } |
70 | 71 | ||
71 | if ($input->fileprefix != "") | 72 | if ($input->fileprefix != "") |
src/InputOutput/IHMImpl/Tools/CommonClass.php
@@ -34,6 +34,57 @@ class CommonClass | @@ -34,6 +34,57 @@ class CommonClass | ||
34 | $t = date("His",$timeStamp)."000"; | 34 | $t = date("His",$timeStamp)."000"; |
35 | return $y.$d.$t; | 35 | return $y.$d.$t; |
36 | } | 36 | } |
37 | + /* | ||
38 | + * @brief DDTime to timestamp conversion | ||
39 | + */ | ||
40 | + public static function DDTimeToTimeStamp($DDTime) | ||
41 | + { | ||
42 | + date_default_timezone_set('UTC'); | ||
43 | + $date = DateTime::createFromFormat('YzHisu', $DDTime); | ||
44 | + | ||
45 | + return strtotime($date->format("Y-m-d\TH:i:s")); | ||
46 | + } | ||
47 | + | ||
48 | + /* | ||
49 | + * @brief DDTime to ISO conversion | ||
50 | + */ | ||
51 | + public static function DDTimeToIso($DDTime) | ||
52 | + { | ||
53 | + $date = DateTime::createFromFormat('YzHisu', $DDTime); | ||
54 | + | ||
55 | + return $date->format("Y-m-d\TH:i:s"); | ||
56 | + } | ||
57 | + | ||
58 | + /* | ||
59 | + * @brief DDTime to ISO conversion | ||
60 | + */ | ||
61 | + public static function DDStartIntervalToStopIso($DDStart, $DDInterval) | ||
62 | + { | ||
63 | + $startStamp = self::DDTimeToTimeStamp($DDStart); | ||
64 | + $intStamp = self::DDTimeToTimeStamp($DDInterval); | ||
65 | + | ||
66 | + return date("Y-m-d\TH:i:s", $startStamp + $intStamp); | ||
67 | + } | ||
68 | + | ||
69 | + public static function rrmdir($dir) | ||
70 | + { | ||
71 | + if (is_dir($dir)) | ||
72 | + { | ||
73 | + $objects = scandir($dir); | ||
74 | + foreach ($objects as $object) | ||
75 | + { // Recursively delete a directory that is not empty and directorys in directory | ||
76 | + if ($object != "." && $object != "..") | ||
77 | + { // If object isn't a directory recall recursively this function | ||
78 | + if (filetype($dir."/".$object) == "dir") | ||
79 | + self::rrmdir($dir."/".$object); | ||
80 | + else | ||
81 | + unlink($dir."/".$object); | ||
82 | + } | ||
83 | + } | ||
84 | + reset($objects); | ||
85 | + rmdir($dir); | ||
86 | + } | ||
87 | + } | ||
37 | } | 88 | } |
38 | 89 | ||
39 | ?> | 90 | ?> |
40 | \ No newline at end of file | 91 | \ No newline at end of file |
src/InputOutput/IHMImpl/Tools/IHMExpressionParserClass.php
@@ -45,6 +45,7 @@ class IHMExpressionParserClass | @@ -45,6 +45,7 @@ class IHMExpressionParserClass | ||
45 | private $functionsArray; | 45 | private $functionsArray; |
46 | 46 | ||
47 | private $templatedParamMgr = NULL; | 47 | private $templatedParamMgr = NULL; |
48 | + private $impexParamMgr = NULL; | ||
48 | 49 | ||
49 | private $isTest = FALSE; | 50 | private $isTest = FALSE; |
50 | 51 | ||
@@ -143,30 +144,45 @@ class IHMExpressionParserClass | @@ -143,30 +144,45 @@ class IHMExpressionParserClass | ||
143 | 144 | ||
144 | //group elements in tree | 145 | //group elements in tree |
145 | $tree = $this->buildTreeElements($elements); | 146 | $tree = $this->buildTreeElements($elements); |
146 | - | 147 | + |
147 | //translate | 148 | //translate |
148 | $params_full = array(); | 149 | $params_full = array(); |
149 | $translated = $this->translate($tree,$params_full); | 150 | $translated = $this->translate($tree,$params_full); |
150 | - | 151 | + |
151 | //keep only params id | 152 | //keep only params id |
152 | $params = array(); | 153 | $params = array(); |
153 | - foreach ($params_full as $param_full) { | 154 | + foreach ($params_full as $param_full) { |
154 | if (array_key_exists("template_args", $param_full)) { | 155 | if (array_key_exists("template_args", $param_full)) { |
155 | $params[] = array( | 156 | $params[] = array( |
156 | "paramid" => $param_full['id'], | 157 | "paramid" => $param_full['id'], |
157 | "fullparamid" => $param_full['fullparamid'], | 158 | "fullparamid" => $param_full['fullparamid'], |
158 | "template_args" => $param_full['template_args'] | 159 | "template_args" => $param_full['template_args'] |
159 | - ); | 160 | + ); |
160 | } | 161 | } |
161 | else if (!$this->isTest && (($templated_param_info = $this->templatedParamMgr->parseTemplatedParam($param_full["id"])) !== FALSE)) { | 162 | else if (!$this->isTest && (($templated_param_info = $this->templatedParamMgr->parseTemplatedParam($param_full["id"])) !== FALSE)) { |
162 | - $params[] = $templated_param_info; | 163 | + $params[] = $templated_param_info; |
164 | + } | ||
165 | + else if ($this->isImpexParam($param_full["id"])) | ||
166 | + { | ||
167 | + if (!$this->impexParamMgr) | ||
168 | + { | ||
169 | + $this->impexParamMgr = new IHMImpexParamClass(); | ||
170 | + } | ||
171 | + $templated_param_info = $this->impexParamMgr->parseImpexParam($param_full["id"]); | ||
172 | + $params[] = $templated_param_info; | ||
163 | } | 173 | } |
164 | else | 174 | else |
165 | $params[] = array("paramid" => $param_full["id"]); | 175 | $params[] = array("paramid" => $param_full["id"]); |
166 | } | 176 | } |
177 | + | ||
167 | return array("expression" => $translated, "params" => $params); | 178 | return array("expression" => $translated, "params" => $params); |
168 | } | 179 | } |
169 | - | 180 | + |
181 | + private function isImpexParam($paramID) | ||
182 | + { | ||
183 | + return preg_match("#^".IHMImpexParamClass::$paramPrefix."#",$paramID); | ||
184 | + } | ||
185 | + | ||
170 | /* | 186 | /* |
171 | * @brief clean expression | 187 | * @brief clean expression |
172 | */ | 188 | */ |
@@ -0,0 +1,288 @@ | @@ -0,0 +1,288 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * @class IHMImpexParamClass | ||
5 | + * @brief Class used to manage impex parameters | ||
6 | + * @details | ||
7 | + */ | ||
8 | +class IHMImpexParamClass extends IHMParamTemplateClass | ||
9 | +{ | ||
10 | + private $dataProducer = 'UNKNOWN'; | ||
11 | + private $simulationRegion = 'UNKNOWN'; | ||
12 | + private $dom; | ||
13 | + private $filePath; | ||
14 | + | ||
15 | + public static $paramPrefix = "spase___IMPEX_NumericalOutput_"; | ||
16 | + | ||
17 | + /* | ||
18 | + * @brief Constructor | ||
19 | + */ | ||
20 | + function __construct() | ||
21 | + { | ||
22 | + $this->filePath = IHMConfigClass::getRemoteParamsFile(); | ||
23 | + $this->dom = new DomDocument("1.0"); | ||
24 | + | ||
25 | + if (!file_exists($this->filePath)) | ||
26 | + throw new Exception("no RemoteParams File ".$this->filePath); | ||
27 | + | ||
28 | + $this->dom->load($this->filePath); | ||
29 | + | ||
30 | + } | ||
31 | + | ||
32 | + public function param2dd($paramID) | ||
33 | + { | ||
34 | + $pairs = array(" " => "_","-" => "_","/" => "_","%" => "_","\\" => "_","$" => "_",":" => "_","+" =>"_","#" => "_","@" => "_","." => "_", ">" => "_", "<" => "_", "," => "_", ")" => "", "(" => "_"); | ||
35 | + return strtr($paramID,$pairs); | ||
36 | + } | ||
37 | + | ||
38 | + public function getDataProducer($paramId) | ||
39 | + { | ||
40 | + $paramNode = $this->dom->getElementById($paramId); | ||
41 | + | ||
42 | + while ($paramNode->tagName !== 'dataCenter') | ||
43 | + { | ||
44 | + $paramNode = $paramNode->parentNode; | ||
45 | + } | ||
46 | + | ||
47 | + if ( $paramNode ) | ||
48 | + $this->dataProducer = $paramNode->getAttribute('xml:id'); | ||
49 | + | ||
50 | + return $this->dataProducer; | ||
51 | + } | ||
52 | + | ||
53 | + public function getResourceID($paramId) | ||
54 | + { | ||
55 | + $paramNode = $this->dom->getElementById($paramId); | ||
56 | + | ||
57 | + while ($paramNode->tagName !== 'dataset') | ||
58 | + { | ||
59 | + $paramNode = $paramNode->parentNode; | ||
60 | + } | ||
61 | + | ||
62 | + if ( $paramNode ) | ||
63 | + $resourceID = $paramNode->getAttribute('xml:id'); | ||
64 | + | ||
65 | + return $resourceID; | ||
66 | + } | ||
67 | + | ||
68 | + public function getTranslatedResourceID($paramId) | ||
69 | + { | ||
70 | + return $this->param2dd($this->getResourceID($paramId)); | ||
71 | + } | ||
72 | + | ||
73 | + public function getSimulationRegion($paramId) | ||
74 | + { | ||
75 | + $paramNode = $this->dom->getElementById($paramId); | ||
76 | + | ||
77 | + while ($paramNode->tagName !== 'simulationRegion') | ||
78 | + { | ||
79 | + $paramNode = $paramNode->parentNode; | ||
80 | + if ( $paramNode->tagName == 'simulationModel') break; | ||
81 | + | ||
82 | + } | ||
83 | + | ||
84 | + if ( $paramNode && $paramNode->tagName == 'simulationRegion') | ||
85 | + $this->simulationRegion = $paramNode->getAttribute('xml:id'); | ||
86 | + | ||
87 | + return $this->simulationRegion; | ||
88 | + } | ||
89 | + | ||
90 | + public function getParameterKey($paramId) | ||
91 | + { | ||
92 | + $parameterKey = 'UNKNOWN'; | ||
93 | + | ||
94 | + $paramNode = $this->dom->getElementById($paramId); | ||
95 | + | ||
96 | + if ( $paramNode ) | ||
97 | + $parameterKey = $paramNode->getAttribute('shortName'); | ||
98 | + | ||
99 | + return $parameterKey; | ||
100 | + } | ||
101 | + | ||
102 | + | ||
103 | + public function getParameterSize($paramId) | ||
104 | + { | ||
105 | + $parameterSize = 'UNKNOWN'; | ||
106 | + | ||
107 | + $paramNode = $this->dom->getElementById($paramId); | ||
108 | + | ||
109 | + if ( $paramNode ) | ||
110 | + $parameterSize = $paramNode->getAttribute('size'); | ||
111 | + | ||
112 | + return $parameterSize; | ||
113 | + } | ||
114 | + | ||
115 | + public function getAccessUrl($paramId) | ||
116 | + { | ||
117 | + $url = 'UNKNOWN'; | ||
118 | + | ||
119 | + $paramNode = $this->dom->getElementById($paramId); | ||
120 | + | ||
121 | + while ($paramNode->tagName !== 'dataset') | ||
122 | + { | ||
123 | + $paramNode = $paramNode->parentNode; | ||
124 | + | ||
125 | + } | ||
126 | + | ||
127 | + if ( $paramNode && $paramNode->hasAttribute('accessUrl')) | ||
128 | + $url = $paramNode->getAttribute('accessUrl'); | ||
129 | + | ||
130 | + return $url; | ||
131 | + } | ||
132 | + | ||
133 | + public function setParamTemplateListFilePath($paramId) | ||
134 | + { | ||
135 | + $this->paramTemplateListFilePath = IHMConfigClass::$remoteDataDir.$this->getDataProducer($paramId).'_Templates.xml'; | ||
136 | + } | ||
137 | + | ||
138 | + /* | ||
139 | + * | ||
140 | + */ | ||
141 | + public function getImpexFullParamId($param_id, $templateArgs = NULL) { | ||
142 | + | ||
143 | + if (!$templateArgs) | ||
144 | + return $param_id; | ||
145 | + | ||
146 | + $fullParamId = $param_id; | ||
147 | + foreach ($templateArgs as $key => $value) | ||
148 | + $fullParamId .= "_".$value; | ||
149 | + | ||
150 | + return $fullParamId; | ||
151 | + } | ||
152 | + | ||
153 | + public function getImpexParamId($fullParamId) | ||
154 | + { | ||
155 | + $pos = strrpos($fullParamId,'_'); | ||
156 | + $id = $fullParamId; | ||
157 | + | ||
158 | + $find = false; | ||
159 | + | ||
160 | + while ($pos && !$find) | ||
161 | + { | ||
162 | + $id = substr($id,0,$pos); | ||
163 | + $param = $this->dom->getElementById($id); | ||
164 | + if ($param) $find = true; | ||
165 | + $pos = strrpos($id,'_'); | ||
166 | + } | ||
167 | + if (!$find) | ||
168 | + throw new Exception("Can not find IMPEX parameter ".$fullParamId); | ||
169 | + | ||
170 | + return $id; | ||
171 | + } | ||
172 | + | ||
173 | + public function parseImpexParam($param_expression) | ||
174 | + { | ||
175 | + $paramId = $this->getImpexParamId($param_expression); | ||
176 | + $this->getDataProducer($paramId); | ||
177 | + $this->getSimulationRegion($paramId); | ||
178 | + $this->setParamTemplateListFilePath($paramId); | ||
179 | + | ||
180 | + $templateArgsString = substr($param_expression,strlen($paramId."_")); | ||
181 | + | ||
182 | + $allTemplatedParams = $this->getParamTemplates(); | ||
183 | + $templatedParams = $allTemplatedParams[$this->simulationRegion]; | ||
184 | + $args = $templatedParams['arguments']; | ||
185 | + | ||
186 | + $templateArgs = array(); | ||
187 | + foreach ($args as $key => $value) | ||
188 | + { | ||
189 | + /*$r = print_r($templatedParams,true); */ | ||
190 | + switch($value["type"]) | ||
191 | + { | ||
192 | + case 'float' : | ||
193 | + case 'double' : | ||
194 | + case 'int': | ||
195 | + $pos = strpos($templateArgsString,'_'); | ||
196 | + $arg_value = substr($templateArgsString,0,$pos); | ||
197 | + $templateArgsString = substr($templateArgsString,$pos+1); | ||
198 | + break; | ||
199 | + case 'list' : | ||
200 | + $arg_items = $value['items']; | ||
201 | + foreach ($arg_items as $arg_key => $arg_val) | ||
202 | + { | ||
203 | + if ( strncmp($arg_key, $templateArgsString, strlen($arg_key)) === 0) | ||
204 | + { | ||
205 | + $arg_value = $arg_key; | ||
206 | + $templateArgsString = substr($templateArgsString,strlen($arg_key)+1); | ||
207 | + break; | ||
208 | + } | ||
209 | + } | ||
210 | + break; | ||
211 | + default: | ||
212 | + } | ||
213 | + | ||
214 | + $templateArgs[$key] = $arg_value; | ||
215 | + } | ||
216 | + | ||
217 | + $params = array( | ||
218 | + "paramid" => $paramId, | ||
219 | + "fullparamid" => $param_expression, | ||
220 | + "template_args" => $templateArgs | ||
221 | + ); | ||
222 | + | ||
223 | + return $params; | ||
224 | + } | ||
225 | + | ||
226 | + /* | ||
227 | + * List of Vector params in this data set | ||
228 | + */ | ||
229 | + public function getVectorList($resourceId) | ||
230 | + { | ||
231 | + $vectorList = array(); | ||
232 | + | ||
233 | + $datasetNode = $this->dom->getElementById($resourceId); | ||
234 | + if ($datasetNode) | ||
235 | + { | ||
236 | + $params = $datasetNode->getElementsByTagName('parameter'); | ||
237 | + foreach ($params as $param) | ||
238 | + { | ||
239 | + if ($param->hasAttribute('size')) | ||
240 | + if ($param->getAttribute('size') == '3') | ||
241 | + $vectorList[] = $param->getAttribute('shortName'); | ||
242 | + } | ||
243 | + } | ||
244 | + | ||
245 | + return $vectorList; | ||
246 | + } | ||
247 | + | ||
248 | + //IMPEXPLOTINIT - predefined plot output | ||
249 | + public function getParamInfoPlotPath($paramId) | ||
250 | + { | ||
251 | + | ||
252 | + if ($this->getDataProducer($paramId) != "IPIM" && !$this->isSpectra($paramId)) | ||
253 | + return null; | ||
254 | + | ||
255 | + $templateXml = IHMConfigClass::$remoteDataDir.$this->getDataProducer($paramId).'_PlotSettings.xml'; | ||
256 | + | ||
257 | + if (!file_exists($templateXml)) | ||
258 | + throw new Exception("No $templateXml"); | ||
259 | + | ||
260 | + $dom = new DomDocument("1.0"); | ||
261 | + if (!$dom->load($templateXml)) | ||
262 | + throw new Exception("Cannot load $templateXml"); | ||
263 | + | ||
264 | + $paramNode = $dom->documentElement; | ||
265 | + $paramNode->setAttribute("xml:id", $paramId); | ||
266 | + | ||
267 | + $plotParamNode = $paramNode->getElementsByTagName('param'); | ||
268 | + if ($plotParamNode->length == 0) | ||
269 | + throw new Exception("No Plot Param Node in $templateXml"); | ||
270 | + | ||
271 | + $plotParamNode->item(0)->setAttribute("id", $paramId); | ||
272 | + | ||
273 | + $filePath = IHMConfigClass::getUserWSPath().$paramId."_plot.xml"; | ||
274 | + | ||
275 | + $dom->save($filePath); | ||
276 | + | ||
277 | + return $filePath; | ||
278 | + | ||
279 | + } | ||
280 | + | ||
281 | + public function isSpectra($paramId) | ||
282 | + { | ||
283 | + $paramNode = $this->dom->getElementById($paramId); | ||
284 | + | ||
285 | + return $paramNode->hasAttribute('isSpectra'); | ||
286 | + | ||
287 | + } | ||
288 | +} | ||
0 | \ No newline at end of file | 289 | \ No newline at end of file |
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -10,6 +10,7 @@ class IHMParamManagerClass | @@ -10,6 +10,7 @@ class IHMParamManagerClass | ||
10 | protected $userParameterLoader = null; | 10 | protected $userParameterLoader = null; |
11 | protected $expressionParser = null; | 11 | protected $expressionParser = null; |
12 | protected $templateParamsManager = null; | 12 | protected $templateParamsManager = null; |
13 | + protected $paramImpexMgr = null; | ||
13 | 14 | ||
14 | /* | 15 | /* |
15 | * @brief Constructor | 16 | * @brief Constructor |
@@ -23,13 +24,15 @@ class IHMParamManagerClass | @@ -23,13 +24,15 @@ class IHMParamManagerClass | ||
23 | * @brief Add an existing parameter | 24 | * @brief Add an existing parameter |
24 | */ | 25 | */ |
25 | public function addExistingParam($param, $paramsData, $templateArgs = NULL) | 26 | public function addExistingParam($param, $paramsData, $templateArgs = NULL) |
26 | - { | 27 | + { |
27 | if ($this->isDerivedParam($param)) | 28 | if ($this->isDerivedParam($param)) |
28 | return $this->addDerivedParam($param,$paramsData); | 29 | return $this->addDerivedParam($param,$paramsData); |
29 | else if ($this->isUploadedParam($param)) | 30 | else if ($this->isUploadedParam($param)) |
30 | return $this->addUploadedParam($param,$paramsData); | 31 | return $this->addUploadedParam($param,$paramsData); |
32 | + else if ($this->isImpexParam($param)) | ||
33 | + return $this->addImpexParam($param,$paramsData,$templateArgs); | ||
31 | else | 34 | else |
32 | - return $this->addLocalParam($param,$paramsData, $templateArgs); | 35 | + return $this->addLocalParam($param,$paramsData,$templateArgs); |
33 | return ""; | 36 | return ""; |
34 | } | 37 | } |
35 | 38 | ||
@@ -37,13 +40,15 @@ class IHMParamManagerClass | @@ -37,13 +40,15 @@ class IHMParamManagerClass | ||
37 | * @brief Add a process parameter | 40 | * @brief Add a process parameter |
38 | */ | 41 | */ |
39 | public function addProcessParam($paramId,$expression,$params,$sampling,$gap,$dateModif,$paramsData) | 42 | public function addProcessParam($paramId,$expression,$params,$sampling,$gap,$dateModif,$paramsData) |
40 | - { | ||
41 | - $paramsData->addProcessParamToCreate($paramId, $expression, $params, $sampling, $gap,$dateModif); | ||
42 | - | 43 | + { |
44 | + $paramsData->addProcessParamToCreate($paramId, $expression, $params, $sampling, $gap,$dateModif); | ||
45 | + | ||
43 | foreach ($params as $param) { | 46 | foreach ($params as $param) { |
44 | - $template_args = NULL; | 47 | + $template_args = NULL; |
48 | + | ||
45 | if (array_key_exists("template_args", $param)) | 49 | if (array_key_exists("template_args", $param)) |
46 | $template_args = $param["template_args"]; | 50 | $template_args = $param["template_args"]; |
51 | + | ||
47 | $this->addExistingParam($param["paramid"],$paramsData,$template_args); | 52 | $this->addExistingParam($param["paramid"],$paramsData,$template_args); |
48 | } | 53 | } |
49 | 54 | ||
@@ -65,6 +70,14 @@ class IHMParamManagerClass | @@ -65,6 +70,14 @@ class IHMParamManagerClass | ||
65 | { | 70 | { |
66 | return preg_match("#^wsd_#",$param); | 71 | return preg_match("#^wsd_#",$param); |
67 | } | 72 | } |
73 | + | ||
74 | + /* | ||
75 | + * @brief Detect if it's IMPEX parameter | ||
76 | + */ | ||
77 | + private function isImpexParam($param) | ||
78 | + { | ||
79 | + return preg_match("#^".IHMImpexParamClass::$paramPrefix."#",$param); | ||
80 | + } | ||
68 | 81 | ||
69 | /* | 82 | /* |
70 | * @brief Add a local parameter | 83 | * @brief Add a local parameter |
@@ -84,12 +97,13 @@ class IHMParamManagerClass | @@ -84,12 +97,13 @@ class IHMParamManagerClass | ||
84 | } | 97 | } |
85 | else | 98 | else |
86 | $paramId = $param; | 99 | $paramId = $param; |
87 | - | 100 | + |
88 | //check templated parameter | 101 | //check templated parameter |
89 | $real_param_id = $paramId; | 102 | $real_param_id = $paramId; |
90 | if ($this->templateParamsManager->isTemplatedParam($paramId)) { | 103 | if ($this->templateParamsManager->isTemplatedParam($paramId)) { |
91 | $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs); | 104 | $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs); |
92 | $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs); | 105 | $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs); |
106 | + | ||
93 | if (empty($paramPath) || !file_exists($paramPath)) | 107 | if (empty($paramPath) || !file_exists($paramPath)) |
94 | throw new Exception('Cannot generate parameter template file '.$paramId); | 108 | throw new Exception('Cannot generate parameter template file '.$paramId); |
95 | } | 109 | } |
@@ -184,7 +198,58 @@ class IHMParamManagerClass | @@ -184,7 +198,58 @@ class IHMParamManagerClass | ||
184 | 198 | ||
185 | return array("id" => $paramId, "indexes" => array(), "calib_infos" => array()); | 199 | return array("id" => $paramId, "indexes" => array(), "calib_infos" => array()); |
186 | } | 200 | } |
187 | - | 201 | + |
202 | + /* | ||
203 | + * @brief Add IMPEX parameter : create dynamically xml parameter descriptor in user WS | ||
204 | + */ | ||
205 | + private function addImpexParam($param,$paramsData,$templateArgs = NULL) | ||
206 | + { | ||
207 | + if (!isset($this->paramImpexMgr)) | ||
208 | + $this->paramImpexMgr = new ImpexParamManager(); | ||
209 | + | ||
210 | + $parameterID = $this->paramImpexMgr->getImpexFullParamId($param, $templateArgs); | ||
211 | + | ||
212 | + $requestNodes = $paramsData->getRequestNodes(); | ||
213 | + | ||
214 | + // it is PARAMSGEN | ||
215 | + if (!$requestNodes) { | ||
216 | + return array("id" => $parameterID); | ||
217 | + } | ||
218 | + | ||
219 | + $timesNode = $requestNodes[0]->getTimesNode(); | ||
220 | + $intervals = $timesNode->getIntervals(); | ||
221 | + $originFile = IHMConfigClass::getUserWSPath().$parameterID.".xml"; | ||
222 | + | ||
223 | + if (!file_exists($originFile)) { | ||
224 | + // create IMPEX parameter info and data | ||
225 | + $res = $this->paramImpexMgr->createImpexParameter($param, $intervals, $templateArgs); | ||
226 | + | ||
227 | + if (!$res["success"]) | ||
228 | + throw new Exception('Error to create IMPEX parameter : '.$res["message"]); | ||
229 | + | ||
230 | + $newParamNode = $paramsData->addLocalParamToCreate($res["param"]["id"], | ||
231 | + $res["param"]["info"]["viId"], $res["param"]["info"]["realVar"], | ||
232 | + $res["param"]["info"]["minSampling"], $res["param"]["info"]["maxSampling"], | ||
233 | + $res["param"]["info"]["type"],$res["param"]["info"]["size"], | ||
234 | + $res["param"]["dateModif"],true); | ||
235 | + | ||
236 | + $tableDef = $res["param"]["info"]["tableDef"]; | ||
237 | + if (isset($tableDef) && array_key_exists('tableDefType', $tableDef) && ($tableDef['tableDefType'] != 'NONE')) | ||
238 | + { | ||
239 | + | ||
240 | + } | ||
241 | + | ||
242 | + return array("id" => $res["param"]["id"], "plotType" => $res["param"]["info"]["plotType"]); | ||
243 | + } | ||
244 | + else { | ||
245 | + // add IMPEX parameter data | ||
246 | + $this->paramImpexMgr->addImpexData($param, $intervals, $templateArgs); | ||
247 | + $paramsData->addParamToCopy($parameterID, $originFile); | ||
248 | + | ||
249 | + return array("id" => $parameterID); | ||
250 | + } | ||
251 | + } | ||
252 | + | ||
188 | /* | 253 | /* |
189 | * @brief Add uploaded parameter | 254 | * @brief Add uploaded parameter |
190 | */ | 255 | */ |
src/InputOutput/IHMImpl/Tools/IHMParamTemplateClass.php
@@ -8,25 +8,27 @@ | @@ -8,25 +8,27 @@ | ||
8 | class IHMParamTemplateClass | 8 | class IHMParamTemplateClass |
9 | { | 9 | { |
10 | protected $paramTemplateList = null; | 10 | protected $paramTemplateList = null; |
11 | + protected $paramTemplateListFilePath; | ||
11 | 12 | ||
12 | - private static $paramTemplateNode = 'paramTemplate'; | ||
13 | - private static $paramTemplateIdAtt = 'paramId'; | ||
14 | - private static $paramTemplateFileNameAtt = 'fileName'; | ||
15 | - private static $paramTemplateArgumentsNode = 'arguments'; | ||
16 | - private static $paramTemplateArgumentNode = 'argument'; | ||
17 | - private static $paramTemplateArgumentKeyAtt = 'key'; | ||
18 | - private static $paramTemplateArgumentNameAtt = 'name'; | ||
19 | - private static $paramTemplateArgumentTypeAtt = 'type'; | ||
20 | - private static $paramTemplateArgumentDefaultAtt = 'default'; | ||
21 | - private static $paramTemplateArgumentListItemNode = 'item'; | ||
22 | - private static $paramTemplateArgumentListItemKeyAtt = 'key'; | ||
23 | - private static $paramTemplateArgumentListItemNameAtt = 'name'; | 13 | + protected static $paramTemplateNode = 'paramTemplate'; |
14 | + protected static $paramTemplateIdAtt = 'paramId'; | ||
15 | + protected static $paramTemplateFileNameAtt = 'fileName'; | ||
16 | + protected static $paramTemplateArgumentsNode = 'arguments'; | ||
17 | + protected static $paramTemplateArgumentNode = 'argument'; | ||
18 | + protected static $paramTemplateArgumentKeyAtt = 'key'; | ||
19 | + protected static $paramTemplateArgumentNameAtt = 'name'; | ||
20 | + protected static $paramTemplateArgumentTypeAtt = 'type'; | ||
21 | + protected static $paramTemplateArgumentDefaultAtt = 'default'; | ||
22 | + protected static $paramTemplateArgumentListItemNode = 'item'; | ||
23 | + protected static $paramTemplateArgumentListItemKeyAtt = 'key'; | ||
24 | + protected static $paramTemplateArgumentListItemNameAtt = 'name'; | ||
24 | 25 | ||
25 | /* | 26 | /* |
26 | * @brief Constructor | 27 | * @brief Constructor |
27 | */ | 28 | */ |
28 | function __construct() | 29 | function __construct() |
29 | { | 30 | { |
31 | + $this->paramTemplateListFilePath = IHMConfigClass::getParamTemplateListFilePath(); | ||
30 | } | 32 | } |
31 | 33 | ||
32 | /* | 34 | /* |
@@ -227,27 +229,27 @@ class IHMParamTemplateClass | @@ -227,27 +229,27 @@ class IHMParamTemplateClass | ||
227 | /* | 229 | /* |
228 | * @brief Load list of templated parameters | 230 | * @brief Load list of templated parameters |
229 | */ | 231 | */ |
230 | - private function loadUserParamManagerFile() | 232 | + protected function loadUserParamManagerFile() |
231 | { | 233 | { |
232 | if (isset($this->paramTemplateList)) | 234 | if (isset($this->paramTemplateList)) |
233 | return; | 235 | return; |
234 | 236 | ||
235 | $this->paramTemplateList = array(); | 237 | $this->paramTemplateList = array(); |
236 | - | 238 | + |
237 | //load xml file | 239 | //load xml file |
238 | $dom = new DomDocument("1.0"); | 240 | $dom = new DomDocument("1.0"); |
239 | - if (!$dom->load(IHMConfigClass::getParamTemplateListFilePath())) | 241 | + if (!$dom->load($this->paramTemplateListFilePath)) |
240 | return; | 242 | return; |
241 | - | 243 | + |
242 | $paramTemplateNodes = $dom->getElementsByTagName(self::$paramTemplateNode); | 244 | $paramTemplateNodes = $dom->getElementsByTagName(self::$paramTemplateNode); |
243 | - | 245 | + |
244 | foreach ($paramTemplateNodes as $paramTemplateNode) { | 246 | foreach ($paramTemplateNodes as $paramTemplateNode) { |
245 | $paramId = $paramTemplateNode->getAttribute(self::$paramTemplateIdAtt); | 247 | $paramId = $paramTemplateNode->getAttribute(self::$paramTemplateIdAtt); |
246 | $paramFileName = $paramTemplateNode->getAttribute(self::$paramTemplateFileNameAtt); | 248 | $paramFileName = $paramTemplateNode->getAttribute(self::$paramTemplateFileNameAtt); |
247 | 249 | ||
248 | if (empty($paramId) || empty($paramFileName)) | 250 | if (empty($paramId) || empty($paramFileName)) |
249 | continue; | 251 | continue; |
250 | - | 252 | + |
251 | $arguments = array(); | 253 | $arguments = array(); |
252 | 254 | ||
253 | $argumentsNode = $paramTemplateNode->getElementsByTagName(self::$paramTemplateArgumentsNode); | 255 | $argumentsNode = $paramTemplateNode->getElementsByTagName(self::$paramTemplateArgumentsNode); |
src/Request/ParamInfoRequestClass.php
@@ -14,7 +14,8 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -14,7 +14,8 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
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 | //Force load of node files to init the NodeFactory | 19 | //Force load of node files to init the NodeFactory |
19 | foreach (glob(dirname(__FILE__)."/ParamsRequestImpl/Nodes/Requests/*NodeClass.php") as $filename) { | 20 | foreach (glob(dirname(__FILE__)."/ParamsRequestImpl/Nodes/Requests/*NodeClass.php") as $filename) { |
20 | require_once $filename; | 21 | require_once $filename; |
@@ -29,6 +30,21 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -29,6 +30,21 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
29 | */ | 30 | */ |
30 | public function run() | 31 | public function run() |
31 | { | 32 | { |
33 | + | ||
34 | + if ($this->requestData->getType() == ParamInfoTypeEnumClass::IMPEXINFO) | ||
35 | + { | ||
36 | + $this->requestData->setSuccess(true); | ||
37 | + | ||
38 | + $result = array(); | ||
39 | + $result['dimensions'] = array( | ||
40 | + 'dim1' => 1, | ||
41 | + 'dim2' => 1 | ||
42 | + ); | ||
43 | + | ||
44 | + $this->requestData->setResult($result); | ||
45 | + return $this->requestData->getSuccess(); | ||
46 | + } | ||
47 | + | ||
32 | $dom = new DOMDocument("1.0","UTF-8"); | 48 | $dom = new DOMDocument("1.0","UTF-8"); |
33 | $dom->preserveWhiteSpace = false; | 49 | $dom->preserveWhiteSpace = false; |
34 | $dom->formatOutput = true; | 50 | $dom->formatOutput = true; |
@@ -41,20 +57,22 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -41,20 +57,22 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
41 | $this->requestData->setLastErrorMessage("Cannot load file"); | 57 | $this->requestData->setLastErrorMessage("Cannot load file"); |
42 | return false; | 58 | return false; |
43 | } | 59 | } |
44 | - | 60 | + |
45 | switch ($this->requestData->getType()) { | 61 | switch ($this->requestData->getType()) { |
46 | - case ParamInfoTypeEnumClass::PLOTINIT : | 62 | + case ParamInfoTypeEnumClass::IMPEXPLOTINIT : |
63 | + case ParamInfoTypeEnumClass::PLOTINIT : | ||
47 | $this->runFromParamFile($dom); | 64 | $this->runFromParamFile($dom); |
48 | - break; | 65 | + break; |
49 | case ParamInfoTypeEnumClass::PARAMINFO : | 66 | case ParamInfoTypeEnumClass::PARAMINFO : |
50 | $this->runFromParamInfoFile($dom); | 67 | $this->runFromParamInfoFile($dom); |
51 | break; | 68 | break; |
52 | default : | 69 | default : |
53 | - $this->requestData->setLastErrorMessage("Unknown ParamInfo type"); | 70 | + $this->requestData->setLastErrorMessage("Unknown ParamInfo type "); |
54 | } | 71 | } |
55 | 72 | ||
56 | return $this->requestData->getSuccess(); | 73 | return $this->requestData->getSuccess(); |
57 | } | 74 | } |
75 | + | ||
58 | 76 | ||
59 | private function runFromParamFile($dom) { | 77 | private function runFromParamFile($dom) { |
60 | $paramNode = new ParamNodeClass(); | 78 | $paramNode = new ParamNodeClass(); |
@@ -67,17 +85,18 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -67,17 +85,18 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
67 | } | 85 | } |
68 | 86 | ||
69 | switch ($this->requestData->getType()) { | 87 | switch ($this->requestData->getType()) { |
88 | + case ParamInfoTypeEnumClass::IMPEXPLOTINIT : | ||
70 | case ParamInfoTypeEnumClass::PLOTINIT : | 89 | case ParamInfoTypeEnumClass::PLOTINIT : |
71 | $outputNode = $paramNode->getOutput(); | 90 | $outputNode = $paramNode->getOutput(); |
72 | if (!isset($outputNode)) { | 91 | if (!isset($outputNode)) { |
73 | $this->requestData->setLastErrorMessage("Cannot parse output node"); | 92 | $this->requestData->setLastErrorMessage("Cannot parse output node"); |
74 | return false; | 93 | return false; |
75 | - } | 94 | + } |
76 | $plotNode = $outputNode->getChildInstanceByName("plot"); | 95 | $plotNode = $outputNode->getChildInstanceByName("plot"); |
77 | if (!isset($plotNode)) { | 96 | if (!isset($plotNode)) { |
78 | $this->requestData->setLastErrorMessage("Cannot parse plot node"); | 97 | $this->requestData->setLastErrorMessage("Cannot parse plot node"); |
79 | return false; | 98 | return false; |
80 | - } | 99 | + } |
81 | $this->requestData->setResult($plotNode); | 100 | $this->requestData->setResult($plotNode); |
82 | $this->requestData->setSuccess(true); | 101 | $this->requestData->setSuccess(true); |
83 | return true; | 102 | return true; |
src/Request/ParamInfoRequestDataClass.php
@@ -9,7 +9,9 @@ abstract class ParamInfoTypeEnumClass | @@ -9,7 +9,9 @@ abstract class ParamInfoTypeEnumClass | ||
9 | { | 9 | { |
10 | const UNKNOWN = ""; | 10 | const UNKNOWN = ""; |
11 | const PLOTINIT = "plot_init"; | 11 | const PLOTINIT = "plot_init"; |
12 | + const IMPEXPLOTINIT = "impex_plot_init"; | ||
12 | const PARAMINFO = "param_info"; | 13 | const PARAMINFO = "param_info"; |
14 | + const IMPEXINFO = "impex_param_info"; | ||
13 | } | 15 | } |
14 | 16 | ||
15 | /** | 17 | /** |
src/Request/ParamsRequestImpl/ParamsRequestClass.php
@@ -177,10 +177,35 @@ class ParamsRequestClass extends ProcessRequestClass | @@ -177,10 +177,35 @@ class ParamsRequestClass extends ProcessRequestClass | ||
177 | 177 | ||
178 | touch($destinationFile, $value["dateModif"]); | 178 | touch($destinationFile, $value["dateModif"]); |
179 | } | 179 | } |
180 | + //create and copy local params files | ||
181 | + foreach ($this->requestData->getLocalParamsToCreateAndCopy() as $key => $value) | ||
182 | + { | ||
183 | + $doc = new DOMDocument("1.0", "UTF-8"); | ||
184 | + $doc->preserveWhiteSpace = false; | ||
185 | + $doc->formatOutput = true; | ||
180 | 186 | ||
187 | + if (!$xmlNode = $value["param"]->toXMLNode($doc)) | ||
188 | + { | ||
189 | + $this->requestData->setLastErrorMessage('Cannot create params XML file for '.$key); | ||
190 | + return false; | ||
191 | + } | ||
192 | + | ||
193 | + $doc->appendChild($xmlNode); | ||
194 | + | ||
195 | + $originFile = IHMConfigClass::getUserWSPath().$key.".xml"; | ||
196 | + $destinationFile = KernelConfigClass::getRequestParamsPath($this->requestData->getWorkingPath()).$key.".xml"; | ||
197 | + | ||
198 | + if (!$doc->save($destinationFile) || !$doc->save($originFile)) | ||
199 | + { | ||
200 | + $this->requestData->setLastErrorMessage('Cannot save params XML file for '.$key); | ||
201 | + return false; | ||
202 | + } | ||
203 | + | ||
204 | + touch($originFile, $value["dateModif"]); | ||
205 | + touch($destinationFile, $value["dateModif"]); | ||
206 | + } | ||
181 | return true; | 207 | return true; |
182 | } | 208 | } |
183 | - | ||
184 | /* | 209 | /* |
185 | * @brief Run a params request | 210 | * @brief Run a params request |
186 | */ | 211 | */ |
src/Request/ParamsRequestImpl/ParamsRequestDataClass.php
@@ -26,6 +26,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | @@ -26,6 +26,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | ||
26 | private $waitingResults = array(); | 26 | private $waitingResults = array(); |
27 | private $processParamsToCreate = array(); | 27 | private $processParamsToCreate = array(); |
28 | private $localParamsToCreate = array(); | 28 | private $localParamsToCreate = array(); |
29 | + private $localParamsToCreateAndCopy = array(); | ||
29 | private $paramsToCopy = array(); | 30 | private $paramsToCopy = array(); |
30 | private $paramId = ""; | 31 | private $paramId = ""; |
31 | 32 | ||
@@ -133,6 +134,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | @@ -133,6 +134,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | ||
133 | } | 134 | } |
134 | $newParam->setProcess($expression); | 135 | $newParam->setProcess($expression); |
135 | $newParam->setOutput(); | 136 | $newParam->setOutput(); |
137 | + | ||
136 | $this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); | 138 | $this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); |
137 | } | 139 | } |
138 | 140 | ||
@@ -141,7 +143,12 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | @@ -141,7 +143,12 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | ||
141 | return $this->localParamsToCreate; | 143 | return $this->localParamsToCreate; |
142 | } | 144 | } |
143 | 145 | ||
144 | - public function addLocalParamToCreate($paramId, $viId, $realVarId, $minSampling, $maxSampling, $type, $size, $dateModif) | 146 | + public function getLocalParamsToCreateAndCopy() |
147 | + { | ||
148 | + return $this->localParamsToCreateAndCopy; | ||
149 | + } | ||
150 | + | ||
151 | + public function addLocalParamToCreate($paramId, $viId, $realVarId, $minSampling, $maxSampling, $type, $size, $dateModif, $isImpex = false) | ||
145 | { | 152 | { |
146 | $newParam = new ParamNodeClass(); | 153 | $newParam = new ParamNodeClass(); |
147 | $newParam->setId($paramId); | 154 | $newParam->setId($paramId); |
@@ -155,7 +162,15 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | @@ -155,7 +162,15 @@ class ParamsRequestDataClass extends ProcessRequestDataClass | ||
155 | 162 | ||
156 | $newParam->setProcess(""); | 163 | $newParam->setProcess(""); |
157 | $newParam->setOutput(); | 164 | $newParam->setOutput(); |
158 | - $this->localParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); | 165 | + |
166 | + if ($isImpex) | ||
167 | + { | ||
168 | + $this->localParamsToCreateAndCopy[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); | ||
169 | + } | ||
170 | + else | ||
171 | + { | ||
172 | + $this->localParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); | ||
173 | + } | ||
159 | 174 | ||
160 | return $newParam; | 175 | return $newParam; |
161 | } | 176 | } |
src/RequestManager.php
@@ -27,7 +27,8 @@ function amdaintegration_autoload($class_name) | @@ -27,7 +27,8 @@ function amdaintegration_autoload($class_name) | ||
27 | 'Request/ParamsRequestImpl/Nodes/Requests', | 27 | 'Request/ParamsRequestImpl/Nodes/Requests', |
28 | 'Request/ProcessRequestImpl', | 28 | 'Request/ProcessRequestImpl', |
29 | 'Request/ProcessRequestImpl/Process', | 29 | 'Request/ProcessRequestImpl/Process', |
30 | - 'Request/TTRequestImpl' | 30 | + 'Request/TTRequestImpl', |
31 | + 'RemoteDataCenter' | ||
31 | ); | 32 | ); |
32 | 33 | ||
33 | foreach($dirs as $dir) | 34 | foreach($dirs as $dir) |
@@ -137,12 +138,12 @@ Class RequestManagerClass | @@ -137,12 +138,12 @@ Class RequestManagerClass | ||
137 | /* | 138 | /* |
138 | * @brief Create an instance of the InputOutput interface in relation with the client | 139 | * @brief Create an instance of the InputOutput interface in relation with the client |
139 | */ | 140 | */ |
140 | - private function createInputOutput($user,$client) | 141 | + private function createInputOutput($user,$userHost = null,$client) |
141 | { | 142 | { |
142 | switch ($client) | 143 | switch ($client) |
143 | { | 144 | { |
144 | case ClientTypeEnumClass::IHM : | 145 | case ClientTypeEnumClass::IHM : |
145 | - return new IHMInputOutputClass($user); | 146 | + return new IHMInputOutputClass($user, $userHost); |
146 | case ClientTypeEnumClass::TEST : | 147 | case ClientTypeEnumClass::TEST : |
147 | return new TestInputOutputClass($user); | 148 | return new TestInputOutputClass($user); |
148 | default : | 149 | default : |
@@ -156,7 +157,7 @@ Class RequestManagerClass | @@ -156,7 +157,7 @@ Class RequestManagerClass | ||
156 | private function runGenericRequest($client,$user,$userHost,$function,$input) | 157 | private function runGenericRequest($client,$user,$userHost,$function,$input) |
157 | { | 158 | { |
158 | //create an instance of the InputOutput interface | 159 | //create an instance of the InputOutput interface |
159 | - $inputOutput = $this->createInputOutput($user, $client); | 160 | + $inputOutput = $this->createInputOutput($user, $userHost, $client); |
160 | 161 | ||
161 | //get the input data from the request input data by using the InputOutput interface | 162 | //get the input data from the request input data by using the InputOutput interface |
162 | $inputdata = $inputOutput->getInputData($input,$function); | 163 | $inputdata = $inputOutput->getInputData($input,$function); |