IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 5, 2007, 3:16:08 PM (19 years ago)
Author:
jhoblitt
Message:

rename exp_id -> exp_name
rename exp_tag -> exp_id
add add rawExp.exp_tag for use as an external name only

File:
1 edited

Legend:

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

    r12131 r14023  
    161161            "UPDATE summitExp"
    162162            " SET imfiles = %d"
    163             " WHERE exp_id = '%s'"
     163            " WHERE exp_name = '%s'"
    164164            " AND camera = '%s'"
    165165            " AND telescope = '%s'";
     
    178178                "DELETE FROM pzPendingExp"
    179179                " WHERE"
    180                 "   exp_id = '%s'"
     180                "   exp_name = '%s'"
    181181                "   AND camera = '%s'"
    182182                "   AND telescope = '%s'";
     
    220220    {
    221221        char *query =
    222             "CREATE TEMPORARY TABLE incoming (exp_id VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), file_id VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_id, camera, telescope, class, class_id)) ENGINE=MEMORY";
     222            "CREATE TEMPORARY TABLE incoming (exp_name VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), file_id VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_name, camera, telescope, class, class_id)) ENGINE=MEMORY";
    223223
    224224        if (!p_psDBRunQuery(config->dbh, query)) {
     
    235235    // load the imfiles (files) into the temp table
    236236    {
    237         char *query = "INSERT INTO incoming (exp_id, camera, telescope, file_id, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
     237        char *query = "INSERT INTO incoming (exp_name, camera, telescope, file_id, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
    238238
    239239        long inserted = p_psDBRunQueryPrepared(config->dbh, newImfiles, query);
     
    270270            "INSERT INTO pzPendingImfile"
    271271            "   SElECT"
    272             "       incoming.exp_id,"
     272            "       incoming.exp_name,"
    273273            "       incoming.camera,"
    274274            "       incoming.telescope,"
    275275            "       incoming.class,"
    276276            "       incoming.class_id,"
    277             "       NULL" // exp_tag, will be assigned later
     277            "       NULL" // exp_id, will be assigned later
    278278            "   FROM incoming"
    279279            "   JOIN pzPendingExp"
    280             "       USING(exp_id, camera, telescope)"
     280            "       USING(exp_name, camera, telescope)"
    281281            "   LEFT JOIN summitImfile"
    282             "       USING(exp_id, camera, telescope, class, class_id)"
     282            "       USING(exp_name, camera, telescope, class, class_id)"
    283283            "   WHERE"
    284             "       summitImfile.exp_id is NULL"
     284            "       summitImfile.exp_name is NULL"
    285285            "       AND summitImfile.camera is NULL"
    286286            "       AND summitImfile.telescope is NULL"
     
    303303            "INSERT INTO summitImfile"
    304304            "   SElECT"
    305             "       incoming.exp_id,"
     305            "       incoming.exp_name,"
    306306            "       incoming.camera,"
    307307            "       incoming.telescope,"
     
    314314            "   FROM incoming"
    315315            "   LEFT JOIN summitImfile"
    316             "       USING(exp_id, camera, telescope, class, class_id)"
     316            "       USING(exp_name, camera, telescope, class, class_id)"
    317317            "   WHERE"
    318             "       summitImfile.exp_id is NULL"
     318            "       summitImfile.exp_name is NULL"
    319319            "       AND summitImfile.camera is NULL"
    320320            "       AND summitImfile.telescope is NULL"
     
    338338            " SET imfiles = (SELECT COUNT(*) FROM summitImfile"
    339339            "   WHERE"
    340             "       exp_id = '%s'"
     340            "       exp_name = '%s'"
    341341            "       AND camera = '%s'"
    342342            "       AND telescope = '%s'"
    343343            ")"
    344344            " WHERE"
    345             "   exp_id = '%s'"
     345            "   exp_name = '%s'"
    346346            "   AND camera = '%s'"
    347347            "   AND telescope = '%s'";
     
    367367    }
    368368
    369     // copy the summitExp row into newExp in order to create a new exp_tag
    370     {
    371         psString exp_tag = pxGenExpTag(config, filesetid);
    372         if (!exp_tag) {
     369    // copy the summitExp row into newExp in order to create a new exp_id
     370    {
     371        psString exp_id = pxGenExpTag(config, filesetid);
     372        if (!exp_id) {
    373373            // rollback
    374374            if (!psDBRollback(config->dbh)) {
     
    382382            "INSERT INTO newExp"
    383383            "   SElECT"
    384             "       '%s'," // exp_tag
    385             "       summitExp.exp_id,"
     384            "       '%s'," // exp_id
     385            "       summitExp.exp_name,"
    386386            "       summitExp.camera,"
    387387            "       summitExp.telescope,"
     
    392392            "   FROM summitExp"
    393393            "   WHERE"
    394             "       summitExp.exp_id = '%s'"
     394            "       summitExp.exp_name = '%s'"
    395395            "       AND summitExp.camera = '%s'"
    396396            "       AND summitExp.telescope = '%s'";
    397397
    398         if (!p_psDBRunQuery(config->dbh, query, exp_tag, filesetid, camera, telescope)) {
    399             // rollback
    400             if (!psDBRollback(config->dbh)) {
    401                 psError(PS_ERR_UNKNOWN, false, "database error");
    402             }
    403             psError(PS_ERR_UNKNOWN, false, "database error");
    404             psFree(exp_tag);
    405             return false;
    406         }
    407         psFree(exp_tag);
     398        if (!p_psDBRunQuery(config->dbh, query, exp_id, filesetid, camera, telescope)) {
     399            // rollback
     400            if (!psDBRollback(config->dbh)) {
     401                psError(PS_ERR_UNKNOWN, false, "database error");
     402            }
     403            psError(PS_ERR_UNKNOWN, false, "database error");
     404            psFree(exp_id);
     405            return false;
     406        }
     407        psFree(exp_id);
    408408
    409409        // sanity check: we should have inserted only one row
     
    419419    }
    420420 
    421     // set the exp_tag for the imfiles (files) in the exposure (fileset) that
     421    // set the exp_id for the imfiles (files) in the exposure (fileset) that
    422422    // we are investigating
    423423    {
    424424        char *query =
    425425            "UPDATE pzPendingImfile"
    426             " SET exp_tag = (SELECT exp_tag from newExp"
    427             "                WHERE exp_id = '%s'"
     426            " SET exp_id = (SELECT exp_id from newExp"
     427            "                WHERE exp_name = '%s'"
    428428            "                AND camera = '%s'"
    429429            "                AND telescope = '%s')"
    430430            " WHERE"
    431             "   exp_id = '%s'"
     431            "   exp_name = '%s'"
    432432            "   AND camera = '%s'"
    433433            "   AND telescope = '%s'";
     
    450450            "   FROM pzPendingExp"
    451451            "   WHERE"
    452             "       pzPendingExp.exp_id = '%s'"
     452            "       pzPendingExp.exp_name = '%s'"
    453453            "       AND pzPendingExp.camera = '%s'"
    454454            "       AND pzPendingExp.telescope = '%s'";
     
    479479            "DELETE FROM pzPendingExp"
    480480            " WHERE"
    481             "   exp_id = '%s'"
     481            "   exp_name = '%s'"
    482482            "   AND camera = '%s'"
    483483            "   AND telescope = '%s'";
     
    524524    // any work
    525525    bool status = false;
    526     psString exp_id = psMetadataLookupStr(&status, config->args, "-filesetid");
     526    psString exp_name = psMetadataLookupStr(&status, config->args, "-filesetid");
    527527    if (!status) {
    528528        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for '-filesetid'");
    529529        return NULL;
    530530    }
    531     if (!exp_id) {
     531    if (!exp_name) {
    532532        psError(PS_ERR_UNKNOWN, true, "-filesetid is required");
    533533        return NULL;
     
    596596        // create a new metadata to represent this line and it's values
    597597        psMetadata *md = psMetadataAlloc();
    598         if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_id", 0, NULL, exp_id)) {
    599             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     598        if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_name", 0, NULL, exp_name)) {
     599            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name");
    600600            psFree(md);
    601601            psFree(tokenCursor);
Note: See TracChangeset for help on using the changeset viewer.