Commit b9a2fc5cf145cb60fb1d21e6ed1c483db8375469

Authored by Benjamin Renard
2 parents ba483e8e ddaf5ac2

Merge branch 'master' into expression-parser-bre

src/FunctionTypeEnumClass.php
@@ -19,6 +19,7 @@ abstract class FunctionTypeEnumClass @@ -19,6 +19,7 @@ abstract class FunctionTypeEnumClass
19 const TTUNION = "tt_union"; 19 const TTUNION = "tt_union";
20 const TTCONVERT = "tt_convert"; 20 const TTCONVERT = "tt_convert";
21 const PARAMINFO = "param_info"; 21 const PARAMINFO = "param_info";
  22 + const USERWSINIT = "user_init";
22 } 23 }
23 ?> 24 ?>
24 25
src/InputOutput/IHMImpl/Config/IHMConfigClass.php
@@ -25,6 +25,8 @@ class IHMConfigClass @@ -25,6 +25,8 @@ class IHMConfigClass
25 25
26 private static $compilationDir = "compilation/"; 26 private static $compilationDir = "compilation/";
27 27
  28 + private static $storedRequestDir = "REQ/";
  29 +
28 private static $requestDir = "RES/"; 30 private static $requestDir = "RES/";
29 31
30 private static $sharedDir = "shared_data/"; 32 private static $sharedDir = "shared_data/";
@@ -43,12 +45,18 @@ class IHMConfigClass @@ -43,12 +45,18 @@ class IHMConfigClass
43 45
44 private static $aliasesFile = "Alias.xml"; 46 private static $aliasesFile = "Alias.xml";
45 47
  48 + private static $wsInfoFile = "WS_info.json";
  49 +
46 private static $processMgrFile = "processManager.xml"; 50 private static $processMgrFile = "processManager.xml";
47 51
  52 + private static $migrationBackupDir = "MIGRATION_BACKUP/";
  53 +
48 private static $jobsMgrFile = "jobs.xml"; 54 private static $jobsMgrFile = "jobs.xml";
49 55
50 private static $userParamMgrFile = "WsParams.xml"; 56 private static $userParamMgrFile = "WsParams.xml";
51 57
  58 + private static $userRequestMgrFile = "Request.xml";
  59 +
52 private static $userName; 60 private static $userName;
53 61
54 private static $userHost; 62 private static $userHost;
@@ -97,10 +105,29 @@ class IHMConfigClass @@ -97,10 +105,29 @@ class IHMConfigClass
97 return $userPath; 105 return $userPath;
98 } 106 }
99 107
  108 + public static function getUserWSInfoFilePath()
  109 + {
  110 + return self::getUserPath().self::$wsInfoFile;
  111 + }
  112 +
100 public static function getProcessManagerFilePath() 113 public static function getProcessManagerFilePath()
101 { 114 {
102 return self::getDataDir().self::$processMgrFile; 115 return self::getDataDir().self::$processMgrFile;
103 } 116 }
  117 +
  118 + public static function getMigrationBackupPath($version)
  119 + {
  120 + $backupPath = self::getDataDir().self::$migrationBackupDir;
  121 + if (!is_dir($backupPath))
  122 + mkdir($backupPath);
  123 + $backupPath .= ("".$version."/");
  124 + if (!is_dir($backupPath))
  125 + mkdir($backupPath);
  126 + $backupPath .= (self::$userName.'/');
  127 + if (!is_dir($backupPath))
  128 + mkdir($backupPath);
  129 + return $backupPath;
  130 + }
104 131
105 public static function getGenericDataPath() 132 public static function getGenericDataPath()
106 { 133 {
@@ -141,6 +168,11 @@ class IHMConfigClass @@ -141,6 +168,11 @@ class IHMConfigClass
141 { 168 {
142 return self::getUserWSPath().self::$userParamMgrFile; 169 return self::getUserWSPath().self::$userParamMgrFile;
143 } 170 }
  171 +
  172 + public static function getUserRequestManagerFilePath()
  173 + {
  174 + return self::getUserWSPath().self::$userRequestMgrFile;
  175 + }
144 176
145 public static function getUserDerivedParamFilePath($paramId) 177 public static function getUserDerivedParamFilePath($paramId)
146 { 178 {
@@ -245,6 +277,16 @@ class IHMConfigClass @@ -245,6 +277,16 @@ class IHMConfigClass
245 277
246 return $requestPath; 278 return $requestPath;
247 } 279 }
  280 +
  281 + public static function getStoredRequestPath()
  282 + {
  283 + $storedRequestPath = self::getUserPath().self::$storedRequestDir;
  284 +
  285 + if (!is_dir($storedRequestPath))
  286 + mkdir($storedRequestPath);
  287 +
  288 + return $storedRequestPath;
  289 + }
248 290
249 public static function getRemoteDataPath() 291 public static function getRemoteDataPath()
250 { 292 {
src/InputOutput/IHMImpl/IHMInputOutputClass.php
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 class IHMInputOutputClass implements InputOutputInterface 8 class IHMInputOutputClass implements InputOutputInterface
9 { 9 {
10 protected $inputOutput = null; 10 protected $inputOutput = null;
  11 + protected $userWSMgr = null;
11 12
12 /* 13 /*
13 * @brief Constructor 14 * @brief Constructor
@@ -16,6 +17,7 @@ class IHMInputOutputClass implements InputOutputInterface @@ -16,6 +17,7 @@ class IHMInputOutputClass implements InputOutputInterface
16 { 17 {
17 IHMConfigClass::setUserName($userName); 18 IHMConfigClass::setUserName($userName);
18 IHMConfigClass::setUserHost($userHost); 19 IHMConfigClass::setUserHost($userHost);
  20 + $this->userWSMgr = new IHMUserWSManagerClass();
19 } 21 }
20 22
21 /* 23 /*
@@ -23,10 +25,6 @@ class IHMInputOutputClass implements InputOutputInterface @@ -23,10 +25,6 @@ class IHMInputOutputClass implements InputOutputInterface
23 */ 25 */
24 public function getInputData($input,$function,$requestId = "") 26 public function getInputData($input,$function,$requestId = "")
25 { 27 {
26 - //check user workspace  
27 - if (IHMConfigClass::getUserName() == "" || !is_dir(IHMConfigClass::getUserPath()))  
28 - throw new Exception('Cannot find user workspace.');  
29 -  
30 switch ($function) 28 switch ($function)
31 { 29 {
32 case FunctionTypeEnumClass::PARAMS : 30 case FunctionTypeEnumClass::PARAMS :
@@ -102,6 +100,8 @@ class IHMInputOutputClass implements InputOutputInterface @@ -102,6 +100,8 @@ class IHMInputOutputClass implements InputOutputInterface
102 case FunctionTypeEnumClass::PARAMINFO : 100 case FunctionTypeEnumClass::PARAMINFO :
103 $this->inputOutput = new IHMInputOutputParamInfoClass(); 101 $this->inputOutput = new IHMInputOutputParamInfoClass();
104 break; 102 break;
  103 + case FunctionTypeEnumClass::USERWSINIT :
  104 + return $this->userWSMgr->init();
105 default : 105 default :
106 throw new Exception('Request type '.$function.' not implemented for this client.'); 106 throw new Exception('Request type '.$function.' not implemented for this client.');
107 } 107 }
src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php
@@ -50,6 +50,14 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface @@ -50,6 +50,14 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface
50 } 50 }
51 51
52 /* 52 /*
  53 + * @brief Get Task
  54 + */
  55 + protected function getTask($input)
  56 + {
  57 + return $input->nodeType;
  58 + }
  59 +
  60 + /*
53 * @brief Unmarshall the time definition from the IHM request 61 * @brief Unmarshall the time definition from the IHM request
54 */ 62 */
55 protected function unmarshallTimeDefinition($input, $requestIndex, $ttFileIndex = -1, $ttIntIndex = -1) 63 protected function unmarshallTimeDefinition($input, $requestIndex, $ttFileIndex = -1, $ttIntIndex = -1)
@@ -208,7 +216,7 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface @@ -208,7 +216,7 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface
208 $this->paramsData->setCompilationPath(IHMConfigClass::getCompilationPath()); 216 $this->paramsData->setCompilationPath(IHMConfigClass::getCompilationPath());
209 $this->paramsData->setLocalBasePath(IHMConfigClass::getLocalBasePath()); 217 $this->paramsData->setLocalBasePath(IHMConfigClass::getLocalBasePath());
210 $this->paramsData->setManagerFilePath(IHMConfigClass::getProcessManagerFilePath()); 218 $this->paramsData->setManagerFilePath(IHMConfigClass::getProcessManagerFilePath());
211 - $this->paramsData->setTask($input->nodeType); 219 + $this->paramsData->setTask($this->getTask($input));
212 $this->input = $input; 220 $this->input = $input;
213 221
214 return $this->unmarshallRequest($input); 222 return $this->unmarshallRequest($input);
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -15,9 +15,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -15,9 +15,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
15 15
16 private $isInstantPlot = false; 16 private $isInstantPlot = false;
17 17
18 - private $interactiveRequestRealIndexes = array();  
19 - private $interactiveMultiPlotState = array();  
20 private $interactiveTimeSelectionState = array(); 18 private $interactiveTimeSelectionState = array();
  19 + private $interactivePlotTitle = array();
  20 + private $interactivePlotIndex = array();
21 private $interactiveCrtTTFileIndex = -1; 21 private $interactiveCrtTTFileIndex = -1;
22 private $interactivePreview = false; 22 private $interactivePreview = false;
23 23
@@ -26,10 +26,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -26,10 +26,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
26 */ 26 */
27 protected function unmarshallRequest($input) 27 protected function unmarshallRequest($input)
28 { 28 {
29 - $this->interactiveRequestRealIndexes = array();  
30 -  
31 - $fullResetZoom = false;  
32 $forceTimeZoomReset = false; 29 $forceTimeZoomReset = false;
  30 + $resetZoom = false;
33 31
34 if (isset($input->{'action'})) 32 if (isset($input->{'action'}))
35 { 33 {
@@ -40,265 +38,196 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -40,265 +38,196 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
40 { 38 {
41 $resetZoom = true; 39 $resetZoom = true;
42 //save request 40 //save request
43 - $this->saveIHMRequest($input); 41 + $this->saveIHMRequest(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $input);
44 } 42 }
45 43
46 - //Get active tab  
47 - $activeTab = NULL;  
48 - foreach ($input->tabs as $tab)  
49 - {  
50 - if ($tab->{'id'} == $input->{'last-plotted-tab'})  
51 - {  
52 - $activeTab = $tab;  
53 - }  
54 - }  
55 -  
56 //Request 44 //Request
57 - $requestIndexInParamData = 0;  
58 - $tabRequestIndex = 0;  
59 $this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE'); 45 $this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE');
60 $this->isFromWS = ($input->{'file-output'} == 'WS'); 46 $this->isFromWS = ($input->{'file-output'} == 'WS');
  47 + $this->paramsData->setRequestIndex($input->{'tab-index'});
61 $postProcessCmd = ""; 48 $postProcessCmd = "";
62 - foreach ($input->tabs as $tab)  
63 - {  
64 - if (isset($activeTab))  
65 - {  
66 - if ($this->isInteractiveRequest)  
67 - {  
68 - if ($activeTab->{'multi-plot-linked'} && !$tab->{'multi-plot-linked'})  
69 - {  
70 - ++$tabRequestIndex;  
71 - //Tab is not linked to the Multi Plot Mode  
72 - continue;  
73 - }  
74 - else if (!$activeTab->{'multi-plot-linked'} && ($tab->{'id'} != $activeTab->{'id'}))  
75 - {  
76 - ++$tabRequestIndex;  
77 - //Plot only current active tab  
78 - continue;  
79 - }  
80 - else if (isset($input->{'force-single-replot'}) && $input->{'force-single-replot'} && ($tab->{'id'} != $activeTab->{'id'}))  
81 - {  
82 - ++$tabRequestIndex;  
83 - //Plot only current active tab when 'force-single-replot' is active  
84 - continue;  
85 - }  
86 - //Reset zoom list if needed  
87 - if ($fullResetZoom || $forceTimeZoomReset)  
88 - $this->resetZoomListForTab($tab->{'id'}, $forceTimeZoomReset && !$fullResetZoom);  
89 - }  
90 - else  
91 - {  
92 - if ($tab->{'id'} != $activeTab->{'id'})  
93 - {  
94 - ++$tabRequestIndex;  
95 - //In no interactive request, plot only active tab  
96 - continue;  
97 - }  
98 - //Reset zoom list if needed  
99 - if ($fullResetZoom || $forceTimeZoomReset)  
100 - $this->resetZoomListForTab($tab->{'id'}, $forceTimeZoomReset && !$fullResetZoom);  
101 - }  
102 - } 49 +
  50 + if ($resetZoom || $forceTimeZoomReset)
  51 + $this->resetZoomList(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $forceTimeZoomReset);
103 52
104 - $requestNode = $this->paramsData->addRequestNode();  
105 - $requestNode->setRealIndex($tabRequestIndex);  
106 - $outputsNode = $requestNode->getOutputsNode();  
107 - $paramsNode = $requestNode->getParamsNode(); 53 + $requestNode = $this->paramsData->addRequestNode();
  54 + $outputsNode = $requestNode->getOutputsNode();
  55 + $paramsNode = $requestNode->getParamsNode();
108 56
109 - //unmarshall time definition  
110 - if ($tab->{'multi-plot-linked'})  
111 - {  
112 - $isIntervalRequest = ($input->timesrc == 'Interval');  
113 - $ttFileIndex = -1;  
114 - $ttIntIndex = -1;  
115 - if ($this->isInteractiveRequest && !$isIntervalRequest && !$tab->{'page-superpose-mode'})  
116 - {  
117 - $ttFileIndex = !isset($input->{'ttFileIndex'}) ? 0 : $input->{'ttFileIndex'};  
118 - $ttIntIndex = !isset($input->{'intIndex'}) ? 0 : $input->{'intIndex'};  
119 - }  
120 - $this->unmarshallTimeDefinition($input, $requestIndexInParamData, $ttFileIndex, $ttIntIndex);  
121 - }  
122 - else  
123 - {  
124 - $isIntervalRequest = ($tab->timesrc == 'Interval');  
125 - $ttFileIndex = -1;  
126 - $ttIntIndex = -1;  
127 - if ($this->isInteractiveRequest && !$isIntervalRequest && !$tab->{'page-superpose-mode'})  
128 - {  
129 - $ttFileIndex = !isset($activeTab->{'ttFileIndex'}) ? 0 : $activeTab->{'ttFileIndex'};  
130 - $ttIntIndex = !isset($activeTab->{'intIndex'}) ? 0 : $activeTab->{'intIndex'};  
131 - }  
132 - $this->unmarshallTimeDefinition($tab, $requestIndexInParamData, $ttFileIndex, $ttIntIndex);  
133 - } 57 + //unmarshall time definition
  58 + $isIntervalRequest = ($input->timesrc == 'Interval');
  59 + $ttFileIndex = -1;
  60 + $ttIntIndex = -1;
  61 + if ($this->isInteractiveRequest && !$isIntervalRequest && !$input->{'page-superpose-mode'})
  62 + {
  63 + $ttFileIndex = !isset($input->{'ttFileIndex'}) ? 0 : $input->{'ttFileIndex'};
  64 + $ttIntIndex = !isset($input->{'intIndex'}) ? 0 : $input->{'intIndex'};
  65 + }
  66 + $this->unmarshallTimeDefinition($input, 0, $ttFileIndex, $ttIntIndex);
134 67
135 - $this->interactiveCrtTTFileIndex = $ttFileIndex; 68 + $this->interactiveCrtTTFileIndex = $ttFileIndex;
136 69
137 - $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); 70 + $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
138 71
139 - $plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false"); 72 + $plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false");
140 73
141 - $compression = "";  
142 - if (!$this->isInteractiveRequest && !$this->isFromWS) 74 + $compression = "";
  75 + if (!$this->isInteractiveRequest && !$this->isFromWS)
  76 + {
  77 + switch ($input->{'file-output'})
143 { 78 {
144 - switch ($input->{'file-output'})  
145 - {  
146 - case 'TGZ' :  
147 - $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR);  
148 - $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP);  
149 - $compression = ".tar.gz";  
150 - break;  
151 - case 'ZIP' :  
152 - $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP);  
153 - $compression = ".zip";  
154 - break;  
155 - default:  
156 - throw new Exception('Compression not implemented.');  
157 - } 79 + case 'TGZ' :
  80 + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR);
  81 + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP);
  82 + $compression = ".tar.gz";
  83 + break;
  84 + case 'ZIP' :
  85 + $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP);
  86 + $compression = ".zip";
  87 + break;
  88 + default:
  89 + throw new Exception('Compression not implemented.');
158 } 90 }
  91 + }
159 92
160 - if ($input->{'one-file-per-interval'})  
161 - $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL);  
162 - else  
163 - $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE); 93 + if ($input->{'one-file-per-interval'})
  94 + $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL);
  95 + else
  96 + $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE);
164 97
165 - //prefix  
166 - $filePrefix = "plot_";  
167 - if ($input->{'file-prefix'} && ($input->{'file-prefix'} != ""))  
168 - $filePrefix = $input->{'file-prefix'};  
169 - $filePrefix .= $tab->{'id'}; 98 + //prefix
  99 + $filePrefix = "plot_";
  100 + if ($input->{'file-prefix'} && ($input->{'file-prefix'} != ""))
  101 + $filePrefix = $input->{'file-prefix'};
  102 + $filePrefix .= $input->{'tab-index'};
