IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.