IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 1, 2010, 12:51:37 PM (16 years ago)
Author:
bills
Message:

When processing root node, insert the streaks object before the node result.
Change -addmask to not set magicRun.state to full. Do that in addresult
if node == 'root' and fault == 0. In revert delete mask objects if the
associted root node is faulted.

File:
1 edited

Legend:

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

    r29553 r29625  
    10591059    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    10601060
     1061    if (!psDBTransaction(config->dbh)) {
     1062        psError(PS_ERR_UNKNOWN, false, "database error");
     1063        return false;
     1064    }
     1065
    10611066    if (!magicNodeResultInsert(config->dbh,
    10621067                               magic_id,
     
    10691074    }
    10701075
     1076    if (fault == 0 && !strcmp(node, "root")) {
     1077        // Set the magicRun state
     1078        psString query = pxDataGet("magictool_setfull.sql");
     1079        if (!query) {
     1080            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1081            if (!psDBRollback(config->dbh)) {
     1082                psError(PS_ERR_UNKNOWN, false, "database error");
     1083            }
     1084            return false;
     1085        }
     1086
     1087        // manually add constraint
     1088        psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);
     1089
     1090        if (!p_psDBRunQuery(config->dbh, query)) {
     1091            psError(PS_ERR_UNKNOWN, false, "database error");
     1092            psFree(query);
     1093            if (!psDBRollback(config->dbh)) {
     1094                psError(PS_ERR_UNKNOWN, false, "database error");
     1095            }
     1096            return false;
     1097        }
     1098        psFree(query);
     1099    }
     1100    if (!psDBCommit(config->dbh)) {
     1101        psError(PS_ERR_UNKNOWN, false, "database error");
     1102        return false;
     1103    }
     1104
    10711105    return true;
    10721106}
     
    10821116    pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "==");
    10831117
    1084     psString query = pxDataGet("magictool_revertnode.sql");
     1118    if (!psListLength(where->list)) {
     1119        psError(PS_ERR_UNKNOWN, false, "search parameters are required");
     1120        psFree(where);
     1121        return false;
     1122    }
     1123    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1124    psFree(where);
     1125
     1126    // don't need a transaction because it is ok if the first query succeeds
     1127    // but the second query does not
     1128    psString query = pxDataGet("magictool_deletemask.sql");
    10851129    if (!query) {
    10861130        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10871131        return false;
    10881132    }
    1089 
    1090     if (psListLength(where->list)) {
    1091         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1092         psStringAppend(&query, " AND %s", whereClause);
     1133    psStringAppend(&query, " AND %s", whereClause);
     1134    if (!p_psDBRunQuery(config->dbh, query)) {
    10931135        psFree(whereClause);
    1094     } else {
    1095         psError(PS_ERR_UNKNOWN, false, "search parameters are required");
    1096         psFree(where);
    1097         return false;
    1098     }
    1099     psFree(where);
     1136        psFree(query);
     1137        psError(PS_ERR_UNKNOWN, false, "failed to delete faulted masks");
     1138        return false;
     1139    }
     1140    psFree(query);
     1141
     1142    query = pxDataGet("magictool_revertnode.sql");
     1143    if (!query) {
     1144        psFree(whereClause);
     1145        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1146        return false;
     1147    }
     1148    psStringAppend(&query, " AND %s", whereClause);
     1149    psFree(whereClause);
    11001150
    11011151    if (!p_psDBRunQuery(config->dbh, query)) {
     1152        psFree(query);
    11021153        psError(PS_ERR_UNKNOWN, false, "failed to revert");
    11031154        return false;
    11041155    }
     1156    psFree(query);
    11051157
    11061158    psS32 numUpdated = psDBAffectedRows(config->dbh);
     
    11801232    // required
    11811233    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
     1234    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    11821235
    11831236    // optional
    1184 //    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
    1185     PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    11861237    PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false);
    1187 
    1188     // default values
    11891238    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    1190 
    1191     if (!psDBTransaction(config->dbh)) {
    1192         psError(PS_ERR_UNKNOWN, false, "database error");
    1193         return false;
    1194     }
    11951239
    11961240    if (!magicMaskInsert(config->dbh,
     
    12051249            psError(PS_ERR_UNKNOWN, false, "database error");
    12061250        }
    1207         return false;
    1208     }
    1209 
    1210     // Set the magicRun state
    1211     psString query = pxDataGet("magictool_addmask.sql");
    1212     if (!query) {
    1213         psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    1214         if (!psDBRollback(config->dbh)) {
    1215             psError(PS_ERR_UNKNOWN, false, "database error");
    1216         }
    1217         return false;
    1218     }
    1219 
    1220     // manually add constraint
    1221     psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);
    1222 
    1223     if (!p_psDBRunQuery(config->dbh, query)) {
    1224         psError(PS_ERR_UNKNOWN, false, "database error");
    1225         psFree(query);
    1226         if (!psDBRollback(config->dbh)) {
    1227             psError(PS_ERR_UNKNOWN, false, "database error");
    1228         }
    1229         return false;
    1230     }
    1231     psFree(query);
    1232 
    1233     if (!psDBCommit(config->dbh)) {
    1234         psError(PS_ERR_UNKNOWN, false, "database error");
    12351251        return false;
    12361252    }
Note: See TracChangeset for help on using the changeset viewer.