IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 28, 2007, 12:01:22 PM (19 years ago)
Author:
jhoblitt
Message:

refactor chiptool & db to preserve metadata history

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/backtrack/ippTools/src/chipqueue.c

    r12232 r13990  
    2323
    2424#include "pxtools.h"
    25 #include "pxdata.h"
    2625#include "chiptool.h"
    2726
     
    3029                     psString workdir,
    3130                     psString label,
    32                      psString recipe,
     31                     psString reduction,
    3332                     psString expgroup,
    3433                     psString dvodb)
     
    3635    PS_ASSERT_PTR_NON_NULL(config, false);
    3736
    38     // load the SQL to enqueue our exp_tags from disk once
    39     static psString queuerawexp_query = NULL;
    40     if (!queuerawexp_query) {
    41         queuerawexp_query = pxDataGet("chiptool_queuerawexp.sql");
    42         psMemSetPersistent(queuerawexp_query, true);
    43         if (!queuerawexp_query) {
    44             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    45             return false;
     37    // start a transaction
     38    if (!psDBTransaction(config->dbh)) {
     39        psError(PS_ERR_UNKNOWN, false, "database error");
     40        return false;
     41    }
     42   
     43    // create a chipRun
     44    if (!chipRunInsert(config->dbh,
     45            0x0,
     46            "run",      // state               
     47            workdir,
     48            "dirty",    // workdir_state
     49            label,
     50            reduction,
     51            expgroup,
     52            dvodb)
     53    ) {
     54        // rollback
     55        if (!psDBRollback(config->dbh)) {
     56            psError(PS_ERR_UNKNOWN, false, "database error");
    4657        }
     58        psError(PS_ERR_UNKNOWN, false, "database error");
     59        return false;
    4760    }
    4861
    49     static psString queuerawimfile_query = NULL;
    50     if (!queuerawimfile_query) {
    51         queuerawimfile_query = pxDataGet("chiptool_queuerawimfile.sql");
    52         psMemSetPersistent(queuerawimfile_query, true);
    53         if (!queuerawexp_query) {
    54             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    55             return false;
    56         }
     62#if 0
     63    // get the chip_id
     64    long chip_id = psDBLastInsertID(config->dbh);
     65#endif
     66
     67    // populate the chipPendingImfile table from rawImfile based on exp_tag,
     68    // where the coresponding newExp.state entry is set to stop
     69    psString query = pxDataGetCached("chiptool_queuerawimfile.sql");
     70    if (!query) {
     71        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     72        return false;
    5773    }
    5874
    59     // queue the exp
    60     if (!p_psDBRunQuery(config->dbh, queuerawexp_query,
    61                 workdir  ? workdir  : "NULL",
    62                 label    ? label    : "NULL",
    63                 recipe   ? recipe   : "NULL",
    64                 expgroup ? expgroup : "NULL",
    65                 dvodb    ? dvodb    : "NULL",
    66                 exp_tag
    67     )) {
     75    // queue the imfiles for the exp_tag
     76    if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
    6877        psError(PS_ERR_UNKNOWN, false, "database error");
    6978        return false;
     
    7786    }
    7887
    79     // queue the imfiles for the exp we just queued
    80     if (!p_psDBRunQuery(config->dbh, queuerawimfile_query)) {
     88    // point of no return
     89    if (!psDBCommit(config->dbh)) {
    8190        psError(PS_ERR_UNKNOWN, false, "database error");
    82         return false;
    83     }
    84 
    85     // just to be safe, we should have changed at least one row
    86     if (psDBAffectedRows(config->dbh) < 1) {
    87         psError(PS_ERR_UNKNOWN, false,
    88                 "no rows affected - should have changed at least one row");
    8991        return false;
    9092    }
Note: See TracChangeset for help on using the changeset viewer.