170 103
171 - $plotOutputNode->setFilePrefix($filePrefix); 104 + $plotOutputNode->setFilePrefix($filePrefix);
172 105
173 - //page  
174 - $pageNode = $plotOutputNode->getPage(); 106 + //page
  107 + $pageNode = $plotOutputNode->getPage();
175 108
176 - $fileFormat = RequestOutputPlotPageFormatEnum::PNG;  
177 - $extension = ".png";  
178 - switch ($input->{'file-format'})  
179 - {  
180 - case 'PNG' :  
181 - $fileFormat = RequestOutputPlotPageFormatEnum::PNG;  
182 - $extension = ".png";  
183 - break;  
184 - case 'PDF' :  
185 - $fileFormat = RequestOutputPlotPageFormatEnum::PDF;  
186 - $extension = ".pdf";  
187 - break;  
188 - case 'PS' :  
189 - $fileFormat = RequestOutputPlotPageFormatEnum::PS;  
190 - $extension = ".ps";  
191 - break;  
192 - case 'SVG' :  
193 - $fileFormat = RequestOutputPlotPageFormatEnum::SVG;  
194 - $extension = ".svg";  
195 - break;  
196 - default:  
197 - throw new Exception('File format not implemented.');  
198 - } 109 + $fileFormat = RequestOutputPlotPageFormatEnum::PNG;
  110 + $extension = ".png";
  111 + switch ($input->{'file-format'})
  112 + {
  113 + case 'PNG' :
  114 + $fileFormat = RequestOutputPlotPageFormatEnum::PNG;
  115 + $extension = ".png";
  116 + break;
  117 + case 'PDF' :
  118 + $fileFormat = RequestOutputPlotPageFormatEnum::PDF;
  119 + $extension = ".pdf";
  120 + break;
  121 + case 'PS' :
  122 + $fileFormat = RequestOutputPlotPageFormatEnum::PS;
  123 + $extension = ".ps";
  124 + break;
  125 + case 'SVG' :
  126 + $fileFormat = RequestOutputPlotPageFormatEnum::SVG;
  127 + $extension = ".svg";
  128 + break;
  129 + default:
  130 + throw new Exception('File format not implemented.');
  131 + }
199 132
200 - $pageNode->setFormat($fileFormat); 133 + $pageNode->setFormat($fileFormat);
201 134
202 - $this->unmarshallTitle($tab, 'page-title', $pageNode->getTitle()); 135 + $this->unmarshallTitle($input, 'page-title', $pageNode->getTitle());
203 136
204 - $isPortrait = false;  
205 - switch ($tab->{'page-orientation'})  
206 - {  
207 - case 'landscape' :  
208 - $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE);  
209 - break;  
210 - case 'portrait' :  
211 - $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT);  
212 - $isPortrait = true;  
213 - break;  
214 - } 137 + $isPortrait = false;
  138 + switch ($input->{'page-orientation'})
  139 + {
  140 + case 'landscape' :
  141 + $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE);
  142 + break;
  143 + case 'portrait' :
  144 + $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT);
  145 + $isPortrait = true;
  146 + break;
  147 + }
215 148
216 - switch ($tab->{'page-dimension'})  
217 - {  
218 - case 'ISO A4' :  
219 - $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4);  
220 - break;  
221 - case 'US letter' :  
222 - $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER);  
223 - break;  
224 - default:  
225 - throw new Exception('Page dimension not implemented.');  
226 - } 149 + switch ($input->{'page-dimension'})
  150 + {
  151 + case 'ISO A4' :
  152 + $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4);
  153 + break;
  154 + case 'US letter' :
  155 + $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER);
  156 + break;
  157 + default:
  158 + throw new Exception('Page dimension not implemented.');
  159 + }
227 160
228 - switch ($tab->{'page-mode'})  
229 - { 161 + switch ($input->{'page-mode'})
  162 + {
230 163
231 - case 'grayscale' :  
232 - $pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE);  
233 - break;  
234 - case 'color' :  
235 - default:  
236 - $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR);  
237 - break;  
238 - }  
239 -  
240 - if ($tab->{'page-margins-activated'})  
241 - {  
242 - $pageNode->getMargins()->setHorizontal($tab->{'page-margin-x'});  
243 - $pageNode->getMargins()->setVertical($tab->{'page-margin-y'});  
244 - } 164 + case 'grayscale' :
  165 + $pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE);
  166 + break;
  167 + case 'color' :
  168 + default:
  169 + $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR);
  170 + break;
  171 + }
245 172
246 - if ($tab->{'page-font-activated'})  
247 - $this->unmarshallFont($tab, 'page-font', $pageNode->getFont()); 173 + if ($input->{'page-margins-activated'})
  174 + {
  175 + $pageNode->getMargins()->setHorizontal($input->{'page-margin-x'});
  176 + $pageNode->getMargins()->setVertical($input->{'page-margin-y'});
  177 + }
248 178
249 - //Superpose mode  
250 - $pageNode->setSuperposeMode($tab->{'page-superpose-mode'} ? "true": "false"); 179 + if ($input->{'page-font-activated'})
  180 + $this->unmarshallFont($input, 'page-font', $pageNode->getFont());
251 181
252 - //Layout  
253 - $this->unmarshallLayout($tab, $pageNode); 182 + //Superpose mode
  183 + $pageNode->setSuperposeMode($input->{'page-superpose-mode'} ? "true": "false");
254 184
255 - foreach ($tab->{'panels'} as $panelData)  
256 - $this->unmarshallPanel($panelData, $pageNode, $paramsNode); 185 + //Layout
  186 + $this->unmarshallLayout($input, $pageNode);
257 187
258 - if ($this->isInteractiveRequest || $this->isFromWS)  
259 - {  
260 - $resultFile = $filePrefix."_*".$extension;  
261 - $waitingResultFile = $filePrefix.$extension;  
262 - }  
263 - else  
264 - {  
265 - $resultFile = $filePrefix."_*".$compression;  
266 - $waitingResultFile = $filePrefix.$compression;  
267 - } 188 + foreach ($input->{'panels'} as $panelData)
  189 + $this->unmarshallPanel($panelData, $pageNode, $paramsNode);
268 190
269 - if ($this->isInteractiveRequest)  
270 - {  
271 - $this->interactiveRequestRealIndexes[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tabRequestIndex;  
272 - $this->interactiveMultiPlotState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tab->{'multi-plot-linked'};  
273 - $this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $isIntervalRequest;  
274 - $this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'});  
275 - $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$tab->{'id'}, $waitingResultFile);  
276 - }  
277 - else  
278 - $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile); 191 + if ($this->isInteractiveRequest || $this->isFromWS)
  192 + {
  193 + $resultFile = $filePrefix."_*".$extension;
  194 + $waitingResultFile = $filePrefix.$extension;
  195 + }
  196 + else
  197 + {
  198 + $resultFile = $filePrefix."_*".$compression;
  199 + $waitingResultFile = $filePrefix.$compression;
  200 + }
279 201
280 - //Remove old result files  
281 - foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) {  
282 - unlink($oldFile);  
283 - } 202 + if ($this->isInteractiveRequest)
  203 + {
  204 + $this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $isIntervalRequest;
  205 + $this->interactivePlotTitle[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $input->{'tab-title'};
  206 + $this->interactivePlotIndex[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $input->{'tab-index'};
  207 + $this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'});
  208 + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $waitingResultFile);
  209 + }
  210 + else
  211 + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile);
284 212
285 - //Post process command to apply to the result file  
286 - if ($postProcessCmd != "")  
287 - $postProcessCmd .= " | ";  
288 - $postProcessCmd .= "mv ".$resultFile." ".$waitingResultFile; 213 + //Remove old result files
  214 + foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) {
  215 + unlink($oldFile);
  216 + }
289 217
290 - if (($this->isInteractiveRequest) && $isPortrait)  
291 - $postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$waitingResultFile;  
292 - else if ($this->isFromWS)  
293 - {  
294 - if ($isPortrait)  
295 - $postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$input->{"ws-result-file"};  
296 - else  
297 - $postProcessCmd .= " | mv ".$waitingResultFile." ".$input->{"ws-result-file"};  
298 - } 218 + //Post process command to apply to the result file
  219 + if ($postProcessCmd != "")
  220 + $postProcessCmd .= " | ";
  221 + $postProcessCmd .= "mv ".$resultFile." ".$waitingResultFile;
299 222
300 - ++$tabRequestIndex;  
301 - ++$requestIndexInParamData; 223 + if (($this->isInteractiveRequest) && $isPortrait)
  224 + $postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$waitingResultFile;
  225 + else if ($this->isFromWS)
  226 + {
  227 + if ($isPortrait)
  228 + $postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$input->{"ws-result-file"};
  229 + else
  230 + $postProcessCmd .= " | mv ".$waitingResultFile." ".$input->{"ws-result-file"};
302 } 231 }
303 232
304 $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest)); 233 $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest));
@@ -307,39 +236,39 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -307,39 +236,39 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
307 return $this->paramsData; 236 return $this->paramsData;
308 } 237 }
309 238
310 - protected function unmarshallLayout($tab, $pageNode) 239 + protected function unmarshallLayout($request, $pageNode)
311 { 240 {
312 - switch ($tab->{'page-layout-type'}) 241 + switch ($request->{'page-layout-type'})
313 { 242 {
314 case 'vertical' : 243 case 'vertical' :
315 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL); 244 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL);
316 - $pageNode->getLayout()->setPanelHeight($tab->{'page-layout-object'}->{'layout-panel-height'});  
317 - $pageNode->getLayout()->setPanelSpacing($tab->{'page-layout-object'}->{'layout-panel-spacing'});  
318 - $pageNode->getLayout()->setExpand($tab->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");  
319 - $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($tab->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false");  
320 - //if ($tab->{'page-layout-object'}->{'layout-timeplot-width'} > 0)  
321 - // $pageNode->setDefaultTimePlotWidth($tab->{'page-layout-object'}->{'layout-timeplot-width'});  
322 - if ($tab->{'page-layout-object'}->{'layout-timeplot-height'} > 0)  
323 - $pageNode->setDefaultTimePlotHeight($tab->{'page-layout-object'}->{'layout-timeplot-height'});  
324 - if ($tab->{'page-layout-object'}->{'layout-xyplot-width'} > 0)  
325 - $pageNode->setDefaultXYPlotWidth($tab->{'page-layout-object'}->{'layout-xyplot-width'});  
326 - if ($tab->{'page-layout-object'}->{'layout-xyplot-height'} > 0)  
327 - $pageNode->setDefaultXYPlotHeight($tab->{'page-layout-object'}->{'layout-xyplot-height'}); 245 + $pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'});
  246 + $pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'});
  247 + $pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");
  248 + $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false");
  249 + //if ($request->{'page-layout-object'}->{'layout-timeplot-width'} > 0)
  250 + // $pageNode->setDefaultTimePlotWidth($request->{'page-layout-object'}->{'layout-timeplot-width'});
  251 + if ($request->{'page-layout-object'}->{'layout-timeplot-height'} > 0)
  252 + $pageNode->setDefaultTimePlotHeight($request->{'page-layout-object'}->{'layout-timeplot-height'});
  253 + if ($request->{'page-layout-object'}->{'layout-xyplot-width'} > 0)
  254 + $pageNode->setDefaultXYPlotWidth($request->{'page-layout-object'}->{'layout-xyplot-width'});
  255 + if ($request->{'page-layout-object'}->{'layout-xyplot-height'} > 0)
  256 + $pageNode->setDefaultXYPlotHeight($request->{'page-layout-object'}->{'layout-xyplot-height'});
328 break; 257 break;
329 case 'auto' : 258 case 'auto' :
330 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO); 259 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO);
331 - $pageNode->getLayout()->setPanelHeight($tab->{'page-layout-object'}->{'layout-panel-height'});  
332 - $pageNode->getLayout()->setPanelSpacing($tab->{'page-layout-object'}->{'layout-panel-spacing'});  
333 - $pageNode->getLayout()->setExpand($tab->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");  
334 - $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($tab->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false"); 260 + $pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'});
  261 + $pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'});
  262 + $pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");
  263 + $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false");
335 break; 264 break;
336 case 'manual' : 265 case 'manual' :
337 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL); 266 $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL);
338 - $timePlotLeftMargin = $tab->{'page-layout-object'}->{'layout-timeplot-margin-left'} ? $tab->{'page-layout-object'}->{'layout-timeplot-margin-left'} : -1;  
339 - $timePlotRightMargin = $tab->{'page-layout-object'}->{'layout-timeplot-margin-right'} ? $tab->{'page-layout-object'}->{'layout-timeplot-margin-right'} : -1; 267 + $timePlotLeftMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} : -1;
  268 + $timePlotRightMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} : -1;
340 $pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin); 269 $pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin);
341 - $xyPlotLeftMargin = $tab->{'page-layout-object'}->{'layout-xyplot-margin-left'} ? $tab->{'page-layout-object'}->{'layout-xyplot-margin-left'} : -1;  
342 - $xyPlotRightMargin = $tab->{'page-layout-object'}->{'layout-xyplot-margin-right'} ? $tab->{'page-layout-object'}->{'layout-xyplot-margin-right'} : -1; 270 + $xyPlotLeftMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} : -1;
  271 + $xyPlotRightMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} : -1;
343 $pageNode->setDefaultXYPlotXMargin($xyPlotLeftMargin, $xyPlotRightMargin); 272 $pageNode->setDefaultXYPlotXMargin($xyPlotLeftMargin, $xyPlotRightMargin);
344 break; 273 break;
345 default: 274 default:
@@ -1481,10 +1410,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1481,10 +1410,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1481 1410
1482 $result[] = array( 1411 $result[] = array(
1483 "id" => $key, 1412 "id" => $key,
1484 - "index" => $this->interactiveRequestRealIndexes[$key],  
1485 - "multiplot" => $this->interactiveMultiPlotState[$key], 1413 + "title" => $this->interactivePlotTitle[$key],
1486 "preview" => $this->interactivePreview, 1414 "preview" => $this->interactivePreview,
1487 "isInterval" => $this->interactiveTimeSelectionState[$key], 1415 "isInterval" => $this->interactiveTimeSelectionState[$key],
  1416 + "index" => $this->interactivePlotIndex[$key],
1488 "ttFileIndex" => $this->interactiveCrtTTFileIndex, 1417 "ttFileIndex" => $this->interactiveCrtTTFileIndex,
1489 "context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult), 1418 "context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult),
1490 "plot" => $waitingResult, 1419 "plot" => $waitingResult,
@@ -1520,9 +1449,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1520,9 +1449,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1520 return "[".$r.",".$g.",".$b."]"; 1449 return "[".$r.",".$g.",".$b."]";
1521 } 1450 }
1522 1451
1523 - private function saveIHMRequest($input) 1452 + private function saveIHMRequest($interactiveId, $input)
1524 { 1453 {
1525 - $path = $this->getWorkingPath()."ihm.request"; 1454 + $path = $this->getWorkingPath()."ihm.request.".$interactiveId;
1526 if (!is_dir($this->getWorkingPath())) 1455 if (!is_dir($this->getWorkingPath()))
1527 mkdir($this->getWorkingPath(),0777); 1456 mkdir($this->getWorkingPath(),0777);
1528 $file = fopen($path, 'w'); 1457 $file = fopen($path, 'w');
@@ -1530,33 +1459,42 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1530,33 +1459,42 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1530 fclose($file); 1459 fclose($file);
1531 } 1460 }
1532 1461
1533 - private function loadIHMRequest() 1462 + private function loadIHMRequest($interactiveId)
1534 { 1463 {
1535 - $path = $this->getWorkingPath()."ihm.request"; 1464 + $path = $this->getWorkingPath()."ihm.request.".$interactiveId;
1536 if (!file_exists($path)) 1465 if (!file_exists($path))
1537 return NULL; 1466 return NULL;
1538 return json_decode(file_get_contents($path)); 1467 return json_decode(file_get_contents($path));
1539 } 1468 }
  1469 +
  1470 +
  1471 +
  1472 + private function loadZoomList($interactiveId)
  1473 + {
  1474 + $path = $this->getWorkingPath()."zoom.list.".$interactiveId;
  1475 + if (!file_exists($path))
  1476 + return NULL;
  1477 + return json_decode(file_get_contents($path));
  1478 + }
  1479 +
  1480 + private function saveZoomList($interactiveId, $zoomList)
  1481 + {
  1482 + $path = $this->getWorkingPath()."zoom.list.".$interactiveId;
  1483 + if (!is_dir($this->getWorkingPath()))
  1484 + mkdir($this->getWorkingPath(),0777);
  1485 + $file = fopen($path, 'w');
  1486 + fwrite($file, json_encode($zoomList));
  1487 + fclose($file);
  1488 + }
