Commit 775592ff53bd747d8198ba2504c80bc48bc49aa5

Authored by Elena.Budnik
1 parent 8c0d5a9f

bug in insNodes addition

Showing 1 changed file with 21 additions and 16 deletions   Show diff stats
src/REMOTEDATA/CDAWEB.php
@@ -18,7 +18,7 @@ class CDAWEB extends RemoteDataCenterClass @@ -18,7 +18,7 @@ class CDAWEB extends RemoteDataCenterClass
18 private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays", 18 private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays",
19 "Magnetic%20Fields%20(space)", "Particles%20(space)", "Plasma%20and%20Solar%20Wind", 19 "Magnetic%20Fields%20(space)", "Particles%20(space)", "Plasma%20and%20Solar%20Wind",
20 "Radio%20and%20Plasma%20Waves%20(space)" ]; 20 "Radio%20and%20Plasma%20Waves%20(space)" ];
21 - // private $validInstrumentTypes = [ "Magnetic%20Fields%20(space)", "Radio%20and%20Plasma%20Waves%20(space)" ]; 21 +// private $validInstrumentTypes = [ "Radio%20and%20Plasma%20Waves%20(space)" ];
22 22
23 // not used : $validInstrumentTypes = ["Ephemeris"]; 23 // not used : $validInstrumentTypes = ["Ephemeris"];
24 24
@@ -26,7 +26,7 @@ class CDAWEB extends RemoteDataCenterClass @@ -26,7 +26,7 @@ class CDAWEB extends RemoteDataCenterClass
26 26
27 // not in "https://heliophysicsdata.sci.gsfc.nasa.gov/queries/CDAWeb_SPASE.xql" List; 27 // not in "https://heliophysicsdata.sci.gsfc.nasa.gov/queries/CDAWeb_SPASE.xql" List;
28 // FOR INFO : Excluded automatically 28 // FOR INFO : Excluded automatically
29 - private $excludeDatasets = ["DMSP_R0_SSJ4", "DMSP_R0_SSIES", "I7_R0_LEPEDEA", "I8_R0_LEPEDEA", "WI_STRAHL0_SWE" ]; 29 + private $excludeDatasets = [ "DMSP_R0_SSJ4", "DMSP_R0_SSIES", "I7_R0_LEPEDEA", "I8_R0_LEPEDEA" ];
30 30
31 protected $DDserverXml, $DDserverXmlName; 31 protected $DDserverXml, $DDserverXmlName;
32 32
@@ -64,6 +64,12 @@ class CDAWEB extends RemoteDataCenterClass @@ -64,6 +64,12 @@ class CDAWEB extends RemoteDataCenterClass
64 64
65 $this->res = new DomDocument(); 65 $this->res = new DomDocument();
66 $this->res->loadXML(curl_exec($this->ch)); 66 $this->res->loadXML(curl_exec($this->ch));
  67 +
  68 + if ($this->res->getElementsByTagName('EndpointAddress')->length == 0) {
  69 + error_log("Problem connect to ".CDAWebConfigClass::$restUrl."/dataviews", 3, err);
  70 + exit("Problem connect to ".CDAWebConfigClass::$restUrl."/dataviews".PHP_EOL);
  71 + }
  72 +
