IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35365


Ignore:
Timestamp:
Apr 4, 2013, 3:00:07 PM (13 years ago)
Author:
bills
Message:

more support for postage stamp preview mode.

Location:
trunk/ippTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/pstamptool_getdependent.sql

    r28145 r35365  
    11SELECT DISTINCT pstampDependent.*
    22FROM pstampDependent
    3 WHERE pstampDependent.state = 'new'
     3WHERE (pstampDependent.state = 'new' OR pstampDependent.state = 'hold')
  • trunk/ippTools/src/pstamptool.c

    r35357 r35365  
    12341234    PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false);
    12351235    PXOPT_LOOKUP_BOOL(no_create,  config->args, "-no_create", false);
     1236    PXOPT_LOOKUP_BOOL(hold,       config->args, "-hold", false);
    12361237
    12371238    psMetadata *where = psMetadataAlloc();
     
    12651266        psError(PS_ERR_UNKNOWN, false, "database error");
    12661267        psFree(query);
     1268        if (!psDBRollback(config->dbh)) {
     1269            psError(PS_ERR_UNKNOWN, false, "database error");
     1270        }
    12671271        return false;
    12681272    }
     
    12721276    if (!output) {
    12731277        psError(PS_ERR_UNKNOWN, false, "database error");
     1278        if (!psDBRollback(config->dbh)) {
     1279            psError(PS_ERR_UNKNOWN, false, "database error");
     1280        }
    12741281        return false;
    12751282    }
     
    12801287            psError(PS_ERR_UNKNOWN, false, "database error");
    12811288            psFree(output);
     1289            if (!psDBRollback(config->dbh)) {
     1290                psError(PS_ERR_UNKNOWN, false, "database error");
     1291            }
    12821292            return false;
    12831293        }
     
    12851295        if (fault > 0) {
    12861296            fprintf(stderr, "existing dependent has fault %d\n", fault);
     1297            if (!psDBRollback(config->dbh)) {
     1298                psError(PS_ERR_UNKNOWN, false, "database error");
     1299            }
     1300            // return the fault to the client. This is used by the postage stamp parser
    12871301            exit (fault);
    12881302        }
     1303        bool commit = false;
     1304        // Check the state of the exisiting dependent. By query it is either
     1305        // new or hold
     1306        psString state = psMetadataLookupStr(NULL, dep, "state");
     1307        if (!hold && !strcmp(state, "hold")) {
     1308            // There is a dependent for this component but it's state is hold.
     1309            // This client needs one that will run.
     1310            // Update the state
     1311            psString updateQuery = NULL;
     1312            psStringAppend(&updateQuery, "UPDATE pstampDependent SET state = 'new' "
     1313                "\nWHERE stage = '%s' AND imagedb = '%s' AND stage_id = %"PRId64 " AND component = '%s'",
     1314                    stage, imagedb, stage_id, component);
     1315
     1316            if (!p_psDBRunQuery(config->dbh, updateQuery)) {
     1317                psError(PS_ERR_UNKNOWN, false, "database error");
     1318                psFree(updateQuery);
     1319                if (!psDBRollback(config->dbh)) {
     1320                    psError(PS_ERR_UNKNOWN, false, "database error");
     1321                }
     1322                return false;
     1323            }
     1324            // set flag to commit this change
     1325            commit = true;
     1326            psFree(updateQuery);
     1327        }
     1328        // print the dep_id for the user
    12891329        printf("%" PRId64 "\n", dep_id);
    12901330        psFree(output);
    1291         if (!psDBRollback(config->dbh)) {
     1331        // now either commit the change or rollback the transaction which releases the lock
     1332        if (commit) {
     1333            if (!psDBCommit(config->dbh)) {
     1334                // rollback
     1335                if (!psDBRollback(config->dbh)) {
     1336                    psError(PS_ERR_UNKNOWN, false, "database error");
     1337                }
    12921338            psError(PS_ERR_UNKNOWN, false, "database error");
     1339            return false;
     1340            }
     1341        } else if (!psDBRollback(config->dbh)) {
     1342            psError(PS_ERR_UNKNOWN, false, "database error");
     1343            return false;
    12931344        }
    12941345        return true;
     
    13081359        config->dbh,
    13091360        0,              // dep_id
    1310         "new",          // state
     1361        hold ? "hold" : "new",          // state
    13111362        stage,
    13121363        stage_id,
  • trunk/ippTools/src/pstamptoolConfig.c

    r35318 r35365  
    223223    psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-need_magic", 0, "define need_magic", false);
    224224    psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-outdir", 0,    "define output directory for dependent (required)", NULL);
     225    psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-hold", 0, "if creating new dependent set it's state to hold", false);
    225226    psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no matching dependent do not create one", false);
    226227
Note: See TracChangeset for help on using the changeset viewer.