1540 1489
1541 private function unmarshallActionRequest($input) 1490 private function unmarshallActionRequest($input)
1542 { 1491 {
1543 $actionInput = $input->{'action'}; 1492 $actionInput = $input->{'action'};
1544 - $multiPlotState = $input->{'multiPlotState'};  
1545 1493
1546 - $plotInput = $this->loadIHMRequest(); 1494 + $plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'});
1547 1495
1548 if (!isset($plotInput)) 1496 if (!isset($plotInput))
1549 - throw new Exception('Cannot retrieve request input for inetractive action.');  
1550 -  
1551 - //Set interactive Multi Plot state  
1552 - foreach ($multiPlotState as $key => $value)  
1553 - {  
1554 - foreach ($plotInput->{'tabs'} as $tab)  
1555 - {  
1556 - if (PLOT_RESULT_FILE_KEY."_".$tab->{'id'} == $key)  
1557 - $tab->{'multi-plot-linked'} = $value;  
1558 - }  
1559 - } 1497 + throw new Exception('Cannot retrieve request input for interactive action.');
1560 1498
1561 switch ($actionInput->{'action'}) 1499 switch ($actionInput->{'action'})
1562 { 1500 {
@@ -1571,8 +1509,6 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1571,8 +1509,6 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1571 return $this->unmarshallNavigation($actionInput, $plotInput); 1509 return $this->unmarshallNavigation($actionInput, $plotInput);
1572 case 'goto' : 1510 case 'goto' :
1573 return $this->unmarshallTTGoto($actionInput, $plotInput); 1511 return $this->unmarshallTTGoto($actionInput, $plotInput);
1574 - case 'synchronize' :  
1575 - return $this->unmarshallSynchronize($actionInput, $plotInput);  
1576 case 'instant' : 1512 case 'instant' :
1577 return $this->unmarshallInstant($actionInput, $plotInput); 1513 return $this->unmarshallInstant($actionInput, $plotInput);
1578 case 'undozoom' : 1514 case 'undozoom' :
@@ -1587,34 +1523,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1587,34 +1523,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1587 //if $isInterval == true, $minOrFileIndex is the min and $maxOrInetrvalIndex is the max 1523 //if $isInterval == true, $minOrFileIndex is the min and $maxOrInetrvalIndex is the max
1588 //if $isInterval == false, $minOrFileIndex is the fileIndex and $maxOrInetrvalIndex is the intervalIndex 1524 //if $isInterval == false, $minOrFileIndex is the fileIndex and $maxOrInetrvalIndex is the intervalIndex
1589 1525
1590 - $zoomList = $this->loadZoomList(); 1526 + $zoomList = $this->loadZoomList($input->interactiveId);
1591 1527
1592 - if (!isset($zoomList->tabs)) 1528 + if (!isset($zoomList))
1593 { 1529 {
1594 //Init zoom list 1530 //Init zoom list
1595 $zoomList = (Object)array( 1531 $zoomList = (Object)array(
1596 - 'tabs' => (Object)array()  
1597 - );  
1598 - }  
1599 -  
1600 - if (!isset($zoomList->tabs->{$input->{'tabId'}}))  
1601 - {  
1602 - $zoomList->tabs->{$input->{'tabId'}} = (Object)array(  
1603 - 'times' => array(),  
1604 - 'panels' => (Object)array() 1532 + 'times' => array(),
  1533 + 'panels' => (Object)array()
1605 ); 1534 );
1606 } 1535 }
1607 1536
1608 if ($input->{'axeId'} == 'timeAxis') 1537 if ($input->{'axeId'} == 'timeAxis')
1609 { 1538 {
1610 if ($isInterval) 1539 if ($isInterval)
1611 - array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array( 1540 + array_push ($zoomList->times, (Object)array(
1612 'isInterval' => true, 1541 'isInterval' => true,
1613 'min' => $minOrFileIndex, 1542 'min' => $minOrFileIndex,
1614 'max' => $maxOrIntervalIndex 1543 'max' => $maxOrIntervalIndex
1615 )); 1544 ));
1616 else 1545 else
1617 - array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array( 1546 + array_push ($zoomList->times, (Object)array(
1618 'isInterval' => false, 1547 'isInterval' => false,
1619 'ttFileIndex' => $minOrFileIndex, 1548 'ttFileIndex' => $minOrFileIndex,
1620 'intIndex' => $maxOrIntervalIndex 1549 'intIndex' => $maxOrIntervalIndex
@@ -1622,163 +1551,103 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1622,163 +1551,103 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1622 } 1551 }
1623 else 1552 else
1624 { 1553 {
1625 - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}})) 1554 + if (!isset($zoomList->panels->{$input->{'panelId'}}))
1626 { 1555 {
1627 - $zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}} = (Object) array( 1556 + $zoomList->panels->{$input->{'panelId'}} = (Object) array(
1628 'axes' => (Object)array() 1557 'axes' => (Object)array()
1629 ); 1558 );
1630 } 1559 }
1631 1560
1632 - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) 1561 + if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
1633 { 1562 {
1634 - $zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array(); 1563 + $zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
1635 } 1564 }
1636 1565
1637 - array_push ($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (Object)array( 1566 + array_push ($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (Object)array(
1638 'min' => $minOrFileIndex, 1567 'min' => $minOrFileIndex,
1639 'max' => $maxOrIntervalIndex 1568 'max' => $maxOrIntervalIndex
1640 )); 1569 ));
1641 } 1570 }
1642 1571
1643 - //save zoom list  
1644 - $path = $this->getWorkingPath()."zoom.list";  
1645 - if (!is_dir($this->getWorkingPath()))  
1646 - mkdir($this->getWorkingPath(),0777);  
1647 - $file = fopen($path, 'w');  
1648 - fwrite($file, json_encode($zoomList));  
1649 - fclose($file); 1572 + $this->saveZoomList($input->interactiveId, $zoomList);
1650 } 1573 }
1651 1574
1652 - private function loadZoomList() 1575 + private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
1653 { 1576 {
1654 - $path = $this->getWorkingPath()."zoom.list";  
1655 - if (!file_exists($path))  
1656 - return NULL;  
1657 - return json_decode(file_get_contents($path));  
1658 - }  
1659 -  
1660 - private function resetZoomListForTab($tabId, $resetOnlyTimeZoom = false)  
1661 - {  
1662 - $zoomList = $this->loadZoomList();  
1663 -  
1664 - if (isset($zoomList->tabs) && isset($zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId}))  
1665 - {  
1666 - if (!$resetOnlyTimeZoom)  
1667 - unset($zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId});  
1668 - else  
1669 - $zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId}->times = array(); 1577 + if (!$resetOnlyTimeZoom) {
  1578 + $zoomList = (Object)array(
  1579 + 'times' => array(),
  1580 + 'panels' => (Object)array()
  1581 + );
1670 } 1582 }
1671 -  
1672 - $path = $this->getWorkingPath()."zoom.list";  
1673 - if (!is_dir($this->getWorkingPath()))  
1674 - mkdir($this->getWorkingPath(),0777);  
1675 - $file = fopen($path, 'w');  
1676 - fwrite($file, json_encode($zoomList));  
1677 - fclose($file); 1583 + else {
  1584 + $zoomList = $this->loadZoomList($interactiveId);
  1585 + $zoomList->times = array();
  1586 + }
  1587 +
  1588 + $this->saveZoomList($interactiveId, $zoomList);
