IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 2, 2007, 3:46:36 PM (19 years ago)
Author:
jhoblitt
Message:

refactor camtool & db to preserve metadata history

File:
1 edited

Legend:

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

    r13937 r13994  
    203203
    204204    // find the chipProcessedExp exposures that we want to queue up.
    205     psString query = psStringCopy("SELECT * FROM chipProcessedExp");
     205//    psString query = psStringCopy("SELECT * FROM chipRun WHERE chipRun.state = 'stop'");
     206    psString query = pxDataGet("camtool_find_chip_id.sql");
     207    if (!query) {
     208        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     209        return false;
     210    }
    206211
    207212    if (where) {
    208         psString whereClause = psDBGenerateWhereSQL(where, "chipProcessedExp");
     213        psString whereClause = psDBGenerateWhereSQL(where, "");
    209214        psFree(where);
    210215        psStringAppend(&query, " %s", whereClause);
     
    245250        psMetadata *md = output->data[i];
    246251
    247         chipProcessedExpRow *row = chipProcessedExpObjectFromMetadata(md);
     252        chipRunRow *row = chipRunObjectFromMetadata(md);
    248253        if (!row) {
    249             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipProcessedExp");
     254            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun");
    250255            psFree(output);
    251256            return false;
     
    601606    }
    602607
    603     // start a transaction so we don't end up with an exp_tag is both
    604     // camPendingExp & camProcessedExp
    605608    if (!psDBTransaction(config->dbh)) {
    606609        psError(PS_ERR_UNKNOWN, false, "database error");
     
    609612    }
    610613
    611     camPendingExpRow *pendingRow = camPendingExpObjectFromMetadata(output->data[0]);
     614    camRunRow *pendingRow = camRunObjectFromMetadata(output->data[0]);
    612615    psFree(output);
    613616    // create a new camProcessedImfile object
     
    615618        pendingRow->cam_id,
    616619        pendingRow->chip_id,
    617         pendingRow->workdir,
    618         pendingRow->label,
    619         pendingRow->reduction,
    620         pendingRow->expgroup,
    621         pendingRow->dvodb,
    622620        uri,
    623621        bg,
     
    637635        code
    638636    );
     637    psFree(pendingRow);
    639638
    640639    // insert the new row into the camProcessedImfile table
     
    646645        psError(PS_ERR_UNKNOWN, false, "database error");
    647646        psFree(row);
    648         psFree(pendingRow);
    649         return false;
    650     }
     647        return false;
     648    }
     649
     650    // since there is only one exp per 'run' set camRun.state = 'stop'
     651    if (!pxcamRunSetState(config, row->cam_id, "stop")) {
     652        psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id);
     653        psFree(row);
     654        return false;
     655    }
     656
    651657    psFree(row);
    652658
    653     // delete the camPendingExp row from the database
    654     if (!camPendingExpDeleteObject(config->dbh, pendingRow)) {
    655         // rollback
    656         if (!psDBRollback(config->dbh)) {
    657             psError(PS_ERR_UNKNOWN, false, "database error");
    658         }
    659         psError(PS_ERR_UNKNOWN, false, "database error");
    660         psFree(pendingRow);
    661         return false;
    662     }
    663 
    664     psFree(pendingRow);
    665 
    666     // point of no return for camPendingExp -> camProcessedExp
    667659    if (!psDBCommit(config->dbh)) {
    668660        psError(PS_ERR_UNKNOWN, false, "database error");
Note: See TracChangeset for help on using the changeset viewer.