Commit 5581ea4125c5636d6938be5accd36e56f2d708b9

Authored by Benjamin Renard
1 parent 0c0b5ee3

First implementation to save statistics requests

src/InputOutput/IHMImpl/IHMInputOutputClass.php
@@ -55,7 +55,7 @@ class IHMInputOutputClass implements InputOutputInterface @@ -55,7 +55,7 @@ class IHMInputOutputClass implements InputOutputInterface
55 //set working dir for interactive plot 55 //set working dir for interactive plot
56 $requestId = "Plot"; 56 $requestId = "Plot";
57 break; 57 break;
58 - case 'statistics' : 58 + case 'statistic' :
59 //catalog generation 59 //catalog generation
60 $this->inputOutput = new IHMInputOutputParamsStatisticsClass(); 60 $this->inputOutput = new IHMInputOutputParamsStatisticsClass();
61 break; 61 break;
src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php
@@ -10,12 +10,12 @@ class IHMJobsManagerClass { @@ -10,12 +10,12 @@ class IHMJobsManagerClass {
10 protected $bkgRootNode = array('condition' => 'bkgSearch-treeRootNode', 10 protected $bkgRootNode = array('condition' => 'bkgSearch-treeRootNode',
11 'request' => 'bkgPlot-treeRootNode', 11 'request' => 'bkgPlot-treeRootNode',
12 'download' => 'bkgDown-treeRootNode', 12 'download' => 'bkgDown-treeRootNode',
13 - 'statistics' => 'bkgStatistics-treeRootNode'); 13 + 'statistic' => 'bkgStatistics-treeRootNode');
14 14
15 protected $resRootNode = array('condition' => 'resSearch-treeRootNode', 15 protected $resRootNode = array('condition' => 'resSearch-treeRootNode',
16 'request' => 'resPlot-treeRootNode', 16 'request' => 'resPlot-treeRootNode',
17 'download' => 'resDown-treeRootNode', 17 'download' => 'resDown-treeRootNode',
18 - 'statistics' => 'resStatistics-treeRootNode'); 18 + 'statistic' => 'resStatistics-treeRootNode');
19 19
20 /* 20 /*
21 * @brief Constructor 21 * @brief Constructor
@@ -382,11 +382,11 @@ class IHMJobsManagerClass { @@ -382,11 +382,11 @@ class IHMJobsManagerClass {
382 $infos['Start date'] = $obj['startDate']; 382 $infos['Start date'] = $obj['startDate'];
383 $infos['Stop date'] = $obj['stopDate']; 383 $infos['Stop date'] = $obj['stopDate'];
384 break; 384 break;
385 - case 'statistics': 385 + case 'statistic':
386 $name = 'statistics_'.time(); 386 $name = 'statistics_'.time();
387 - $infos['Name'] = $obj['name']; // TODO: name toujours égal à 'test' (?)  
388 -  
389 - // TODO : lire data/user/TT/tt_0.xml -> trouver ttname + nbIntervals 387 + if($obj['name'] != '') {
  388 + $infos['Name'] = $obj['name'];
  389 + }
390 390
391 if(array_key_exists('timeTables', $obj)) { 391 if(array_key_exists('timeTables', $obj)) {
392 $ttXml = new DomDocument(); 392 $ttXml = new DomDocument();
src/InputOutput/IHMImpl/Tools/IHMUserWSManagerClass.php
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 */ 7 */
8 class IHMUserWSManagerClass 8 class IHMUserWSManagerClass
9 { 9 {
10 - private static $WS_VERSION = 2; 10 + private static $WS_VERSION = 3;
11 11
12 protected $wsInfo = null; 12 protected $wsInfo = null;
13 13
@@ -84,6 +84,35 @@ class IHMUserWSManagerClass @@ -84,6 +84,35 @@ class IHMUserWSManagerClass
84 return file_put_contents(IHMConfigClass::getUserWSInfoFilePath(),$json_data); 84 return file_put_contents(IHMConfigClass::getUserWSInfoFilePath(),$json_data);
85 } 85 }
86 86
  87 + private function updateFromVersion2() {
  88 + // Update WS for save statistic 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 + $statisticNodeTag = 'statisticList';
  102 + $statisticNodes = $dom->documentElement->getElementsByTagName($statisticNodeTag);
  103 + // Id statistic root node already exists, nothing to do
  104 + if ($statisticNodes->length > 0) {
  105 + return TRUE;
  106 + }
  107 +
  108 + // Create statistic root node
  109 + $statisticNode = $dom->createElement($statisticNodeTag);
  110 + $statisticNode->setAttribute('xml:id', 'statistic-treeRootNode');
  111 + $dom->documentElement->appendChild($statisticNode);
  112 +
  113 + return $dom->save($req_mgr_file_path);
  114 + }
  115 +
87 private function updateFromVersion1() { 116 private function updateFromVersion1() {
88 // Update WS for save download requests 117 // Update WS for save download requests
89 118