1678 } 1589 }
1679 1590
1680 private function undoZoomInList($input) 1591 private function undoZoomInList($input)
1681 { 1592 {
1682 - $zoomList = $this->loadZoomList(); 1593 + $zoomList = $this->loadZoomList($input->interactiveId);
1683 1594
1684 $result = NULL; 1595 $result = NULL;
1685 - if (isset($zoomList->tabs) && isset($zoomList->tabs->{$input->{'tabId'}})) 1596 + if ($zoomList)
1686 { 1597 {
1687 if ($input->{'axeId'} == 'timeAxis') 1598 if ($input->{'axeId'} == 'timeAxis')
1688 { 1599 {
1689 - if (count($zoomList->tabs->{$input->{'tabId'}}->times) <= 0) 1600 + if (count($zoomList->times) <= 0)
1690 return NULL; 1601 return NULL;
1691 - $result = array_pop($zoomList->tabs->{$input->{'tabId'}}->times); 1602 + $result = array_pop($zoomList->times);
1692 } 1603 }
1693 else 1604 else
1694 { 1605 {
1695 - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}})) 1606 + if (!isset($zoomList->panels->{$input->{'panelId'}}))
1696 return NULL; 1607 return NULL;
1697 1608
1698 - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) 1609 + if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
1699 return NULL; 1610 return NULL;
1700 1611
1701 - $result = array_pop($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}); 1612 + $result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}});
1702 } 1613 }
1703 } 1614 }
1704 else 1615 else
1705 return NULL; 1616 return NULL;
1706 1617
1707 - $path = $this->getWorkingPath()."zoom.list";  
1708 - if (!is_dir($this->getWorkingPath()))  
1709 - mkdir($this->getWorkingPath(),0777);  
1710 - $file = fopen($path, 'w');  
1711 - fwrite($file, json_encode($zoomList));  
1712 - fclose($file); 1618 + $this->saveZoomList($input->interactiveId, $zoomList);
1713 1619
1714 return $result; 1620 return $result;
1715 } 1621 }
1716 1622
1717 private function unmarshallZoom($input, $plotInput, $isUndo = false) 1623 private function unmarshallZoom($input, $plotInput, $isUndo = false)
1718 { 1624 {
1719 - //Find current tab  
1720 - $crtTab = NULL;  
1721 - foreach ($plotInput->{'tabs'} as $tab)  
1722 - {  
1723 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1724 - {  
1725 - $crtTab = $tab;  
1726 - break;  
1727 - }  
1728 - }  
1729 -  
1730 - if (!$crtTab)  
1731 - throw new Exception('Cannot retrieve plot tab for navigation action.');  
1732 -  
1733 if ($input->{'axeId'} == 'timeAxis') 1625 if ($input->{'axeId'} == 'timeAxis')
1734 { 1626 {
1735 //Zoom on Time Axis 1627 //Zoom on Time Axis
1736 - if ($crtTab->{'multi-plot-linked'}) 1628 + if ($plotInput->{'timesrc'} != 'Interval')
1737 { 1629 {
1738 - //Update multi plot time definition  
1739 - if ($plotInput->{'timesrc'} != 'Interval')  
1740 - {  
1741 - $plotInput->{'timesrc'} = 'Interval';  
1742 - if (!$isUndo)  
1743 - $this->addZoomInList($input,false,  
1744 - isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'}: 0,  
1745 - isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'}: 0);  
1746 - }  
1747 - else  
1748 - {  
1749 - if (!$isUndo)  
1750 - $this->addZoomInList($input,true,$plotInput->{'startDate'},$plotInput->{'stopDate'});  
1751 - }  
1752 - $plotInput->{'startDate'} = $input->{'min'};  
1753 - $plotInput->{'stopDate'} = $input->{'max'}; 1630 + $plotInput->{'timesrc'} = 'Interval';
  1631 + if (!$isUndo)
  1632 + $this->addZoomInList($input,false,
  1633 + isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
  1634 + isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0);
1754 } 1635 }
1755 else 1636 else
1756 { 1637 {
1757 - if ($crtTab->{'timesrc'} != 'Interval')  
1758 - {  
1759 - $crtTab->{'timesrc'} = 'Interval';  
1760 - if (!$isUndo)  
1761 - $this->addZoomInList($input,false,  
1762 - isset($crtTab->{'ttFileIndex'}) ? $crtTab->{'ttFileIndex'} : 0,  
1763 - isset($crtTab->{'intIndex'}) ? $crtTab->{'intIndex'} : 0);  
1764 - }  
1765 - else  
1766 - {  
1767 - if (!$isUndo)  
1768 - $this->addZoomInList($input,true,$crtTab->{'startDate'},$crtTab->{'stopDate'});  
1769 - }  
1770 - $crtTab->{'startDate'} = $input->{'min'};  
1771 - $crtTab->{'stopDate'} = $input->{'max'}; 1638 + if (!$isUndo)
  1639 + $this->addZoomInList($input,true,$plotInput->{'startDate'},$plotInput->{'stopDate'});
1772 } 1640 }
  1641 + $plotInput->{'startDate'} = $input->{'min'};
  1642 + $plotInput->{'stopDate'} = $input->{'max'};
1773 1643
1774 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1775 $plotInput->{'force-time-zoom-reset'} = false; 1644 $plotInput->{'force-time-zoom-reset'} = false;
1776 - $this->saveIHMRequest($plotInput); 1645 + $this->saveIHMRequest($input->interactiveId, $plotInput);
1777 return $plotInput; 1646 return $plotInput;
1778 } 1647 }
1779 1648
1780 //Digital axis zoom 1649 //Digital axis zoom
1781 - foreach ($crtTab->{'panels'} as $panel) 1650 + foreach ($plotInput->{'panels'} as $panel)
1782 { 1651 {
1783 if ($input->{'panelId'} == $panel->{'id'}) 1652 if ($input->{'panelId'} == $panel->{'id'})
1784 { 1653 {
@@ -1791,8 +1660,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1791,8 +1660,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1791 $oldMax = $axis->{'axis-range-max'}; 1660 $oldMax = $axis->{'axis-range-max'};
1792 $axis->{'axis-range-min'} = $input->{'min'}; 1661 $axis->{'axis-range-min'} = $input->{'min'};
1793 $axis->{'axis-range-max'} = $input->{'max'}; 1662 $axis->{'axis-range-max'} = $input->{'max'};
1794 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1795 - $this->saveIHMRequest($plotInput); 1663 + $this->saveIHMRequest($input->interactiveId, $plotInput);
1796 //Do not save 'force-single-replot' in request file! 1664 //Do not save 'force-single-replot' in request file!
1797 $plotInput->{'force-single-replot'} = true; 1665 $plotInput->{'force-single-replot'} = true;
1798 $plotInput->{'force-time-zoom-reset'} = false; 1666 $plotInput->{'force-time-zoom-reset'} = false;
@@ -1830,30 +1698,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1830,30 +1698,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1830 1698
1831 private function unmarshallNavigation($input, $plotInput) 1699 private function unmarshallNavigation($input, $plotInput)
1832 { 1700 {
1833 - //Find current tab  
1834 - $crtTab = NULL;  
1835 - foreach ($plotInput->{'tabs'} as $tab)  
1836 - {  
1837 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1838 - {  
1839 - $crtTab = $tab;  
1840 - break;  
1841 - }  
1842 - }  
1843 -  
1844 - if (!$crtTab)  
1845 - throw new Exception('Cannot retrieve plot tab for navigation action.');  
1846 -  
1847 - if ($crtTab->{'multi-plot-linked'})  
1848 - {  
1849 - $startTime = $plotInput->{'startDate'};  
1850 - $stopTime = $plotInput->{'stopDate'};  
1851 - }  
1852 - else  
1853 - {  
1854 - $startTime = $crtTab->{'startDate'};  
1855 - $stopTime = $crtTab->{'stopDate'};  
1856 - } 1701 + $startTime = $plotInput->{'startDate'};
  1702 + $stopTime = $plotInput->{'stopDate'};
1857 1703
1858 //Compute new start / stop time 1704 //Compute new start / stop time
1859 date_default_timezone_set('UTC'); 1705 date_default_timezone_set('UTC');
@@ -1896,114 +1742,30 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1896,114 +1742,30 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1896 $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp); 1742 $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp);
1897 1743
1898 //Update request 1744 //Update request
1899 - if ($crtTab->{'multi-plot-linked'})  
1900 - {  
1901 - $plotInput->{'startDate'} = $startTime;  
1902 - $plotInput->{'stopDate'} = $stopTime;  
1903 - }  
1904 - else  
1905 - {  
1906 - $crtTab->{'startDate'} = $startTime;  
1907 - $crtTab->{'stopDate'} = $stopTime;  
1908 - } 1745 + $plotInput->{'startDate'} = $startTime;
  1746 + $plotInput->{'stopDate'} = $stopTime;
1909 1747
1910 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1911 $plotInput->{'force-time-zoom-reset'} = true; 1748 $plotInput->{'force-time-zoom-reset'} = true;
1912 - $this->saveIHMRequest($plotInput); 1749 + $this->saveIHMRequest($input->interactiveId, $plotInput);
1913 return $plotInput; 1750 return $plotInput;
1914 } 1751 }
1915 1752
1916 private function unmarshallTTGoto($input, $plotInput) 1753 private function unmarshallTTGoto($input, $plotInput)
1917 { 1754 {
1918 - //Find current tab  
1919 - $crtTab = NULL;  
1920 - foreach ($plotInput->{'tabs'} as $tab)  
1921 - {  
1922 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1923 - {  
1924 - $crtTab = $tab;  
1925 - break;  
1926 - }  
1927 - }  
1928 -  
1929 - if (!$crtTab)  
1930 - throw new Exception('Cannot retrieve plot tab for navigation action.');  
1931 -  
1932 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1933 -  
1934 - if ($crtTab->{'multi-plot-linked'})  
1935 - {  
1936 - $plotInput->{'timesrc'} = 'TimeTable';  
1937 - $plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};  
1938 - $plotInput->{'intIndex'} = $input->{'intIndex'};  
1939 - }  
1940 - else  
1941 - {  
1942 - $crtTab->{'timesrc'} = 'TimeTable';  
1943 - $crtTab->{'ttFileIndex'} = $input->{'ttFileIndex'};  
1944 - $crtTab->{'intIndex'} = $input->{'intIndex'};  
1945 - } 1755 + $plotInput->{'timesrc'} = 'TimeTable';
  1756 + $plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
  1757 + $plotInput->{'intIndex'} = $input->{'intIndex'};
1946 1758
1947 $plotInput->{'force-time-zoom-reset'} = true; 1759 $plotInput->{'force-time-zoom-reset'} = true;
1948 - $this->saveIHMRequest($plotInput);  
1949 - return $plotInput;  
1950 - }  
1951 -  
1952 - private function unmarshallSynchronize($input, $plotInput)  
1953 - {  
1954 - //Find current tab  
1955 - $crtTab = NULL;  
1956 - foreach ($plotInput->{'tabs'} as $tab)  
1957 - {  
1958 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1959 - {  
1960 - $crtTab = $tab;  
1961 - break;  
1962 - }  
1963 - }  
1964 -  
1965 - if (!$crtTab)  
1966 - throw new Exception('Cannot retrieve plot tab for synchronize action.');  
1967 -  
1968 - if ($crtTab->{'multi-plot-linked'})  
1969 - {  
1970 -  
1971 - }  
1972 - else  
1973 - {  
1974 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1975 - $crtTab->{'ttFileIndex'} = $plotInput->{'ttFileIndex'};  
1976 - $crtTab->{'intIndex'} = $plotInput->{'intIndex'};  
1977 - $crtTab->{'timesrc'} = $plotInput->{'timesrc'};  
1978 - $crtTab->{'timeTables'} = $plotInput->{'timeTables'};  
1979 - $crtTab->{'startDate'} = $plotInput->{'startDate'};  
1980 - $crtTab->{'stopDate'} = $plotInput->{'stopDate'};  
1981 - }  
1982 -  
1983 - $plotInput->{'force-time-zoom-reset'} = true;  
1984 - $this->saveIHMRequest($plotInput); 1760 + $this->saveIHMRequest($input->interactiveId, $plotInput);
1985 return $plotInput; 1761 return $plotInput;
1986 } 1762 }
1987 1763
1988 private function unmarshallInstant($input, $plotInput) 1764 private function unmarshallInstant($input, $plotInput)
1989 { 1765 {
1990 - //Find current tab  
1991 - $crtTab = NULL;  
1992 - foreach ($plotInput->{'tabs'} as $tab)  
1993 - {  
1994 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1995 - {  
1996 - $crtTab = $tab;  
1997 - break;  
1998 - }  
1999 - }  
2000 -  
2001 - if (!$crtTab)  
2002 - throw new Exception('Cannot retrieve plot tab for instant plot.');  
2003 -  
2004 //Find current panel 1766 //Find current panel
2005 $crtPanel = NULL; 1767 $crtPanel = NULL;
2006 - foreach ($crtTab->{'panels'} as $panel) 1768 + foreach ($plotInput->{'panels'} as $panel)
2007 { 1769 {
2008 if ($input->{'panelId'} == $panel->{'id'}) 1770 if ($input->{'panelId'} == $panel->{'id'})
2009 { 1771 {
@@ -2068,21 +1830,15 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -2068,21 +1830,15 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2068 "file-format" => "PNG", 1830 "file-format" => "PNG",
2069 "file-output" => "INTERACTIVE", 1831 "file-output" => "INTERACTIVE",
2070 "file-prefix" => "instant", 1832 "file-prefix" => "instant",
2071 - "last-plotted-tab"=> 1,  
2072 "timesrc" => "Interval", 1833 "timesrc" => "Interval",
2073 "startDate" => date("Y-m-dTH:i:s", $timeStamp - 3600), 1834 "startDate" => date("Y-m-dTH:i:s", $timeStamp - 3600),
2074 "stopDate" => date("Y-m-dTH:i:s", $timeStamp + 3600), 1835 "stopDate" => date("Y-m-dTH:i:s", $timeStamp + 3600),
2075 - "tabs" => array()  
2076 - );  
2077 -  
2078 - $instantTab = (Object)array(  
2079 "id" => 1, 1836 "id" => 1,
2080 - "multi-plot-linked" => true,  
2081 - "page-margins-activated" => $crtTab->{"page-margins-activated"},  
2082 - "page-margin-x" => $crtTab->{"page-margin-x"},  
2083 - "page-margin-y" => $crtTab->{"page-margin-y"},  
2084 - "page-orientation" => $crtTab->{"page-orientation"},  
2085 - "page-dimension" => $crtTab->{"page-dimension"}, 1837 + "page-margins-activated" => $plotInput->{"page-margins-activated"},
  1838 + "page-margin-x" => $plotInput->{"page-margin-x"},
  1839 + "page-margin-y" => $plotInput->{"page-margin-y"},
  1840 + "page-orientation" => $plotInput->{"page-orientation"},
  1841 + "page-dimension" => $plotInput->{"page-dimension"},
2086 "page-layout-type" => "vertical", 1842 "page-layout-type" => "vertical",
2087 "page-layout-object" => (Object)array( 1843 "page-layout-object" => (Object)array(
2088 "layout-expand" => true, 1844 "layout-expand" => true,
@@ -2131,10 +1887,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -2131,10 +1887,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2131 ); 1887 );
2132 $instantPanel->{"params"}[] = $instantParam; 1888 $instantPanel->{"params"}[] = $instantParam;
2133 1889
2134 - $instantTab->{"panels"}[] = $instantPanel;  
2135 -  
2136 - $instantPlotInput->{"tabs"}[] = $instantTab;  
2137 - 1890 + $instantPlotInput->{"panels"}[] = $instantPanel;
2138 1891
2139 return $instantPlotInput; 1892 return $instantPlotInput;
2140 } 1893 }
src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php
@@ -5,8 +5,7 @@ @@ -5,8 +5,7 @@
5 * @details 5 * @details
6 */ 6 */
7 class IHMJobsManagerClass { 7 class IHMJobsManagerClass {
8 -  
9 - protected $jobXml, $jobXmlName; 8 + protected $isWSJob = false;
10 9
11 protected $bkgRootNode = array('condition' => 'bkgSearch-treeRootNode', 10 protected $bkgRootNode = array('condition' => 'bkgSearch-treeRootNode',
12 'request' => 'bkgPlot-treeRootNode', 11 'request' => 'bkgPlot-treeRootNode',
@@ -26,27 +25,149 @@ class IHMJobsManagerClass { @@ -26,27 +25,149 @@ class IHMJobsManagerClass {
26 } 25 }
27 26
28 /* 27 /*
29 - * @brief Load jobs file and create it if needed  
30 - */  
31 - protected function init() 28 + * @brief Get path to the jobs file
  29 + */
  30 + protected function getJobsFilePath()
  31 + {
  32 + return IHMConfigClass::getUserJobsFile();
  33 + }
  34 +
  35 + /*
  36 + * @bried Send an error notification
  37 + */
  38 + protected function sendErrorNotification($message) {
  39 + // Nothing to do here
  40 + // It used to send an email with WS
  41 + }
  42 +
  43 + /*
  44 + * @brief Decode a request object file
  45 + */
  46 + public function getRequestObjectFile($id)
  47 + {
  48 + if (!file_exists($this->getRequestObjectFilePath($id)))
  49 + return NULL;
  50 + return json_decode(file_get_contents($this->getRequestObjectFilePath($id)));
  51 + }
  52 +
  53 + /*
  54 + * @brief delete a job
  55 + */
  56 + public function deleteJob($id)
  57 + {
  58 + return $this->concurrentAccessJobsFile(array($this,'deleteJobFromId'),$id);
  59 + }
  60 +
  61 + /*
  62 + * @brief get job info about a job
  63 + */
  64 + public function getJobInfo($id)
  65 + {
  66 + return $this->concurrentAccessJobsFile(array($this,'getJobInfoById'),$id);
  67 + }
  68 +
  69 + /*
  70 + * @brief Add a new job
  71 + */
  72 + public function addJob($obj, $id, $folder, $running, $start, $result, $exitcode, $exectime = 0)
  73 + {
  74 + return $this->concurrentAccessJobsFile(array($this,'addNewJob'), array(
  75 + 'obj' => $obj,
  76 + 'id' => $id,
  77 + 'folder' => $folder,
  78 + 'running' => $running,
  79 + 'start' => $start,
  80 + 'result' => $result,
  81 + 'exitcode' => $exitcode,
  82 + 'exectime' => $exectime,
  83 + ));
  84 + }
  85 +
  86 + /*
  87 + * @brief Update the status of a job
  88 + */
  89 + public function updateJobStatus($id, $running, $exitcode, $exectime = 0)
32 { 90 {
33 - $this->jobXmlName = IHMConfigClass::getUserJobsFile();  
34 - $this->jobXml = new DomDocument("1.0"); 91 + return $this->concurrentAccessJobsFile(array($this,'updateJobStatusById'), array(
  92 + 'id' => $id,
  93 + 'running' => $running,
  94 + 'exitcode' => $exitcode,
  95 + 'exectime' => $exectime,
  96 + ));
  97 + }
35 98
36 - if (!file_exists($this->jobXmlName)) 99 + /*
  100 + * @brief Get the list of jobs with a specific status
  101 + */
  102 + public function getJobsByStatus($status)
  103 + {
  104 + return $this->concurrentAccessJobsFile(array($this,'getJobsByStatusInDom'), $status);
  105 + }
  106 +
  107 + /*
  108 + * @brief Get jobs that use a specific working dir
  109 + */
  110 + public function getJobsByWorkingDir($folder)
  111 + {
  112 + return $this->concurrentAccessJobsFile(array($this,'getJobsByWorkingDirInDom'), $folder);
  113 + }
  114 +
  115 + /*
  116 + * @brief Get all jobs to clean (immediate result jobs)
  117 + */
  118 + public function getJobsToClean()
  119 + {
  120 + return $this->concurrentAccessJobsFile(array($this,'getJobsToCleanInDom'), array());
  121 + }
  122 +
  123 + /*
  124 + *
  125 + */
  126 + protected function concurrentAccessJobsFile($callback, $additionalParams)
  127 + {
  128 + $lockFile = $this->getJobsFilePath().".lockfile";
  129 +
  130 + $fp = fopen($lockFile, "w+");
  131 +
  132 + if ($fp === false) {
  133 + $this->sendErrorNotification('Cannot open jobs manager lock file');
  134 + return array('success' => false, 'message' => 'Cannot open jobs manager lock file');
  135 + }
  136 +
  137 + $res = true;
  138 +
  139 + if (flock($fp, LOCK_EX))
37 { 140 {
38 - $res = $this->createJobsFile();  
39 - if (!$res['success'])  
40 - return $res; 141 + if (!file_exists($this->getJobsFilePath())) {
  142 + $res = $this->createJobsFile();
  143 + if (!$res) {
  144 + $this->sendErrorNotification('Cannot create '.$this->getJobsFilePath());
  145 + }
  146 + }
  147 + if ($res)
  148 + {
  149 + $dom = new DOMDocument("1.0","UTF-8");
  150 + $dom->preserveWhiteSpace = false;
  151 + $dom->formatOutput = true;
  152 + $res = $dom->load($this->getJobsFilePath());
  153 + if ($res) {
  154 + $func_res = call_user_func($callback,$dom,$additionalParams);
  155 + }
  156 + else {
  157 + $this->sendErrorNotification('Cannot load '.$this->getJobsFilePath());
  158 + }
  159 + }
41 } 160 }
  161 + else
  162 + $res = FALSE;
42 163
43 - $res = $this->jobXml->load($this->jobXmlName);  
44 - if (!$res)  
45 - return array(  
46 - "success" => false,  
47 - "message" => "Cannot load jobs file"); 164 + fclose($fp);
48 165
49 - return array("success" => true); 166 + if ($res)
  167 + return $func_res;
  168 +
  169 + $this->sendErrorNotification('Error during the concurrent access of the jobs manager file');
  170 + return array('success' => false, 'message' => 'Error during the concurrent access of the jobs manager file');
50 } 171 }
51 172
52 /* 173 /*
@@ -54,36 +175,33 @@ class IHMJobsManagerClass { @@ -54,36 +175,33 @@ class IHMJobsManagerClass {
54 */ 175 */
55 protected function createJobsFile() 176 protected function createJobsFile()
56 { 177 {
57 - $rootElement = $this->jobXml->createElement('jobs');  
58 - $jobsInProgress = $this->jobXml->createElement('jobsInProgress'); 178 + $dom = new DOMDocument("1.0","UTF-8");
  179 + $dom->preserveWhiteSpace = false;
  180 + $dom->formatOutput = true;
  181 +
  182 + $rootElement = $dom->createElement('jobs');
  183 + $jobsInProgress = $dom->createElement('jobsInProgress');
59 184
60 foreach ($this->bkgRootNode as $key => $value) 185 foreach ($this->bkgRootNode as $key => $value)
61 { 186 {
62 - $element = $this->jobXml->createElement("$key"); 187 + $element = $dom->createElement("$key");
63 $element->setAttribute('xml:id',$value); 188 $element->setAttribute('xml:id',$value);
64 $jobsInProgress->appendChild($element); 189 $jobsInProgress->appendChild($element);
65 } 190 }
66 - $jobsFinished = $this->jobXml->createElement('jobsFinished'); 191 + $jobsFinished = $dom->createElement('jobsFinished');
67 192
68 foreach ($this->resRootNode as $key => $value) 193 foreach ($this->resRootNode as $key => $value)
69 { 194 {
70 - $element = $this->jobXml->createElement("$key"); 195 + $element = $dom->createElement("$key");
71 $element->setAttribute('xml:id',"$value"); 196 $element->setAttribute('xml:id',"$value");
72 $jobsFinished->appendChild($element); 197 $jobsFinished->appendChild($element);
73 } 198 }
74 199
75 $rootElement->appendChild($jobsInProgress); 200 $rootElement->appendChild($jobsInProgress);
76 $rootElement->appendChild($jobsFinished); 201 $rootElement->appendChild($jobsFinished);
77 - $this->jobXml->appendChild($rootElement);  
78 -  
79 - $res = $this->jobXml->save($this->jobXmlName); 202 + $dom->appendChild($rootElement);
80 203
81 - if (!$res)  
82 - return array(  
83 - "success" => false,  
84 - "message" => "Cannot create new jobs file");  
85 -  
86 - return array("success" => true); 204 + return $dom->save($this->getJobsFilePath());
87 } 205 }
88 206
89 /* 207 /*
@@ -105,16 +223,6 @@ class IHMJobsManagerClass { @@ -105,16 +223,6 @@ class IHMJobsManagerClass {
105 } 223 }
106 224
107 /* 225 /*
108 - * @brief Decode a request object file  
109 - */  
110 - public function getRequestObjectFile($id)  
111 - {  
112 - if (!file_exists($this->getRequestObjectFilePath($id)))  
113 - return NULL;  
114 - return json_decode(file_get_contents($this->getRequestObjectFilePath($id)));  
115 - }  
116 -  
117 - /*  
118 * @brief Delete a request object file 226 * @brief Delete a request object file
119 */ 227 */
120 protected function deleteRequestObjectFile($id) { 228 protected function deleteRequestObjectFile($id) {
@@ -137,15 +245,11 @@ class IHMJobsManagerClass { @@ -137,15 +245,11 @@ class IHMJobsManagerClass {
137 } 245 }
138 246
139 /* 247 /*
140 - * @brief delete a job 248 + * @brief delete a job from job id
141 */ 249 */
142 - public function deleteJob($id) 250 + protected function deleteJobFromId($dom, $id)
143 { 251 {
144 - $res = $this->init();  
145 - if (!$res['success'])  
146 - return $res;  
147 -  
148 - $job = $this->jobXml->getElementById($id); 252 + $job = $dom->getElementById($id);
149 253
150 //delete job 254 //delete job
151 if (!$job) 255 if (!$job)
@@ -179,7 +283,7 @@ class IHMJobsManagerClass { @@ -179,7 +283,7 @@ class IHMJobsManagerClass {
179 $this->deleteRequestObjectFile($id); 283 $this->deleteRequestObjectFile($id);
180 284
181 $job->parentNode->removeChild($job); 285 $job->parentNode->removeChild($job);
182 - $res = $this->jobXml->save($this->jobXmlName); 286 + $res = $dom->save($this->getJobsFilePath());
183 287
184 if (!$res) 288 if (!$res)
185 return array( 289 return array(
@@ -192,45 +296,24 @@ class IHMJobsManagerClass { @@ -192,45 +296,24 @@ class IHMJobsManagerClass {
192 /* 296 /*
193 * @brief get job info about a job 297 * @brief get job info about a job
194 */ 298 */
195 - public function getJobInfo($id) 299 + protected function getJobInfoById($dom, $id)
196 { 300 {
197 - $res = $this->init();  
198 - if (!$res['success'])  
199 - return $res;  
200 -  
201 - $job = $this->jobXml->getElementById($id);  
202 -  
203 - $attributes = [];  
204 - foreach( $job->attributes as $attrName => $attrNode) {  
205 - $attributes[$attrName] = $attrNode->nodeValue;  
206 - } 301 + $job = $dom->getElementById($id);
207 302
208 $format = 'unknown'; 303 $format = 'unknown';
209 $compression = 'unknown'; 304 $compression = 'unknown';
210 - if($job) 305 + if(!$job)
211 { 306 {
  307 + return array(
  308 + 'success' => false,
  309 + 'message' => "Cannot retrieve job ".$id,
  310 + );
  311 + }
  312 +
  313 + if (!$this->isWSJob) {
  314 + // Not used for a WS job
212 $name = $job->getAttribute('name'); 315 $name = $job->getAttribute('name');
213 - $status = $job->getAttribute('status');  
214 - $jobType = $job->getAttribute('jobType');  
215 $info = $job->getAttribute('info'); 316 $info = $job->getAttribute('info');
216 - $start = $job->getAttribute('start');  
217 - $stop = $job->getAttribute('stop');  
218 - $result = $job->getAttribute('result');  
219 - $folder = $job->getAttribute('folder');  
220 - $exectime = $job->getAttribute('exectime');  
221 - $request_obj = $this->getRequestObjectFile($id);  
222 - if (isset($request_obj))  
223 - {  
224 - if (isset($request_obj->format))  
225 - {  
226 - $format = strtolower($request_obj->format);  
227 - if (($format == "pdf") || ($format == "ps"))  
228 - //auto compression for plot request  
229 - $compression = ".tar.gz";  
230 - }  
231 - if (isset($request_obj->compression))  
232 - $compression = strtolower($request_obj->compression);  
233 - }  
234 $sendToSamp = $job->getAttribute('sendToSamp'); 317 $sendToSamp = $job->getAttribute('sendToSamp');
235 if (empty($sendToSamp)) { 318 if (empty($sendToSamp)) {
236 $sendToSamp = false; 319 $sendToSamp = false;
@@ -239,37 +322,57 @@ class IHMJobsManagerClass { @@ -239,37 +322,57 @@ class IHMJobsManagerClass {
239 $sendToSamp = ($sendToSamp == "true"); 322 $sendToSamp = ($sendToSamp == "true");
240 } 323 }
241 } 324 }
242 - return array( 325 + $exectime = $job->getAttribute('exectime');
  326 + $status = $job->getAttribute('status');
  327 + $jobType = $job->getAttribute('jobType');
  328 + $start = $job->getAttribute('start');
  329 + $stop = $job->getAttribute('stop');
  330 + $result = $job->getAttribute('result');
  331 + $folder = $job->getAttribute('folder');
  332 + $request_obj = $this->getRequestObjectFile($id);
  333 + if (isset($request_obj))
  334 + {
  335 + if (isset($request_obj->format))
  336 + {
  337 + $format = strtolower($request_obj->format);
  338 + if (($format == "pdf") || ($format == "ps"))
  339 + //auto compression for plot request
  340 + $compression = ".tar.gz";
  341 + }
  342 + if (isset($request_obj->compression))
  343 + $compression = strtolower($request_obj->compression);
  344 + }
  345 +
  346 + $result = array(
243 'success' => true, 347 'success' => true,
244 'id' => $id, 348 'id' => $id,
245 - 'name' => $name,  
246 'status' => $status, 349 'status' => $status,
247 - 'exectime' => $exectime,  
248 'jobType' => $jobType, 350 'jobType' => $jobType,
249 - 'info' => $info,  
250 'start' => $start, 351 'start' => $start,
251 'stop' => $stop, 352 'stop' => $stop,
252 'folder' => $folder, 353 'folder' => $folder,
253 'result' => $result, 354 'result' => $result,
254 'format' => $format, 355 'format' => $format,
255 'compression' => $compression, 356 'compression' => $compression,
256 - 'sendToSamp' => $sendToSamp, 357 + 'exectime' => $exectime,
257 ); 358 );
  359 +
  360 + if (!$this->isWSJob) {
  361 + $result['name'] = $name;
  362 + $result['info'] = $info;
  363 + $result['sendToSamp'] = $sendToSamp;
  364 + }
  365 +
  366 + return $result;
258 } 367 }
259 368
260 /* 369 /*
261 - * @brief Add a new job  
262 - */  
263 - public function addJob($obj, $id, $folder, $running, $start, $result, $exitcode, $exectime) 370 + * @brief Getjob info from request object
  371 + */
  372 + protected function getRequestInfo($obj, $start)
264 { 373 {
265 - $obj = get_object_vars($obj); // Allow access to elements where the key is in dash-separated form.  
266 - $res = $this->init();  
267 - if (!$res['success'])  
268 - return $res;  
269 -  
270 $infos = []; 374 $infos = [];
271 switch ($obj['nodeType']) { 375 switch ($obj['nodeType']) {
272 - // Data mining  
273 case 'condition': 376 case 'condition':
274 $name = 'datamining_'.time(); 377 $name = 'datamining_'.time();
275 if($obj['name'] != '') { 378 if($obj['name'] != '') {
@@ -279,7 +382,6 @@ class IHMJobsManagerClass { @@ -279,7 +382,6 @@ class IHMJobsManagerClass {
279 $infos['Start date'] = $obj['startDate']; 382 $infos['Start date'] = $obj['startDate'];
280 $infos['Stop date'] = $obj['stopDate']; 383 $infos['Stop date'] = $obj['stopDate'];
281 break; 384 break;
282 -  
283 case 'statistics': 385 case 'statistics':
284 $name = 'statistics_'.time(); 386 $name = 'statistics_'.time();
285 $infos['Name'] = $obj['name']; // TODO: name toujours égal à 'test' (?) 387 $infos['Name'] = $obj['name']; // TODO: name toujours égal à 'test' (?)
@@ -325,7 +427,6 @@ class IHMJobsManagerClass { @@ -325,7 +427,6 @@ class IHMJobsManagerClass {
325 $infos['Parameters'] = '<ul><li>' . join('</li><li>', $params) . '</li></ul>'; 427 $infos['Parameters'] = '<ul><li>' . join('</li><li>', $params) . '</li></ul>';
326 } 428 }
327 break; 429 break;
328 -  
329 case 'download': 430 case 'download':
330 $name = $obj['downloadSrc'] == '2' ? "download_fits_".time() : "download_data_".time(); 431 $name = $obj['downloadSrc'] == '2' ? "download_fits_".time() : "download_data_".time();
331 $params = []; 432 $params = [];
@@ -340,35 +441,25 @@ class IHMJobsManagerClass { @@ -340,35 +441,25 @@ class IHMJobsManagerClass {
340 $infos['Start date'] = $obj['startDate']; 441 $infos['Start date'] = $obj['startDate'];
341 $infos['Stop date'] = $obj['stopDate']; 442 $infos['Stop date'] = $obj['stopDate'];
342 break; 443 break;
343 -  
344 - // Plot  
345 case 'request': 444 case 'request':
346 $name = "request_".time(); 445 $name = "request_".time();
347 446
348 $infos['Output'] = strtolower($obj['file-format']) . ' (' . strtolower($obj['file-output']) . ')'; 447 $infos['Output'] = strtolower($obj['file-format']) . ' (' . strtolower($obj['file-output']) . ')';
349 - foreach ($obj['tabs'] as $tab) {  
350 - if($tab->id == $obj['last-plotted-tab']) {  
351 - $infos['Start date'] = $tab->startDate;  
352 - $infos['Stop date'] = $tab->stopDate;  
353 -  
354 - $strPanels = [];  
355 -  
356 - foreach ($tab->panels as $panel) {  
357 - $strParams = '';  
358 - foreach ($panel->params as $param) {  
359 - $strParams .= $param->paramid . ($param === end($panel->params) ? '' : ', ');  
360 - }  
361 - $infos['• Panel ' . $panel->id] = $strParams;  
362 - } 448 + $infos['Start date'] = $obj->startDate;
  449 + $infos['Stop date'] = $obj->stopDate;
363 450
364 - continue; 451 + foreach ($obj->panels as $panel) {
  452 + $strParams = '';
  453 + foreach ($panel->params as $param) {
  454 + $strParams .= $param->paramid . ($param === end($panel->params) ? '' : ', ');
365 } 455 }
  456 + $infos['• Panel ' . $panel->id] = $strParams;
366 } 457 }
367 break; 458 break;
368 -  
369 default: 459 default:
370 $name = "unknown_".time(); 460 $name = "unknown_".time();
371 } 461 }
  462 +
372 $infos['Started at'] = gmdate("Y-m-d H:i:s", $start); 463 $infos['Started at'] = gmdate("Y-m-d H:i:s", $start);
373 464
374 $strInfo = ''; 465 $strInfo = '';
@@ -376,84 +467,104 @@ class IHMJobsManagerClass { @@ -376,84 +467,104 @@ class IHMJobsManagerClass {
376 $strInfo .= ($key == 'Started at' ? '<hr/>' : '') . '<b>' . $key . '</b>: ' . $info . '<br/>'; 467 $strInfo .= ($key == 'Started at' ? '<hr/>' : '') . '<b>' . $key . '</b>: ' . $info . '<br/>';
377 } 468 }
378 469
379 - $newJob = $this->jobXml->createElement('job');  
380 - $newJob->setAttribute('xml:id', $id);  
381 - $newJob->setAttribute('jobType', $obj['nodeType']);  
382 - $newJob->setAttribute('name', $name);  
383 - $newJob->setAttribute('info', $strInfo);  
384 - $newJob->setAttribute('folder', $folder);  
385 - $newJob->setAttribute('result', $result);  
386 - $newJob->setAttribute('start', date('d-m-Y H:i:s', $start));  
387 - $newJob->setAttribute('exectime', $exectime);  
388 - //to know if know if it's an immediate job or not  
389 - $newJob->setAttribute('immediate', !$running); 470 + return array($name, $strInfo);
  471 + }
  472 +
  473 + /*
  474 + * @brief Get job key
  475 + */
  476 + protected function getJobKey($obj)
  477 + {
  478 + return $obj['nodeType'];
  479 + }
390 480
391 - $sendToSamp = isset($obj['sendToSamp']) ? $obj['sendToSamp'] : FALSE;  
392 - if ($sendToSamp) {  
393 - $newJob->setAttribute('sendToSamp', "true"); 481 + /*
  482 + * @brief Add a new job
  483 + */
  484 + protected function addNewJob($dom, $args)
  485 + {
  486 + $obj = get_object_vars($args['obj']); // Allow access to elements where the key is in dash-separated form.
  487 + $key = $this->getJobKey($obj);
  488 +
  489 +
  490 + $newJob = $dom->createElement('job');
  491 + $newJob->setAttribute('xml:id', $args['id']);
  492 + $newJob->setAttribute('jobType', $key);
  493 + $newJob->setAttribute('folder', $args['folder']);
  494 + $newJob->setAttribute('result', $args['result']);
  495 + $newJob->setAttribute('start', date('d-m-Y H:i:s', $args['start']));
  496 + //to know if know if it's an immediate job or not
  497 + $newJob->setAttribute('immediate', !$args['running']);
  498 + $newJob->setAttribute('exectime', $args['exectime']);
  499 + if (!$this->isWSJob) {
  500 + list($name, $strInfo) = $this->getRequestInfo($obj, $args['name']);
  501 + $newJob->setAttribute('name', $name);
  502 + $newJob->setAttribute('info', $strInfo);
  503 + $sendToSamp = isset($obj['sendToSamp']) ? $obj['sendToSamp'] : FALSE;
  504 + if ($sendToSamp) {
  505 + $newJob->setAttribute('sendToSamp', "true");
  506 + }
  507 + }
  508 + else {
  509 + $newJob->setAttribute('user', IHMConfigClass::getUserName());
  510 + $newJob->setAttribute('host', IHMConfigClass::getUserHost());
394 } 511 }
395 512
396 - $key = $obj['nodeType'];  
397 - if ($running) 513 +
  514 + if ($args['running'])
398 { 515 {
399 - $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$key]); 516 + $rootJobNode = $dom->getElementById($this->bkgRootNode[$key]);
400 if (!$rootJobNode) 517 if (!$rootJobNode)
401 { 518 {
402 - $rootJobNode = $this->jobXml->createElement("$key"); 519 + $rootJobNode = $dom->createElement("$key");
403 $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$key]); 520 $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$key]);
404 - $jobsInProgress = $this->jobXml->getElementsByTagName('jobsInProgress')->item(0); 521 + $jobsInProgress = $dom->getElementsByTagName('jobsInProgress')->item(0);
405 $jobsInProgress->appendChild($rootJobNode); 522 $jobsInProgress->appendChild($rootJobNode);
406 } 523 }
407 } 524 }
408 else 525 else
409 { 526 {
410 - $rootJobNode = $this->jobXml->getElementById($this->resRootNode[$key]); 527 + $rootJobNode = $dom->getElementById($this->resRootNode[$key]);
411 if (!$rootJobNode) 528 if (!$rootJobNode)
412 { 529 {
413 - $rootJobNode = $this->jobXml->createElement("$key"); 530 + $rootJobNode = $dom->createElement("$key");
414 $rootJobNode->setAttribute('xml:id', $this->resRootNode[$key]); 531 $rootJobNode->setAttribute('xml:id', $this->resRootNode[$key]);
415 - $jobsFinished = $this->jobXml->getElementsByTagName('jobsFinished')->item(0); 532 + $jobsFinished = $dom->getElementsByTagName('jobsFinished')->item(0);
416 $jobsFinished->appendChild($rootJobNode); 533 $jobsFinished->appendChild($rootJobNode);
417 } 534 }
418 } 535 }
419 536
420 $rootJobNode->appendChild($newJob); 537 $rootJobNode->appendChild($newJob);
421 538
422 - if (!$this->jobXml->save($this->jobXmlName)) 539 + if (!$dom->save($this->getJobsFilePath()))
423 return array("success" => false, "message" => "Cannot save job manager file"); 540 return array("success" => false, "message" => "Cannot save job manager file");
424 541
425 - $this->saveRequestObjectFile($obj, $id); 542 + $this->saveRequestObjectFile($obj, $args['id']);
426 543
427 - $this->updateJobStatus($id, $running, $exitcode, $exectime); 544 + $this->updateJobStatusById($dom, $args);
428 545
429 - return $this->getJobInfo($id); 546 + return $this->getJobInfoById($dom, $args['id']);
430 } 547 }
431 548
432 /* 549 /*
433 - * @brief Update the status of a job 550 + * @brief Update the status of a job by id
434 */ 551 */
435 - public function updateJobStatus($id, $running, $exitcode, $exectime = 0) 552 + protected function updateJobStatusById($dom, $args)
436 { 553 {
437 - $res = $this->init();  
438 - if (!$res['success'])  
439 - return $res;  
440 -  
441 - $this->lockService();  
442 -  
443 - $job = $this->jobXml->getElementById($id); 554 + $job = $dom->getElementById($args['id']);
444 555
445 if (!isset($job)) { 556 if (!isset($job)) {
446 return array("success" => false, "message" => "Cannot found job"); 557 return array("success" => false, "message" => "Cannot found job");
447 } 558 }
448 559
449 - $jobstatus = $this->getJobStatus($running,$exitcode); 560 + $jobstatus = $this->getJobStatus($args['running'], $args['exitcode']);
450 $job->setAttribute('status', $jobstatus); 561 $job->setAttribute('status', $jobstatus);
451 562
452 - $job->setAttribute('exectime', $exectime); 563 + $job->setAttribute('exectime', $args['exectime']);
453 564
454 $infos = []; 565 $infos = [];
455 566
456 - if ($running) { 567 + if ($args['running']) {
457 $job->setAttribute('stop', 'unknown'); 568 $job->setAttribute('stop', 'unknown');
458 } else if ($job->getAttribute('stop') == '' || $job->getAttribute('stop') == 'unknown') { 569 } else if ($job->getAttribute('stop') == '' || $job->getAttribute('stop') == 'unknown') {
459 $job->setAttribute('stop', date('d-m-Y H:i:s', time())); 570 $job->setAttribute('stop', date('d-m-Y H:i:s', time()));
@@ -462,31 +573,33 @@ class IHMJobsManagerClass { @@ -462,31 +573,33 @@ class IHMJobsManagerClass {
462 $interval = (new DateTime('now'))->diff($start); 573 $interval = (new DateTime('now'))->diff($start);
463 $infos['Job duration'] = $interval->format('%Hh %Im %Ss'); 574 $infos['Job duration'] = $interval->format('%Hh %Im %Ss');
464 575
465 - $resPath = glob(USERWORKINGDIR . $job->getAttribute('folder') . '/' . $job->getAttribute('result') . '*')[0]; 576 + if (!$this->isWSJob) {
  577 + $resPath = glob(USERWORKINGDIR . $job->getAttribute('folder') . '/' . $job->getAttribute('result') . '*')[0];
466 578
467 - if($job->getAttribute('jobType') == 'condition') {  
468 - $resXml = new DomDocument();  
469 - $resXml->load($resPath);  
470 - $infos['nb intervals'] = $resXml->getElementsByTagName('nbIntervals')->item(0)->nodeValue;  
471 - } 579 + if($job->getAttribute('jobType') == 'condition') {
  580 + $resXml = new DomDocument();
  581 + $resXml->load($resPath);
  582 + $infos['nb intervals'] = $resXml->getElementsByTagName('nbIntervals')->item(0)->nodeValue;
  583 + }
472 584
473 - $fileSize = filesize($resPath);  
474 - if ($fileSize < 1024) {  
475 - $strSize = number_format($fileSize, 2, '.', ' ') . 'b';  
476 - } else if($fileSize < 1024*1024) {  
477 - $strSize = number_format($fileSize/1024, 2, '.', ' ') . 'kb';  
478 - } else if($fileSize < 1024*1024*1024) {  
479 - $strSize = number_format($fileSize/(1024*1024), 2, '.', ' ') . 'mb';  
480 - } else {  
481 - $strSize = number_format($fileSize/(1024*1024*1024), 2, '.', ' ') . 'gb'; 585 + $fileSize = filesize($resPath);
  586 + if ($fileSize < 1024) {
  587 + $strSize = number_format($fileSize, 2, '.', ' ') . 'b';
  588 + } else if($fileSize < 1024*1024) {
  589 + $strSize = number_format($fileSize/1024, 2, '.', ' ') . 'kb';
  590 + } else if($fileSize < 1024*1024*1024) {
  591 + $strSize = number_format($fileSize/(1024*1024), 2, '.', ' ') . 'mb';
  592 + } else {
  593 + $strSize = number_format($fileSize/(1024*1024*1024), 2, '.', ' ') . 'gb';
  594 + }
  595 + $infos['File size'] = $strSize;
482 } 596 }
483 - $infos['File size'] = $strSize;  
484 597
485 - $this->jobXml->getElementById($this->resRootNode[$job->getAttribute('jobType')])->appendChild($job); 598 + $dom->getElementById($this->resRootNode[$job->getAttribute('jobType')])->appendChild($job);
486 } 599 }
487 600
488 - if($exitcode != 0) {  
489 - $infos['Error code'] = $exitcode; 601 + if($args['exitcode'] != 0) {
  602 + $infos['Error code'] = $args['exitcode'];
490 } 603 }
491 604
492 $strInfo = $job->getAttribute('info'); 605 $strInfo = $job->getAttribute('info');
@@ -495,30 +608,22 @@ class IHMJobsManagerClass { @@ -495,30 +608,22 @@ class IHMJobsManagerClass {
495 } 608 }
496 $job->setAttribute('info', $strInfo); 609 $job->setAttribute('info', $strInfo);
497 610
498 - $res = $this->jobXml->save($this->jobXmlName);  
499 -  
500 - $this->unlockService(); 611 + $res = $dom->save($this->getJobsFilePath());
501 612
502 if (!$res) 613 if (!$res)
503 return array( 614 return array(
504 'success' => false, 615 'success' => false,
505 'message' => "Cannot save jobs status file"); 616 'message' => "Cannot save jobs status file");
506 617
507 - return $this->getJobInfo($id); 618 + return $this->getJobInfoById($dom, $args['id']);
508 } 619 }
509 620
510 - public function lockService(){}  
511 - public function unlockService(){}  
512 /* 621 /*
513 - * @brief Get the list of jobs with a specific status 622 + * @brief Get the list of jobs with a specific status in a $dom
514 */ 623 */
515 - public function getJobsByStatus($status) 624 + protected function getJobsByStatusInDom($dom, $status)
516 { 625 {
517 - $res = $this->init();  
518 - if (!$res['success'])  
519 - return $res;  
520 -  
521 - $xp = new domxpath($this->jobXml); 626 + $xp = new domxpath($dom);
522 $jobs = $xp->query("//job[@status='".$status."']"); 627 $jobs = $xp->query("//job[@status='".$status."']");
523 628
524 $jobsId = array(); 629 $jobsId = array();
@@ -529,15 +634,11 @@ class IHMJobsManagerClass { @@ -529,15 +634,11 @@ class IHMJobsManagerClass {
529 } 634 }
530 635
531 /* 636 /*
532 - * @brief Get jobs that use a specific working dir 637 + * @brief Get jobs that use a specific working dir in a $dom
533 */ 638 */
534 - public function getJobsByWorkingDir($folder) 639 + protected function getJobsByWorkingDirInDom($dom, $folder)
535 { 640 {
536 - $res = $this->init();  
537 - if (!$res['success'])  
538 - return $res;  
539 -  
540 - $xp = new domxpath($this->jobXml); 641 + $xp = new domxpath($dom);
541 $jobs = $xp->query("//job[@folder='".$folder."']"); 642 $jobs = $xp->query("//job[@folder='".$folder."']");
542 643
543 $jobsId = array(); 644 $jobsId = array();
@@ -548,16 +649,12 @@ class IHMJobsManagerClass { @@ -548,16 +649,12 @@ class IHMJobsManagerClass {
548 } 649 }
549 650
550 /* 651 /*
551 - * @brief Get all jobs to clean (immediate result jobs) 652 + * @brief Get all jobs to clean (immediate result jobs) in a $dom
552 */ 653 */
553 - public function getJobsToClean() 654 + protected function getJobsToCleanInDom($dom)
554 { 655 {
555 - $res = $this->init();  
556 - if (!$res['success'])  
557 - return $res;  
558 -  
559 // Get immediate jobs 656 // Get immediate jobs
560 - $xp = new domxpath($this->jobXml); 657 + $xp = new domxpath($dom);
561 $jobs = $xp->query("//job[@immediate='1']"); 658 $jobs = $xp->query("//job[@immediate='1']");
562 659
563 $jobsId = array(); 660 $jobsId = array();
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -189,6 +189,7 @@ class IHMParamManagerClass @@ -189,6 +189,7 @@ class IHMParamManagerClass
189 189
190 //check templated parameter 190 //check templated parameter
191 $real_param_id = $paramId; 191 $real_param_id = $paramId;
  192 + $paramPath = "";
192 if ($this->templateParamsManager->isTemplatedParam($paramId)) { 193 if ($this->templateParamsManager->isTemplatedParam($paramId)) {
193 $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink); 194 $paramPath = $this->templateParamsManager->generateTemplatedParamFile($paramId, $templateArgs, $tableLink);
194 $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs); 195 $real_param_id = $this->templateParamsManager->getTemplatedParamId($paramId, $templateArgs);
@@ -205,7 +206,7 @@ class IHMParamManagerClass @@ -205,7 +206,7 @@ class IHMParamManagerClass
205 206
206 $this->addLinkedLocalParams($paramId, $paramsData, $templateArgs); 207 $this->addLinkedLocalParams($paramId, $paramsData, $templateArgs);
207 208
208 - return array("id" => $real_param_id, "indexes" => $indexes, "calib_infos" => $calib_infos); 209 + return array("id" => $real_param_id, "indexes" => $indexes, "calib_infos" => $calib_infos, "path" => $paramPath);
209 } 210 }
210 211
211 /* 212 /*
src/InputOutput/IHMImpl/Tools/IHMParamTemplateClass.php
@@ -114,7 +114,6 @@ class IHMParamTemplateClass @@ -114,7 +114,6 @@ class IHMParamTemplateClass
114 } 114 }
115 115
116 $exploded_args = sscanf($template_args_str , $args_format); 116 $exploded_args = sscanf($template_args_str , $args_format);
117 - error_log($exploded_args);  
118 117
119 if ($exploded_args === -1) 118 if ($exploded_args === -1)
120 return FALSE; 119 return FALSE;
src/InputOutput/IHMImpl/Tools/IHMUserWSManagerClass.php 0 → 100644
@@ -0,0 +1,192 @@ @@ -0,0 +1,192 @@
  1 +<?php
  2 +
  3 +/**
  4 + * @class IHMUserWSManagerClass
  5 + * @brief Manager for IHM user workspace
  6 + * @details
  7 + */
  8 +class IHMUserWSManagerClass
  9 +{
  10 + private static $WS_VERSION = 1;
  11 +
  12 + protected $wsInfo = null;
  13 +
  14 + public function init()
  15 + {
  16 + //check user workspace
  17 + if (IHMConfigClass::getUserName() == "" || !is_dir(IHMConfigClass::getUserPath()))
  18 + throw new Exception('Cannot find user workspace.');
  19 +
  20 + //Load info about WS
  21 + if (!$this->loadWSInfoFile())
  22 + throw new Exception('Error to load workspace info file.');
  23 +
  24 + //Update WS if need
  25 + if (!$this->update())
  26 + throw new Exception('Error during user workspace conversion.');
  27 +
  28 + return TRUE;
  29 + }
  30 +
  31 + public function update()
  32 + {
  33 + while (IHMUserWSManagerClass::$WS_VERSION > $this->wsInfo['version']) {
  34 + $updateMethod = "updateFromVersion".$this->wsInfo['version'];
  35 + if (method_exists($this,$updateMethod)) {
  36 + if (!$this->{$updateMethod}()) {
  37 + return FALSE;
  38 + }
  39 + }
  40 + $this->wsInfo['version'] += 1;
  41 + if (!$this->saveWSInfoFile()) {
  42 + return FALSE;
  43 + }
  44 + }
  45 + return TRUE;
  46 + }
  47 +
  48 + private function loadWSInfoFile()
  49 + {
  50 + if (file_exists(IHMConfigClass::getUserWSInfoFilePath())) {
  51 + $infoContent = file_get_contents(IHMConfigClass::getUserWSInfoFilePath());
  52 + if (empty($infoContent)) {
  53 + return FALSE;
  54 + }
  55 + $this->wsInfo = json_decode($infoContent, TRUE);
  56 + if (empty($this->wsInfo)) {
  57 + return FALSE;
  58 + }
  59 +
  60 + return TRUE;
  61 + }
  62 +
  63 + //Init info file
  64 + $this->wsInfo = array(
  65 + "version" => 0,
  66 + );
  67 +
  68 + return $this->saveWSInfoFile();
  69 + }
  70 +
  71 + private function saveWSInfoFile()
  72 + {
  73 + if (empty($this->wsInfo)) {
  74 + return FALSE;
  75 + }
  76 +
  77 + $json_data = json_encode($this->wsInfo);
  78 +
  79 + if ($json_data === FALSE) {
  80 + return FALSE;
  81 + }
  82 +
  83 +
  84 + return file_put_contents(IHMConfigClass::getUserWSInfoFilePath(),$json_data);
  85 + }
  86 +
  87 + private function updateFromVersion0() {
  88 + // This update split plot requests
  89 +
  90 + // Load user requests file
  91 + $req_mgr_file_path = IHMConfigClass::getUserRequestManagerFilePath();
  92 + if (!file_exists($req_mgr_file_path)) {
  93 + return TRUE;
  94 + }
  95 +
  96 + $dom = new DOMDocument();
  97 + if (!$dom->load($req_mgr_file_path)) {
  98 + return FALSE;
  99 + }
  100 +
  101 + // Retrieve all plot requests and last request id
  102 + $plot_requests = array();
  103 + $last_id = 0;
  104 + foreach ($dom->getElementsByTagName('request') as $requestNode) {
  105 + $request_id = $requestNode->getAttribute("xml:id");
  106 + $plot_requests[$request_id] = $requestNode;
  107 + sscanf($request_id, "req_%d", $crt_id);
  108 + if ($crt_id > $last_id) {
  109 + $last_id = $crt_id;
  110 + }
  111 + }
  112 +
  113 + if (empty($plot_requests)) {
  114 + //No plot requests
  115 + return TRUE;
  116 + }
  117 +
  118 + // Split requests
  119 + $split_plot = array();
  120 + foreach ($plot_requests as $id => $node) {
  121 + $req_data_path = IHMConfigClass::getStoredRequestPath() . $id;
  122 + if (!file_exists($req_data_path)) {
  123 + continue;
  124 + }
  125 + $req_data_content = file_get_contents($req_data_path);
  126 + if (!$req_data_content) {
  127 + continue;
  128 + }
  129 + $req_data_json = json_decode($req_data_content,TRUE);
  130 + if (!$req_data_json) {
  131 + continue;
  132 + }
  133 + if (array_key_exists("tabs", $req_data_json)) {
  134 + $split_plot[$id] = array();
  135 + $tab_index = 1;
  136 + foreach ($req_data_json["tabs"] as $tab) {
  137 + $new_splitted_request = array_merge(array(), $tab);
  138 + foreach (array_keys($req_data_json) as $key) {
  139 + if (in_array($key, array('tabs', 'startDate', 'stopDate', 'durationDay', 'durationHour', 'durationMin', 'durationSec'))) {
  140 + continue;
  141 + }
  142 + $new_splitted_request[$key] = $req_data_json[$key];
  143 + }
  144 + if (count($req_data_json["tabs"]) > 1) {
  145 + if (!empty($new_splitted_request['tab-name'])) {
  146 + $new_splitted_request['name'] .= ('_' . $new_splitted_request['tab-name']);
  147 + }
  148 + else {
  149 + $new_splitted_request['name'] .= ('_Plot' . $tab_index);
  150 + }
  151 + }
  152 + foreach (array("tab-name", "last-plotted-tab", "active-tab-id", "last-tab-id", "multi-plot-linked") as $key) {
  153 + unset($new_splitted_request[$key]);
  154 + }
  155 + ++$last_id;
  156 + $new_splitted_request['id'] = "req_".$last_id;
  157 + file_put_contents(IHMConfigClass::getStoredRequestPath() . $new_splitted_request['id'], json_encode($new_splitted_request));
  158 + $split_plot[$id][$new_splitted_request['id']] = $new_splitted_request['name'];
  159 + ++$tab_index;
  160 + }
  161 + }
  162 + }
  163 +
  164 + if (!empty($split_plot)) {
  165 + //Backup
  166 + $backupPath = IHMConfigClass::getMigrationBackupPath($this->wsInfo['version']);
  167 + copy($req_mgr_file_path, $backupPath.basename($req_mgr_file_path));
  168 + foreach ($split_plot as $old_key => $split) {
  169 + $req_data_path = IHMConfigClass::getStoredRequestPath() . $old_key;
  170 + copy($req_data_path, $backupPath.basename($req_data_path));
  171 + }
  172 +
  173 + //Apply split in user requests file + cleanup
  174 + foreach ($split_plot as $old_key => $split) {
  175 + $parentNode = $plot_requests[$old_key]->parentNode;
  176 + $parentNode->removeChild($plot_requests[$old_key]);
  177 + unlink(IHMConfigClass::getStoredRequestPath() . $old_key);
  178 + foreach ($split as $new_key => $new_name) {
  179 + $new_node = $dom->createElement("request");
  180 + $new_node->setAttribute("xml:id", $new_key);
  181 + $new_node->setAttribute("name", $new_name);
  182 + $parentNode->appendChild($new_node);
  183 + }
  184 + }
  185 +
  186 + $dom->save($req_mgr_file_path);
  187 + }
  188 +
  189 + return TRUE;
  190 + }
  191 +}
  192 +
src/InputOutput/WSImpl/Config/WSConfigClass.php
@@ -21,12 +21,14 @@ class WSConfigClass @@ -21,12 +21,14 @@ class WSConfigClass
21 21
22 private static $wsResultDir = "WSRESULT"; 22 private static $wsResultDir = "WSRESULT";
23 private static $jobsFile = "WSjobs.xml"; 23 private static $jobsFile = "WSjobs.xml";
24 - private static $LockFile = "LOCK";  
25 24
26 private static $WebUrl; 25 private static $WebUrl;
27 26
28 private static $dataSetInfoDir = "LocalData/DataSetInfo"; 27 private static $dataSetInfoDir = "LocalData/DataSetInfo";
29 28
  29 + private static $anonymousUserName = "impex";
  30 + private static $anonymousUserPwd = "impexfp7";
  31 +
30 public static function getUrl() 32 public static function getUrl()
31 { 33 {
32 //self::$WebUrl = "http://apus.irap.omp.eu/NEWAMDA/data/"; 34 //self::$WebUrl = "http://apus.irap.omp.eu/NEWAMDA/data/";
@@ -45,22 +47,6 @@ class WSConfigClass @@ -45,22 +47,6 @@ class WSConfigClass
45 return IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$jobsFile; 47 return IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$jobsFile;
46 } 48 }
47 49
48 - public static function lockServices()  
49 - {  
50 - touch(IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$LockFile);  
51 - }  
52 -  
53 - public static function isLockedServices()  
54 - {  
55 - return file_exists(IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$LockFile);  
56 - }  
57 -  
58 - public static function unlockServices()  
59 - {  
60 - if (file_exists(IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$LockFile))  
61 - unlink(IHMConfigClass::getDataDir().self::$wsResultDir.'/'.self::$LockFile);  
62 - }  
63 -  
64 public static function getDataSetInfoDir() 50 public static function getDataSetInfoDir()
65 { 51 {
66 return IHMConfigClass::getGenericDataPath().self::$dataSetInfoDir.'/'; 52 return IHMConfigClass::getGenericDataPath().self::$dataSetInfoDir.'/';
@@ -75,5 +61,15 @@ class WSConfigClass @@ -75,5 +61,15 @@ class WSConfigClass
75 { 61 {
76 return IHMConfigClass::getGenericDataPath()."LocalData/OrbitsAll.xml"; 62 return IHMConfigClass::getGenericDataPath()."LocalData/OrbitsAll.xml";
77 } 63 }
  64 +
  65 + public static function getAnonymousUserName()
  66 + {
  67 + return self::$anonymousUserName;
  68 + }
  69 +
  70 + public static function getAnonymousUserPwd()
  71 + {
  72 + return self::$anonymousUserPwd;
  73 + }
78 } 74 }
79 ?> 75 ?>
src/InputOutput/WSImpl/Params/DownloadImpl/WSInputOutputParamsDownloadClass.php
@@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
7 */ 7 */
8 class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass 8 class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
9 { 9 {
  10 + protected $templateParamsManager = null;
  11 +
10 /* 12 /*
11 * @brief Constructor 13 * @brief Constructor
12 */ 14 */
@@ -14,7 +16,17 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -14,7 +16,17 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
14 { 16 {
15 $this->paramManager = new IHMParamManagerClass(); 17 $this->paramManager = new IHMParamManagerClass();
16 $this->jobsManager = new WSJobsManagerClass(); 18 $this->jobsManager = new WSJobsManagerClass();
  19 + $this->templateParamsManager = new IHMParamTemplateClass();
17 } 20 }
  21 +
  22 + /*
  23 + * @brief Get Task
  24 + */
  25 + protected function getTask($input)
  26 + {
  27 + return WSInputOutputClass::getService();
  28 + }
  29 +
18 /* 30 /*
19 * @brief method to unmarshall a download request 31 * @brief method to unmarshall a download request
20 */ 32 */
@@ -31,6 +43,9 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -31,6 +43,9 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
31 $outputsNode = $requestNode->getOutputsNode(); 43 $outputsNode = $requestNode->getOutputsNode();
32 $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD); 44 $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD);
33 45
  46 + // hash is used to be sure to have a unique file name for two differents requests
  47 + $hash = "";
  48 +
34 switch (strtoupper($input->timeformat)) 49 switch (strtoupper($input->timeformat))
35 { 50 {
36 case 'ISO08601' : 51 case 'ISO08601' :
@@ -42,6 +57,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -42,6 +57,7 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
42 default : 57 default :
43 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO); 58 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO);
44 } 59 }
  60 + $hash .= $input->timeformat;
45 61
46 switch ($input->fileformat) 62 switch ($input->fileformat)
47 { 63 {
@@ -67,38 +83,46 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -67,38 +83,46 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
67 83
68 //add params to output 84 //add params to output
69 $resultFile = WSInputOutputClass::getService(); 85 $resultFile = WSInputOutputClass::getService();
  86 + $resultFile .= "_".$input->file_info;
70 $isFirst = true; 87 $isFirst = true;
  88 + $firstParam = "";
  89 +
71 90
72 foreach ($input->list as $param) 91 foreach ($input->list as $param)
73 { 92 {
74 - $paramInfo = $this->paramManager->addExistingParam($param->paramid, $this->paramsData, $param->template_args);  
75 - // $this->paramManager->applyRangesAndIndexes($this->paramsData, $param, FALSE, $paramInfo); 93 + $id = $param->paramid;
  94 + $parsedParam = $this->templateParamsManager->parseTemplatedParam($id);
  95 + $tempArgs = array();
  96 + if ($parsedParam !== FALSE) {
  97 + $id = $parsedParam['paramid'];
  98 + foreach ($parsedParam['template_args'] as $key => $val) {
  99 + $tempArgs[$key] = $val;
  100 + }
  101 + }
  102 + $paramInfo = $this->paramManager->addExistingParam($id, $this->paramsData, $tempArgs);
76 103
77 $downloadNode->addParam($paramInfo['id'],$paramInfo['indexes'],$paramInfo['calib_infos']); 104 $downloadNode->addParam($paramInfo['id'],$paramInfo['indexes'],$paramInfo['calib_infos']);
78 $paramsNode->addParam($paramInfo['id']); 105 $paramsNode->addParam($paramInfo['id']);
79 106
80 - if ( WSInputOutputClass::getService() == WSConfigClass::DATASET && $isFirst)  
81 - {  
82 - $resultFile .= "_".$this->getDatasetIdFromParamInfo($param->paramid);  
83 - $isFirst = false; 107 + if ($isFirst) {
  108 + $firstParam = $paramInfo['id'];
  109 + $isFirst = FALSE;
84 } 110 }
85 - elseif ( WSInputOutputClass::getService() != WSConfigClass::DATASET )  
86 - {  
87 - $resultFile .= "_".$paramInfo['id'];  
88 - if (!empty($paramInfo['indexes']))  
89 - foreach ($paramInfo['indexes'] as $index)  
90 - $resultFile .= "_".$index;  
91 - }  
92 -  
93 } 111 }
94 112
95 - if ($input->sampling)  
96 - { 113 + if (isset($input->sampling))
  114 + {
97 $downloadNode->setSamplingTime($input->sampling); 115 $downloadNode->setSamplingTime($input->sampling);
98 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE); 116 $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE);
99 - } 117 + $hash .= $input->sampling;
  118 + }
  119 + else if (isset($input->ref_sampling_param))
  120 + {
  121 + $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_REFPARAM);
  122 + $hash .= $input->ref_sampling_param;
  123 + }
100 else { 124 else {
101 - $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_PER_PARAMETER_PER_INTERVAL); 125 + $downloadNode->setStructure(RequestOutputDownloadStructureEnum::ONE_FILE_PER_PARAMETER_PER_INTERVAL);
102 } 126 }
103 127
104 switch ($input->compression) 128 switch ($input->compression)
@@ -114,28 +138,29 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -114,28 +138,29 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
114 $resultFilePrefix = "output-"; 138 $resultFilePrefix = "output-";
115 } 139 }
116 140
117 - $resultFile .= "_".date("Ymd\THis", strtotime($input->startDate))."_".date("Ymd\THis",strtotime($input->stopDate)); 141 + $resultFile .= '_' . md5($hash) . "_".date("Ymd\THis", strtotime($input->startDate))."_".date("Ymd\THis",strtotime($input->stopDate));
118 142
119 $this->paramsData->addWaitingResult(WSInputOutputClass::getService(), $resultFile.$extension); 143 $this->paramsData->addWaitingResult(WSInputOutputClass::getService(), $resultFile.$extension);
120 144
121 // internal kernel output 145 // internal kernel output
122 - $postProcessCmd = "mv ".$resultFilePrefix."*"; 146 + $postProcessCmd = "mv ".$resultFilePrefix.$firstParam."*[0-9]";
123 147
124 $postProcessCmd .= $extension; 148 $postProcessCmd .= $extension;
125 $postProcessCmd .= " ".WSConfigClass::getWsResultDir().$resultFile.$extension; 149 $postProcessCmd .= " ".WSConfigClass::getWsResultDir().$resultFile.$extension;
126 150
127 $this->paramsData->setPostCmd($postProcessCmd); 151 $this->paramsData->setPostCmd($postProcessCmd);
128 -  
129 - 152 +
130 $this->paramsData->setBatchEnable(WSConfigClass::$enableBatch); 153 $this->paramsData->setBatchEnable(WSConfigClass::$enableBatch);
131 154
  155 + $this->paramsData->setFromWS(true);
  156 +
132 return $this->paramsData; 157 return $this->paramsData;
133 } 158 }
134 159
135 /* 160 /*
136 * @brief Unmarshall the time definition from the WS request 161 * @brief Unmarshall the time definition from the WS request
137 */ 162 */
138 - protected function unmarshallTimeDefinition($input, $requestIndex) 163 + protected function unmarshallTimeDefinition($input, $requestIndex, $ttFileIndex = -1, $ttIntIndex = -1)
139 { 164 {
140 $requestNodes = $this->paramsData->getRequestNodes(); 165 $requestNodes = $this->paramsData->getRequestNodes();
141 $timesNode = $requestNodes[$requestIndex]->getTimesNode(); 166 $timesNode = $requestNodes[$requestIndex]->getTimesNode();
@@ -154,27 +179,18 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass @@ -154,27 +179,18 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
154 protected function addToJobsFile($data,$resultKey) 179 protected function addToJobsFile($data,$resultKey)
155 { 180 {
156 $waitingResult = $data->getWaitingResult($resultKey); 181 $waitingResult = $data->getWaitingResult($resultKey);
157 -  
158 - return $this->jobsManager->addJob( 182 +
  183 + $result = $this->jobsManager->addJob(
159 $this->input, 184 $this->input,
160 $data->getId(), 185 $data->getId(),
161 $this->getWorkingDirName(), 186 $this->getWorkingDirName(),
162 $data->getStatus() == ProcessStatusEnumClass::RUNNING, 187 $data->getStatus() == ProcessStatusEnumClass::RUNNING,
163 $data->getStart(), 188 $data->getStart(),
164 $waitingResult, 189 $waitingResult,
165 - $data->getErrorCode());  
166 - }  
167 -  
168 - protected function getDatasetIdFromParamInfo($paramId)  
169 - {  
170 - $paramInfoFilePath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml";  
171 - $dom = new DomDocument("1.0");  
172 -  
173 - $dom->load($paramInfoFilePath);  
174 -  
175 - return $dom->getElementsByTagName("dataset_id")->item(0)->nodeValue;  
176 -  
177 - 190 + $data->getErrorCode(),
  191 + $data->getExecTime());
  192 +
  193 + return $result;
178 } 194 }
179 195
180 /* 196 /*
src/InputOutput/WSImpl/Params/PlotImpl/WSInputOutputParamsPlotClass.php
@@ -14,6 +14,14 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -14,6 +14,14 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
14 $this->paramManager = new IHMParamManagerClass(); 14 $this->paramManager = new IHMParamManagerClass();
15 $this->jobsManager = new WSJobsManagerClass(); 15 $this->jobsManager = new WSJobsManagerClass();
16 } 16 }
  17 +
  18 + /*
  19 + * @brief Get Task
  20 + */
  21 + protected function getTask($input)
  22 + {
  23 + return WSInputOutputClass::getService();
  24 + }
17 25
18 /* 26 /*
19 * @brief method to unmarshall a plot request 27 * @brief method to unmarshall a plot request
@@ -21,18 +29,14 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -21,18 +29,14 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
21 protected function unmarshallRequest($input) 29 protected function unmarshallRequest($input)
22 { 30 {
23 //Request 31 //Request
24 - $requestIndexInParamData = 0;  
25 - $tabRequestIndex = 1;  
26 -  
27 $postProcessCmd = ""; 32 $postProcessCmd = "";
28 33
29 $requestNode = $this->paramsData->addRequestNode(); 34 $requestNode = $this->paramsData->addRequestNode();
30 - $requestNode->setRealIndex($tabRequestIndex);  
31 $outputsNode = $requestNode->getOutputsNode(); 35 $outputsNode = $requestNode->getOutputsNode();
32 $paramsNode = $requestNode->getParamsNode(); 36 $paramsNode = $requestNode->getParamsNode();
33 37
34 //unmarshall time definition 38 //unmarshall time definition
35 - $this->unmarshallTimeDefinition($input, $tabRequestIndex-1, $requestIndexInParamData); 39 + $this->unmarshallTimeDefinition($input, 0);
36 40
37 $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); 41 $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
38 $plotOutputNode->setWriteContextFile("false"); 42 $plotOutputNode->setWriteContextFile("false");
@@ -112,6 +116,8 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -112,6 +116,8 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
112 116
113 $this->paramsData->setBatchEnable(true); 117 $this->paramsData->setBatchEnable(true);
114 $this->paramsData->setPostCmd($postProcessCmd); 118 $this->paramsData->setPostCmd($postProcessCmd);
  119 +
  120 + $this->paramsData->setFromWS(true);
115 121
116 return $this->paramsData; 122 return $this->paramsData;
117 } 123 }
@@ -170,7 +176,8 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -170,7 +176,8 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
170 $data->getStatus() == ProcessStatusEnumClass::RUNNING, 176 $data->getStatus() == ProcessStatusEnumClass::RUNNING,
171 $data->getStart(), 177 $data->getStart(),
172 $waitingResult, 178 $waitingResult,
173 - $data->getErrorCode()); 179 + $data->getErrorCode(),
  180 + $data->getExecTime());
174 } 181 }
175 182
176 /* 183 /*
src/InputOutput/WSImpl/Tools/WSJobsManagerClass.php
@@ -23,211 +23,25 @@ class WSJobsManagerClass extends IHMJobsManagerClass { @@ -23,211 +23,25 @@ class WSJobsManagerClass extends IHMJobsManagerClass {
23 */ 23 */
24 function __construct() 24 function __construct()
25 { 25 {
  26 + $this->isWSJob = TRUE;
26 } 27 }
27 28
28 - /*  
29 - * @brief Load jobs file and create it if needed  
30 - */  
31 - protected function init()  
32 - {  
33 - $this->jobXmlName = WSConfigClass::getWsJobsFile();  
34 - $this->jobXml = new DomDocument("1.0");  
35 -  
36 - if (!file_exists($this->jobXmlName))  
37 - {  
38 - $res = $this->createJobsFile();  
39 - if (!$res['success']) {  
40 - error_log("WebServices Error : Cannot create WSjobs.xml", 1, email);  
41 - return $res;  
42 - }  
43 - }  
44 -  
45 - while (WSConfigClass::isLockedServices())  
46 - sleep(1);  
47 -  
48 - $res = $this->jobXml->load($this->jobXmlName);  
49 - if (!$res) {  
50 - error_log("WebServices Error : Cannot load WSjobs.xml", 1, email);  
51 - return array(  
52 - "success" => false,  
53 - "message" => "Cannot load jobs file");  
54 - }  
55 -  
56 - return array("success" => true);  
57 - }  
58 -  
59 - /*  
60 - * @brief get job info about a job  
61 - */  
62 - public function getJobInfo($id)  
63 - {  
64 - $res = $this->init();  
65 - if (!$res['success'])  
66 - return $res;  
67 -  
68 - $job = $this->jobXml->getElementById($id);  
69 - $format = 'unknown';  
70 - $compression = 'unknown';  
71 - if($job)  
72 - {  
73 - // $name = $job->getAttribute('name');  
74 - $status = $job->getAttribute('status');  
75 - $jobType = $job->getAttribute('jobType');  
76 - // $info = $job->getAttribute('info');  
77 - $start = $job->getAttribute('start');  
78 - $stop = $job->getAttribute('stop');  
79 - $result = $job->getAttribute('result');  
80 - $folder = $job->getAttribute('folder');  
81 - $request_obj = $this->getRequestObjectFile($id);  
82 - if (isset($request_obj))  
83 - {  
84 - if (isset($request_obj->fileformat))  
85 - {  
86 - $format = strtolower($request_obj->format);  
87 - if (($format == "pdf") || ($format == "ps"))  
88 - //auto compression for plot request  
89 - $compression = ".tar.gz";  
90 -  
91 - // if ($format == "ascii") $format = 'txt';  
92 - }  
93 - if (isset($request_obj->compression))  
94 - $compression = strtolower($request_obj->compression);  
95 - }  
96 - }  
97 - return array(  
98 - 'success' => true,  
99 - 'id' => $id,  
100 - // 'name' => $name,  
101 - 'status' => $status,  
102 - 'jobType' => $jobType,  
103 - // 'info' => $info,  
104 - 'start' => $start,  
105 - 'stop' => $stop,  
106 - 'folder' => $folder,  
107 - 'result' => $result,  
108 - 'format' => $format,  
109 - 'compression' => $compression  
110 - );  
111 - }  
112 -  
113 - public function lockService(){  
114 - if (!WSConfigClass::isLockedServices())  
115 - WSConfigClass::lockServices();  
116 - }  
117 -  
118 - public function unlockService(){  
119 - if (WSConfigClass::isLockedServices())  
120 - WSConfigClass::unlockServices();  
121 - }  
122 - /*  
123 - * @brief Add a new job  
124 - */  
125 - public function addJob($obj, $id, $folder,  
126 - $running, $start, $result, $exitcode)  
127 - {  
128 - $res = $this->init();  
129 -  
130 - if (!$res['success'])  
131 - return $res;  
132 -  
133 - $this->lockService();  
134 -  
135 - $key = WSInputOutputClass::getService();  
136 -  
137 - $newJob = $this->jobXml->createElement('job');  
138 -  
139 - $newJob->setAttribute('xml:id', $id);  
140 - $newJob->setAttribute('jobType', $key);  
141 -  
142 - $newJob->setAttribute('result', $result);  
143 - $newJob->setAttribute('folder', $folder);  
144 - $newJob->setAttribute('start', date('d-m-Y H:i:s', $start));  
145 - $newJob->setAttribute('user', IHMConfigClass::getUserName());  
146 - $newJob->setAttribute('host', IHMConfigClass::getUserHost()); 29 + protected function getJobsFilePath()
  30 + {
  31 + return WSConfigClass::getWsJobsFile();
  32 + }
147 33
148 - if ($running)  
149 - {  
150 - $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$key]);  
151 - if (!$rootJobNode)  
152 - {  
153 - $rootJobNode = $this->jobXml->createElement("$key");  
154 - $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$key]);  
155 - $jobsInProgress = $this->jobXml->getElementsByTagName('jobsInProgress')->item(0);  
156 - $jobsInProgress->appendChild($rootJobNode);  
157 - }  
158 - }  
159 - else  
160 - {  
161 - $rootJobNode = $this->jobXml->getElementById($this->resRootNode[$key]);  
162 - if (!$rootJobNode)  
163 - {  
164 - $rootJobNode = $this->jobXml->createElement("$key");  
165 - $rootJobNode->setAttribute('xml:id', $this->resRootNode[$key]);  
166 - $jobsFinished = $this->jobXml->getElementsByTagName('jobsFinished')->item(0);  
167 - $jobsFinished->appendChild($rootJobNode);  
168 - }  
169 - }  
170 -  
171 - $rootJobNode->appendChild($newJob);  
172 -  
173 - if (!$this->jobXml->save($this->jobXmlName)) {  
174 - $this->unlockService();  
175 - return array("success" => false, "message" => "Cannot save job manager file");  
176 - }  
177 - $this->unlockService();  
178 - $this->saveRequestObjectFile($obj, $id);  
179 -  
180 - $res = $this->updateJobStatus($id, $running, $exitcode);  
181 -  
182 - return $res;  
183 - 34 + protected function sendErrorNotification($message) {
  35 + error_log("WebServices Error : ".$message);
  36 + error_log("WebServices Error : ".$message, email);
184 } 37 }
185 38
186 -  
187 /* 39 /*
188 - * @brief delete a job  
189 - */  
190 - public function deleteJob($id) 40 + * @brief Get job key
  41 + */
  42 + protected function getJobKey($obj)
191 { 43 {
192 - $res = $this->init();  
193 - if (!$res['success'])  
194 - return $res;  
195 -  
196 - $job = $this->jobXml->getElementById($id);  
197 -  
198 - //delete job  
199 - if (!$job)  
200 - return array('success' => false, 'message' => "Job not reachable");  
201 -  
202 - $folder = $job->getAttribute('folder');  
203 -  
204 - //be sure that it's an AMDA working dir before deletion...  
205 - $fullFolderPath = IHMConfigClass::getRequestPath().$folder.'/';  
206 -  
207 - if ((isset($folder)) &&  
208 - ($folder != "") &&  
209 - is_dir($fullFolderPath) &&  
210 - (preg_match("/DD[0-9A-Za-z]*_/",$folder) ||  
211 - preg_match("/Plot[0-9]*_/",$folder)))  
212 - {  
213 - foreach (glob($fullFolderPath.'*') as $filename)  
214 - {  
215 - if (is_dir($filename) && (basename($filename) == 'params'))  
216 - {  
217 - //recursive deletion only for "params" dir (a full recursive deletion is probably too dangerous...)  
218 - foreach (glob($filename.'/*') as $paramname)  
219 - unlink($paramname);  
220 - rmdir($filename);  
221 - }  
222 - else  
223 - unlink($filename);  
224 - }  
225 - rmdir($fullFolderPath);  
226 - }  
227 -  
228 - $this->deleteRequestObjectFile($id);  
229 -  
230 - return array('success' => true, 'id' => $id); 44 + return WSInputOutputClass::getService();
231 } 45 }
232 46
233 public function getResultFromProcessId($id) 47 public function getResultFromProcessId($id)
src/Request/Config/KernelConfigClass.php
@@ -223,6 +223,8 @@ class KernelConfigClass @@ -223,6 +223,8 @@ class KernelConfigClass
223 $appProperties["app.process.DYNAMIC_LOADING"] = "false"; 223 $appProperties["app.process.DYNAMIC_LOADING"] = "false";
224 $appProperties["app.process.plugins.xml"] = KERNEL_CONFIG_DIR.'/plugins.xml'; 224 $appProperties["app.process.plugins.xml"] = KERNEL_CONFIG_DIR.'/plugins.xml';
225 225
  226 + $appProperties["app.process.plugins.xsd"] = AMDA_KERNEL_DIR.'/config/xsd/parser/plugins.xsd';
  227 +
226 $appProperties["app.plot.configfile"] = KERNEL_CONFIG_DIR.'/'.self::$plotConfigFile; 228 $appProperties["app.plot.configfile"] = KERNEL_CONFIG_DIR.'/'.self::$plotConfigFile;
227 229
228 $appProperties["app.param.gapthreshold"] = self::$defaultGapThreshold; 230 $appProperties["app.param.gapthreshold"] = self::$defaultGapThreshold;
src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php
@@ -82,8 +82,6 @@ define (&quot;REQUEST_NAME&quot;, &quot;request&quot;); @@ -82,8 +82,6 @@ define (&quot;REQUEST_NAME&quot;, &quot;request&quot;);
82 */ 82 */
83 class RequestNodeClass extends NodeClass 83 class RequestNodeClass extends NodeClass
84 { 84 {
85 - private $realIndex = 0;  
86 -  
87 public function __construct() 85 public function __construct()
88 { 86 {
89 parent::__construct(REQUEST_NAME); 87 parent::__construct(REQUEST_NAME);
@@ -108,16 +106,6 @@ class RequestNodeClass extends NodeClass @@ -108,16 +106,6 @@ class RequestNodeClass extends NodeClass
108 return $this->getFirstChildByName(REQUESTOUTPUTS_NAME); 106 return $this->getFirstChildByName(REQUESTOUTPUTS_NAME);
109 } 107 }
110 108
111 - public function setRealIndex($index)  
112 - {  
113 - $this->realIndex = $index;  
114 - }  
115 -  
116 - public function getRealIndex()  
117 - {  
118 - return $this->realIndex;  
119 - }  
120 -  
121 public function loadFromNode($xmlNode) 109 public function loadFromNode($xmlNode)
122 { 110 {
123 $paramsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTPARAMS_NAME); 111 $paramsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTPARAMS_NAME);
@@ -135,4 +123,4 @@ class RequestNodeClass extends NodeClass @@ -135,4 +123,4 @@ class RequestNodeClass extends NodeClass
135 } 123 }
136 } 124 }
137 125
138 -?>  
139 \ No newline at end of file 126 \ No newline at end of file
  127 +?>
src/Request/ParamsRequestImpl/ParamsRequestClass.php
@@ -27,7 +27,7 @@ class ParamsRequestClass extends ProcessRequestClass @@ -27,7 +27,7 @@ class ParamsRequestClass extends ProcessRequestClass
27 { 27 {
28 if ($cmd != "") 28 if ($cmd != "")
29 $cmd .= " && "; 29 $cmd .= " && ";
30 - $cmd .= KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath($requestNode->getRealIndex()); 30 + $cmd .= KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath();
31 } 31 }
32 $this->requestData->setCmd($cmd); 32 $this->requestData->setCmd($cmd);
33 break; 33 break;
@@ -72,15 +72,15 @@ class ParamsRequestClass extends ProcessRequestClass @@ -72,15 +72,15 @@ class ParamsRequestClass extends ProcessRequestClass
72 72
73 if (!$xmlNode = $requestNode->toXMLNode($doc)) 73 if (!$xmlNode = $requestNode->toXMLNode($doc))
74 { 74 {
75 - $this->requestData->setLastErrorMessage('Cannot create params request XML file for request '.$requestNode->getRealIndex()); 75 + $this->requestData->setLastErrorMessage('Cannot create params request XML file for request');
76 return false; 76 return false;
77 } 77 }
78 78
79 $doc->appendChild($xmlNode); 79 $doc->appendChild($xmlNode);
80 80
81 - if (!$doc->save($this->getRequestFilePath($requestNode->getRealIndex()))) 81 + if (!$doc->save($this->getRequestFilePath()))
82 { 82 {
83 - $this->requestData->setLastErrorMessage('Cannot save params request XML file for request '.$requestNode->getRealIndex()); 83 + $this->requestData->setLastErrorMessage('Cannot save params request XML file for request');
84 return false; 84 return false;
85 } 85 }
86 86
@@ -96,7 +96,7 @@ class ParamsRequestClass extends ProcessRequestClass @@ -96,7 +96,7 @@ class ParamsRequestClass extends ProcessRequestClass
96 //} 96 //}
97 //libxml_clear_errors(); 97 //libxml_clear_errors();
98 98
99 - $this->requestData->setLastErrorMessage('Params request XML file not valid for request '.$requestNode->getRealIndex()/*.' ('.$error_msg.')'*/); 99 + $this->requestData->setLastErrorMessage('Params request XML file not valid for request'/*.' ('.$error_msg.')'*/);
100 return false; 100 return false;
101 } 101 }
102 //libxml_use_internal_errors(false); 102 //libxml_use_internal_errors(false);
@@ -243,9 +243,9 @@ class ParamsRequestClass extends ProcessRequestClass @@ -243,9 +243,9 @@ class ParamsRequestClass extends ProcessRequestClass
243 /* 243 /*
244 * @brief Get the request file path for AMDA_Kernel 244 * @brief Get the request file path for AMDA_Kernel
245 */ 245 */
246 - private function getRequestFilePath($requestIndex) 246 + private function getRequestFilePath()
247 { 247 {
248 - return $this->requestData->getWorkingPath()."request_".$requestIndex.".xml"; 248 + return $this->requestData->getWorkingPath()."request_".$this->requestData->getRequestIndex().".xml";
249 } 249 }
250 } 250 }
251 ?> 251 ?>
src/Request/ParamsRequestImpl/ParamsRequestDataClass.php
@@ -32,6 +32,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass @@ -32,6 +32,7 @@ class ParamsRequestDataClass extends ProcessRequestDataClass
32 private $paramId = ""; 32 private $paramId = "";
33 private $datasetId = array(); 33 private $datasetId = array();
34 private $task = ""; 34 private $task = "";
  35 + private $requestIndex = 0;
35 36
36 function __construct() 37 function __construct()
37 { 38 {
@@ -77,6 +78,16 @@ class ParamsRequestDataClass extends ProcessRequestDataClass @@ -77,6 +78,16 @@ class ParamsRequestDataClass extends ProcessRequestDataClass
77 { 78 {
78 $this->task = $task; 79 $this->task = $task;
79 } 80 }
  81 +
  82 + public function getRequestIndex()
  83 + {
  84 + return $this->requestIndex;
  85 + }
  86 +
  87 + public function setRequestIndex($requestIndex)
  88 + {
  89 + $this->requestIndex = $requestIndex;
  90 + }
80 91
81 public function addRequestNode() 92 public function addRequestNode()
82 { 93 {
src/Request/ProcessRequestImpl/Process/ProcessClass.php
@@ -19,16 +19,18 @@ class ProcessClass @@ -19,16 +19,18 @@ class ProcessClass
19 private $pID; 19 private $pID;
20 private $runningPath; 20 private $runningPath;
21 private $runningStart; 21 private $runningStart;
  22 + private $fromWS;
22 23
23 /* 24 /*
24 * @brief Constructor 25 * @brief Constructor
25 */ 26 */
26 - function __construct($command, $postProcessCmd = "", $getErrorMsgCmd = "") 27 + function __construct($command, $postProcessCmd = "", $getErrorMsgCmd = "", $fromWS = FALSE)
27 { 28 {
28 $this->command = $command; 29 $this->command = $command;
29 $this->postProcessCmd = $postProcessCmd; 30 $this->postProcessCmd = $postProcessCmd;
30 $this->getErrorMsgCmd = $getErrorMsgCmd; 31 $this->getErrorMsgCmd = $getErrorMsgCmd;
31 $this->pID = 0; 32 $this->pID = 0;
  33 + $this->fromWS = $fromWS;
32 } 34 }
33 35
34 /* 36 /*
@@ -187,6 +189,14 @@ class ProcessClass @@ -187,6 +189,14 @@ class ProcessClass
187 } 189 }
188 190
189 /* 191 /*
  192 + * @brief To know if a process is running from WebService
  193 + */
  194 + public function getFromWS()
  195 + {
  196 + return $this->fromWS;
  197 + }
  198 +
  199 + /*
190 * @brief Run the process 200 * @brief Run the process
191 */ 201 */
192 public function run($runningPath, $envArray) 202 public function run($runningPath, $envArray)
src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php
@@ -19,9 +19,9 @@ class ProcessManagerClass @@ -19,9 +19,9 @@ class ProcessManagerClass
19 /* 19 /*
20 * @brief Run a process 20 * @brief Run a process
21 */ 21 */
22 - public function runProcess($cmd, $runningPath, $envArray, $postProcessCmd, $getErrorMsgCmd, $batchEnabled) 22 + public function runProcess($cmd, $runningPath, $envArray, $postProcessCmd, $getErrorMsgCmd, $batchEnabled, $fromWS = FALSE)
23 { 23 {
24 - $process = new ProcessClass($cmd, $postProcessCmd, $getErrorMsgCmd); 24 + $process = new ProcessClass($cmd, $postProcessCmd, $getErrorMsgCmd, $fromWS);
25 25
26 if (!$process->run($runningPath, $envArray)) 26 if (!$process->run($runningPath, $envArray))
27 return array("success" => false, "message" => "Cannot run the process"); 27 return array("success" => false, "message" => "Cannot run the process");
@@ -168,6 +168,7 @@ class ProcessManagerClass @@ -168,6 +168,7 @@ class ProcessManagerClass
168 $this->updateProcessStatusToNode($dom,$processNode,"runningstart",$process->getRunningStart()); 168 $this->updateProcessStatusToNode($dom,$processNode,"runningstart",$process->getRunningStart());
169 $this->updateProcessStatusToNode($dom,$processNode,"isrunning",$process->isRunning() ? "true" : "false"); 169 $this->updateProcessStatusToNode($dom,$processNode,"isrunning",$process->isRunning() ? "true" : "false");
170 $this->updateProcessStatusToNode($dom,$processNode,"lastupdate",time()); 170 $this->updateProcessStatusToNode($dom,$processNode,"lastupdate",time());
  171 + $this->updateProcessStatusToNode($dom,$processNode,"fromws", $process->getFromWS() ? "true" : "false");
171 } 172 }
172 173
173 /* 174 /*
@@ -191,7 +192,8 @@ class ProcessManagerClass @@ -191,7 +192,8 @@ class ProcessManagerClass
191 "runningstart" => $this->getNodeValueFromNode($processNode, "runningstart"), 192 "runningstart" => $this->getNodeValueFromNode($processNode, "runningstart"),
192 "isrunning" => ($this->getNodeValueFromNode($processNode, "isrunning") == "true"), 193 "isrunning" => ($this->getNodeValueFromNode($processNode, "isrunning") == "true"),
193 "iskilled" => ($this->getNodeValueFromNode($processNode, "iskilled") == "true"), 194 "iskilled" => ($this->getNodeValueFromNode($processNode, "iskilled") == "true"),
194 - "lastupdate" => $this->getNodeValueFromNode($processNode, "lastupdate") 195 + "lastupdate" => $this->getNodeValueFromNode($processNode, "lastupdate"),
  196 + "fromws" => ($this->getNodeValueFromNode($processNode, "fromws") == "true"),
195 ); 197 );
196 } 198 }
197 199
src/Request/ProcessRequestImpl/ProcessRequestClass.php
@@ -96,7 +96,7 @@ class ProcessRequestClass extends RequestAbstractClass @@ -96,7 +96,7 @@ class ProcessRequestClass extends RequestAbstractClass
96 $this->requestData->setErrorMsg($processInfo['errormsg']); 96 $this->requestData->setErrorMsg($processInfo['errormsg']);
97 } 97 }
98 $this->requestData->setExecTime($processInfo['exectime']); 98 $this->requestData->setExecTime($processInfo['exectime']);
99 - $processMgr->deleteProcess($processInfo['id'], $result['success']); 99 + $processMgr->deleteProcess($processInfo['id']);
100 } 100 }
101 101
102 $this->requestData->setStart($processInfo['runningstart']); 102 $this->requestData->setStart($processInfo['runningstart']);
@@ -127,7 +127,8 @@ class ProcessRequestClass extends RequestAbstractClass @@ -127,7 +127,8 @@ class ProcessRequestClass extends RequestAbstractClass
127 $this->requestData->getEnvVars(), 127 $this->requestData->getEnvVars(),
128 $this->requestData->getPostCmd(), 128 $this->requestData->getPostCmd(),
129 $this->requestData->getGetErrorMsgCmd(), 129 $this->requestData->getGetErrorMsgCmd(),
130 - $this->requestData->getBatchEnable()); 130 + $this->requestData->getBatchEnable(),
  131 + $this->requestData->getFromWS());
131 if ($result['success']) { 132 if ($result['success']) {
132 $return_code = TRUE; 133 $return_code = TRUE;
133 $this->updateProcess($result['result'], $processMgr); 134 $this->updateProcess($result['result'], $processMgr);
src/Request/ProcessRequestImpl/ProcessRequestDataClass.php
@@ -49,7 +49,8 @@ class ProcessRequestDataClass extends RequestDataClass @@ -49,7 +49,8 @@ class ProcessRequestDataClass extends RequestDataClass
49 private $errorMsg = ""; 49 private $errorMsg = "";
50 private $execTime = 0; 50 private $execTime = 0;
51 private $start = 0; 51 private $start = 0;
52 - private $runningPath = ""; 52 + private $runningPath = "";
  53 + private $fromWS = false;
53 54
54 public function getManagerFilePath() 55 public function getManagerFilePath()
55 { 56 {
@@ -200,6 +201,16 @@ class ProcessRequestDataClass extends RequestDataClass @@ -200,6 +201,16 @@ class ProcessRequestDataClass extends RequestDataClass
200 { 201 {
201 $this->execTime = $execTime; 202 $this->execTime = $execTime;
202 } 203 }
  204 +
  205 + public function getFromWS()
  206 + {
  207 + return $this->fromWS;
  208 + }
  209 +
  210 + public function setFromWS($fromWS)
  211 + {
  212 + $this->fromWS = $fromWS;
  213 + }
203 } 214 }
204 215
205 ?> 216 ?>
src/Request/UserRequestClass.php 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +<?php
  2 +/**
  3 + * @class UserRequestClass
  4 + * @brief Implementation of a RequestAbstractClass for a user request
  5 + * @details
  6 + */
  7 +class UserRequestClass extends RequestAbstractClass
  8 +{
  9 + /*
  10 + * @brief Init a user request
  11 + */
  12 + public function init()
  13 + {
  14 + //For the moment, nothing to do
  15 + return TRUE;
  16 + }
  17 +
  18 + /*
  19 + * @brief Run a user request
  20 + */
  21 + public function run()
  22 + {
  23 + //For the moment, nothing to do
  24 + return TRUE;
  25 + }
  26 +}
  27 +?>
src/RequestManagerClass.php
@@ -82,6 +82,8 @@ Class RequestManagerClass @@ -82,6 +82,8 @@ Class RequestManagerClass
82 return new TTRequestClass($user, $userHost); 82 return new TTRequestClass($user, $userHost);
83 case FunctionTypeEnumClass::PARAMINFO : 83 case FunctionTypeEnumClass::PARAMINFO :
84 return new ParamInfoRequestClass($user, $userHost); 84 return new ParamInfoRequestClass($user, $userHost);
  85 + case FunctionTypeEnumClass::USERWSINIT :
  86 + return new UserRequestClass($user, $userHost);
85 default : 87 default :
86 throw new Exception('Request '.$function.' not implemented.'); 88 throw new Exception('Request '.$function.' not implemented.');
87 } 89 }