67 $this->dataViewURL = $this->res->getElementsByTagName('EndpointAddress')->item(0)->nodeValue; 73 $this->dataViewURL = $this->res->getElementsByTagName('EndpointAddress')->item(0)->nodeValue;
68 } 74 }
69 75
@@ -75,16 +81,16 @@ class CDAWEB extends RemoteDataCenterClass @@ -75,16 +81,16 @@ class CDAWEB extends RemoteDataCenterClass
75 $this->setDataViewURL(); 81 $this->setDataViewURL();
76 $this->obsGroupsIds = array(); 82 $this->obsGroupsIds = array();
77 83
78 - foreach ( $this->validInstrumentTypes as $insType) 84 + foreach ($this->validInstrumentTypes as $insType)
79 { 85 {
80 curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/observatoryGroupsAndInstruments?instrumentType=".$insType); 86 curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/observatoryGroupsAndInstruments?instrumentType=".$insType);
81 echo $insType.PHP_EOL; 87 echo $insType.PHP_EOL;
82 $this->res->loadXML(curl_exec($this->ch)); 88 $this->res->loadXML(curl_exec($this->ch));
83 - // $this->res->save($insType.".xml");  
84 - $observatoryGroups = $this->res->getElementsByTagName("ObservatoryGroupInstrumentDescription"); 89 +
  90 + $observatoryGroups = $this->res->getElementsByTagName("ObservatoryGroupInstrumentDescription");
85 91
86 - foreach ( $observatoryGroups as $obsGroup )  
87 - { 92 + foreach ($observatoryGroups as $obsGroup)
  93 + {
88 $obsGroupId = $obsGroup->getElementsByTagName('Name')->item(0)->nodeValue; 94 $obsGroupId = $obsGroup->getElementsByTagName('Name')->item(0)->nodeValue;
89 95
90 // Exclude some Missions 96 // Exclude some Missions
@@ -502,15 +508,14 @@ class CDAWEB extends RemoteDataCenterClass @@ -502,15 +508,14 @@ class CDAWEB extends RemoteDataCenterClass
502 foreach ($groupIds as $groupId => $obss) 508 foreach ($groupIds as $groupId => $obss)
503 { 509 {
504 $obsNodes = array(); 510 $obsNodes = array();
505 - 511 +
506 foreach ($obss as $obs => $inss) 512 foreach ($obss as $obs => $inss)
507 { 513 {
508 // ! observatory OMNI is taken for observatoriesGroup OMNI only ! 514 // ! observatory OMNI is taken for observatoriesGroup OMNI only !
509 if (substr($obs,0,4) == "OMNI" && substr($groupId,0,4) != "OMNI"){ 515 if (substr($obs,0,4) == "OMNI" && substr($groupId,0,4) != "OMNI"){
510 echo 'OMNI '.$obs.' '.$missionId.PHP_EOL; 516 echo 'OMNI '.$obs.' '.$missionId.PHP_EOL;
511 continue; 517 continue;
512 - }  
513 - 518 + }
514 $insNodes = array(); 519 $insNodes = array();
515 // Create instrument nodes 520 // Create instrument nodes
516 foreach ($inss as $ins => $dss) 521 foreach ($inss as $ins => $dss)
@@ -536,19 +541,19 @@ class CDAWEB extends RemoteDataCenterClass @@ -536,19 +541,19 @@ class CDAWEB extends RemoteDataCenterClass
536 if (!$insSpaseId ) 541 if (!$insSpaseId )
537 $insSpaseId = $ins; 542 $insSpaseId = $ins;
538 543
539 - $obsSpaseId = $this->getObservatorySpase(); 544 + $obsSpaseId = strtolower($this->getObservatorySpase());
540 if (!$obsSpaseId ) 545 if (!$obsSpaseId )
541 - $obsSpaseId = $obs; 546 + $obsSpaseId = strtolower($obs);
542 547
543 $insId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obsSpaseId).":".$this->param2dd($insSpaseId); 548 $insId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obsSpaseId).":".$this->param2dd($insSpaseId);
544 549
545 if (!($insNode = $this->domAmda->getElementById($insId))){ 550 if (!($insNode = $this->domAmda->getElementById($insId))){
546 $insNode = $this->createInstrumentNode($insSpaseId, $obsSpaseId, $groupId); 551 $insNode = $this->createInstrumentNode($insSpaseId, $obsSpaseId, $groupId);
547 - $insNodes[] = $insNode;  
548 - } 552 + }
549 foreach ($dsNodes as $dsNode){ 553 foreach ($dsNodes as $dsNode){
550 $insNode->appendChild($dsNode); 554 $insNode->appendChild($dsNode);
551 } 555 }
  556 + $insNodes[] = $insNode;
552 } 557 }
553 } // foreach ($inss as $ins => $dss) 558 } // foreach ($inss as $ins => $dss)
554 if ($insNodes) 559 if ($insNodes)
@@ -557,13 +562,13 @@ class CDAWEB extends RemoteDataCenterClass @@ -557,13 +562,13 @@ class CDAWEB extends RemoteDataCenterClass
557 562
558 if (!($obsNode = $this->domAmda->getElementById($obsId))){ 563 if (!($obsNode = $this->domAmda->getElementById($obsId))){
559 $obsNode = $this->createObservatoryNode($obsSpaseId, $groupId); 564 $obsNode = $this->createObservatoryNode($obsSpaseId, $groupId);
560 -  
561 - $obsNodes[] = $obsNode;  
562 } 565 }
563 566
564 foreach ($insNodes as $insNode){ 567 foreach ($insNodes as $insNode){
565 $obsNode->appendChild($insNode); 568 $obsNode->appendChild($insNode);
566 } 569 }
  570 +
  571 + $obsNodes[] = $obsNode;
567 } 572 }
568 } // foreach ($obss as $obs => $inss) 573 } // foreach ($obss as $obs => $inss)
569 574