Commit 9846ec70eb5ac1fe53ca25bd8a65ade711dea28f

Authored by Benjamin Renard
1 parent 98c5bd44

WS getDataset without resampling #7170 + Fix some warning

php/RemoteDataCenter/IPIM.php
... ... @@ -136,7 +136,7 @@ class IPIM extends SimulationDataCenterClass
136 136 return $this->getFileName($resourceID);
137 137 }
138 138  
139   - public function getData($params)
  139 + public function getData($params, $isSpectra = false)
140 140 {
141 141 // $r = print_r($params,true);
142 142 // error_log($params['accessUrl'],3,'/home/budnik/LOG');
... ...
php/RemoteDataCenter/LESIA.php
... ... @@ -300,7 +300,7 @@ class LESIA extends SimulationDataCenterClass
300 300 $TemplatesXml->save(RemoteData.$this->baseID."/".$this->templateFile);
301 301 }
302 302  
303   - public function getData($params)
  303 + public function getData($params, $isSpectra = false)
304 304 {
305 305 // $r = print_r($params,true);
306 306 // error_log($r,3,'/home/budnik/LOG');
... ...
php/RemoteDataCenter/SimulationDataCenterClass.php
... ... @@ -445,7 +445,7 @@ class SimulationDataCenterClass extends RemoteDataCenterClass
445 445 $TemplatesXml->save(RemoteData.$this->baseID.'/'.$this->templateFile);
446 446 }
447 447  
448   - protected function createSpecialArgs($dom = null)
  448 + protected function createSpecialArgs($dom)
449 449 {
450 450 return array();
451 451 }
... ...
php/WebServices/WebServer.php
... ... @@ -175,8 +175,6 @@ class WebServer
175 175 $xpath = new DOMXpath($orbitsXml);
176 176 $path = '//orbites[@mission="'.$spacecraft.'" and @coordinate_system="'.$orbitRequest['coordinateSystem'].'" and @units="'.$orbitRequest['units'].'" ] ';
177 177  
178   -error_log($path);
179   -
180 178 $orbits = $xpath->query($path);
181 179  
182 180 foreach ($orbits as $orbit)
... ... @@ -199,7 +197,7 @@ error_log($path);
199 197 "Cannot find orbit data for ".$orbitRequest['spacecraft']." for ".$orbitRequest['startTime']."-".$orbitRequest['stopTime']." in ".$orbitRequest['units']." ".$orbitRequest['coordinateSystem']."($paramStart - $paramStop)");
200 198 }
201 199  
202   - private function doDownloadRequest($interval, $paramList, $formatInfo)
  200 + private function doDownloadRequest($interval, $paramList, $formatInfo, $file_info)
203 201 {
204 202 if (!isset($this->paramLoader))
205 203 $this->paramLoader = new IHMUserParamLoaderClass();
... ... @@ -236,6 +234,8 @@ error_log($path);
236 234 $params[] = $param;
237 235 }
238 236  
  237 + $ref_sampling_param = isset($formatInfo['ref_sampling_param']) ? $formatInfo['ref_sampling_param'] : NULL;
  238 +
239 239 $obj = (object)array(
240 240 "sampling" => $interval['sampling'],
241 241 "startDate" => $interval['startTime'],
... ... @@ -243,7 +243,9 @@ error_log($path);
243 243 "list" => $params,
244 244 "fileformat" => $formatInfo['format'],
245 245 "timeformat" => $formatInfo['timeFormat'],
246   - "compression" => $formatInfo['gzip']
  246 + "compression" => $formatInfo['gzip'],
  247 + "ref_sampling_param" => $ref_sampling_param,
  248 + "file_info" => $file_info,
247 249 );
248 250  
249 251  
... ... @@ -296,7 +298,7 @@ error_log($path);
296 298 $locParamSrcDom = new DomDocument("1.0");
297 299 $locParamSrcDom->preserveWhiteSpace = FALSE; /// Important !!! otherwise removeChild() leaves empty text nodes
298 300  
299   - if (!$locParamSrcDom->load($locParamSrc))
  301 + if (!@$locParamSrcDom->load($locParamSrc))
