IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 28, 2006, 5:25:54 PM (20 years ago)
Author:
jhoblitt
Message:

require ippdb 0.0.38
the "big" exp_id -> exp_tag conversion

File:
1 edited

Legend:

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

    r9028 r9057  
    7272        "SELECT newExp.*"
    7373        "   FROM newExp"
    74         " LEFT JOIN newImfile USING(exp_id)"
    75         " LEFT JOIN rawScienceExp USING(exp_id)"
    76         " LEFT JOIN rawDetrendExp USING(exp_id)"
     74        " LEFT JOIN newImfile USING(exp_tag)"
     75        " LEFT JOIN rawScienceExp USING(exp_tag)"
     76        " LEFT JOIN rawDetrendExp USING(exp_tag)"
    7777        " WHERE"
    78         "   newExp.exp_id IS NOT NULL"
    79         "   AND newImfile.exp_id IS NULL"
    80         "   AND rawScienceExp.exp_id IS NULL"
     78        "   newExp.exp_tag IS NOT NULL"
     79        "   AND newImfile.exp_tag IS NULL"
     80        "   AND rawScienceExp.exp_tag IS NULL"
    8181        "   AND newExp.imfiles ="
    82         "   (SELECT COUNT(exp_id) FROM rawImfile"
    83         "       WHERE rawImfile.exp_id = newExp.exp_id)"
     82        "   (SELECT COUNT(exp_tag) FROM rawImfile"
     83        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
    8484        ;
    8585
     
    123123
    124124    // select newImfiles that:
    125     // exp_id is in newExp
    126     // don't have their exp_id in rawScienceExp
    127     // don't have their exp_id in rawDetrendExp
    128     // XXX having the same exp_id in newExp and raw*Exp is probably an error
     125    // exp_tag is in newExp
     126    // don't have their exp_tag in rawScienceExp
     127    // don't have their exp_tag in rawDetrendExp
     128    // XXX having the same exp_tag in newExp and raw*Exp is probably an error
    129129    // that should be checked for
    130130    char *query =
    131131        "SELECT newImfile.* FROM newImfile"
    132         " LEFT JOIN newExp USING(exp_id)"
    133         " LEFT JOIN rawScienceExp USING(exp_id)"
    134         " LEFT JOIN rawDetrendExp USING (exp_id)"
    135         " WHERE newExp.exp_id is NOT NULL"
    136         " AND rawScienceExp.exp_id IS NULL"
    137         " AND rawDetrendExp.exp_id IS NULL";
     132        " LEFT JOIN newExp USING(exp_tag)"
     133        " LEFT JOIN rawScienceExp USING(exp_tag)"
     134        " LEFT JOIN rawDetrendExp USING (exp_tag)"
     135        " WHERE newExp.exp_tag is NOT NULL"
     136        " AND rawScienceExp.exp_tag IS NULL"
     137        " AND rawDetrendExp.exp_tag IS NULL";
    138138
    139139    if (!p_psDBRunQuery(config->dbh, query)) {
     
    175175    PS_ASSERT_PTR_NON_NULL(config, false);
    176176
    177     // make sure that the exp_id(s) are ready to be updated based on:
    178     // exp_id is not in rawScienceExp
    179     // exp_id is not in rawDetrendExp
    180     // exp_id is not in newImfile
     177    // make sure that the exp_tag(s) are ready to be updated based on:
     178    // exp_tag is not in rawScienceExp
     179    // exp_tag is not in rawDetrendExp
     180    // exp_tag is not in newImfile
    181181    // that the correct count of imfiles is in rawImfile
    182182
     
    184184        "SELECT newExp.*"
    185185        "   FROM newExp"
    186         " LEFT JOIN newImfile USING(exp_id)"
    187         " LEFT JOIN rawScienceExp USING(exp_id)"
    188         " LEFT JOIN rawDetrendExp USING(exp_id)"
     186        " LEFT JOIN newImfile USING(exp_tag)"
     187        " LEFT JOIN rawScienceExp USING(exp_tag)"
     188        " LEFT JOIN rawDetrendExp USING(exp_tag)"
    189189        " WHERE"
    190         "   newExp.exp_id IS NOT NULL"
    191         "   AND newImfile.exp_id IS NULL"
    192         "   AND rawScienceExp.exp_id IS NULL"
     190        "   newExp.exp_tag IS NOT NULL"
     191        "   AND newImfile.exp_tag IS NULL"
     192        "   AND rawScienceExp.exp_tag IS NULL"
    193193        "   AND newExp.imfiles ="
    194         "   (SELECT COUNT(exp_id) FROM rawImfile"
    195         "       WHERE rawImfile.exp_id = newExp.exp_id)"
     194        "   (SELECT COUNT(exp_tag) FROM rawImfile"
     195        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
    196196        );
    197197
    198198    {       
    199199        bool status = false;
    200         psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     200        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
    201201        if (!status) {
    202             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     202            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    203203            psFree(query);
    204204            return false;
    205205        }
    206         if (exp_id) {
    207             psStringAppend(&query, " AND newExp.exp_id = '%s'", exp_id);
     206        if (exp_tag) {
     207            psStringAppend(&query, " AND newExp.exp_tag = '%s'", exp_tag);
    208208        }
    209209    }
     
    359359        psArray *rawImfiles = NULL;
    360360        {
    361             // build a query to search by exp_id
     361            // build a query to search by exp_tag
    362362            psMetadata *where = psMetadataAlloc();
    363             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", newExp->exp_id)) {
     363            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", newExp->exp_tag)) {
    364364                // rollback
    365365                if (!psDBRollback(config->dbh)) {
    366366                    psError(PS_ERR_UNKNOWN, false, "database error");
    367367                }
    368                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     368                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    369369                psFree(where);
    370370                psFree(newExp);
     
    381381                psError(PS_ERR_UNKNOWN, false, "database error");
    382382            }
    383             psError(PS_ERR_UNKNOWN, false, "found no rawImfiles associated with exp_id %s", newExp->exp_id);
     383            psError(PS_ERR_UNKNOWN, false, "found no rawImfiles associated with exp_tag %s", newExp->exp_tag);
    384384            psFree(newExp);
    385385            psFree(output);
     
    439439        "SELECT * FROM"
    440440            " (SELECT newImfile.* FROM newImfile"
    441                 " LEFT JOIN newExp USING(exp_id)"
    442                 " LEFT JOIN rawScienceExp USING(exp_id)"
    443                 " LEFT JOIN rawDetrendExp USING (exp_id)"
    444                 " WHERE newExp.exp_id IS NOT NULL"
    445                 " AND rawScienceExp.exp_id IS NULL"
    446                 " AND rawDetrendExp.exp_id IS NULL) AS foo"
    447         ); // WHERE class is generated from exp_id, class, & class_id
     441                " LEFT JOIN newExp USING(exp_tag)"
     442                " LEFT JOIN rawScienceExp USING(exp_tag)"
     443                " LEFT JOIN rawDetrendExp USING (exp_tag)"
     444                " WHERE newExp.exp_tag IS NOT NULL"
     445                " AND rawScienceExp.exp_tag IS NULL"
     446                " AND rawDetrendExp.exp_tag IS NULL) AS foo"
     447        ); // WHERE class is generated from exp_tag, class, & class_id
    448448
    449449    {
    450         // build a query to search by exp_id, class, class_id
     450        // build a query to search by exp_tag, class, class_id
    451451        psMetadata *where = psMetadataAlloc();
    452452        bool status = false;
    453         psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     453        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
    454454        if (!status) {
    455             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     455            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    456456            psFree(query);
    457457            return false;
    458458        }
    459         if (exp_id) {
    460             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
    461                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     459        if (exp_tag) {
     460            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
     461                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    462462                psFree(where);
    463463                psFree(query);
     
    619619{
    620620    return p1PendingExpRowAlloc(
    621         newExp->exp_id,
     621        newExp->exp_tag,
    622622        newExp->camera,
    623623        newExp->telescope,
     
    642642
    643643    return p2PendingExpRowAlloc(
    644         exp->exp_id,
     644        exp->exp_tag,
    645645        "my recipe",
    646646        0xff, // XXX calc version number
     
    652652{
    653653    return p2PendingImfileRowAlloc(
    654         rawImfile->exp_id,
     654        rawImfile->exp_tag,
    655655        rawImfile->class_id,
    656656        rawImfile->uri,
     
    796796
    797797    return rawDetrendExpRowAlloc(
    798         exp->exp_id,
     798        exp->exp_tag,
    799799        exp->camera,
    800800        exp->telescope,
     
    941941
    942942    return rawImfileRowAlloc(
    943         imfile->exp_id,
     943        imfile->exp_tag,
    944944        imfile->class,
    945945        imfile->class_id,
Note: See TracChangeset for help on using the changeset viewer.