Commit 232a6b9fcba210fc1a6bec40d7026c0d9f5e1029
Exists in
master
Merge branch 'WIP'
Showing
5 changed files
with
328 additions
and
12 deletions
Show diff stats
... | ... | @@ -0,0 +1,68 @@ |
1 | + | |
2 | +/** @file GetModificationDate.c | |
3 | +* @brief Stand-alone executable <br> Returns modification date for given VI in DDBase <br> | |
4 | +* | |
5 | +* @details GetModificationDate(string *) <br> | |
6 | +* @arg \c argv[1] Path to VI directory | |
7 | +* @arg \c argv[2] Times file name | |
8 | +*/ | |
9 | + | |
10 | + | |
11 | +#include <stdlib.h> | |
12 | +#include <stdio.h> | |
13 | +#include <string.h> | |
14 | +#include <time.h> | |
15 | +#include <sys/stat.h> | |
16 | +#include <math.h> | |
17 | +#include <netcdf.h> | |
18 | +#include <DD.h> | |
19 | + | |
20 | + | |
21 | + | |
22 | +/*---------------- NC ERROR --------------------------------------*/ | |
23 | +void nc_handle_error(int status) | |
24 | +{ | |
25 | + fprintf(stderr, "%s\n", nc_strerror(status)); | |
26 | + exit(1); | |
27 | +} | |
28 | + | |
29 | +/* ----------------------- MAIN ------------------------------------*/ | |
30 | +int main(int argc, char *argv[]) | |
31 | +{ | |
32 | + int status, len; | |
33 | + | |
34 | + if (argc < 3){ | |
35 | + fprintf(stderr,"Usage: GetModificationDate path_to_vi times_file_name\n"); | |
36 | + exit(1); | |
37 | + } | |
38 | + | |
39 | + char timesPath[512]; | |
40 | + memset(timesPath, 0, 512*sizeof(char)); | |
41 | + strcat(timesPath, argv[1]); | |
42 | + strcat(timesPath, "/"); | |
43 | + strcat(timesPath, argv[2]); | |
44 | + | |
45 | + // Open VI_times.nc | |
46 | + int DataID; | |
47 | + if ((status = nc_open(timesPath, NC_NOWRITE, &DataID)) != NC_NOERR) | |
48 | + nc_handle_error(status); | |
49 | + | |
50 | + char modificationDate[21]; | |
51 | + memset(modificationDate, 0, 21*sizeof(char)); | |
52 | + if ((status = nc_get_att_text(DataID, NC_GLOBAL, "ModificationDate", modificationDate)) != NC_NOERR) { | |
53 | + struct stat b; | |
54 | + if (!stat(timesPath, &b)) { | |
55 | + strftime(modificationDate, 21, "%Y-%m-%dT%H:%M:%SZ", localtime( &b.st_mtime)); | |
56 | + } | |
57 | + } | |
58 | + | |
59 | + nc_close(DataID); | |
60 | + | |
61 | + if (strcmp(modificationDate, "") == 0) { | |
62 | + exit(1); | |
63 | + } | |
64 | + | |
65 | + printf("%s\n", modificationDate); | |
66 | + | |
67 | + exit(0); | |
68 | +} | ... | ... |
... | ... | @@ -0,0 +1,98 @@ |
1 | + | |
2 | +/** @file GetReleaseDate.c | |
3 | +* @brief Stand-alone executable <br> Returns release date for given VI in DDBase <br> | |
4 | +* | |
5 | +* @details GetReleaseDate(string *) <br> | |
6 | +* @arg \c argv[1] Path to VI directory | |
7 | +* @arg \c argv[2] Times file name | |
8 | +* | |
9 | +*/ | |
10 | + | |
11 | + | |
12 | +#include <stdlib.h> | |
13 | +#include <stdio.h> | |
14 | +#include <string.h> | |
15 | +#include <time.h> | |
16 | +#include <sys/stat.h> | |
17 | +#include <math.h> | |
18 | +#include <netcdf.h> | |
19 | +#include <DD.h> | |
20 | + | |
21 | + | |
22 | + | |
23 | +/*---------------- NC ERROR --------------------------------------*/ | |
24 | +void nc_handle_error(int status) | |
25 | +{ | |
26 | + fprintf(stderr, "%s\n", nc_strerror(status)); | |
27 | + exit(1); | |
28 | +} | |
29 | + | |
30 | +/* ----------------------- MAIN ------------------------------------*/ | |
31 | +int main(int argc, char *argv[]) | |
32 | +{ | |
33 | + int status, len; | |
34 | + | |
35 | + if (argc < 3){ | |
36 | + fprintf(stderr,"Usage: GetReleaseDate path_to_vi times_file_name\n"); | |
37 | + exit(1); | |
38 | + } | |
39 | + | |
40 | + char timesPath[512]; | |
41 | + memset(timesPath, 0, 512*sizeof(char)); | |
42 | + strcat(timesPath, argv[1]); | |
43 | + strcat(timesPath, "/"); | |
44 | + strcat(timesPath, argv[2]); | |
45 | + | |
46 | + // Open VI_times.nc | |
47 | + int DataID; | |
48 | + if ((status = nc_open(timesPath, NC_NOWRITE, &DataID)) != NC_NOERR) | |
49 | + nc_handle_error(status); | |
50 | + | |
51 | + int FileID; | |
52 | + if ((status = nc_inq_varid(DataID, "FileName", &FileID)) != NC_NOERR) | |
53 | + nc_handle_error(status); | |
54 | + | |
55 | + int Filedims[2]; | |
56 | + if ((status = nc_inq_var(DataID, FileID, NULL, NULL, NULL, Filedims, NULL)) != NC_NOERR) | |
57 | + nc_handle_error(status); | |
58 | + | |
59 | + size_t nb_records; | |
60 | + if ((nc_inq_dimlen(DataID, Filedims[0], &nb_records)) != NC_NOERR) | |
61 | + nc_handle_error(status); | |
62 | + | |
63 | + int i; | |
64 | + char FileName[32]; | |
65 | + char filePath[512]; | |
66 | + size_t count[2] = {1L,32L}; | |
67 | + size_t start[2] = {0L,0L}; | |
68 | + struct stat attrib; | |
69 | + | |
70 | + time_t releaseDate = 0; | |
71 | + for (i = 0; i < nb_records; ++i) { | |
72 | + count[1] = 32; | |
73 | + start[0] = i; | |
74 | + if ((status = nc_get_vara_text(DataID, FileID, start, count, FileName)) != NC_NOERR) | |
75 | + nc_handle_error(status); | |
76 | + memset(filePath, 0, 512*sizeof(char)); | |
77 | + strcat(filePath, argv[1]); | |
78 | + strcat(filePath, "/"); | |
79 | + strcat(filePath, FileName); | |
80 | + strcat(filePath, ".gz"); | |
81 | + stat(filePath, &attrib); | |
82 | + if (releaseDate < attrib.st_mtime) | |
83 | + releaseDate = attrib.st_mtime; | |
84 | + } | |
85 | + | |
86 | + | |
87 | + nc_close(DataID); | |
88 | + | |
89 | + if (releaseDate == 0) | |
90 | + exit(1); | |
91 | + | |
92 | + char releaseDateISO[21]; | |
93 | + memset(releaseDateISO, 0, 21*sizeof(char)); | |
94 | + strftime(releaseDateISO, 21, "%Y-%m-%dT%H:%M:%SZ", localtime( &releaseDate)); | |
95 | + | |
96 | + printf("%s\n", releaseDateISO); | |
97 | + exit(0); | |
98 | +} | ... | ... |
src/DATA/TOOLS/TimesUpdate.c
... | ... | @@ -46,6 +46,7 @@ |
46 | 46 | #include <dirent.h> |
47 | 47 | #include <netcdf.h> |
48 | 48 | #include <math.h> |
49 | +#include <time.h> | |
49 | 50 | #include <DD.h> |
50 | 51 | |
51 | 52 | /* Global Constant definitions */ |
... | ... | @@ -269,6 +270,7 @@ main(int argc, char **argv) |
269 | 270 | char name[100]; |
270 | 271 | int compress = 0; |
271 | 272 | int status; |
273 | + int updateModificationDate = 0; | |
272 | 274 | |
273 | 275 | double LastTime = 0.0, FirstTime = 0.0; // Times of the hall between files |
274 | 276 | |
... | ... | @@ -390,14 +392,18 @@ main(int argc, char **argv) |
390 | 392 | /*--------- Look the conditions ---------------*/ |
391 | 393 | condition = ALLRIGHT; |
392 | 394 | if((CurrentRecord->StartD < FirstTime - 60.0) && |
393 | - (CurrentRecord->StopD > LastTime + 60.0)) condition = LEFTRIGHTOVER; | |
395 | + (CurrentRecord->StopD > LastTime + 60.0)) | |
396 | + condition = LEFTRIGHTOVER; | |
394 | 397 | else if((CurrentRecord->StartD < FirstTime - 60.0) && |
395 | - (CurrentRecord->StopD < FirstTime + 60.0)) condition = ALLLEFT; | |
398 | + (CurrentRecord->StopD < FirstTime + 60.0)) | |
399 | + condition = ALLLEFT; | |
396 | 400 | else if((CurrentRecord->StartD < FirstTime - 60.0) && |
397 | 401 | (CurrentRecord->StopD > FirstTime) && |
398 | - (CurrentRecord->StopD < LastTime + 60.0)) condition = LEFTOVER; | |
402 | + (CurrentRecord->StopD < LastTime + 60.0)) | |
403 | + condition = LEFTOVER; | |
399 | 404 | else if((CurrentRecord->StartD >= FirstTime - 60.0) && |
400 | - (CurrentRecord->StopD <= LastTime + 60.0)) condition = WELLIN; | |
405 | + (CurrentRecord->StopD <= LastTime + 60.0)) | |
406 | + condition = WELLIN; | |
401 | 407 | else if((CurrentRecord->StartD >= FirstTime - 60.0) && |
402 | 408 | (CurrentRecord->StartD < LastTime) && |
403 | 409 | (CurrentRecord->StopD > LastTime + 60.0))condition = RIGHTOVER; |
... | ... | @@ -407,14 +413,33 @@ main(int argc, char **argv) |
407 | 413 | /* What to do with these conditions ----------------*/ |
408 | 414 | switch(condition) |
409 | 415 | { |
410 | - case WELLIN : InsertRecord((size_t)ihole, CurrentRecord); InsertFlag = 1; break; | |
411 | - case ALLLEFT : RemoveRecord((size_t)(ihole-1),CurrentRecord); ihole--; break; | |
412 | - case ALLRIGHT : ihole++; break; | |
413 | - case LEFTOVER : RemoveRecord((size_t)(ihole-1),CurrentRecord); ihole--; break; | |
414 | - case RIGHTOVER : RemoveRecord((size_t)ihole,CurrentRecord); break; | |
415 | - case LEFTRIGHTOVER : RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
416 | - RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
417 | - ihole--; break; | |
416 | + case WELLIN : | |
417 | + InsertRecord((size_t)ihole, CurrentRecord); | |
418 | + InsertFlag = 1; | |
419 | + break; | |
420 | + case ALLLEFT : | |
421 | + RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
422 | + updateModificationDate = 1; | |
423 | + ihole--; | |
424 | + break; | |
425 | + case ALLRIGHT : | |
426 | + ihole++; | |
427 | + break; | |
428 | + case LEFTOVER : | |
429 | + RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
430 | + updateModificationDate = 1; | |
431 | + ihole--; | |
432 | + break; | |
433 | + case RIGHTOVER : | |
434 | + RemoveRecord((size_t)ihole,CurrentRecord); | |
435 | + updateModificationDate = 1; | |
436 | + break; | |
437 | + case LEFTRIGHTOVER : | |
438 | + RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
439 | + RemoveRecord((size_t)(ihole-1),CurrentRecord); | |
440 | + updateModificationDate = 1; | |
441 | + ihole--; | |
442 | + break; | |
418 | 443 | } |
419 | 444 | } // While InsertFlag |
420 | 445 | } // if RecordsNumber > 0 |
... | ... | @@ -425,6 +450,25 @@ main(int argc, char **argv) |
425 | 450 | } // If current argument file is OK |
426 | 451 | } // CASE |
427 | 452 | } // For several arguments |
453 | + | |
454 | + char modificationDate[21]; | |
455 | + memset(modificationDate, 0, 21*sizeof(char)); | |
456 | + | |
457 | + int modDateAttrib; | |
458 | + if ((status = nc_inq_attid(tmID, NC_GLOBAL, "ModificationDate", &modDateAttrib)) != NC_NOERR) { | |
459 | + updateModificationDate = 1; | |
460 | + } | |
461 | + | |
462 | + if (updateModificationDate == 1) { | |
463 | + char modificationDate[21]; | |
464 | + memset(modificationDate, 0, 21*sizeof(char)); | |
465 | + time_t t = time(NULL); | |
466 | + strftime(modificationDate, 21, "%Y-%m-%dT%H:%M:%SZ", localtime(&t)); | |
467 | + nc_redef(tmID); | |
468 | + status = nc_put_att_text (tmID, NC_GLOBAL, "ModificationDate", 20, modificationDate); | |
469 | + nc_enddef(tmID); | |
470 | + } | |
471 | + | |
428 | 472 | status = nc_close(tmID); |
429 | 473 | return(0); |
430 | 474 | } | ... | ... |
src/DDSERVICES/SOAP/DDserverWeb.php
... | ... | @@ -101,6 +101,81 @@ |
101 | 101 | return $result; |
102 | 102 | } |
103 | 103 | |
104 | + | |
105 | +/** | |
106 | +* Returns list of datasets with TimeRestriction | |
107 | +*/ | |
108 | +function getVIInfo($viId) | |
109 | +{ | |
110 | + $result = array( | |
111 | + ); | |
112 | + $referXML = baseDir."/DDsys.xml"; | |
113 | + $DDsys = new DOMDocument("1.0"); | |
114 | + @$DDsys->load($referXML); | |
115 | + $xp = new domxpath($DDsys); | |
116 | + $VINodes = $xp->query("//NAME[.='".str_replace(":", "_",$viId)."']"); | |
117 | + $result = array( | |
118 | + 'success' => FALSE | |
119 | + ); | |
120 | + | |
121 | + if ($VINodes->length == 0) { | |
122 | + return $result; | |
123 | + } | |
124 | + | |
125 | + $VINode = $VINodes->item(0)->parentNode; | |
126 | + | |
127 | + $locationNode = $VINode->getElementsByTagName("LOCATION"); | |
128 | + $nameNode = $VINode->getElementsByTagName("NAME"); | |
129 | + $timesNode = $VINode->getElementsByTagName("TIMES"); | |
130 | + if (($locationNode->length > 0) && ($nameNode->length > 0) && ($timesNode->length > 0)) | |
131 | + { | |
132 | + | |
133 | + | |
134 | + $locationNode = $locationNode->item(0); | |
135 | + $nameNode = $nameNode->item(0); | |
136 | + $location = $locationNode->nodeValue; | |
137 | + $viName = $nameNode->nodeValue; | |
138 | + $timesNode = $timesNode->item(0); | |
139 | + $timesFile = $timesNode->nodeValue; | |
140 | + | |
141 | + if (!empty($location) && !empty($viName)) { | |
142 | + | |
143 | + // Start / Stop Date | |
144 | + $referFile = baseDir."/refer.nc"; | |
145 | + $cmd = DDBASEBIN."/StartStop ".$referFile." ".$viId; | |
146 | + $startStopDate = system($cmd); | |
147 | + | |
148 | + // Release date | |
149 | + $releaseDate = NULL; | |
150 | + $cmd = "/opt/tools/DDServer/bin/GetReleaseDate ".$location." ".$timesFile; | |
151 | + $output = array(); | |
152 | + exec($cmd, $output, $result_code); | |
153 | + if ($result_code == 0) | |
154 | + $releaseDate = $output[0]; | |
155 | + | |
156 | + // Modification date | |
157 | + $cmd = "/opt/tools/DDServer/bin/GetModificationDate ".$location." ".$timesFile; | |
158 | + $output = array(); | |
159 | + exec($cmd, $output, $result_code); | |
160 | + if ($result_code == 0) | |
161 | + $modificationDate = $output[0]; | |
162 | + if (!isset($releaseDate)) | |
163 | + $releaseDate = $modificationDate; | |
164 | + | |
165 | + | |
166 | + $result = array( | |
167 | + 'success' => TRUE, | |
168 | + 'viName' => $viName, | |
169 | + 'releaseDate' => $releaseDate, | |
170 | + 'modificationDate' => $modificationDate, | |
171 | + 'startStopDate' => $startStopDate | |
172 | + ); | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + return $result; | |
177 | +} | |
178 | + | |
104 | 179 | /** |
105 | 180 | * Returns restricted TimeRestriction and GlobalStop in case of time restriction |
106 | 181 | */ | ... | ... |
src/DDSERVICES/SOAP/dd.wsdl.in
... | ... | @@ -47,6 +47,14 @@ |
47 | 47 | </tns:element> |
48 | 48 | </tns:sequence> |
49 | 49 | </tns:complexType> |
50 | + <tns:complexType name="VIInfo"> | |
51 | + <tns:sequence> | |
52 | + <tns:element minOccurs="1" maxOccurs="1" name="vi" type="xsd:string"/> | |
53 | + <tns:element minOccurs="1" maxOccurs="1" name="releaseDate" type="xsd:string"/> | |
54 | + <tns:element minOccurs="1" maxOccurs="1" name="modificationDate" type="xsd:string"/> | |
55 | + <tns:element minOccurs="1" maxOccurs="1" name="startStopDate" type="xsd:string"/> | |
56 | + </tns:sequence> | |
57 | + </tns:complexType> | |
50 | 58 | </types> |
51 | 59 | |
52 | 60 | <message name='isRemoteViAddedRequest'> |
... | ... | @@ -182,6 +190,12 @@ |
182 | 190 | <message name='getDatasetsWithTimeRestrictionResponse'> |
183 | 191 | <part name='Result' type='tns:ListOfDatasetTimeRestrictionData'/> |
184 | 192 | </message> |
193 | +<message name='getVIInfoRequest'> | |
194 | + <part name='viId' type='xsd:string'/> | |
195 | +</message> | |
196 | +<message name='getVIInfoResponse'> | |
197 | + <part name='Result' type='tns:VIInfo'/> | |
198 | +</message> | |
185 | 199 | |
186 | 200 | <portType name='AmdaPortType'> |
187 | 201 | <operation name='isRemoteViAdded'> |
... | ... | @@ -268,6 +282,12 @@ |
268 | 282 | <input message='tns:getDatasetsWithTimeRestrictionRequest'/> |
269 | 283 | <output message='tns:getDatasetsWithTimeRestrictionResponse'/> |
270 | 284 | </operation> |
285 | + <operation name='getVIInfo'> | |
286 | + <input message='tns:getVIInfoRequest'/> | |
287 | + <output message='tns:getVIInfoResponse'/> | |
288 | + </operation> | |
289 | + | |
290 | + | |
271 | 291 | </portType> |
272 | 292 | |
273 | 293 | <binding name='AmdaBinding' type='tns:AmdaPortType'> |
... | ... | @@ -504,6 +524,17 @@ |
504 | 524 | encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> |
505 | 525 | </output> |
506 | 526 | </operation> |
527 | + <operation name='getVIInfo'> | |
528 | + <soap:operation soapAction='getVIInfo'/> | |
529 | + <input> | |
530 | + <soap:body use='encoded' | |
531 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | |
532 | + </input> | |
533 | + <output> | |
534 | + <soap:body use='encoded' | |
535 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | |
536 | + </output> | |
537 | + </operation> | |
507 | 538 | </binding> |
508 | 539 | |
509 | 540 | <service name='AmdaService'> | ... | ... |