- Timestamp:
- Mar 29, 2009, 6:15:31 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/regtool.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Property svn:ignore
-
old new 32 32 flatcorr 33 33 pstamptool 34 disttool
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.c
r23352 r23594 319 319 320 320 psMetadata *where = psMetadataAlloc(); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 324 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 325 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 324 326 325 327 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 407 409 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 408 410 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 411 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 412 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 409 413 410 414 psString query = pxDataGet("regtool_revertprocessedimfile.sql"); … … 419 423 psStringAppend(&query, " AND %s", whereClause); 420 424 psFree(whereClause); 425 } else { 426 psFree(where); 427 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 428 return false; 421 429 } 422 430 psFree(where); … … 429 437 psFree(query); 430 438 431 if (psDBAffectedRows(config->dbh) < 1) { 432 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 433 return false; 434 } 439 int numUpdated = psDBAffectedRows(config->dbh); 440 441 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawImfile", numUpdated); 435 442 436 443 return true; … … 441 448 { 442 449 PS_ASSERT_PTR_NON_NULL(config, false); 450 451 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 452 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 453 454 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 455 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 456 457 if ((code == INT16_MAX) && !isfinite(user_1)) { 458 psError(PS_ERR_UNKNOWN, false, "one of -code or -user_1 must be selected"); 459 return false; 460 } 461 if ((code != INT16_MAX) && isfinite(user_1)) { 462 psError(PS_ERR_UNKNOWN, false, "only one of -code or -user_1 must be selected"); 463 return false; 464 } 443 465 444 466 psMetadata *where = psMetadataAlloc(); … … 446 468 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 447 469 448 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 449 450 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 451 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 452 psFree (where); 453 return false; 470 if (code != INT16_MAX) { 471 // this is fairly dangerous : can set all if the where is not set... 472 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 473 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 474 psFree (where); 475 return false; 476 } 477 } 478 479 if (isfinite(user_1)) { 480 psString query = pxDataGet("regtool_updateprocessedimfile.sql"); 481 if (!query) { 482 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 483 return false; 484 } 485 486 if (!p_psDBRunQueryF(config->dbh, query, user_1, exp_id, class_id)) { 487 psError(PS_ERR_UNKNOWN, false, "database error"); 488 psFree(query); 489 return false; 490 } 491 psFree(query); 454 492 } 455 493 psFree (where); … … 764 802 hostname, 765 803 code, 766 NULL 804 NULL, 805 0 767 806 )) { 768 807 // rollback … … 806 845 exp_id, 807 846 workdir, 808 label,847 label, 809 848 reduction, 810 849 NULL, // expgroup … … 957 996 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 958 997 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 998 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 999 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 959 1000 960 1001 psString query = pxDataGet("regtool_revertprocessedexp.sql"); … … 968 1009 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); 969 1010 psStringAppend(&query, " AND %s", whereClause); 1011 psFree(whereClause); 1012 } else { 970 1013 psFree(where); 971 psFree(whereClause); 1014 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 1015 return false; 972 1016 } 973 1017 psFree(where); … … 980 1024 psFree(query); 981 1025 982 if (psDBAffectedRows(config->dbh) < 1) { 983 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 984 return false; 985 } 1026 int numUpdated = psDBAffectedRows(config->dbh); 1027 1028 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawExp", numUpdated); 986 1029 987 1030 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
