IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2011, 2:44:12 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110906
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906

  • branches/eam_branches/ipp-20110906/ippTools/src

  • branches/eam_branches/ipp-20110906/ippTools/src/chiptool.c

    r31954 r32630  
    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", false, 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_S64(class_id, config->args, "-class_id", true, false);
     1005    PXOPT_LOOKUP_S16(quality, config->args, "-set_quality", true, false);
     1006
     1007    if (!quality) {
     1008        psError(PXTOOLS_ERR_CONFIG, true, "non-zero quality value is required");
     1009        return false;
     1010    }
     1011
     1012    if (psListLength(where->list) == 0) {
     1013        // won't get here
     1014        psError(PXTOOLS_ERR_CONFIG, true, "-chip_id and -class_id are required");
     1015        return false;
     1016    }
     1017
     1018    psString query = pxDataGet("chiptool_dropprocessedimfile_update.sql");
     1019    if (!query) {
     1020        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1021        return false;
     1022    }
     1023    psString delete_query = pxDataGet("chiptool_dropprocessedimfile_delete.sql");
     1024    if (!delete_query) {
     1025        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1026        return false;
     1027    }
     1028    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1029    psStringAppend(&query, " WHERE %s", whereClause);
     1030    psFree(where);
     1031
     1032    if (!psDBTransaction(config->dbh)) {
     1033        psError(PS_ERR_UNKNOWN, false, "database error");
     1034        return false;
     1035    }
     1036    if (!p_psDBRunQueryF(config->dbh, query, quality)) {
     1037        if (!psDBRollback(config->dbh)) {
     1038            psError(PS_ERR_UNKNOWN, false, "database error on rollback");
     1039        }
     1040        psError(PS_ERR_UNKNOWN, false, "database error");
     1041        psFree(query);
     1042        return false;
     1043    }
     1044    psFree(query);
     1045
     1046    psStringAppend(&delete_query, " AND %s", whereClause);
     1047    psFree(whereClause);
     1048    if (!p_psDBRunQuery(config->dbh, delete_query)) {
     1049        if (!psDBRollback(config->dbh)) {
     1050            psError(PS_ERR_UNKNOWN, false, "database error on rollback");
     1051        }
     1052        psError(PS_ERR_UNKNOWN, false, "database error");
     1053        psFree(delete_query);
     1054        return false;
     1055    }
     1056    psFree(delete_query);
     1057
     1058    if (!psDBCommit(config->dbh)) {
     1059        psError(PS_ERR_UNKNOWN, false, "database error");
     1060        return false;
     1061    }
    9881062    return true;
    9891063}
     
    14181492    psMetadata *where = psMetadataAlloc();
    14191493    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
    1420 
     1494    PXOPT_COPY_S64(config->args, where,  "-chip_id",    "chip_id", "==");
    14211495    // look for completed chipPendingExp
    14221496    // migrate them to chipProccessedExp & camPendingExp
     
    14321506        psFree(whereClause);
    14331507    }
     1508
     1509    psTrace("chiptool", 10, "%s\n", query);
    14341510    psFree(where);
    14351511
Note: See TracChangeset for help on using the changeset viewer.