Commit 05fbcab0fdd9da3dabc1d4d9666c169de3332aea
1 parent
1b0e0631
Exists in
master
and in
9 other branches
DDServices reorganized
Showing
10 changed files
with
44 additions
and
275 deletions
Show diff stats
CMakeLists.txt
... | ... | @@ -49,6 +49,7 @@ add_subdirectory(src/DECODERS/themis/esamom2nc) |
49 | 49 | add_subdirectory(src/DECODERS/themis/fgm2nc) |
50 | 50 | add_subdirectory(src/DECODERS/themis/sst2nc) |
51 | 51 | add_subdirectory(src/DATA/TOOLS) |
52 | +add_subdirectory(src/DDSERVICES/TOOLS) | |
52 | 53 | add_subdirectory(tests) |
53 | 54 | |
54 | 55 | install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
... | ... | @@ -58,5 +59,7 @@ install(FILES "scripts/UpdateInfoVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWN |
58 | 59 | install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT) |
59 | 60 | install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER) |
60 | 61 | install(DIRECTORY "src/REMOTEDATA/" DESTINATION bin/REMOTEDATA) |
62 | +install(DIRECTORY "src/DDSERVICES/SOAP/" DESTINATION DDService) | |
63 | +install(DIRECTORY "src/DDSERVICES/REST/" DESTINATION DDService) | |
61 | 64 | |
62 | 65 | SET(CMAKE_VERBOSE_MAKEFILE ON) |
... | ... |
src/DATA/MANAGER/RemoveVI.php
src/DDSERVICES/SOAP/src/Makefile deleted
... | ... | @@ -1,30 +0,0 @@ |
1 | -#----------------------------------------------------- | |
2 | -# MAKEFILE for DD SERVER Services | |
3 | -#--------------------------------------------------------- | |
4 | - | |
5 | -EXE = StartStop GetFileNames GetInfo | |
6 | - | |
7 | -lib: $(EXE) | |
8 | - | |
9 | -install: | |
10 | - install -d -m a+rx,ug+w ../bin | |
11 | - cp $(EXE) ../bin | |
12 | - | |
13 | -clean: | |
14 | - tag="*.o" ${EXE};\ | |
15 | - for file in $$tag; do \ | |
16 | - echo $$file; rm -f $$file;\ | |
17 | - done | |
18 | - find -name \*~ -delete | |
19 | - | |
20 | -deinstall: | |
21 | - echo "Do nothing" | |
22 | - | |
23 | -StartStop: StartStop.c | |
24 | - ${CC} ${CFLAGS} -o StartStop StartStop.c ${INC} ${LIB} -lnetcdf | |
25 | - | |
26 | -GetInfo: GetInfo.c | |
27 | - ${CC} ${CFLAGS} -o GetInfo GetInfo.c ${INC} ${LIB} -lnetcdf | |
28 | - | |
29 | -GetFileNames: GetFileNames.c | |
30 | - ${CC} ${CFLAGS} -o GetFileNames GetFileNames.c ${INC} ${LIB} -lnetcdf -lDD |
src/DDSERVICES/SOAP/src/StartStop.c deleted
... | ... | @@ -1,104 +0,0 @@ |
1 | - | |
2 | -/** @file StartStop.c | |
3 | -* @brief Stand-alone executable <br> Returns real Start-Stop for VI in DDBase <br> | |
4 | -* Is used in DD Server WebServices <br> | |
5 | -* @details StartStop(string *, string *) <br> | |
6 | -* @arg \c argv[1] Full name of DDBase reference file <br> | |
7 | -* @arg \c argv[2] Virtual Instrument ID (DD notation) <br> | |
8 | -* Output: YYYYDDdayHHMMSSMLS-YYYYDDdayHHMMSSMLS | |
9 | -* | |
10 | -* @date 10.10.2007 | |
11 | -* @version $Id: StartStop.c,v 1.3 2011/09/05 11:27:34 budnik Exp $ | |
12 | -*/ | |
13 | - | |
14 | - | |
15 | -#include <stdlib.h> | |
16 | -#include <stdio.h> | |
17 | -#include <string.h> | |
18 | -#include <time.h> | |
19 | -#include <math.h> | |
20 | -#include <netcdf.h> | |
21 | -#include <DD.h> | |
22 | - | |
23 | - | |
24 | -int DataID, RecID, VarID, StartID, StopID; | |
25 | -size_t RecNum; | |
26 | -char StartT[TIMELENGTH], StopT[TIMELENGTH], Var[128]; | |
27 | -size_t count[2] = {1L,TIMELENGTH}; | |
28 | -size_t start[2] = {0L,0L}; | |
29 | -size_t countVar[2] = {1L,128L}; | |
30 | - | |
31 | -/*---------------- NC ERROR --------------------------------------*/ | |
32 | -void nc_handle_error(int status) | |
33 | -{ | |
34 | - fprintf(stderr, "%s\n", nc_strerror(status)); | |
35 | - exit(1); | |
36 | -} | |
37 | - | |
38 | -/* ----------------------- MAIN ------------------------------------*/ | |
39 | - int main(int argc, char *argv[]) | |
40 | -{ | |
41 | - | |
42 | - int status, len; | |
43 | - | |
44 | - char Project[50],Instrument[50],Mode[50], RInstrName[100]; | |
45 | - | |
46 | - | |
47 | - if (argc < 3) | |
48 | - { | |
49 | - fprintf(stderr,"Usage: StartStop reference_file_name DD_VI_ID\n"); | |
50 | - exit(0); | |
51 | - } | |
52 | - | |
53 | - | |
54 | - if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR) | |
55 | - nc_handle_error(status); | |
56 | - | |
57 | - sscanf(argv[2], "%[^:]%*c%[^:]%*c%[^:]%*c",Project, | |
58 | - Instrument, | |
59 | - Mode); | |
60 | - sprintf(RInstrName,"%s_%s_%s\0",Project,Instrument,Mode); | |
61 | - | |
62 | - if ((status = nc_inq_varid(DataID,RInstrName,&VarID)) != NC_NOERR) | |
63 | - nc_handle_error(status); | |
64 | - | |
65 | - start[0] = 1; | |
66 | - if((status = nc_get_vara_text(DataID, VarID, start, countVar, Var)) != NC_NOERR) | |
67 | - nc_handle_error(status); | |
68 | - | |
69 | - len = strcspn(Var," "); Var[len] = '\0'; | |
70 | - | |
71 | - if ((status = nc_close(DataID)) != NC_NOERR) nc_handle_error(status); | |
72 | - | |
73 | -// Open VI_times.nc | |
74 | - | |
75 | - if ((status = nc_open(Var, NC_NOWRITE, &DataID)) != NC_NOERR) | |
76 | - nc_handle_error(status); | |
77 | - | |
78 | - if ((status = nc_inq_dimid(DataID, "record", &RecID)) != NC_NOERR) | |
79 | - nc_handle_error(status); | |
80 | - | |
81 | -// Get Number of Records | |
82 | - | |
83 | - if ((status = nc_inq_dimlen(DataID, RecID, &RecNum)) != NC_NOERR) | |
84 | - nc_handle_error(status); | |
85 | - | |
86 | - if ((status = nc_inq_varid(DataID, "StartTime", &StartID)) != NC_NOERR) | |
87 | - nc_handle_error(status); | |
88 | - if ((status = nc_inq_varid(DataID, "StopTime", &StopID)) != NC_NOERR) | |
89 | - nc_handle_error(status); | |
90 | - | |
91 | -// Get The First Start and The Last Stop Times | |
92 | - start[0] = 0; | |
93 | - | |
94 | - if((status = nc_get_vara_text(DataID, StartID, start, count, StartT)) != NC_NOERR) | |
95 | - nc_handle_error(status); | |
96 | - | |
97 | - start[0] = RecNum-1; | |
98 | - if((status = nc_get_vara_text(DataID, StopID, start, count, StopT)) != NC_NOERR) | |
99 | - nc_handle_error(status); | |
100 | - | |
101 | - printf("%s-%s\n", StartT, StopT); | |
102 | - if ((status = nc_close(DataID)) != NC_NOERR) nc_handle_error(status); | |
103 | - | |
104 | -} |
... | ... | @@ -0,0 +1,20 @@ |
1 | + | |
2 | +PROJECT(DDSERVICS_SOAP_TOOLS) | |
3 | + | |
4 | +include_directories( | |
5 | + ${DDCLIENTINCLUDE_DIR} | |
6 | + ${NETCDFINCLUDE_DIR} | |
7 | + ${LIBXML2_INCLUDE_DIR} | |
8 | +) | |
9 | + | |
10 | +#Configuration de l'exรฉcutable | |
11 | + | |
12 | +file( GLOB SOURCE_FILES ./*.c ) | |
13 | + | |
14 | +foreach( sourcefile ${SOURCE_FILES} ) | |
15 | + get_filename_component( source ${sourcefile} NAME) | |
16 | + string( REPLACE ".c" "" exefile ${source} ) | |
17 | + add_executable( ${exefile} ${source} ) | |
18 | + target_link_libraries( ${exefile} ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${LIBXML2_LIBRARIES}) | |
19 | + install (TARGETS ${exefile} DESTINATION bin) | |
20 | +endforeach( sourcefile ${SOURCE_FILE} ) | |
... | ... |
src/DDSERVICES/SOAP/src/GetFileNames.c renamed to src/DDSERVICES/TOOLS/GetFileNames.c
src/DDSERVICES/SOAP/src/GetInfo.c renamed to src/DDSERVICES/TOOLS/GetInfo.c
src/DATA/TOOLS/StartStop.c renamed to src/DDSERVICES/TOOLS/StartStop.c
src/REMOTEDATA/CDAWEB.php
... | ... | @@ -12,6 +12,7 @@ class CDAWEB extends RemoteDataCenterClass |
12 | 12 | |
13 | 13 | private $observatoryGroups, $instrumentTypes; |
14 | 14 | private $CDAWEB = array(), $masterCDF = array(); |
15 | + private $header; | |
15 | 16 | |
16 | 17 | // https://cdaweb.gsfc.nasa.gov/WS/cdasr/1/dataviews/sp_phys/instrumentTypes |
17 | 18 | private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays", |
... | ... | @@ -38,7 +39,10 @@ class CDAWEB extends RemoteDataCenterClass |
38 | 39 | } |
39 | 40 | |
40 | 41 | public function init() |
41 | - { | |
42 | + { | |
43 | + | |
44 | + error_log("CDAWEB Proxy creation on ".date("Y-m-d").PHP_EOL,3,log); | |
45 | + | |
42 | 46 | $this->getAllSpaseDatasets(); |
43 | 47 | } |
44 | 48 | |
... | ... | @@ -127,10 +131,7 @@ class CDAWEB extends RemoteDataCenterClass |
127 | 131 | |
128 | 132 | $this->obsGroupsIds[$insType][$obsGroupId] = $obsIds; |
129 | 133 | } |
130 | - } | |
131 | - | |
132 | - // print_r($this->obsGroupsIds); | |
133 | - // $this->closeConnection(); | |
134 | + } | |
134 | 135 | } |
135 | 136 | |
136 | 137 | protected function getDatasetByObservatoryAndInstrument($obsGroupId, $obsId, $insId) |
... | ... | @@ -139,19 +140,22 @@ class CDAWEB extends RemoteDataCenterClass |
139 | 140 | |
140 | 141 | $grpEncodedId = $this->html_encode($obsGroupId); |
141 | 142 | $insEncodedId = $this->html_encode($insId); |
143 | + $obsEncodedId = $this->html_encode($obsId); | |
142 | 144 | |
143 | 145 | $res = new DomDocument("1.0"); |
144 | - curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/datasets?observatoryGroup=$grpEncodedId&instrument=$insEncodedId"); | |
146 | + // curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/datasets?observatoryGroup=$grpEncodedId&instrument=$insEncodedId"); | |
147 | + | |
148 | + curl_setopt($this->ch, CURLOPT_URL, $this->dataViewURL."/datasets?observatory=$obsEncodedId&instrument=$insEncodedId"); | |
145 | 149 | |
146 | 150 | $res->loadXML(curl_exec($this->ch)); |
147 | -// $this->res->save('dataset.xml'); | |
148 | -// exit(); | |
151 | +exit ($res->saveXML()); | |
152 | + | |
149 | 153 | $datasets = $res->getElementsByTagName('DatasetDescription'); |
150 | 154 | $dsIds = array(); |
151 | 155 | |
152 | 156 | foreach ( $datasets as $ds) |
153 | 157 | { |
154 | - $obs = $ds->getElementsByTagName('Observatory')->item(0)->nodeValue; | |
158 | + // $obs = $ds->getElementsByTagName('Observatory')->item(0)->nodeValue; | |
155 | 159 | if ($obs != $obsId ) continue; |
156 | 160 | $dsIds[] = $ds->getElementsByTagName('Id')->item(0)->nodeValue; |
157 | 161 | } |
... | ... | @@ -159,132 +163,6 @@ class CDAWEB extends RemoteDataCenterClass |
159 | 163 | return $dsIds; |
160 | 164 | } |
161 | 165 | |
162 | - protected function createMissionNodes() | |
163 | - { | |
164 | - $missionNodes = array(); | |
165 | - $missionIds = array(); | |
166 | - // unique values | |
167 | - // $this->obsGroupsIds = array_map("unserialize", array_unique(array_map("serialize", $this->obsGroupsIds))); | |
168 | - | |
169 | - foreach ($this->obsGroupsIds as $groupId => $insTypes) | |
170 | - { | |
171 | - // echo ' GroupID '.$groupId.PHP_EOL; | |
172 | - $missionId = $this->baseID.":".$this->param2dd($groupId); | |
173 | - | |
174 | - if (!in_array($missionId, $missionIds)) | |
175 | - { | |
176 | - $missionNode = $this->domAmda->createElement('mission'); | |
177 | - $missionNode->setAttribute("xml:id",$missionId); | |
178 | - $missionNode->setAttribute("name",$groupId); | |
179 | - | |
180 | - $missionIds[] = $missionId; | |
181 | - $newNode = true; | |
182 | - } | |
183 | - else { | |
184 | - $key = array_search($missionId, $missionIds); | |
185 | - $missionNode = $missionNodes[$key]; | |
186 | - $newNode = false; | |
187 | - } | |
188 | - | |
189 | - foreach ($insTypes as $insType => $obss){ | |
190 | - // echo $insType.PHP_EOL; | |
191 | - | |
192 | - foreach ( $obss as $obs => $inss){ | |
193 | - // echo $obs.PHP_EOL; | |
194 | - // OMNI ONLY ONCE | |
195 | - if (substr($obs,0,4) == "OMNI" && substr($missionId,0,4) != "OMNI"){ | |
196 | - //echo ' '.$obs.' '.$missionId.PHP_EOL; | |
197 | - continue; | |
198 | - } | |
199 | - | |
200 | - if (file_exists(RemoteData."/".CDAWebConfigClass::$mapXML)) { | |
201 | - $obsAMDA = $this->alias(RemoteData."/".CDAWebConfigClass::$mapXML, $obs); | |
202 | - } | |
203 | - else { | |
204 | - $obsAMDA = $obs; | |
205 | - } | |
206 | - | |
207 | - $obsId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obsAMDA); | |
208 | - $obsNodes = $missionNode->getElementsByTagName('observatory'); | |
209 | - $newObsNode = true; | |
210 | - | |
211 | - foreach ($obsNodes as $node){ | |
212 | - $id = $node->getAttribute("xml:id"); | |
213 | - | |
214 | - if ($id == $obsId) { | |
215 | - $obsNode = $node; | |
216 | - $newObsNode = false; | |
217 | - break; | |
218 | - } | |
219 | - } | |
220 | - | |
221 | - if ( $newObsNode ){ | |
222 | - $obsNode = $this->createObservatoryNode($obs, $groupId); | |
223 | - } | |
224 | - | |
225 | - foreach ($inss as $ins => $dss){ | |
226 | - $insId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obs).":".$this->param2dd($ins); | |
227 | - $insNodes = $obsNode->getElementsByTagName('instrument'); | |
228 | - $newInsNode = true; | |
229 | - | |
230 | - foreach ($insNodes as $node){ | |
231 | - $id = $node->getAttribute("xml:id"); | |
232 | - | |
233 | - if ($id == $insId) { | |
234 | - $insNode = $node; | |
235 | - $newInsNode = false; | |
236 | - break; | |
237 | - } | |
238 | - } | |
239 | - | |
240 | - if ( $newInsNode ) | |
241 | - $insNode = $this->createInstrumentNode($ins, $obs, $groupId); | |
242 | - | |
243 | - foreach ($dss as $ds){ | |
244 | - $dsId = $this->baseID.":".$ds; | |
245 | - $dsNodes = $insNode->getElementsByTagName('dataset'); | |
246 | - $newDsNode = true; | |
247 | - | |
248 | - foreach ($dsNodes as $node){ | |
249 | - $id = $node->getAttribute("xml:id"); | |
250 | - | |
251 | - if ($id == $dsId){ | |
252 | - $dsNode = $node; | |
253 | - $newDsNode = false; | |
254 | - break; | |
255 | - } | |
256 | - } | |
257 | - | |
258 | - if ($newDsNode) { | |
259 | - $this->initDDServerXml($ds,$ins,$obs); | |
260 | - | |
261 | - $dsNode = $this->createDatasetNode($ds); | |
262 | - if ($dsNode){ | |
263 | - $insNode->appendChild($dsNode); | |
264 | - $this->saveDDServerXml(); | |
265 | - } | |
266 | - } | |
267 | - } | |
268 | - | |
269 | - if ($newInsNode && $insNode->hasChildNodes()) | |
270 | - $obsNode->appendChild($insNode); | |
271 | - } | |
272 | - | |
273 | - if ($newObsNode && $obsNode->hasChildNodes()){ | |
274 | - $missionNode->appendChild($obsNode); | |
275 | - } | |
276 | - } | |
277 | - | |
278 | - } | |
279 | - | |
280 | - if ($newNode) | |
281 | - $missionNodes[] = $missionNode; | |
282 | - } | |
283 | - | |
284 | - return $missionNodes; | |
285 | - | |
286 | - } | |
287 | - | |
288 | 166 | protected function createObservatoryNode($id, $grpId) |
289 | 167 | { |
290 | 168 | |
... | ... | @@ -447,7 +325,7 @@ class CDAWEB extends RemoteDataCenterClass |
447 | 325 | $this->CDAWEB[$key[0]->innertext] = $ref[0]->innertext; |
448 | 326 | } |
449 | 327 | |
450 | - echo "SPASE-defined CDAWEB datasets : ".count($this->CDAWEB).PHP_EOL; | |
328 | + echo "SPASE-defined CDAWEB datasets : ".count($this->CDAWEB).PHP_EOL; | |
451 | 329 | } |
452 | 330 | |
453 | 331 | protected function initDDServerXml($ds, $ins, $obs) |
... | ... | @@ -706,6 +584,8 @@ class CDAWEB extends RemoteDataCenterClass |
706 | 584 | } |
707 | 585 | $first = false; |
708 | 586 | } |
587 | + | |
588 | + $this->closeConnection(); | |
709 | 589 | } |
710 | 590 | |
711 | 591 | protected function createMissionNode($groupId){ |
... | ... | @@ -754,6 +634,7 @@ class CDAWEB extends RemoteDataCenterClass |
754 | 634 | |
755 | 635 | protected function setDataCenterAttributes(){} |
756 | 636 | protected function makeArgumentsList(){} |
637 | + | |
757 | 638 | } |
758 | 639 | ?> |
759 | 640 | |
... | ... |
src/REMOTEDATA/RemoteDataCenterClass.php
... | ... | @@ -62,7 +62,6 @@ abstract class RemoteDataCenterClass |
62 | 62 | abstract public function init(); |
63 | 63 | abstract protected function getRemoteTree(); |
64 | 64 | abstract protected function setDataCenterAttributes(); |
65 | - abstract protected function createMissionNodes(); | |
66 | 65 | abstract protected function makeArgumentsList(); |
67 | 66 | // abstract public function getDatasetInfo($ds); |
68 | 67 | // abstract public function getData($ds, $start, $stop); |
... | ... | @@ -110,11 +109,11 @@ abstract class RemoteDataCenterClass |
110 | 109 | foreach ($missionNodes as $missionNode) |
111 | 110 | $this->dataCenter->appendChild($missionNode); |
112 | 111 | } |
113 | - | |
112 | + | |
114 | 113 | protected function getIdFromSpase($spaseId) |
115 | 114 | { |
116 | - $temp = explode('/',$spaseId); | |
117 | - return $temp[count($temp)-1]; | |
115 | + $temp = explode('/',$spaseId); | |
116 | + return $temp[count($temp)-1]; | |
118 | 117 | } |
119 | 118 | |
120 | 119 | public function monitor() |
... | ... |