IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 2, 2008, 2:05:26 PM (18 years ago)
Author:
bills
Message:

Add modes for transitioning chipProcessedImfiles from full to cleaned
and cleaned to full and full to purged.
Added COLUMN data_state to chipProcessedImfile to record the state.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/chiptool.c

    r19324 r19334  
    5050static bool donecleanupMode(pxConfig *config);
    5151static bool runMode(pxConfig *config);
     52static bool tocleanedimfileMode(pxConfig *config);
     53static bool tofullimfileMode(pxConfig *config);
     54static bool topurgedimfileMode(pxConfig *config);
    5255
    5356static bool chipProcessedCompleteExp(pxConfig *config);
     
    7679        MODECASE(CHIPTOOL_MODE_PROCESSEDIMFILE,         processedimfileMode);
    7780        MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,   revertprocessedimfileMode);
    78         MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,updateprocessedimfileMode);
     81        MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,   updateprocessedimfileMode);
    7982        MODECASE(CHIPTOOL_MODE_BLOCK,                   blockMode);
    8083        MODECASE(CHIPTOOL_MODE_MASKED,                  maskedMode);
     
    8588        MODECASE(CHIPTOOL_MODE_DONECLEANUP,             donecleanupMode);
    8689        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
     90        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
     91        MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
     92        MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
    8793        default:
    8894            psAbort("invalid option (this should not happen)");
     
    334340    PS_ASSERT_PTR_NON_NULL(config, false);
    335341
    336     // chip_id, ext_tag, class_id are required
     342    // chip_id, exp_tag, class_id are required
    337343    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
    338344    PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false);
     
    379385                                   exp_id,
    380386                                   class_id,
     387                                   "full",
    381388                                   uri,
    382389                                   bg,
     
    417424    // XXX I've decided to make the transaction cover the Exp migration as
    418425    // well.  Otherwise, if the last imfile in an exp is moved and the exp
    419     // migration fails then the data base is left in a satuation where the exp
     426    // migration fails then the data base is left in a situation where the exp
    420427    // migration can't happen.
    421428
     
    10691076    return true;
    10701077}
     1078
     1079// update chipProcessedImfile.data_state to given value.
     1080// afterwards, if all imfiles in the exposure have the new state, update the state for the exposure as well
     1081// shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
     1082
     1083static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
     1084{
     1085    PS_ASSERT_PTR_NON_NULL(config, false);
     1086
     1087    // chip_id, class_id are required
     1088    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
     1089    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
     1090
     1091    psString query = pxDataGet("chiptool_change_imfile_data_state.sql");
     1092
     1093    if (!psDBTransaction(config->dbh)) {
     1094        psError(PS_ERR_UNKNOWN, false, "database error");
     1095        return false;
     1096    }
     1097
     1098    // note only updates if chipRun.state = run_state
     1099    if (!p_psDBRunQuery(config->dbh, query, data_state, chip_id, class_id, run_state)) {
     1100        psError(PS_ERR_UNKNOWN, false, "database error");
     1101        // rollback
     1102        if (!psDBRollback(config->dbh)) {
     1103            psError(PS_ERR_UNKNOWN, false, "database error");
     1104        }
     1105        psError(PS_ERR_UNKNOWN, false, "database error");
     1106        return false;
     1107    }
     1108    psFree(query);
     1109
     1110    // XXX Comment copied from addpendingimfile
     1111    // I've decided to make the transaction cover the Exp migration as
     1112    // well.  Otherwise, if the last imfile in an exp is moved and the exp
     1113    // migration fails then the data base is left in a situation where the exp
     1114    // migration can't happen.
     1115
     1116    query = pxDataGet("chiptool_change_exp_state.sql");
     1117    if (!p_psDBRunQuery(config->dbh, query, data_state, chip_id, data_state)) {
     1118        // rollback
     1119        if (!psDBRollback(config->dbh)) {
     1120            psError(PS_ERR_UNKNOWN, false, "database error");
     1121        }
     1122        psError(PS_ERR_UNKNOWN, false, "database error");
     1123        return false;
     1124    }
     1125
     1126    if (!psDBCommit(config->dbh)) {
     1127        psError(PS_ERR_UNKNOWN, false, "database error");
     1128        return false;
     1129    }
     1130
     1131    return true;
     1132}
     1133static bool tocleanedimfileMode(pxConfig *config)
     1134{
     1135    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
     1136}
     1137static bool tofullimfileMode(pxConfig *config)
     1138{
     1139    return change_imfile_data_state(config, "full", "update");
     1140}
     1141static bool topurgedimfileMode(pxConfig *config)
     1142{
     1143    return change_imfile_data_state(config, "purged", "goto_purged");
     1144}
Note: See TracChangeset for help on using the changeset viewer.