Commit ea5cac1a89149801091fd039169232bcca3a2b9a
1 parent
ca5a298d
Exists in
master
and in
1 other branch
WIP
Showing
3 changed files
with
58 additions
and
16 deletions
Show diff stats
src/DATA/TOOLS/GetModificationDate.c
@@ -45,12 +45,12 @@ int main(int argc, char *argv[]) | @@ -45,12 +45,12 @@ int main(int argc, char *argv[]) | ||
45 | if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR) | 45 | if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR) |
46 | nc_handle_error(status); | 46 | nc_handle_error(status); |
47 | 47 | ||
48 | - char* modificationDate = (char *) malloc(21); | 48 | + char modificationDate[21]; |
49 | memset(modificationDate, 0, 21*sizeof(char)); | 49 | memset(modificationDate, 0, 21*sizeof(char)); |
50 | if ((status = nc_get_att_text(DataID, NC_GLOBAL, "ModificationDate", modificationDate)) != NC_NOERR) { | 50 | if ((status = nc_get_att_text(DataID, NC_GLOBAL, "ModificationDate", modificationDate)) != NC_NOERR) { |
51 | struct stat b; | 51 | struct stat b; |
52 | if (!stat(argv[1], &b)) { | 52 | if (!stat(argv[1], &b)) { |
53 | - strftime(modificationDate, 100, "%Y-%m-%dT%H:%M:%SZ", localtime( &b.st_mtime)); | 53 | + strftime(modificationDate, 21, "%Y-%m-%dT%H:%M:%SZ", localtime( &b.st_mtime)); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 |
src/DATA/TOOLS/TimesUpdate.c
@@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | #include <netcdf.h> | 47 | #include <netcdf.h> |
48 | #include <math.h> | 48 | #include <math.h> |
49 | +#include <time.h> | ||
49 | #include <DD.h> | 50 | #include <DD.h> |
50 | 51 | ||
51 | /* Global Constant definitions */ | 52 | /* Global Constant definitions */ |
@@ -269,6 +270,7 @@ main(int argc, char **argv) | @@ -269,6 +270,7 @@ main(int argc, char **argv) | ||
269 | char name[100]; | 270 | char name[100]; |
270 | int compress = 0; | 271 | int compress = 0; |
271 | int status; | 272 | int status; |
273 | + int updateModificationDate = 0; | ||
272 | 274 | ||
273 | double LastTime = 0.0, FirstTime = 0.0; // Times of the hall between files | 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,14 +392,18 @@ main(int argc, char **argv) | ||
390 | /*--------- Look the conditions ---------------*/ | 392 | /*--------- Look the conditions ---------------*/ |
391 | condition = ALLRIGHT; | 393 | condition = ALLRIGHT; |
392 | if((CurrentRecord->StartD < FirstTime - 60.0) && | 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 | else if((CurrentRecord->StartD < FirstTime - 60.0) && | 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 | else if((CurrentRecord->StartD < FirstTime - 60.0) && | 400 | else if((CurrentRecord->StartD < FirstTime - 60.0) && |
397 | (CurrentRecord->StopD > FirstTime) && | 401 | (CurrentRecord->StopD > FirstTime) && |
398 | - (CurrentRecord->StopD < LastTime + 60.0)) condition = LEFTOVER; | 402 | + (CurrentRecord->StopD < LastTime + 60.0)) |
403 | + condition = LEFTOVER; | ||
399 | else if((CurrentRecord->StartD >= FirstTime - 60.0) && | 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 | else if((CurrentRecord->StartD >= FirstTime - 60.0) && | 407 | else if((CurrentRecord->StartD >= FirstTime - 60.0) && |
402 | (CurrentRecord->StartD < LastTime) && | 408 | (CurrentRecord->StartD < LastTime) && |
403 | (CurrentRecord->StopD > LastTime + 60.0))condition = RIGHTOVER; | 409 | (CurrentRecord->StopD > LastTime + 60.0))condition = RIGHTOVER; |
@@ -407,14 +413,33 @@ main(int argc, char **argv) | @@ -407,14 +413,33 @@ main(int argc, char **argv) | ||
407 | /* What to do with these conditions ----------------*/ | 413 | /* What to do with these conditions ----------------*/ |
408 | switch(condition) | 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 | } // While InsertFlag | 444 | } // While InsertFlag |
420 | } // if RecordsNumber > 0 | 445 | } // if RecordsNumber > 0 |
@@ -425,6 +450,17 @@ main(int argc, char **argv) | @@ -425,6 +450,17 @@ main(int argc, char **argv) | ||
425 | } // If current argument file is OK | 450 | } // If current argument file is OK |
426 | } // CASE | 451 | } // CASE |
427 | } // For several arguments | 452 | } // For several arguments |
453 | + | ||
454 | + if (updateModificationDate == 1) { | ||
455 | + char modificationDate[21]; | ||
456 | + memset(modificationDate, 0, 21*sizeof(char)); | ||
457 | + time_t t = time(NULL); | ||
458 | + strftime(modificationDate, 21, "%Y-%m-%dT%H:%M:%SZ", localtime(&t)); | ||
459 | + nc_redef(tmID); | ||
460 | + status = nc_put_att_text (tmID, NC_GLOBAL, "ModificationDate", 20, modificationDate); | ||
461 | + nc_enddef(tmID); | ||
462 | + } | ||
463 | + | ||
428 | status = nc_close(tmID); | 464 | status = nc_close(tmID); |
429 | return(0); | 465 | return(0); |
430 | } | 466 | } |
src/DDSERVICES/SOAP/DDserverWeb.php
@@ -144,12 +144,18 @@ function getDatasetsModificationDates() | @@ -144,12 +144,18 @@ function getDatasetsModificationDates() | ||
144 | } | 144 | } |
145 | 145 | ||
146 | // Modification date | 146 | // Modification date |
147 | - | 147 | + $cmd = "/opt/tools/DDServer/bin/GetModificationDate ".$timesFile; |
148 | + exec($cmd, $output, $result_code); | ||
149 | + if ($result_code === 0) | ||
150 | + $modificationDate = $output[0]; | ||
151 | + if (!isset($releaseDate)) | ||
152 | + $releaseDate = $modificationDate; | ||
153 | + | ||
148 | 154 | ||
149 | $result[] = array( | 155 | $result[] = array( |
150 | 'vi' => $viName, | 156 | 'vi' => $viName, |
151 | 'releaseDate' => $releaseDate, | 157 | 'releaseDate' => $releaseDate, |
152 | - 'modificationDate' => "2018-01-01T00:00:00.000Z", | 158 | + 'modificationDate' => $modificationDate, |
153 | ); | 159 | ); |
154 | } | 160 | } |
155 | } | 161 | } |