300 302 $this->throwError("getObsDataTree", "Cannot load Amda Local DataBase Parameters description file".$this->userID);
301 303  
302 304 $xp = new domxpath($locParamSrcDom);
... ... @@ -376,10 +378,10 @@ error_log($path);
376 378  
377 379 $this->excludePrivateNodes($locParamSrc,$locParamDst);
378 380  
379   - if (!copy($wsParamSrc, WSConfigClass::getWsResultDir().$wsParamDst))
  381 + if (($this->userID == WSConfigClass::getAnonymousUserName()) || !copy($wsParamSrc, WSConfigClass::getWsResultDir().$wsParamDst))
380 382 return array('success' => true,'ParameterList' =>
381 383 array("LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst));
382   -
  384 +
383 385 return array('success' => true,'ParameterList' =>
384 386 array("UserDefinedParameters" => WSConfigClass::getUrl().$wsParamDst,
385 387 "LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst));
... ... @@ -390,7 +392,6 @@ error_log($path);
390 392 */
391 393 public function getParameter($data)
392 394 {
393   -error_log("BRE =============================> getParameter");
394 395 $res = $this->init($data);
395 396  
396 397 if (!$res['success']){
... ... @@ -446,7 +447,7 @@ error_log("BRE =============================> getParameter");
446 447 $res = $this->doDownloadRequest(
447 448 array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling),
448 449 array("params" => $paramId),
449   - array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip));
  450 + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $paramId);
450 451  
451 452 if ($res['success'])
452 453 return $res;
... ... @@ -503,60 +504,52 @@ error_log("BRE =============================> getParameter");
503 504 $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"]));
504 505 }
505 506  
506   - if (!$vars["timeFormat"]) {
  507 + if (empty($vars["timeFormat"])) {
507 508 $timeFormat = "ISO8601";
508 509 }
509 510 else {
510 511 $timeFormat = $vars["timeFormat"];
511 512 }
512   -
513   - $dataSetDom = $this->getDatasetInfo($vars['datasetID']);
  513 +
  514 + if (empty($vars['datasetID'])) {
  515 + $this->throwError("requestError", "Missing datasetID definition");
  516 + }
  517 + $datasetId = $vars['datasetID'];
  518 + $dataSetDom = $this->getDatasetInfo($datasetId);
514 519  
515 520 $params = $dataSetDom->getElementsByTagName("parameter");
516 521  
517 522 if ($params->length == 0)
518   - $this->throwError("systemError", "Cannot find parameter list for dataset ".$vars['datasetID']);
  523 + $this->throwError("systemError", "Cannot find parameter list for dataset ".$datasetId);
519 524  
520 525 $paramId = array();
521 526  
522 527 foreach ($params as $p)
523 528 $paramId[] = $p->nodeValue;
524 529  
525   - if (!$vars["sampling"])
  530 + if (empty($vars["sampling"]))
526 531 {
527   - $sampling = $dataSetDom->getElementsByTagName('min_sampling')->item(0)->nodeValue;
528   -
529   - $units = substr($sampling,-1);
530   - $sampling = substr($sampling,0,strlen($sampling)-1);
531   -
532   - switch ($units) {
533   -// case 'S':
534   -// $sampling = floatval($sampling);
535   -// break;
536   - case 'M':
537   - $sampling = floatval($sampling)*60;
538   - break;
539   - case 'H':
540   - $sampling = floatval($sampling)*60*60;
541   - break;
542   - default:
543   - }
  532 + $sampling = NULL;
  533 + $ref_sampling_param = $paramId[0];
544 534 }
545 535 else {
546 536 $sampling = $vars["sampling"];
  537 + $ref_sampling_param = NULL;
547 538 }
548 539  
549   - if (!$vars["gzip"])
  540 + if (empty($vars["gzip"]))
550 541 $gzip = 0;
551 542 else
552   - $gzip = $vars["gzip"];
  543 + $gzip = ($vars["gzip"] == 1);
  544 +
  545 + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII';
553 546  
554 547 $this->service = strtolower(__FUNCTION__);
555 548  
556 549 $res = $this->doDownloadRequest(
557   - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling),
  550 + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling, "ref_sampling_param" => $ref_sampling_param),
558 551 array("params" => $paramId),
559   - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip));
  552 + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $datasetId);
