IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19702


Ignore:
Timestamp:
Sep 23, 2008, 12:43:04 PM (18 years ago)
Author:
bills
Message:

added modes to change imfile state for cleanup,update,purge processing

Location:
trunk/ippTools
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/Makefile.am

    r19521 r19702  
    7979     difftool_skyfile.sql \
    8080     difftool_todiffskyfile.sql \
     81     faketool_change_exp_state.sql \
     82     faketool_change_imfile_data_state.sql \
    8183     faketool_completely_processed_exp.sql \
    8284     faketool_donecleanup.sql \
  • trunk/ippTools/share/chiptool_change_exp_state.sql

    r19527 r19702  
    11-- change state of chipRun from goto_cleaned to cleaned or goto_purged to purged
    2 -- when all of the consituant imfiles are in the rgith state
     2-- when all of the constituant imfiles are in the right state
    33-- arguments are new state (cleaned or purged) chip_id and new state again for
    44-- the chipProcessedImfile sub query
  • trunk/ippTools/src/faketool.c

    r19592 r19702  
    4848static bool pendingcleanupimfileMode(pxConfig *config);
    4949static bool donecleanupMode(pxConfig *config);
     50static bool tocleanedimfileMode(pxConfig *config);
     51static bool tofullimfileMode(pxConfig *config);
     52static bool topurgedimfileMode(pxConfig *config);
    5053
    5154static bool fakeProcessedCompleteExp(pxConfig *config);
     
    8386        MODECASE(FAKETOOL_MODE_PENDINGCLEANUPIMFILE,    pendingcleanupimfileMode);
    8487        MODECASE(FAKETOOL_MODE_DONECLEANUP,             donecleanupMode);
     88        MODECASE(FAKETOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
     89        MODECASE(FAKETOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
     90        MODECASE(FAKETOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
     91 
    8592        default:
    8693            psAbort("invalid option (this should not happen)");
     
    11291136    return true;
    11301137}
     1138
     1139// update fakeProcessedImfile.data_state to given value.
     1140// afterwards, if all imfiles in the exposure have the new state, update the state for the exposure as well
     1141// shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
     1142
     1143static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
     1144{
     1145    PS_ASSERT_PTR_NON_NULL(config, false);
     1146
     1147    // fake_id, class_id are required
     1148    PXOPT_LOOKUP_S64(fake_id, config->args, "-fake_id", true, false);
     1149    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
     1150
     1151    psString query = pxDataGet("faketool_change_imfile_data_state.sql");
     1152
     1153    if (!psDBTransaction(config->dbh)) {
     1154        psError(PS_ERR_UNKNOWN, false, "database error");
     1155        return false;
     1156    }
     1157
     1158    // note only updates if fakeRun.state = run_state
     1159    if (!p_psDBRunQuery(config->dbh, query, data_state, fake_id, class_id, run_state)) {
     1160        psError(PS_ERR_UNKNOWN, false, "database error");
     1161        // rollback
     1162        if (!psDBRollback(config->dbh)) {
     1163            psError(PS_ERR_UNKNOWN, false, "database error");
     1164        }
     1165        psError(PS_ERR_UNKNOWN, false, "database error");
     1166        return false;
     1167    }
     1168    psFree(query);
     1169
     1170    if (psDBAffectedRows(config->dbh) < 1) {
     1171        psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
     1172        return false;
     1173    }
     1174   
     1175    query = pxDataGet("faketool_change_exp_state.sql");
     1176    if (!p_psDBRunQuery(config->dbh, query, data_state, fake_id, data_state)) {
     1177        // rollback
     1178        if (!psDBRollback(config->dbh)) {
     1179            psError(PS_ERR_UNKNOWN, false, "database error");
     1180        }
     1181        psError(PS_ERR_UNKNOWN, false, "database error");
     1182        return false;
     1183    }
     1184
     1185    if (!psDBCommit(config->dbh)) {
     1186        psError(PS_ERR_UNKNOWN, false, "database error");
     1187        return false;
     1188    }
     1189
     1190    return true;
     1191}
     1192static bool tocleanedimfileMode(pxConfig *config)
     1193{
     1194    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
     1195}
     1196static bool tofullimfileMode(pxConfig *config)
     1197{
     1198    return change_imfile_data_state(config, "full", "update");
     1199}
     1200static bool topurgedimfileMode(pxConfig *config)
     1201{
     1202    return change_imfile_data_state(config, "purged", "goto_purged");
     1203}
  • trunk/ippTools/src/faketool.h

    r19092 r19702  
    4141    FAKETOOL_MODE_PENDINGCLEANUPIMFILE,
    4242    FAKETOOL_MODE_DONECLEANUP,
     43    FAKETOOL_MODE_TOCLEANEDIMFILE,
     44    FAKETOOL_MODE_TOFULLIMFILE,
     45    FAKETOOL_MODE_TOPURGEDIMFILE,
    4346} FAKETOOLMode;
    4447
  • trunk/ippTools/src/faketoolConfig.c

    r19592 r19702  
    278278    psMetadataAddBool(donecleanupArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
    279279    psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     280    // -tocleanedimfile
     281    psMetadata *tocleanedimfileArgs = psMetadataAlloc();
     282    psMetadataAddS64(tocleanedimfileArgs, PS_LIST_TAIL, "-fake_id", 0,          "fake ID to update", 0);
     283    psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     284
     285    // -tofullimfile
     286    psMetadata *tofullimfileArgs = psMetadataAlloc();
     287    psMetadataAddS64(tofullimfileArgs, PS_LIST_TAIL, "-fake_id", 0,          "fake ID to update", 0);
     288    psMetadataAddStr(tofullimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     289
     290    // -topurgedimfile
     291    psMetadata *topurgedimfileArgs = psMetadataAlloc();
     292    psMetadataAddS64(topurgedimfileArgs, PS_LIST_TAIL, "-fake_id", 0,          "fake ID to update", 0);
     293    psMetadataAddStr(topurgedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     294
     295
    280296
    281297    psMetadata *argSets = psMetadataAlloc();
     
    297313    PXOPT_ADD_MODE("-pendingcleanupimfile",  "show runs that need to be cleaned up", FAKETOOL_MODE_PENDINGCLEANUPIMFILE, pendingcleanupimfileArgs);
    298314    PXOPT_ADD_MODE("-donecleanup",           "show runs that have been cleaned",     FAKETOOL_MODE_DONECLEANUP,          donecleanupArgs);
     315    PXOPT_ADD_MODE("-tocleanedimfile",      "set imfile state to cleaned",           FAKETOOL_MODE_TOCLEANEDIMFILE,      tocleanedimfileArgs);
     316    PXOPT_ADD_MODE("-tofullimfile",        "set imfile state to full",               FAKETOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
     317    PXOPT_ADD_MODE("-topurgedimfile",      "set imfile state to purged",             FAKETOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
     318
    299319
    300320    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.