Commit e994cf93cca5369dc7b04c16629e707a474962d6
Exists in
master
and in
58 other branches
merging master
Showing
9 changed files
with
145 additions
and
242 deletions
Show diff stats
src/ClientTypeEnumClass.php
src/InputOutput/SharedObjectsUpdater/SharedObjectsUpdaterInputOutputClass.php
0 → 100644
... | ... | @@ -0,0 +1,47 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * @class SharedObjectsUpdaterInputOutputClass | |
5 | + * @brief Class that's implement an InputOutputInterface for AMDA Shared Objects updater. | |
6 | + * @details | |
7 | + */ | |
8 | +class SharedObjectsUpdaterInputOutputClass implements InputOutputInterface | |
9 | +{ | |
10 | + protected $inputOutput = null; | |
11 | + | |
12 | + /* | |
13 | + * @brief Constructor | |
14 | + */ | |
15 | + function __construct() | |
16 | + { | |
17 | + } | |
18 | + | |
19 | + /* | |
20 | + * @brief translate input data from AMDA Shared Objects updater to AMDA_Integration module | |
21 | + */ | |
22 | + public function getInputData($input,$function,$requestId = "") | |
23 | + { | |
24 | + switch ($function) | |
25 | + { | |
26 | + case FunctionTypeEnumClass::TTCONVERT : | |
27 | + $this->inputOutput = new SharedObjectsUpdaterInputOutputTTClass(); | |
28 | + break; | |
29 | + default : | |
30 | + throw new Exception('Request type '.$function.' not implemented for this client.'); | |
31 | + } | |
32 | + return $this->inputOutput->getInputData($input,$function,$requestId); | |
33 | + } | |
34 | + | |
35 | + /* | |
36 | + * @brief translate output data from AMDA_Integration module to AMDA IHM | |
37 | + */ | |
38 | + public function getOutput($data) | |
39 | + { | |
40 | + if (!isset($this->inputOutput)) | |
41 | + return array("success" => false, "message" => "Input Output Interface not initialized for this request"); | |
42 | + | |
43 | + return $this->inputOutput->getOutput($data); | |
44 | + } | |
45 | +} | |
46 | + | |
47 | +?> | |
... | ... |
src/InputOutput/SharedObjectsUpdater/TimeTables/SharedObjectsUpdaterInputOutputTTClass.php
0 → 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * @class SharedObjectsUpdaterInputOutputTTClass | |
5 | + * @brief | |
6 | + * @details | |
7 | +*/ | |
8 | +class SharedObjectsUpdaterInputOutputTTClass implements InputOutputInterface | |
9 | +{ | |
10 | + private $processData = NULL; | |
11 | + | |
12 | + | |
13 | + /* | |
14 | + * @brief Constructor | |
15 | + */ | |
16 | + function __construct() | |
17 | + { | |
18 | + | |
19 | + } | |
20 | + | |
21 | + /* | |
22 | + * @brief translate input data from AMDA shared objects updater to AMDA_Integration module for a tt process request | |
23 | + */ | |
24 | + public function getInputData($input, $function, $requestId="") | |
25 | + { | |
26 | + if (isset($this->processData)) | |
27 | + unset($this->processData); | |
28 | + | |
29 | + $processData = new TTRequestDataClass(); | |
30 | + $processData->setInputFileName($input['inputFile']); | |
31 | + switch ($input['inputFormat']) { | |
32 | + case 'ASCII': | |
33 | + $processData->setInputFileFormat(TTRequestFileFormatEnum::ASCII); | |
34 | + break; | |
35 | + case 'VOTABLE': | |
36 | + $processData->setInputFileFormat(TTRequestFileFormatEnum::VOTABLE); | |
37 | + break; | |
38 | + case 'INTERNAL': | |
39 | + $processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL); | |
40 | + break; | |
41 | + default: | |
42 | + throw new Exception('Unknown input format'); | |
43 | + } | |
44 | + $processData->setOutputDir($input['outputDir']); | |
45 | + $processData->setOutputFileFormat(TTRequestFileFormatEnum::INTERNAL); | |
46 | + $processData->setOutputFileName($input['outputFileName']); | |
47 | + $processData->setType($function); | |
48 | + $processData->setCmd("ttConversion"); | |
49 | + | |
50 | + $this->processData = $processData; | |
51 | + | |
52 | + return $this->processData; | |
53 | + } | |
54 | + | |
55 | + /* | |
56 | + * @brief translate output data from AMDA_Integration module to AMDA shared objects updater request | |
57 | + */ | |
58 | + public function getOutput($data) | |
59 | + { | |
60 | + $result = array('success' => $data->getSuccess()); | |
61 | + if ($result['success']) { | |
62 | + $result['file'] = $data->getOutputDir()."/".$data->getOutputFileName(); | |
63 | + } | |
64 | + return $result; | |
65 | + } | |
66 | +} | |
67 | + | |
68 | +?> | |
... | ... |
src/Request/Config/KernelConfigClass.php
... | ... | @@ -121,6 +121,11 @@ class KernelConfigClass |
121 | 121 | { |
122 | 122 | return MissionInfo; |
123 | 123 | } |
124 | + | |
125 | + public static function getCommonLibPath() | |
126 | + { | |
127 | + return CommonLib; | |
128 | + } | |
124 | 129 | |
125 | 130 | public static function getKernelBinPath() |
126 | 131 | { |
... | ... | @@ -173,7 +178,8 @@ class KernelConfigClass |
173 | 178 | |
174 | 179 | $appProperties["app.plugin"] = AMDA_KERNEL_BUILD_DIR.'/'.self::$pluginDir; |
175 | 180 | $appProperties["app.process.src"] = $compilation_path.self::$userSrcDir; |
176 | - $appProperties["app.process.lib"] = $compilation_path.self::$userLibDir; | |
181 | + $appProperties["app.process.lib"] = self::getCommonLibPath(); | |
182 | + $appProperties["app.process.userlib"] = $compilation_path.self::$userLibDir; | |
177 | 183 | $appProperties["app.process.CXX_COMPILER"] = self::$cxxCompiler; |
178 | 184 | $appProperties["app.process.CMAKE_CXX_FLAGS"] = self::$cmakeFlags; |
179 | 185 | |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Params/ParamNodeClass.php
... | ... | @@ -14,6 +14,7 @@ define ("PARAM_GAP", "gap_threshold"); |
14 | 14 | define ("PARAM_GET", "get"); |
15 | 15 | define ("PARAM_PROCESS", "process"); |
16 | 16 | define ("PARAM_PROCESS_DESCRIPTION", "description"); |
17 | +define ("PARAM_PROCESS_USERPROCESS", "userProcess"); | |
17 | 18 | define ("PARAM_OUTPUT", "output"); |
18 | 19 | |
19 | 20 | abstract class ParamGetTypeEnum |
... | ... | @@ -109,11 +110,14 @@ class ParamNodeClass extends NodeClass |
109 | 110 | return NULL; |
110 | 111 | } |
111 | 112 | |
112 | - public function setProcess($process, $process_info) | |
113 | + public function setProcess($process, $process_info, $isUserProcess = false) | |
113 | 114 | { |
114 | 115 | $node = $this->getChildInstanceByName(PARAM_PROCESS, true); |
115 | 116 | $node->setValue($process); |
116 | 117 | $node->setAttribute(PARAM_PROCESS_DESCRIPTION, $process_info); |
118 | + if ($isUserProcess) { | |
119 | + $node->setAttribute(PARAM_PROCESS_USERPROCESS, $isUserProcess ? "true" : "false"); | |
120 | + } | |
117 | 121 | } |
118 | 122 | |
119 | 123 | public function setOutput() |
... | ... |
src/Request/ParamsRequestImpl/ParamsRequestDataClass.php
... | ... | @@ -164,7 +164,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass |
164 | 164 | else |
165 | 165 | $amdaParamNode->setParamName($getParam['paramid']); |
166 | 166 | } |
167 | - $newParam->setProcess($expression, $expression_info); | |
167 | + $newParam->setProcess($expression, $expression_info, true); | |
168 | 168 | $newParam->setOutput(); |
169 | 169 | |
170 | 170 | $this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif); |
... | ... |
src/RequestManager.php deleted
... | ... | @@ -1,236 +0,0 @@ |
1 | -<?php | |
2 | - | |
3 | -//autoload configuration | |
4 | -function amdaintegration_autoload($class_name) | |
5 | -{ | |
6 | - $dirs = array( | |
7 | - 'InputOutput', | |
8 | - 'InputOutput/IHMImpl', | |
9 | - 'InputOutput/IHMImpl/Config', | |
10 | - 'InputOutput/IHMImpl/Params', | |
11 | - 'InputOutput/IHMImpl/Params/DataMiningImpl', | |
12 | - 'InputOutput/IHMImpl/Params/StatisticsImpl', | |
13 | - 'InputOutput/IHMImpl/Params/DownloadImpl', | |
14 | - 'InputOutput/IHMImpl/Params/GenInfoParamImpl', | |
15 | - 'InputOutput/IHMImpl/Params/PlotImpl', | |
16 | - 'InputOutput/IHMImpl/Params/GeneratorImpl', | |
17 | - 'InputOutput/IHMImpl/Process', | |
18 | - 'InputOutput/IHMImpl/ParamInfo', | |
19 | - 'InputOutput/IHMImpl/Tools', | |
20 | - 'InputOutput/IHMImpl/TimeTables', | |
21 | - 'InputOutput/TestImpl', | |
22 | - 'Request', | |
23 | - 'Request/Config', | |
24 | - 'Request/ParamsRequestImpl', | |
25 | - 'Request/ParamsRequestImpl/Nodes', | |
26 | - 'Request/ParamsRequestImpl/Nodes/Infos', | |
27 | - 'Request/ParamsRequestImpl/Nodes/Params', | |
28 | - 'Request/ParamsRequestImpl/Nodes/Requests', | |
29 | - 'Request/ProcessRequestImpl', | |
30 | - 'Request/ProcessRequestImpl/Process', | |
31 | - 'Request/TTRequestImpl' | |
32 | - ); | |
33 | - | |
34 | - $ihm_dirs = array( | |
35 | - IHM_SRC_DIR.'/php/classes', | |
36 | - IHM_SRC_DIR.'/php/RemoteDataCenter' | |
37 | - ); | |
38 | - | |
39 | - $find = false; | |
40 | - | |
41 | - foreach($dirs as $dir) | |
42 | - { | |
43 | - $file = __DIR__.'/'.$dir.'/'.$class_name.'.php'; | |
44 | - if (file_exists($file)) | |
45 | - { | |
46 | - require $file; | |
47 | - $find = true; | |
48 | - break; | |
49 | - } | |
50 | - } | |
51 | - | |
52 | - if (!$find) | |
53 | - foreach($ihm_dirs as $dir) | |
54 | - { | |
55 | - $file = $dir.'/'.$class_name.'.php'; | |
56 | - if (file_exists($file)) | |
57 | - { | |
58 | - require $file; | |
59 | - break; | |
60 | - } | |
61 | - } | |
62 | -} | |
63 | - | |
64 | -spl_autoload_register('amdaintegration_autoload'); | |
65 | - | |
66 | -/** | |
67 | - * @class FunctionTypeEnumClass | |
68 | - * @brief Abstract class used as an enumerate for function type. | |
69 | - * @details | |
70 | -*/ | |
71 | -abstract class FunctionTypeEnumClass | |
72 | -{ | |
73 | - const PARAMS = "params"; | |
74 | - const PARAMSGEN = "params_gen"; | |
75 | - const PARAMSGEN = "params_info_gen"; | |
76 | - const ACTION = "action"; | |
77 | - const PROCESSDELETE = "process_delete"; | |
78 | - const PROCESSRUNNINGINFO = "process_running_info"; | |
79 | - const PROCESSGETINFO = "process_get_info"; | |
80 | - const PROCESSCLEAN = "process_clean"; | |
81 | - const PROCESSGETREQUEST = "process_get_request"; | |
82 | - const TTMERGE = "tt_merge"; | |
83 | - const TTUNION = "tt_union"; | |
84 | - const TTCONVERT = "tt_convert"; | |
85 | - const PARAMINFO = "param_info"; | |
86 | -} | |
87 | - | |
88 | -/** | |
89 | - * @class ClientTypeEnumClass | |
90 | - * @brief Abstract class used as an enumerate for AMDA_Integration client. | |
91 | - * @details | |
92 | - */ | |
93 | -abstract class ClientTypeEnumClass | |
94 | -{ | |
95 | - const IHM = "ihm"; | |
96 | - const TEST = "test"; | |
97 | -} | |
98 | - | |
99 | -/** | |
100 | - * @class RequestManagerClass | |
101 | - * @brief Main class to manage a request that's come from an AMDA client | |
102 | - * @details | |
103 | - */ | |
104 | -Class RequestManagerClass | |
105 | -{ | |
106 | - public static $version = "1.6.0"; | |
107 | - | |
108 | -/* | |
109 | - * @brief Constructor | |
110 | -*/ | |
111 | - function __construct() | |
112 | - { | |
113 | - } | |
114 | - | |
115 | -/* | |
116 | - * @brief Treat a request that's come from the IHM | |
117 | -*/ | |
118 | - public function runIHMRequest($user, $userHost, $function, $input) | |
119 | - { | |
120 | - return $this->runGenericRequest(ClientTypeEnumClass::IHM,$user,$userHost,$function,$input); | |
121 | - } | |
122 | - | |
123 | -/* | |
124 | - * @brief Treat a request that's come from a test script | |
125 | -*/ | |
126 | - public function runTestRequest($user, $function, $input) | |
127 | - { | |
128 | - $userHost = ""; | |
129 | - return $this->runGenericRequest(ClientTypeEnumClass::TEST,$user,$userHost,$function,$input); | |
130 | - } | |
131 | - | |
132 | -/* | |
133 | - * @brief Create the request instance in relation with the function type | |
134 | -*/ | |
135 | - private function createRequest($user, $userHost, $function) | |
136 | - { | |
137 | - switch ($function) | |
138 | - { | |
139 | - case FunctionTypeEnumClass::PARAMS : | |
140 | - case FunctionTypeEnumClass::PARAMSGEN : | |
141 | - case FunctionTypeEnumClass::ACTION : | |
142 | - return new ParamsRequestClass($user, $userHost); | |
143 | - case FunctionTypeEnumClass::PROCESSDELETE : | |
144 | - case FunctionTypeEnumClass::PROCESSRUNNINGINFO : | |
145 | - case FunctionTypeEnumClass::PROCESSGETINFO : | |
146 | - case FunctionTypeEnumClass::PROCESSCLEAN : | |
147 | - case FunctionTypeEnumClass::PROCESSGETREQUEST : | |
148 | - return new ProcessRequestClass($user, $userHost); | |
149 | - case FunctionTypeEnumClass::TTMERGE : | |
150 | - case FunctionTypeEnumClass::TTUNION : | |
151 | - case FunctionTypeEnumClass::TTCONVERT : | |
152 | - return new TTRequestClass($user, $userHost); | |
153 | - case FunctionTypeEnumClass::PARAMINFO : | |
154 | - return new ParamInfoRequestClass($user, $userHost); | |
155 | - default : | |
156 | - throw new Exception('Request '.$function.' not implemented.'); | |
157 | - } | |
158 | - } | |
159 | - | |
160 | -/* | |
161 | - * @brief Create an instance of the InputOutput interface in relation with the client | |
162 | -*/ | |
163 | - private function createInputOutput($user,$userHost = null,$client) | |
164 | - { | |
165 | - switch ($client) | |
166 | - { | |
167 | - case ClientTypeEnumClass::IHM : | |
168 | - return new IHMInputOutputClass($user, $userHost); | |
169 | - case ClientTypeEnumClass::TEST : | |
170 | - return new TestInputOutputClass($user); | |
171 | - default : | |
172 | - throw new Exception('Client '.$client.' not implemented.'); | |
173 | - } | |
174 | - } | |
175 | - | |
176 | -/* | |
177 | - * @brief Sequence used to run a request | |
178 | -*/ | |
179 | - private function runGenericRequest($client,$user,$userHost,$function,$input) | |
180 | - { | |
181 | - //create an instance of the InputOutput interface | |
182 | - $inputOutput = $this->createInputOutput($user, $userHost, $client); | |
183 | - | |
184 | - //get the input data from the request input data by using the InputOutput interface | |
185 | - $inputdata = $inputOutput->getInputData($input,$function); | |
186 | - | |
187 | - //create an instance of the RequestClass to run the request | |
188 | - $request = $this->createRequest($user, $userHost, $function); | |
189 | - | |
190 | - if (is_array($inputdata)) | |
191 | - { | |
192 | - $outputdata = array(); | |
193 | - foreach ($inputdata as $data) | |
194 | - //execute the request | |
195 | - $outputdata[] = $this->runSingleRequest($request,$data); | |
196 | - } | |
197 | - else | |
198 | - $outputdata = $this->runSingleRequest($request,$inputdata); | |
199 | - | |
200 | - //get the request output data from the output data by using the InputOutput interface | |
201 | - return $inputOutput->getOutput($outputdata); | |
202 | - } | |
203 | - | |
204 | -/* | |
205 | - * @brief Run a single request | |
206 | -*/ | |
207 | - private function runSingleRequest($request,$data) | |
208 | - { | |
209 | - //link the request to the input data | |
210 | - $request->setData($data); | |
211 | - | |
212 | - //init the request | |
213 | - if (!$request->init()) | |
214 | - { | |
215 | - $crtData = $request->getData(); | |
216 | - if (isset($crtData)) | |
217 | - throw new Exception('Request initialization error : '.$crtData->getLastErrorMessage()); | |
218 | - else | |
219 | - throw new Exception('Cannot init request. Unknown error.'); | |
220 | - } | |
221 | - | |
222 | - //run the request | |
223 | - if (!$request->run()) | |
224 | - { | |
225 | - $crtData = $request->getData(); | |
226 | - if ($crtData) | |
227 | - throw new Exception('Request execution error : '.$crtData->getLastErrorMessage()); | |
228 | - else | |
229 | - throw new Exception('Cannot run request. Unknown error.'); | |
230 | - } | |
231 | - | |
232 | - return $request->getData(); | |
233 | - } | |
234 | -} | |
235 | - | |
236 | -?> |
src/RequestManagerClass.php
... | ... | @@ -48,6 +48,16 @@ Class RequestManagerClass |
48 | 48 | } |
49 | 49 | |
50 | 50 | /* |
51 | + * @brief Treat a request that's come from AMDA shared objects updater | |
52 | +*/ | |
53 | + public function runSharedObjectsUpdaterRequest($function, $input) | |
54 | + { | |
55 | + $user = ""; | |
56 | + $userHost = ""; | |
57 | + return $this->runGenericRequest(ClientTypeEnumClass::SHAREDOBJECTSUPDATER,$user,$userHost,$function,$input); | |
58 | + } | |
59 | + | |
60 | +/* | |
51 | 61 | * @brief Create the request instance in relation with the function type |
52 | 62 | */ |
53 | 63 | private function createRequest($user, $userHost, $function) |
... | ... | @@ -89,7 +99,9 @@ Class RequestManagerClass |
89 | 99 | case ClientTypeEnumClass::WS : |
90 | 100 | return new WSInputOutputClass($user, $userHost); |
91 | 101 | case ClientTypeEnumClass::TEST : |
92 | - return new TestInputOutputClass($user); | |
102 | + return new TestInputOutputClass($user); | |
103 | + case ClientTypeEnumClass::SHAREDOBJECTSUPDATER : | |
104 | + return new SharedObjectsUpdaterInputOutputClass(); | |
93 | 105 | default : |
94 | 106 | throw new Exception('Client '.$client.' not implemented.'); |
95 | 107 | } |
... | ... | @@ -105,7 +117,7 @@ Class RequestManagerClass |
105 | 117 | |
106 | 118 | //get the input data from the request input data by using the InputOutput interface |
107 | 119 | $inputdata = $inputOutput->getInputData($input,$function); |
108 | - | |
120 | + | |
109 | 121 | //create an instance of the RequestClass to run the request |
110 | 122 | $request = $this->createRequest($user, $userHost, $function); |
111 | 123 | |
... | ... |
src/amdaintegration_autoload.php
... | ... | @@ -25,6 +25,8 @@ function amdaintegration_autoload($class_name) |
25 | 25 | 'InputOutput/WSImpl/Params/PlotImpl', |
26 | 26 | 'InputOutput/WSImpl/Tools', |
27 | 27 | 'InputOutput/WSImpl/TimeTables', |
28 | + 'InputOutput/SharedObjectsUpdater', | |
29 | + 'InputOutput/SharedObjectsUpdater/TimeTables', | |
28 | 30 | 'Request', |
29 | 31 | 'Request/Config', |
30 | 32 | 'Request/ParamsRequestImpl', |
... | ... | @@ -45,7 +47,6 @@ function amdaintegration_autoload($class_name) |
45 | 47 | ); |
46 | 48 | |
47 | 49 | $find = false; |
48 | - | |
49 | 50 | $file = __DIR__.'/'.$class_name.'.php'; |
50 | 51 | |
51 | 52 | if (file_exists($file)) |
... | ... |