560 553  
561 554 if ($res['success']) return $res;
562 555  
... ... @@ -693,17 +686,24 @@ error_log("BRE =============================> getParameter");
693 686 $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"]));
694 687 }
695 688  
696   - if (!$vars["timeFormat"]) {
  689 + if (empty($vars["timeFormat"])) {
697 690 $timeFormat = "ISO8601";
698 691 }
699 692 else {
700 693 $timeFormat = $vars["timeFormat"];
701 694 }
702   -
  695 +
  696 + if (empty($vars["spacecraft"])) {
  697 + $this->throwError("requestError", "Missing spacecraft definition");
  698 + }
703 699 $spacecraft = $vars["spacecraft"];
  700 +
  701 + if (empty($vars["coordinateSystem"])) {
  702 + $this->throwError("requestError", "Missing coordinateSystem definition");
  703 + }
704 704 $coordinateSystem = $vars["coordinateSystem"];
705 705  
706   - if (!$vars["units"])
  706 + if (empty($vars["units"]))
707 707 $units = "km";
708 708 else
709 709 $units = $vars["units"];
... ... @@ -720,17 +720,21 @@ error_log("BRE =============================> getParameter");
720 720 $paramId = array();
721 721 array_push($paramId, $orbitParam['parameterID']);
722 722  
723   - if (!$vars["gzip"])
  723 + if (empty($vars["gzip"]))
724 724 $gzip = 0;
725 725 else
726   - $gzip = $vars["gzip"];
  726 + $gzip = ($vars["gzip"] == 1);
  727 +
  728 + $sampling = !empty($vars["sampling"]) ? $vars["sampling"] : NULL;
  729 +
  730 + $outputFormat = !empty($vars["outputFormat"]) ? $vars["outputFormat"] : 'ASCII';
727 731  
728   - $this->service = strtolower(__FUNCTION__);
  732 + $this->service = strtolower(__FUNCTION__);
729 733  
730 734 $res = $this->doDownloadRequest(
731   - array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]),
  735 + array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling),
732 736 array("params" => $paramId),
733   - array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip));
  737 + array("format" => $outputFormat, "timeFormat"=> $timeFormat, "gzip"=>$gzip), $orbitParam['parameterID']);
734 738  
735 739 if ($res['success']) return $res;
736 740  
... ...
php/classes/AmdaStats.php
... ... @@ -12,7 +12,8 @@ class AmdaStats {
12 12 public $usersToExclude = array('bouchemit', 'impex');
13 13 public $success = true;
14 14 private $user = null;
15   - private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistics'=>'statistics','getparameter'=>'ws_print');
  15 + private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistics'=>'statistics',
  16 + 'getparameter'=>'ws_print', 'getdataset' => 'ws_print', 'getorbites' => 'ws_print');
16 17  
17 18 public function __construct($user) {
18 19  
... ...
php/classes/CatalogMgr.php
... ... @@ -31,7 +31,7 @@ class CatalogMgr extends TimeTableMgr
31 31 }
32 32  
33 33  
34   - public function loadIntervalsFromObject($id, $type, $start = NULL, $limit = NULL)
  34 + public function loadIntervalsFromObject($id, $type = '', $start = NULL, $limit = NULL)
35 35 {
36 36 $result = parent::loadIntervalsFromObject($id, $type, $start, $limit);
37 37 if (!isset($result['success']) || !$result['success']) {
... ...
php/rest/getParameterList.php
... ... @@ -39,7 +39,7 @@
39 39  
40 40 if ($result['ParameterList']){
41 41 foreach($result['ParameterList'] as $key => $value) {
42   - echo "<$key>$value</$key><br/>";
  42 + echo "<$key>$value</$key>";
43 43 }
44 44 }
45 45 else {
... ...