From 775592ff53bd747d8198ba2504c80bc48bc49aa5 Mon Sep 17 00:00:00 2001 From: Elena.Budnik Date: Mon, 11 Dec 2017 16:32:11 +0100 Subject: [PATCH] bug in insNodes addition --- src/REMOTEDATA/CDAWEB.php | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/REMOTEDATA/CDAWEB.php b/src/REMOTEDATA/CDAWEB.php index eb6ef48..477ef3e 100644 --- a/src/REMOTEDATA/CDAWEB.php +++ b/src/REMOTEDATA/CDAWEB.php @@ -18,7 +18,7 @@ class CDAWEB extends RemoteDataCenterClass private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays", "Magnetic%20Fields%20(space)", "Particles%20(space)", "Plasma%20and%20Solar%20Wind", "Radio%20and%20Plasma%20Waves%20(space)" ]; - // private $validInstrumentTypes = [ "Magnetic%20Fields%20(space)", "Radio%20and%20Plasma%20Waves%20(space)" ]; +// private $validInstrumentTypes = [ "Radio%20and%20Plasma%20Waves%20(space)" ]; // not used : $validInstrumentTypes = ["Ephemeris"]; @@ -26,7 +26,7 @@ class CDAWEB extends RemoteDataCenterClass // not in "https://heliophysicsdata.sci.gsfc.nasa.gov/queries/CDAWeb_SPASE.xql" List; // FOR INFO : Excluded automatically - private $excludeDatasets = ["DMSP_R0_SSJ4", "DMSP_R0_SSIES", "I7_R0_LEPEDEA", "I8_R0_LEPEDEA", "WI_STRAHL0_SWE" ]; + private $excludeDatasets = [ "DMSP_R0_SSJ4", "DMSP_R0_SSIES", "I7_R0_LEPEDEA", "I8_R0_LEPEDEA" ]; protected $DDserverXml, $DDserverXmlName; @@ -64,6 +64,12 @@ class CDAWEB extends RemoteDataCenterClass $this->res = new DomDocument(); $this->res->loadXML(curl_exec($this->ch)); + + if ($this->res->getElementsByTagName('EndpointAddress')->length == 0) { + error_log("Problem connect to ".CDAWebConfigClass::$restUrl."/dataviews", 3, err); + exit("Problem connect to ".CDAWebConfigClass::$restUrl."/dataviews".PHP_EOL); + } + $this->dataViewURL = $this->res->getElementsByTagName('EndpointAddress')->item(0)->nodeValue; } @@ -75,16 +81,16 @@ class CDAWEB extends RemoteDataCenterClass $this->setDataViewURL(); $this->obsGroupsIds = array(); - foreach ( $this->validInstrumentTypes as $insType) + foreach ($this->validInstrumentTypes as $insType) { curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/observatoryGroupsAndInstruments?instrumentType=".$insType); echo $insType.PHP_EOL; $this->res->loadXML(curl_exec($this->ch)); - // $this->res->save($insType.".xml"); - $observatoryGroups = $this->res->getElementsByTagName("ObservatoryGroupInstrumentDescription"); + + $observatoryGroups = $this->res->getElementsByTagName("ObservatoryGroupInstrumentDescription"); - foreach ( $observatoryGroups as $obsGroup ) - { + foreach ($observatoryGroups as $obsGroup) + { $obsGroupId = $obsGroup->getElementsByTagName('Name')->item(0)->nodeValue; // Exclude some Missions @@ -502,15 +508,14 @@ class CDAWEB extends RemoteDataCenterClass foreach ($groupIds as $groupId => $obss) { $obsNodes = array(); - + foreach ($obss as $obs => $inss) { // ! observatory OMNI is taken for observatoriesGroup OMNI only ! if (substr($obs,0,4) == "OMNI" && substr($groupId,0,4) != "OMNI"){ echo 'OMNI '.$obs.' '.$missionId.PHP_EOL; continue; - } - + } $insNodes = array(); // Create instrument nodes foreach ($inss as $ins => $dss) @@ -536,19 +541,19 @@ class CDAWEB extends RemoteDataCenterClass if (!$insSpaseId ) $insSpaseId = $ins; - $obsSpaseId = $this->getObservatorySpase(); + $obsSpaseId = strtolower($this->getObservatorySpase()); if (!$obsSpaseId ) - $obsSpaseId = $obs; + $obsSpaseId = strtolower($obs); $insId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obsSpaseId).":".$this->param2dd($insSpaseId); if (!($insNode = $this->domAmda->getElementById($insId))){ $insNode = $this->createInstrumentNode($insSpaseId, $obsSpaseId, $groupId); - $insNodes[] = $insNode; - } + } foreach ($dsNodes as $dsNode){ $insNode->appendChild($dsNode); } + $insNodes[] = $insNode; } } // foreach ($inss as $ins => $dss) if ($insNodes) @@ -557,13 +562,13 @@ class CDAWEB extends RemoteDataCenterClass if (!($obsNode = $this->domAmda->getElementById($obsId))){ $obsNode = $this->createObservatoryNode($obsSpaseId, $groupId); - - $obsNodes[] = $obsNode; } foreach ($insNodes as $insNode){ $obsNode->appendChild($insNode); } + + $obsNodes[] = $obsNode; } } // foreach ($obss as $obs => $inss) -- libgit2 0.21.2