Commit 8a92ee198eb22826473f7caddbfe1a25cde6dba0
1 parent
b8502f4d
Exists in
master
and in
111 other branches
timeTobatch special setting
Showing
1 changed file
with
76 additions
and
87 deletions
Show diff stats
php/classes/WebServer.php
@@ -83,7 +83,8 @@ class WebServer | @@ -83,7 +83,8 @@ class WebServer | ||
83 | private $wsUserMgr; | 83 | private $wsUserMgr; |
84 | private $resultMgr, $myParamsInfoMgr; | 84 | private $resultMgr, $myParamsInfoMgr; |
85 | private $dataFileName; | 85 | private $dataFileName; |
86 | - | 86 | + private $timeToBatchMode = 300; // secs |
87 | + | ||
87 | function __construct() | 88 | function __construct() |
88 | { | 89 | { |
89 | $this->userID = 'impex'; | 90 | $this->userID = 'impex'; |
@@ -102,7 +103,7 @@ class WebServer | @@ -102,7 +103,7 @@ class WebServer | ||
102 | // [timeFormat] => ISO8601 | 103 | // [timeFormat] => ISO8601 |
103 | // [gzip] => 0 | 104 | // [gzip] => 0 |
104 | 105 | ||
105 | - protected function init($data) | 106 | + protected function init($data, $serverAccess = false) |
106 | { | 107 | { |
107 | if(is_object($data)){ | 108 | if(is_object($data)){ |
108 | $vars = get_object_vars($data); | 109 | $vars = get_object_vars($data); |
@@ -126,6 +127,11 @@ class WebServer | @@ -126,6 +127,11 @@ class WebServer | ||
126 | else | 127 | else |
127 | $this->userPWD = 'impexfp7'; | 128 | $this->userPWD = 'impexfp7'; |
128 | 129 | ||
130 | + // set special timeToBatchMode interval | ||
131 | + if ($serverAccess) { | ||
132 | + KernelConfigClass::setTimeToBatchMode($this->timeToBatchMode); | ||
133 | + } | ||
134 | + | ||
129 | return array('success' => true, 'vars' => $vars); | 135 | return array('success' => true, 'vars' => $vars); |
130 | } | 136 | } |
131 | 137 | ||
@@ -225,17 +231,17 @@ class WebServer | @@ -225,17 +231,17 @@ class WebServer | ||
225 | 231 | ||
226 | public function getTimeTablesList($data) | 232 | public function getTimeTablesList($data) |
227 | { | 233 | { |
228 | - if(is_object($data)) | ||
229 | - { | ||
230 | - $vars = get_object_vars($data); | ||
231 | - $this->isSoap = true; | ||
232 | - } | ||
233 | - else | ||
234 | - $vars = $data; | ||
235 | - | ||
236 | - if (isset($vars['userID']) && $vars['userID'] == 'impex'){ | ||
237 | - $this->throwError('requestError', "Request Error: no time tables for anonymous"); | ||
238 | - } | 234 | +// if(is_object($data)) |
235 | +// { | ||
236 | +// $vars = get_object_vars($data); | ||
237 | +// $this->isSoap = true; | ||
238 | +// } | ||
239 | +// else | ||
240 | +// $vars = $data; | ||
241 | +// | ||
242 | +// if (isset($vars['userID']) && $vars['userID'] == 'impex'){ | ||
243 | +// $this->throwError('requestError', "Request Error: no time tables for anonymous"); | ||
244 | +// } | ||
239 | 245 | ||
240 | $res = $this->init($data); | 246 | $res = $this->init($data); |
241 | $vars = $res['vars']; | 247 | $vars = $res['vars']; |
@@ -365,7 +371,7 @@ class WebServer | @@ -365,7 +371,7 @@ class WebServer | ||
365 | $mission = $vars["missionID"]; | 371 | $mission = $vars["missionID"]; |
366 | 372 | ||
367 | $ID = $this->setID(); // unique JobID | 373 | $ID = $this->setID(); // unique JobID |
368 | - $resDirName = WSRESULT.$ID; // Define a temporary directory for results | 374 | + $resDirName = WSRESULT.$ID; // Define a temporary directory for results |
369 | 375 | ||
370 | if (is_dir($resDirName)) | 376 | if (is_dir($resDirName)) |
371 | $this->rrmdir($resDirName); | 377 | $this->rrmdir($resDirName); |
@@ -423,14 +429,14 @@ class WebServer | @@ -423,14 +429,14 @@ class WebServer | ||
423 | $timeAxisObject = (Object) array( | 429 | $timeAxisObject = (Object) array( |
424 | "id" => "time", | 430 | "id" => "time", |
425 | "axis-type" => "time", | 431 | "axis-type" => "time", |
426 | - "axis-range-extend" => true | 432 | + "axis-range-extend" => true |
427 | ); | 433 | ); |
428 | $panelObject->{"axes"}[] = $timeAxisObject; | 434 | $panelObject->{"axes"}[] = $timeAxisObject; |
429 | 435 | ||
430 | $yAxisObject = (Object) array( | 436 | $yAxisObject = (Object) array( |
431 | "id" => "y-left", | 437 | "id" => "y-left", |
432 | "axis-type" => "y-left", | 438 | "axis-type" => "y-left", |
433 | - "axis-range-extend" => true | 439 | + "axis-range-extend" => true |
434 | ); | 440 | ); |
435 | $panelObject->{"axes"}[] = $yAxisObject; | 441 | $panelObject->{"axes"}[] = $yAxisObject; |
436 | 442 | ||
@@ -582,9 +588,7 @@ class WebServer | @@ -582,9 +588,7 @@ class WebServer | ||
582 | */ | 588 | */ |
583 | public function getParameter($data) | 589 | public function getParameter($data) |
584 | { | 590 | { |
585 | - $multiParam = false; | ||
586 | - | ||
587 | - $res = $this->init($data); | 591 | + $res = $this->init($data, true); |
588 | 592 | ||
589 | $resMgr = $this->initUserMgr(); | 593 | $resMgr = $this->initUserMgr(); |
590 | 594 | ||
@@ -593,15 +597,12 @@ class WebServer | @@ -593,15 +597,12 @@ class WebServer | ||
593 | } | 597 | } |
594 | 598 | ||
595 | $vars = $res['vars']; | 599 | $vars = $res['vars']; |
596 | - | ||
597 | - $startTime = strtotime($vars["startTime"]); | ||
598 | - $stopTime = strtotime($vars["stopTime"]); | ||
599 | 600 | ||
600 | - if ($stopTime <= $startTime){ | 601 | + if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ |
601 | $this->throwError("requestError", "Requested time interval should be greater than 0"); | 602 | $this->throwError("requestError", "Requested time interval should be greater than 0"); |
602 | } | 603 | } |
603 | 604 | ||
604 | - $dataFileName = $this->getDataFileName($vars, $multiParam); | 605 | + $dataFileName = $this->getDataFileName($vars); |
605 | 606 | ||
606 | if ($dataFileName['success']) { | 607 | if ($dataFileName['success']) { |
607 | $this->dataFileName = $dataFileName['fileName']; | 608 | $this->dataFileName = $dataFileName['fileName']; |
@@ -634,13 +635,11 @@ class WebServer | @@ -634,13 +635,11 @@ class WebServer | ||
634 | array("userName" => $this->userID, "userPwd" => $this->userPWD, "sessionID" => $this->sessionID), | 635 | array("userName" => $this->userID, "userPwd" => $this->userPWD, "sessionID" => $this->sessionID), |
635 | array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream), | 636 | array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream), |
636 | $dataFileName); | 637 | $dataFileName); |
637 | - | ||
638 | - | 638 | + |
639 | if ($res['success']) | 639 | if ($res['success']) |
640 | return $res; | 640 | return $res; |
641 | 641 | ||
642 | - $this->throwError("serverError", $res['message']); | ||
643 | - | 642 | + $this->throwError("serverError", $res['message']); |
644 | } | 643 | } |
645 | 644 | ||
646 | /* | 645 | /* |
@@ -648,8 +647,6 @@ class WebServer | @@ -648,8 +647,6 @@ class WebServer | ||
648 | */ | 647 | */ |
649 | public function getOrbites($data) | 648 | public function getOrbites($data) |
650 | { | 649 | { |
651 | - $multiParam = false; | ||
652 | - | ||
653 | $res = $this->init($data); | 650 | $res = $this->init($data); |
654 | 651 | ||
655 | $resMgr = $this->initUserMgr(); | 652 | $resMgr = $this->initUserMgr(); |
@@ -659,11 +656,8 @@ class WebServer | @@ -659,11 +656,8 @@ class WebServer | ||
659 | } | 656 | } |
660 | 657 | ||
661 | $vars = $res['vars']; | 658 | $vars = $res['vars']; |
662 | - | ||
663 | - $startTime = strtotime($vars["startTime"]); | ||
664 | - $stopTime = strtotime($vars["stopTime"]); | ||
665 | 659 | ||
666 | - if ($stopTime <= $startTime){ | 660 | + if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ |
667 | $this->throwError("requestError", "Requested time interval should be greater than 0"); | 661 | $this->throwError("requestError", "Requested time interval should be greater than 0"); |
668 | } | 662 | } |
669 | 663 | ||
@@ -693,7 +687,7 @@ class WebServer | @@ -693,7 +687,7 @@ class WebServer | ||
693 | $this->throwError("requestError", $orbitesParam['message']); | 687 | $this->throwError("requestError", $orbitesParam['message']); |
694 | } | 688 | } |
695 | 689 | ||
696 | - $dataFileName = $this->getDataFileName($orbitesParam, $multiParam); | 690 | + $dataFileName = $this->getDataFileName($orbitesParam); |
697 | 691 | ||
698 | if ($dataFileName['success']) { | 692 | if ($dataFileName['success']) { |
699 | $this->dataFileName = $dataFileName['fileName']; | 693 | $this->dataFileName = $dataFileName['fileName']; |
@@ -732,22 +726,17 @@ class WebServer | @@ -732,22 +726,17 @@ class WebServer | ||
732 | */ | 726 | */ |
733 | public function getDataset($data) | 727 | public function getDataset($data) |
734 | { | 728 | { |
735 | - $multiParam = true; | ||
736 | - | ||
737 | $res = $this->init($data); | 729 | $res = $this->init($data); |
738 | 730 | ||
739 | $resMgr = $this->initUserMgr(); | 731 | $resMgr = $this->initUserMgr(); |
740 | 732 | ||
741 | $vars = $res['vars']; | 733 | $vars = $res['vars']; |
742 | - | ||
743 | - $startTime = strtotime($vars["startTime"]); | ||
744 | - $stopTime = strtotime($vars["stopTime"]); | ||
745 | 734 | ||
746 | - if ($stopTime <= $startTime){ | 735 | + if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ |
747 | $this->throwError("requestError", "Requested time interval should be greater than 0"); | 736 | $this->throwError("requestError", "Requested time interval should be greater than 0"); |
748 | } | 737 | } |
749 | 738 | ||
750 | - $dataFileName = $this->getDataFileName($vars, $multiParam); | 739 | + $dataFileName = $this->getDataFileName($vars, true); |
751 | 740 | ||
752 | if ($dataFileName['success']) { | 741 | if ($dataFileName['success']) { |
753 | $this->dataFileName = $dataFileName['fileName']; | 742 | $this->dataFileName = $dataFileName['fileName']; |
@@ -768,7 +757,7 @@ class WebServer | @@ -768,7 +757,7 @@ class WebServer | ||
768 | $matches=array(); | 757 | $matches=array(); |
769 | preg_match("/([a-z])$/", $vars["sampling"], $matches); | 758 | preg_match("/([a-z])$/", $vars["sampling"], $matches); |
770 | 759 | ||
771 | - $dataFileName = $this->getDataFileName($vars, $multiParam); | 760 | + $dataFileName = $this->getDataFileName($vars, true); |
772 | 761 | ||
773 | if ($dataFileName['success']) { | 762 | if ($dataFileName['success']) { |
774 | $this->dataFileName = $dataFileName['fileName']; | 763 | $this->dataFileName = $dataFileName['fileName']; |
@@ -943,22 +932,22 @@ class WebServer | @@ -943,22 +932,22 @@ class WebServer | ||
943 | } | 932 | } |
944 | 933 | ||
945 | $obj = (object)array( | 934 | $obj = (object)array( |
946 | - "nodeType" => "download", | ||
947 | - "downloadSrc" => "0", | ||
948 | - "structure" => $structure, | ||
949 | - "refparamSampling" => false, | ||
950 | - "sampling" => $interval['sampling'], | ||
951 | - "timesrc" => "Interval", | ||
952 | - "startDate" => $interval['startTime'], | ||
953 | - "stopDate" => $interval['stopTime'], | ||
954 | - "list" => $params, | ||
955 | - "fileformat" => $fileInfo['fileFormat'], | ||
956 | - "timeformat" => $fileInfo['timeFormat'], | ||
957 | - "compression" => $fileInfo['compression'], | ||
958 | - "extension" => $fileInfo['wsExtension'], | ||
959 | - "disablebatch" => false, | ||
960 | - "dataFileName" => $this->dataFileName | ||
961 | - ); | 935 | + "nodeType" => "download", |
936 | + "downloadSrc" => "0", | ||
937 | + "structure" => $structure, | ||
938 | + "refparamSampling" => false, | ||
939 | + "sampling" => $interval['sampling'], | ||
940 | + "timesrc" => "Interval", | ||
941 | + "startDate" => $interval['startTime'], | ||
942 | + "stopDate" => $interval['stopTime'], | ||
943 | + "list" => $params, | ||
944 | + "fileformat" => $fileInfo['fileFormat'], | ||
945 | + "timeformat" => $fileInfo['timeFormat'], | ||
946 | + "compression" => $fileInfo['compression'], | ||
947 | + "extension" => $fileInfo['wsExtension'], | ||
948 | + "disablebatch" => false, | ||
949 | + "dataFileName" => $this->dataFileName | ||
950 | + ); | ||
962 | 951 | ||
963 | if (!isset($this->requestManager)) | 952 | if (!isset($this->requestManager)) |
964 | $this->requestManager = new RequestManagerClass(); | 953 | $this->requestManager = new RequestManagerClass(); |
@@ -1012,24 +1001,24 @@ class WebServer | @@ -1012,24 +1001,24 @@ class WebServer | ||
1012 | } | 1001 | } |
1013 | 1002 | ||
1014 | 1003 | ||
1015 | - protected function timeIntervalToDuration($startTime,$stopTime) | ||
1016 | - { | ||
1017 | - $duration = strtotime($stopTime) - strtotime($startTime); | ||
1018 | - $durationDay = intval($duration/(86400)); | ||
1019 | - $duration = $duration - $durationDay*86400; | ||
1020 | - $durationHour = intval($duration/(3600)); | ||
1021 | - $duration = $duration - $durationHour*3600; | ||
1022 | - $durationMin = intval($duration/(60)); | ||
1023 | - $durationSec = $duration - $durationMin*60; | ||
1024 | - | ||
1025 | - return array("success" => true, "days" => sprintf("%04s", strval($durationDay)), | ||
1026 | - "hours" => sprintf("%02s", strval($durationHour)), | ||
1027 | - "mins" => sprintf("%02s", strval($durationMin)), | ||
1028 | - "secs" => sprintf("%02s", strval($durationSec)) | ||
1029 | - ); | ||
1030 | - } | ||
1031 | - | ||
1032 | - protected function getDataFileName($vars, $multiParam) | 1004 | +// protected function timeIntervalToDuration($startTime,$stopTime) |
1005 | +// { | ||
1006 | +// $duration = strtotime($stopTime) - strtotime($startTime); | ||
1007 | +// $durationDay = intval($duration/(86400)); | ||
1008 | +// $duration = $duration - $durationDay*86400; | ||
1009 | +// $durationHour = intval($duration/(3600)); | ||
1010 | +// $duration = $duration - $durationHour*3600; | ||
1011 | +// $durationMin = intval($duration/(60)); | ||
1012 | +// $durationSec = $duration - $durationMin*60; | ||
1013 | +// | ||
1014 | +// return array("success" => true, "days" => sprintf("%04s", strval($durationDay)), | ||
1015 | +// "hours" => sprintf("%02s", strval($durationHour)), | ||
1016 | +// "mins" => sprintf("%02s", strval($durationMin)), | ||
1017 | +// "secs" => sprintf("%02s", strval($durationSec)) | ||
1018 | +// ); | ||
1019 | +// } | ||
1020 | + | ||
1021 | + protected function getDataFileName($vars, $multiParam = false) | ||
1033 | { | 1022 | { |
1034 | if ($vars['startTime'] && $vars['stopTime'] && $vars['parameterID'] && !$multiParam){ | 1023 | if ($vars['startTime'] && $vars['stopTime'] && $vars['parameterID'] && !$multiParam){ |
1035 | $fileName = $vars['parameterID']."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); | 1024 | $fileName = $vars['parameterID']."-".strtotime($vars['startTime'])."-".strtotime($vars['stopTime']); |
@@ -1102,15 +1091,15 @@ class WebServer | @@ -1102,15 +1091,15 @@ class WebServer | ||
1102 | return $vars; | 1091 | return $vars; |
1103 | } | 1092 | } |
1104 | 1093 | ||
1105 | - private function compress($srcName, $dstName) | ||
1106 | - { | ||
1107 | - $fp = fopen($srcName, "r"); | ||
1108 | - $data = fread($fp, filesize($srcName)); | ||
1109 | - fclose($fp); | ||
1110 | - | ||
1111 | - $zp = gzopen($dstName, "w9"); | ||
1112 | - gzwrite($zp, $data); | ||
1113 | - gzclose($zp); | ||
1114 | - } | 1094 | +// private function compress($srcName, $dstName) |
1095 | +// { | ||
1096 | +// $fp = fopen($srcName, "r"); | ||
1097 | +// $data = fread($fp, filesize($srcName)); | ||
1098 | +// fclose($fp); | ||
1099 | +// | ||
1100 | +// $zp = gzopen($dstName, "w9"); | ||
1101 | +// gzwrite($zp, $data); | ||
1102 | +// gzclose($zp); | ||
1103 | +// } | ||
1115 | } | 1104 | } |
1116 | ?> | 1105 | ?> |
1117 | \ No newline at end of file | 1106 | \ No newline at end of file |