IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2011, 11:55:43 AM (15 years ago)
Author:
bills
Message:

add chiptool -dropprocessedimfile

File:
1 edited

Legend:

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

    r32520 r32573  
    4343static bool revertprocessedimfileMode(pxConfig *config);
    4444static bool updateprocessedimfileMode(pxConfig *config);
     45static bool dropprocessedimfileMode(pxConfig *config);
    4546static bool advanceexpMode(pxConfig *config);
    4647static bool blockMode(pxConfig *config);
     
    8889        MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,   revertprocessedimfileMode);
    8990        MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,   updateprocessedimfileMode);
     91        MODECASE(CHIPTOOL_MODE_DROPPROCESSEDIMFILE,     dropprocessedimfileMode);
    9092        MODECASE(CHIPTOOL_MODE_ADVANCEEXP,              advanceexpMode);
    9193        MODECASE(CHIPTOOL_MODE_BLOCK,                   blockMode);
     
    962964    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    963965    PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    964     PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, NULL);
     966    PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false);
    965967    if (psListLength(where->list) == 0) {
    966968        psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     
    986988
    987989
     990    return true;
     991}
     992
     993// "drop" previously processed components as though the original processing
     994// had poor quality. Sets quality, data_state, clears fault and magicked
     995// Deletes corresponding magicDSFile (if one exists)
     996static bool dropprocessedimfileMode(pxConfig *config)
     997{
     998    PS_ASSERT_PTR_NON_NULL(config, false);
     999
     1000    psMetadata *where = psMetadataAlloc();
     1001    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipProcessedImfile.chip_id", "==");
     1002    PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
     1003    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
     1004    PXOPT_LOOKUP_S16(quality, config->args, "-set_quality", true, false);
     1005
     1006    if (!quality) {
     1007        psError(PXTOOLS_ERR_CONFIG, true, "non-zero quality value is required");
     1008        return false;
     1009    }
     1010
     1011    if (psListLength(where->list) == 0) {
     1012        psError(PXTOOLS_ERR_CONFIG, true, "-chip_id is required");
     1013        return false;
     1014    }
     1015
     1016    psString query = pxDataGet("chiptool_dropprocessedimfile_update.sql");
     1017    if (!query) {
     1018        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1019        return false;
     1020    }
     1021    psString delete_query = pxDataGet("chiptool_dropprocessedimfile_delete.sql");
     1022    if (!delete_query) {
     1023        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1024        return false;
     1025    }
     1026    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1027    psStringAppend(&query, " WHERE %s", whereClause);
     1028    psFree(where);
     1029
     1030    if (!psDBTransaction(config->dbh)) {
     1031        psError(PS_ERR_UNKNOWN, false, "database error");
     1032        return false;
     1033    }
     1034    if (!p_psDBRunQueryF(config->dbh, query, quality)) {
     1035        if (!psDBRollback(config->dbh)) {
     1036            psError(PS_ERR_UNKNOWN, false, "database error on rollback");
     1037        }
     1038        psError(PS_ERR_UNKNOWN, false, "database error");
     1039        psFree(query);
     1040        return false;
     1041    }
     1042    psFree(query);
     1043
     1044    psStringAppend(&delete_query, " AND %s", whereClause);
     1045    psFree(whereClause);
     1046    if (!p_psDBRunQuery(config->dbh, delete_query)) {
     1047        if (!psDBRollback(config->dbh)) {
     1048            psError(PS_ERR_UNKNOWN, false, "database error on rollback");
     1049        }
     1050        psError(PS_ERR_UNKNOWN, false, "database error");
     1051        psFree(delete_query);
     1052        return false;
     1053    }
     1054    psFree(delete_query);
     1055
     1056    if (!psDBCommit(config->dbh)) {
     1057        psError(PS_ERR_UNKNOWN, false, "database error");
     1058        return false;
     1059    }
    9881060    return true;
    9891061}
Note: See TracChangeset for help on using the changeset viewer.