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/dettool.c

    r9046 r9057  
    127127
    128128     psString query = psStringCopy("SELECT rawDetrendExp.* FROM rawDetrendExp"
    129         " LEFT JOIN detInputExp ON rawDetrendExp.exp_id = detInputExp.exp_id"
    130         " WHERE detInputExp.exp_id IS NULL");
     129        " LEFT JOIN detInputExp ON rawDetrendExp.exp_tag = detInputExp.exp_tag"
     130        " WHERE detInputExp.exp_tag IS NULL");
    131131
    132132    if (config->where) {
     
    190190    }
    191191
    192     // we have to support multipe exp_ids
    193     psMetadataItem *item = psMetadataLookup(config->args, "-exp_id");
     192    // we have to support multipe exp_tags
     193    psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag");
    194194    if (!item) {
    195195        // this shouldn't actually happen when using psArgs
    196         psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
     196        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
    197197        return false;
    198198    }
    199199    psMetadata *where = psMetadataAlloc();
    200200
    201     // make sure that -exp_id was parsed correctly
     201    // make sure that -exp_tag was parsed correctly
    202202    // XXX this can be removed someday
    203203    if (item->type == PS_DATA_METADATA_MULTI) {
     
    205205        psMetadataItem *mItem = NULL;
    206206        while ((mItem = psListGetAndIncrement(iter))) {
    207             psString exp_id = mItem->data.V;
    208             // if exp_id is NULL then it means that -exp_id has not been
     207            psString exp_tag = mItem->data.V;
     208            // if exp_tag is NULL then it means that -exp_tag has not been
    209209            // specified
    210             if (!exp_id) {
     210            if (!exp_tag) {
    211211                psError(PS_ERR_UNKNOWN, true,
    212                         "at least one -exp_id is required");
     212                        "at least one -exp_tag is required");
    213213                psFree(where);
    214214                return false;
    215215            }
    216216
    217             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
    218                  PS_META_DUPLICATE_OK, "==", exp_id)) {
    219                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     217            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
     218                 PS_META_DUPLICATE_OK, "==", exp_tag)) {
     219                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    220220                psFree(iter);
    221221                psFree(where);
     
    226226    } else {
    227227        psAbort(config->argv[0],
    228                 "-exp_id was not parsed correctly (this should not happen");
     228                "-exp_tag was not parsed correctly (this should not happen");
    229229    }
    230230
     
    234234    }
    235235
    236     // check that the specified exp_ids actually exist
     236    // check that the specified exp_tags actually exist
    237237    psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0);
    238238    psFree(where);
     
    242242    }
    243243
    244     // we should have one rawDetrendExp row per exp_id specified
     244    // we should have one rawDetrendExp row per exp_tag specified
    245245    if (psListLength(item->data.list) != psArrayLength(detrendExps)) {
    246246        psAbort(config->argv[0],
    247     "an -exp_id matched more then one rawDetrendExp (this should not happen");
     247    "an -exp_tag matched more then one rawDetrendExp (this should not happen");
    248248
    249249    }
     
    717717        det_id,
    718718        iteration,
    719         rawExp->exp_id,
     719        rawExp->exp_tag,
    720720        true            // use
    721721    );
     
    729729    // select rawDetrendExp.*
    730730    // by:
    731     // exp_id
     731    // exp_tag
    732732
    733733    psString query = psStringCopy(
     
    735735        " FROM detInputExp"
    736736        " JOIN rawDetrendExp"
    737         " USING(exp_id)"
     737        " USING(exp_tag)"
    738738        );
    739739
     
    789789    //
    790790    // det_id is in detInputExp
    791     // exp_id is in detInputExp
     791    // exp_tag is in detInputExp
    792792    // det_id is not in detProccessedImfile
    793     // exp_id is not in detProccessedImfile
     793    // exp_tag is not in detProccessedImfile
    794794    // class_is is not in detProccessedImfile
    795795    psString query = psStringCopy(
    796796            "SELECT detInputExp.det_id, detRun.det_type, rawImfile.*"
    797797            " FROM rawImfile"
    798             " LEFT JOIN detInputExp USING(exp_id) "
     798            " LEFT JOIN detInputExp USING(exp_tag) "
    799799            " LEFT JOIN detRun ON detInputExp.det_id = detRun.position"
    800800            " LEFT JOIN detProcessedImfile"
    801801                " ON detInputExp.det_id = detProcessedImfile.det_id"
    802                 " AND rawImfile.exp_id = detProcessedImfile.exp_id"
     802                " AND rawImfile.exp_tag = detProcessedImfile.exp_tag"
    803803                " AND rawImfile.class_id = detProcessedImfile.class_id"
    804804            " WHERE"
    805805            " detInputExp.det_id IS NOT NULL"
    806             " AND detInputExp.exp_id IS NOT NULL"
     806            " AND detInputExp.exp_tag IS NOT NULL"
    807807            " AND detProcessedImfile.det_id IS NULL"
    808             " AND detProcessedImfile.exp_id IS NULL"
     808            " AND detProcessedImfile.exp_tag IS NULL"
    809809            " AND detProcessedImfile.class_id IS NULL"
    810810        );
     
    861861    }
    862862
    863     // select exp_ids from detInputExp matching det_idp
     863    // select exp_tags from detInputExp matching det_idp
    864864    // where query should be pre-generated
    865865    psArray *detInputExp =
     
    870870    }
    871871
    872     // generate where query with just the exp_ids
    873     psMetadata *where_exp_ids = psMetadataAlloc();
     872    // generate where query with just the exp_tags
     873    psMetadata *where_exp_tags = psMetadataAlloc();
    874874    for (long i = 0; i < psArrayLength(detInputExp); i++) {
    875875        detInputExpRow *row = detInputExp->data[i];
    876         if (!psMetadataAddStr(where_exp_ids, PS_LIST_TAIL, "exp_id",
    877                 PS_META_DUPLICATE_OK, "==", row->exp_id)
     876        if (!psMetadataAddStr(where_exp_tags, PS_LIST_TAIL, "exp_tag",
     877                PS_META_DUPLICATE_OK, "==", row->exp_tag)
    878878        ) {
    879             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     879            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    880880            psFree(detInputExp);
    881             psFree(where_exp_ids);
     881            psFree(where_exp_tags);
    882882            return NULL;
    883883        }
     
    885885    psFree(detInputExp);
    886886
    887     // select rawImfiles with matching exp_ids
     887    // select rawImfiles with matching exp_tags
    888888    psArray *rawImfiles =
    889         rawImfileSelectRowObjects(config->dbh, where_exp_ids, 0);
    890     psFree(where_exp_ids);
     889        rawImfileSelectRowObjects(config->dbh, where_exp_tags, 0);
     890    psFree(where_exp_tags);
    891891    if (!rawImfiles) {
    892892        psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found");
     
    901901    PS_ASSERT_PTR_NON_NULL(config, false);
    902902
    903     // det_id, exp_id, class_id, uri, recipe, -bg, -bg_stdev, & -bg_mean_stdev
     903    // det_id, exp_tag, class_id, uri, recipe, -bg, -bg_stdev, & -bg_mean_stdev
    904904    // are required
    905905    bool status = false;
     
    913913        return false;
    914914    }
    915     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
    916     if (!status) {
    917         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
    918         return false;
    919     }
    920     if (!exp_id) {
    921         psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
     915    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     916    if (!status) {
     917        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
     918        return false;
     919    }
     920    if (!exp_tag) {
     921        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
    922922        return false;
    923923    }
     
    988988    }
    989989
    990     // find the matching rawImfile by exp_id/class_id
     990    // find the matching rawImfile by exp_tag/class_id
    991991    psMetadata *where = psMetadataAlloc();
    992     if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
    993         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     992    if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
     993        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    994994        psFree(where);
    995995        return false;
     
    10111011    detProcessedImfileRow *detRow = detProcessedImfileRowAlloc(
    10121012        (psS32)atol(det_id),
    1013         exp_id,
     1013        exp_tag,
    10141014        class_id,
    10151015        uri,
     
    10441044    // by:
    10451045    // find the current iteration bassed on det_id
    1046     // find all exp_ids in the current det_id/iteration from detInputExp
    1047     // find all rawImfiles in the current exp_ids
    1048     // compare to detProcessedImfiles by det_id/exp_id
     1046    // find all exp_tags in the current det_id/iteration from detInputExp
     1047    // find all rawImfiles in the current exp_tags
     1048    // compare to detProcessedImfiles by det_id/exp_tag
    10491049    // found how many imfile there are in each class_id
    10501050    // and:
     
    10651065        "    AND detRun.iteration = detInputExp.iteration"
    10661066        " JOIN rawDetrendExp"
    1067         "    ON detInputExp.exp_id = rawDetrendExp.exp_id"
     1067        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    10681068        " JOIN detProcessedImfile"
    10691069        "    ON detInputExp.det_id = detProcessedImfile.det_id"
    1070         "    AND detInputExp.exp_id = detProcessedImfile.exp_id"
     1070        "    AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
    10711071        " LEFT JOIN detStackedImfile"
    10721072        "    ON detInputExp.det_id = detStackedImfile.det_id"
     
    10741074        "    AND detProcessedImfile.class_id = detStackedImfile.class_id"
    10751075        " LEFT JOIN rawImfile"
    1076         "    ON detInputExp.exp_id = rawImfile.exp_id"
     1076        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
    10771077        "    AND detProcessedImfile.class_id = rawImfile.class_id"
    10781078        " WHERE"
     
    11651165        // det_id is not in detStackedImfile
    11661166        // iteration is not in detStackedImfile
    1167         // detProcessedImfile.exp_id is not in detStackedImfile
     1167        // detProcessedImfile.exp_tag is not in detStackedImfile
    11681168        // detProcessedImfile.class_id is not in detStackedImfile
    11691169        // and detInputExp.include is 1
     
    11801180            "       ON detRun.position = detInputExp.det_id"
    11811181            "       AND detRun.iteration = detInputExp.iteration"
    1182             "       AND detProcessedImfile.exp_id = detInputExp.exp_id"
     1182            "       AND detProcessedImfile.exp_tag = detInputExp.exp_tag"
    11831183            "   LEFT JOIN detStackedImfile"
    11841184            "       ON detRun.position = detStackedImfile.det_id"
     
    12671267    // remove detStackedImfiles unless -unmask
    12681268    if (!psMetadataLookupBool(&status, config->args, "-unmask")) {
    1269         // detStackedImfiles doesn't have an exp_id so we have to generate the
     1269        // detStackedImfiles doesn't have an exp_tag so we have to generate the
    12701270        // where query ourselves
    12711271        bool status = false;
     
    12931293            if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
    12941294                    (psS32)atoi(det_id))) {
    1295                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     1295                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    12961296                psFree(where);
    12971297                return false;
     
    15821582    if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
    15831583            (psS32)atoi(det_id))) {
    1584         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     1584        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    15851585        psFree(where);
    15861586        return false;
     
    17941794    // by:
    17951795    // find the current iteration bassed on det_id
    1796     // find all exp_ids in the current det_id/iteration from detInputExp
     1796    // find all exp_tags in the current det_id/iteration from detInputExp
    17971797    // sort to detInputExp.imfiles to find the largest value per det_id/iter
    17981798    // compare imfiles to the number of detStackedImfiles by class_id
     
    18121812        "     AND detRun.iteration = detInputExp.iteration"
    18131813        " LEFT JOIN rawDetrendExp"
    1814         "     ON detInputExp.exp_id = rawDetrendExp.exp_id"
     1814        "     ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    18151815        " LEFT JOIN detStackedImfile"
    18161816        "     ON detInputExp.det_id = detStackedImfile.det_id"
     
    18191819        "   detStackedImfile.normalize = 1"
    18201820        " GROUP BY"
    1821         "     rawDetrendExp.exp_id"
     1821        "     rawDetrendExp.exp_tag"
    18221822        " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)"
    18231823        );
     
    21062106        psMetadata *where = psMetadataAlloc();
    21072107        for (long i = 0; i < psArrayLength(inputExps); i++) {
    2108             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
     2108            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
    21092109                    PS_META_DUPLICATE_OK, "==",
    2110                     ((detInputExpRow *)inputExps->data[i])->exp_id)) {
    2111                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     2110                    ((detInputExpRow *)inputExps->data[i])->exp_tag)) {
     2111                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    21122112                psFree(inputExps);
    21132113                psFree(where);
     
    23122312        " JOIN detProcessedImfile"
    23132313        "   ON detRun.position = detProcessedImfile.det_id"
    2314         "   AND detInputExp.exp_id = detProcessedImfile.exp_id"
     2314        "   AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
    23152315        " JOIN detNormalizedImfile"
    23162316        "   ON detRun.position = detNormalizedImfile.det_id"
     
    23202320        "   ON detRun.position = detResidImfile.det_id"
    23212321        "   AND detRun.iteration = detResidImfile.iteration"
    2322         "   AND detProcessedImfile.exp_id = detResidImfile.exp_id"
     2322        "   AND detProcessedImfile.exp_tag = detResidImfile.exp_tag"
    23232323        "   AND detProcessedImfile.class_id = detResidImfile.class_id"
    23242324        " WHERE"
    23252325        "   detResidImfile.det_id IS NULL"
    23262326        "   AND detResidImfile.iteration IS NULL"
    2327         "   AND detResidImfile.exp_id IS NULL"
     2327        "   AND detResidImfile.exp_tag IS NULL"
    23282328        "   AND detResidImfile.class_id IS NULL"
    23292329        " UNION"
     
    23392339        " JOIN detProcessedImfile"
    23402340        "   ON detRun.position = detProcessedImfile.det_id"
    2341         "   AND detInputExp.exp_id = detProcessedImfile.exp_id"
     2341        "   AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
    23422342        " JOIN detStackedImfile"
    23432343        "   ON detRun.position = detStackedImfile.det_id"
     
    23472347        "   ON detRun.position = detResidImfile.det_id"
    23482348        "   AND detRun.iteration = detResidImfile.iteration"
    2349         "   AND detProcessedImfile.exp_id = detResidImfile.exp_id"
     2349        "   AND detProcessedImfile.exp_tag = detResidImfile.exp_tag"
    23502350        "   AND detStackedImfile.class_id = detResidImfile.class_id"
    23512351        " WHERE"
    23522352        "   detResidImfile.det_id IS NULL"
    23532353        "   AND detResidImfile.iteration IS NULL"
    2354         "   AND detResidImfile.exp_id IS NULL"
     2354        "   AND detResidImfile.exp_tag IS NULL"
    23552355        "   AND detResidImfile.class_id IS NULL"
    23562356        "   AND detStackedImfile.normalize = 0"
     
    25712571
    25722572    // make sure that there is a coresponding entry in detNormalizedImfile
    2573     // and the exp_id specified is valid
     2573    // and the exp_tag specified is valid
    25742574    // select * from detNormalizedImfile
    25752575    // by det_id, iteration, class_id
     
    25882588        "   ON detNormalizedImfile.det_id = detResidImfile.det_id"
    25892589        "   AND detNormalizedImfile.iteration= detResidImfile.iteration"
    2590         "   AND detInputExp.exp_id = detResidImfile.exp_id"
     2590        "   AND detInputExp.exp_tag = detResidImfile.exp_tag"
    25912591        "   AND detNormalizedImfile.class_id = detResidImfile.class_id"
    25922592        " WHERE"
    25932593        "  detResidImfile.det_id IS NULL"
    25942594        "  AND detResidImfile.iteration IS NULL"
    2595         "  AND detResidImfile.exp_id IS NULL"
     2595        "  AND detResidImfile.exp_tag IS NULL"
    25962596        "  AND detResidImfile.class_id IS NULL"
    2597         "  AND detInputExp.exp_id = '%s'"
     2597        "  AND detInputExp.exp_tag = '%s'"
    25982598        " UNION"
    25992599        " SELECT"
     
    26082608        "   ON detStackedImfile.det_id = detResidImfile.det_id"
    26092609        "   AND detStackedImfile.iteration= detResidImfile.iteration"
    2610         "   AND detInputExp.exp_id = detResidImfile.exp_id"
     2610        "   AND detInputExp.exp_tag = detResidImfile.exp_tag"
    26112611        "   AND detStackedImfile.class_id = detResidImfile.class_id"
    26122612        " WHERE"
    26132613        "   detResidImfile.det_id IS NULL"
    26142614        "   AND detResidImfile.iteration IS NULL"
    2615         "   AND detResidImfile.exp_id IS NULL"
     2615        "   AND detResidImfile.exp_tag IS NULL"
    26162616        "   AND detResidImfile.class_id IS NULL"
    2617         "   AND detInputExp.exp_id = '%s'"
     2617        "   AND detInputExp.exp_tag = '%s'"
    26182618        "   AND detStackedImfile.normalize = 0"
    26192619        " ) as detNormStackedImfile"
     
    26782678    }
    26792679
    2680     // exp_id is manadatory to cross check that this is a exp_id for this
     2680    // exp_tag is manadatory to cross check that this is a exp_tag for this
    26812681    // detRUn
    26822682    bool status = false;
    2683     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
    2684     if (!status) {
    2685         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     2683    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     2684    if (!status) {
     2685        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    26862686        psFree(query);
    26872687        return false;
    26882688    }
    2689     if (!exp_id) {
    2690         psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
     2689    if (!exp_tag) {
     2690        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
    26912691        psFree(query);
    26922692        return false;
    26932693    }
    26942694
    2695     if (!p_psDBRunQuery(config->dbh, query, exp_id, exp_id)) {
     2695    if (!p_psDBRunQuery(config->dbh, query, exp_tag, exp_tag)) {
    26962696        psError(PS_ERR_UNKNOWN, false, "database error");
    26972697        psFree(query);
     
    27572757
    27582758    bool status = false;
    2759     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
    2760     if (!status) {
    2761         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
    2762         return false;
    2763     }
    2764     if (!exp_id) {
    2765         psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
     2759    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     2760    if (!status) {
     2761        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
     2762        return false;
     2763    }
     2764    if (!exp_tag) {
     2765        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
    27662766        return false;
    27672767    }
     
    28272827            normalizedImfile->det_id,
    28282828            normalizedImfile->iteration,
    2829             exp_id,
     2829            exp_tag,
    28302830            normalizedImfile->class_id,
    28312831            uri,
     
    28452845    // select detResidImfile.*
    28462846    // by:
    2847     // where det_id, iteration, exp_id is not in detResidExp;
     2847    // where det_id, iteration, exp_tag is not in detResidExp;
    28482848
    28492849    psString query = psStringCopy(
     
    28522852        " FROM detResidImfile"
    28532853        " LEFT JOIN detResidExp"
    2854         "   USING(det_id, iteration, exp_id)"
     2854        "   USING(det_id, iteration, exp_tag)"
    28552855        " WHERE"
    28562856        "   detResidExp.det_id IS NULL"
    28572857        "   AND detResidExp.iteration IS NULL"
    2858         "   AnD detResidExp.exp_id IS NULL"
     2858        "   AnD detResidExp.exp_tag IS NULL"
    28592859        );
    28602860
     
    29172917    // select detRun.iteration
    29182918    // select detRun.det_type
    2919     // select detInputExp.exp_id
     2919    // select detInputExp.exp_tag
    29202920    // select detInputExp.include
    29212921    // by:
    29222922    // find the current iteration bassed on det_id
    2923     // find all exp_ids in the current det_id/iteration from detInputExp
     2923    // find all exp_tags in the current det_id/iteration from detInputExp
    29242924    // compare to detInputExp.imfiles to derResidImfile by class_id
    29252925    // and:
    2926     // detResidImfile.{det_id, iteration, exp_id} is not in detResidExp
     2926    // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp
    29272927
    29282928    psString query = psStringCopy(
     
    29312931        "   iteration,"
    29322932        "   det_type,"
    2933         "   exp_id,"
     2933        "   exp_tag,"
    29342934        "   include"
    29352935        " FROM"
     
    29382938        "       detRun.iteration,"
    29392939        "       detRun.det_type,"
    2940         "       detInputExp.exp_id,"
     2940        "       detInputExp.exp_tag,"
    29412941        "       detInputExp.include,"
    29422942        "       rawDetrendExp.imfiles"
     
    29462946        "       AND detRun.iteration = detInputExp.iteration"
    29472947        "   LEFT JOIN rawDetrendExp"
    2948         "       ON detInputExp.exp_id = rawDetrendExp.exp_id"
     2948        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    29492949        "   LEFT JOIN detResidImfile"
    29502950        "       ON detRun.position = detResidImfile.det_id"
    29512951        "       AND detRun.iteration = detResidImfile.iteration"
    2952         "       AND detInputExp.exp_id = detResidImfile.exp_id"
     2952        "       AND detInputExp.exp_tag = detResidImfile.exp_tag"
    29532953        "   LEFT JOIN detResidExp"
    29542954        "       ON detRun.position = detResidExp.det_id"
    29552955        "       AND detRun.iteration = detResidExp.iteration"
    2956         "       AND detInputExp.exp_id = detResidExp.exp_id"
     2956        "       AND detInputExp.exp_tag = detResidExp.exp_tag"
    29572957        "   WHERE"
    29582958        "       detResidExp.det_id IS NULL"
    29592959        "       AND detResidExp.iteration IS NULL"
    2960         "       AND detResidExp.exp_id IS NULL"
     2960        "       AND detResidExp.exp_tag IS NULL"
    29612961        "   GROUP BY"
    2962         "       detInputExp.exp_id"
     2962        "       detInputExp.exp_tag"
    29632963        "   HAVING"
    29642964        "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)"
     
    30263026    // select detRun.iteration
    30273027    // select detRun.det_type
    3028     // select detInputExp.exp_id
     3028    // select detInputExp.exp_tag
    30293029    // select detInputExp.include
    30303030    // by:
    30313031    // find the current iteration bassed on det_id
    3032     // find all exp_ids in the current det_id/iteration from detInputExp
     3032    // find all exp_tags in the current det_id/iteration from detInputExp
    30333033    // compare to detInputExp.imfiles to derResidImfile by class_id
    30343034    // and:
    3035     // detResidImfile.{det_id, iteration, exp_id} is not in detResidExp
     3035    // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp
    30363036
    30373037    psString query = psStringCopy(
     
    30393039        "   det_id,"
    30403040        "   iteration,"
    3041         "   exp_id,"
     3041        "   exp_tag,"
    30423042        "   include"
    30433043        " FROM"
     
    30463046        "       detRun.iteration,"
    30473047        "       detRun.det_type,"
    3048         "       detInputExp.exp_id,"
     3048        "       detInputExp.exp_tag,"
    30493049        "       detInputExp.include,"
    30503050        "       rawDetrendExp.imfiles"
     
    30543054        "       AND detRun.iteration = detInputExp.iteration"
    30553055        "   LEFT JOIN rawDetrendExp"
    3056         "       ON detInputExp.exp_id = rawDetrendExp.exp_id"
     3056        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    30573057        "   LEFT JOIN detResidImfile"
    30583058        "       ON detRun.position = detResidImfile.det_id"
    30593059        "       AND detRun.iteration = detResidImfile.iteration"
    3060         "       AND detInputExp.exp_id = detResidImfile.exp_id"
     3060        "       AND detInputExp.exp_tag = detResidImfile.exp_tag"
    30613061        "   LEFT JOIN detResidExp"
    30623062        "       ON detRun.position = detResidExp.det_id"
    30633063        "       AND detRun.iteration = detResidExp.iteration"
    3064         "       AND detInputExp.exp_id = detResidExp.exp_id"
     3064        "       AND detInputExp.exp_tag = detResidExp.exp_tag"
    30653065        "   WHERE"
    30663066        "       detResidExp.det_id IS NULL"
    30673067        "       AND detResidExp.iteration IS NULL"
    3068         "       AND detResidExp.exp_id IS NULL"
     3068        "       AND detResidExp.exp_tag IS NULL"
    30693069        "   GROUP BY"
    3070         "       detInputExp.exp_id"
     3070        "       detInputExp.exp_tag"
    30713071        "   HAVING"
    30723072        "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)"
     
    30753075
    30763076    {
    3077         // build a query to search by det_id, iteration, exp_id
     3077        // build a query to search by det_id, iteration, exp_tag
    30783078        psMetadata *where = psMetadataAlloc();
    30793079        bool status = false;
     
    31073107            return false;
    31083108        }
    3109         psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
    3110         if (!status) {
    3111             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     3109        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     3110        if (!status) {
     3111            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    31123112            psFree(where);
    31133113            psFree(query);
    31143114            return false;
    31153115        }
    3116         if (exp_id) {
    3117             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
    3118                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     3116        if (exp_tag) {
     3117            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
     3118                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    31193119                psFree(where);
    31203120                psFree(query);
     
    32083208        return false;
    32093209    }
    3210     psString exp_id = psMetadataLookupStr(&status, row, "exp_id");
    3211     if (!status) {
    3212         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");
    3213         return false;
    3214     }
    3215     if (!exp_id) {
    3216         psError(PS_ERR_UNKNOWN, true, "exp_id is required");
     3210    psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag");
     3211    if (!status) {
     3212        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag");
     3213        return false;
     3214    }
     3215    if (!exp_tag) {
     3216        psError(PS_ERR_UNKNOWN, true, "exp_tag is required");
    32173217        return false;
    32183218    }
     
    32833283            det_id,
    32843284            iteration,
    3285             exp_id,
     3285            exp_tag,
    32863286            recipe,
    32873287            bg,
     
    33433343    // by:
    33443344    // find the current iteration bassed on det_id
    3345     // find all exp_ids in the current det_id/iteration from detInputExp
    3346     // find all exp_ids in the current det_id/iteration from detResidExp
    3347     // compare the counts of exp_ids
     3345    // find all exp_tags in the current det_id/iteration from detInputExp
     3346    // find all exp_tags in the current det_id/iteration from detResidExp
     3347    // compare the counts of exp_tags
    33483348
    33493349    psString query = psStringCopy(
     
    33573357        "       detRun.iteration,"
    33583358        "       detRun.det_type,"
    3359         "       detInputExp.exp_id"
     3359        "       detInputExp.exp_tag"
    33603360        "   FROM detRun"
    33613361        "       LEFT JOIN detInputExp"
     
    33633363        "       AND detRun.iteration = detInputExp.iteration"
    33643364        "   LEFT JOIN rawDetrendExp"
    3365         "       ON detInputExp.exp_id = rawDetrendExp.exp_id"
     3365        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    33663366        "   LEFT JOIN detResidExp"
    33673367        "       ON detRun.position = detResidExp.det_id"
    33683368        "       AND detRun.iteration = detResidExp.iteration"
    3369         "       AND detInputExp.exp_id = detResidExp.exp_id"
     3369        "       AND detInputExp.exp_tag = detResidExp.exp_tag"
    33703370        "   GROUP BY"
    33713371        "       detRun.position,"
    33723372        "       detRun.iteration"
    33733373        "   HAVING"
    3374         "       COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)"
     3374        "       COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)"
    33753375        " ) AS residdetrun"
    33763376        );
     
    34253425    PS_ASSERT_PTR_NON_NULL(config, false);
    34263426
    3427     // build a query to search by det_id, iteration, exp_id
     3427    // build a query to search by det_id, iteration, exp_tag
    34283428    psMetadata *where = psMetadataAlloc();
    34293429    bool status = false;
     
    34533453        return false;
    34543454    }
    3455     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
    3456     if (!status) {
    3457         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     3455    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     3456    if (!status) {
     3457        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    34583458        psFree(where);
    34593459        return false;
    34603460    }
    3461     if (exp_id) {
    3462         if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
    3463             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     3461    if (exp_tag) {
     3462        if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
     3463            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    34643464            psFree(where);
    34653465            return false;
     
    34683468
    34693469    // find the values we're going to set
    3470     // copy everything but det_id, iteration, & exp_id from the args and
     3470    // copy everything but det_id, iteration, & exp_tag from the args and
    34713471    // remove the '-' prefix
    34723472    psMetadata *set = psMetadataAlloc();
     
    36013601    // by:
    36023602    // find the current iteration bassed on det_id
    3603     // find all exp_ids in the current det_id/iteration from detInputExp
    3604     // find all exp_ids in the current det_id/iteration from detResidExp
    3605     // compare the counts of exp_ids
     3603    // find all exp_tags in the current det_id/iteration from detInputExp
     3604    // find all exp_tags in the current det_id/iteration from detResidExp
     3605    // compare the counts of exp_tags
    36063606
    36073607    psString query = psStringCopy(
     
    36133613        "       detRun.position AS det_id,"
    36143614        "       detRun.iteration,"
    3615         "       detInputExp.exp_id"
     3615        "       detInputExp.exp_tag"
    36163616        "   FROM detRun"
    36173617        "       LEFT JOIN detInputExp"
     
    36193619        "       AND detRun.iteration = detInputExp.iteration"
    36203620        "   LEFT JOIN rawDetrendExp"
    3621         "       ON detInputExp.exp_id = rawDetrendExp.exp_id"
     3621        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
    36223622        "   LEFT JOIN detResidExp"
    36233623        "       ON detRun.position = detResidExp.det_id"
    36243624        "       AND detRun.iteration = detResidExp.iteration"
    3625         "       AND detInputExp.exp_id = detResidExp.exp_id"
     3625        "       AND detInputExp.exp_tag = detResidExp.exp_tag"
    36263626        "   GROUP BY"
    36273627        "       detRun.position,"
    36283628        "       detRun.iteration"
    36293629        "   HAVING"
    3630         "       COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)"
     3630        "       COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)"
    36313631        " ) AS residdetrun"
    36323632        );
    36333633
    36343634    {
    3635         // build a query to search by det_id, iteration, exp_id
     3635        // build a query to search by det_id, iteration, exp_tag
    36363636        psMetadata *where = psMetadataAlloc();
    36373637        bool status = false;
     
    38393839    // select detRun.position
    38403840    // select detRun.iteration
    3841     // select detInputExp.exp_id
     3841    // select detInputExp.exp_tag
    38423842    // select detResidExp.accept
    38433843    // by:
    38443844    // find the current iteration bassed on det_id
    3845     // find all exp_ids in the current det_id/iteration from detInputExp
    3846     // find all exp_ids in the current det_id/iteration from detResidExp
    3847     // compare the counts of exp_ids
     3845    // find all exp_tags in the current det_id/iteration from detInputExp
     3846    // find all exp_tags in the current det_id/iteration from detResidExp
     3847    // compare the counts of exp_tags
    38483848
    38493849    psString query = psStringCopy(
     
    38513851        "   detRun.position AS det_id,"
    38523852        "   detRun.iteration,"
    3853         "   detInputExp.exp_id,"
     3853        "   detInputExp.exp_tag,"
    38543854        "   detResidExp.accept"
    38553855        " FROM detRun"
     
    38603860        "   ON detRun.position = detResidExp.det_id"
    38613861        "   AND detRun.iteration = detResidExp.iteration"
    3862         "   AND detInputExp.exp_id = detResidExp.exp_id"
     3862        "   AND detInputExp.exp_tag = detResidExp.exp_tag"
    38633863        " WHERE"
    3864         "   detInputExp.exp_id IS NOT NULL"
     3864        "   detInputExp.exp_tag IS NOT NULL"
    38653865        "   AND detResidExp.accept IS NOT NULL"
    38663866        " GROUP BY"
    38673867        "   detRun.position,"
    38683868        "   detRun.iteration,"
    3869         "   detInputExp.exp_id"
     3869        "   detInputExp.exp_tag"
    38703870        " HAVING"
    3871         "   COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)"
     3871        "   COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)"
    38723872        );
    38733873
     
    39103910    for (long i = 0; i < psArrayLength(output); i++) {
    39113911        psMetadata *row = output->data[i];
    3912         psString exp_id = psMetadataLookupStr(&status, row, "exp_id");
     3912        psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag");
    39133913        if (!status) {
    39143914            // rollback
     
    39163916                psError(PS_ERR_UNKNOWN, false, "database error");
    39173917            }
    3918             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");
     3918            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag");
    39193919            psFree(output);
    39203920            return false;
     
    39363936                    (psS32)atol(det_id),
    39373937                    newIteration,
    3938                     exp_id,
     3938                    exp_tag,
    39393939                    accept
    39403940                )
     
    40984098    }
    40994099
    4100     // we have to support multipe exp_ids
    4101     psMetadataItem *item = psMetadataLookup(config->args, "-exp_id");
     4100    // we have to support multipe exp_tags
     4101    psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag");
    41024102    if (!item) {
    41034103        // this shouldn't actually happen when using psArgs
    4104         psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
    4105         return false;
    4106     }
    4107 
    4108     psList *exp_id_list = item->data.list;
     4104        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
     4105        return false;
     4106    }
     4107
     4108    psList *exp_tag_list = item->data.list;
    41094109    psMetadata *where = psMetadataAlloc();
    4110     // make sure that -exp_id was parsed correctly
     4110    // make sure that -exp_tag was parsed correctly
    41114111    // XXX this can be removed someday
    41124112    if (item->type == PS_DATA_METADATA_MULTI) {
     
    41144114        psMetadataItem *mItem = NULL;
    41154115        while ((mItem = psListGetAndIncrement(iter))) {
    4116             psString exp_id = mItem->data.V;
    4117             // if exp_id is NULL then it means that -exp_id has not been
     4116            psString exp_tag = mItem->data.V;
     4117            // if exp_tag is NULL then it means that -exp_tag has not been
    41184118            // specified
    4119             if (!exp_id) {
     4119            if (!exp_tag) {
    41204120                psError(PS_ERR_UNKNOWN, true,
    4121                         "at least one -exp_id is required");
     4121                        "at least one -exp_tag is required");
    41224122                psFree(where);
    41234123                return false;
    41244124            }
    41254125
    4126             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
    4127                         PS_META_DUPLICATE_OK, "==", exp_id)) {
    4128                 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     4126            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
     4127                        PS_META_DUPLICATE_OK, "==", exp_tag)) {
     4128                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    41294129                psFree(iter);
    41304130                psFree(where);
     
    41354135    } else {
    41364136        psAbort(config->argv[0],
    4137                 "-exp_id was not parsed correctly (this should not happen");
    4138     }
    4139 
    4140     // check that the specified exp_ids actually exist in the iteration zero
     4137                "-exp_tag was not parsed correctly (this should not happen");
     4138    }
     4139
     4140    // check that the specified exp_tags actually exist in the iteration zero
    41414141    // detInputExp set
    41424142
     
    41624162    }
    41634163
    4164     // build a hash for the valid exp_ids
    4165     psHash *valid_exp_ids = psHashAlloc(psArrayLength(detrendExps));
     4164    // build a hash for the valid exp_tags
     4165    psHash *valid_exp_tags = psHashAlloc(psArrayLength(detrendExps));
    41664166    for (long i = 0; i < psArrayLength(detrendExps); i++) {
    4167         psHashAdd(valid_exp_ids,
    4168             ((detInputExpRow *)detrendExps->data[i])->exp_id,
     4167        psHashAdd(valid_exp_tags,
     4168            ((detInputExpRow *)detrendExps->data[i])->exp_tag,
    41694169            detrendExps->data[i]
    41704170        );
     
    41764176    if (!psDBTransaction(config->dbh)) {
    41774177        psError(PS_ERR_UNKNOWN, false, "database error");
    4178         psFree(valid_exp_ids);
     4178        psFree(valid_exp_tags);
    41794179        return false;
    41804180    }
     
    41874187            psError(PS_ERR_UNKNOWN, false, "database error");
    41884188        }
    4189         psFree(valid_exp_ids);
    4190         return false;
    4191     }
    4192 
    4193     // check exp_ids and build up an array of new detInputExp rows at the same
     4189        psFree(valid_exp_tags);
     4190        return false;
     4191    }
     4192
     4193    // check exp_tags and build up an array of new detInputExp rows at the same
    41944194    // time
    4195     psListIterator *iter = psListIteratorAlloc(exp_id_list, 0, false);
     4195    psListIterator *iter = psListIteratorAlloc(exp_tag_list, 0, false);
    41964196    psMetadataItem *mItem = NULL;
    4197     psArray *newInputExps = psArrayAlloc(psListLength(exp_id_list));
     4197    psArray *newInputExps = psArrayAlloc(psListLength(exp_tag_list));
    41984198    while ((mItem = psListGetAndIncrement(iter))) {
    4199         detInputExpRow *inputExp = psHashLookup(valid_exp_ids,
     4199        detInputExpRow *inputExp = psHashLookup(valid_exp_tags,
    42004200                (char *)mItem->data.V);
    42014201        if (!inputExp) {
     
    42044204                psError(PS_ERR_UNKNOWN, false, "database error");
    42054205            }
    4206             // invalid exp_id
    4207             psError(PS_ERR_UNKNOWN, false, "exp_id %s is invalid for det_id %s",
     4206            // invalid exp_tag
     4207            psError(PS_ERR_UNKNOWN, false, "exp_tag %s is invalid for det_id %s",
    42084208                    (char *)mItem->data.V, det_id);
    42094209            psFree(iter);
    4210             psFree(valid_exp_ids);
     4210            psFree(valid_exp_tags);
    42114211            return false;
    42124212        }
     
    42144214            (psS32)atol(det_id),
    42154215            newIteration,
    4216             inputExp->exp_id,
     4216            inputExp->exp_tag,
    42174217            true   // use
    42184218        );
     
    42214221    }
    42224222    psFree(iter);
    4223     psFree(valid_exp_ids);
     4223    psFree(valid_exp_tags);
    42244224
    42254225    for (long i = 0; i < psArrayLength(newInputExps); i++) {
Note: See TracChangeset for help on using the changeset viewer.