IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8289


Ignore:
Timestamp:
Aug 11, 2006, 3:03:14 PM (20 years ago)
Author:
jhoblitt
Message:

update -definebyexp to output in mdc/simple

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r8288 r8289  
    213213    }
    214214
    215     if (where->list->n < 1) {
     215    if (psListLength(where->list) < 1) {
    216216        psFree(where);
    217217        where = NULL;
     
    226226    }
    227227
    228     // we should have one rawDetrendExp row be exp_id specified
     228    // we should have one rawDetrendExp row per exp_id specified
    229229    if (psListLength(item->data.list) != psArrayLength(detrendExps)) {
    230230        psAbort(config->argv[0],
     
    260260    psFree(detrendExps);
    261261
    262     for (long i = 0; i < psArrayLength(inputExps); i++) {
    263         if (!detInputExpInsertObject(config->dbh, inputExps->data[i])) {
     262    // insert detInputExp objects into the database
     263    if (!detInputExpInsertObjects(config->dbh, inputExps)) {
     264        psError(PS_ERR_UNKNOWN, false, "database error");
     265        // rollback
     266        if (!psDBRollback(config->dbh)) {
    264267            psError(PS_ERR_UNKNOWN, false, "database error");
    265             // rollback
    266             if (!psDBRollback(config->dbh)) {
    267                 psError(PS_ERR_UNKNOWN, false, "database error");
    268             }
    269             psFree(inputExps);
    270             return false;
    271         }
     268        }
     269        psFree(inputExps);
     270        return false;
    272271    }
    273272    psFree(inputExps);
     
    279278    }
    280279
     280    bool simple = false;
     281    {
     282        bool status = false;
     283        simple = psMetadataLookupBool(&status, config->args, "-simple");
     284        if (!status) {
     285            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     286            return false;
     287        }
     288    }
     289
    281290    // print the new det_id
    282     printf("%ld\n", det_id);
     291    psArray *detRuns = NULL;
     292    {
     293        psMetadata *where = psMetadataAlloc();
     294        // map det_id -> position
     295        psMetadataAddS32(where, PS_LIST_TAIL, "position", 0, "==", det_id);
     296        detRuns = psDBSelectRows(config->dbh, "detRun", where, 0);
     297        psFree(where);
     298    }
     299    if (!detRuns) {
     300        psError(PS_ERR_UNKNOWN, false, "can't find the detRun we just created");
     301        return false;
     302    }
     303    // sanity check results
     304    if (psArrayLength(detRuns) != 1) {
     305        psAbort(config->argv[0], "found more then one detRun matching det_id %ld(this should not happen)", det_id);
     306        return false;
     307    }
     308
     309    // map position -> det_id
     310    // but leave position in the metadata as ippdbPrintMetadatas() will strip it
     311    // for us
     312    for (long i = 0; i < psArrayLength(detRuns); i++) {
     313        bool status = false;
     314        psS32 position = psMetadataLookupS32(&status, detRuns->data[i], "position");
     315        if (!status) {
     316            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
     317            psFree(detRuns);
     318            return false;
     319        }
     320        psMetadataAddS32(detRuns->data[i], PS_LIST_HEAD, "det_id", 0, NULL, position);
     321    }
     322
     323    // negative simple so the default is true
     324    if (!ippdbPrintMetadatas(stdout, detRuns, "detRun", !simple)) {
     325        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     326        psFree(detRuns);
     327        return false;
     328    }
     329    psFree(detRuns);
    283330
    284331    return true;
  • trunk/ippTools/src/dettoolConfig.c

    r8288 r8289  
    4545    psMetadataAddStr(definebyexpArgs, PS_LIST_TAIL, "-det_type",  0,
    4646            "define the type of detrend run (required)", NULL);
     47    psMetadataAddBool(definebyexpArgs, PS_LIST_TAIL, "-simple",  0,
     48            "use the simple output format", false);
    4749
    4850    // -runs
Note: See TracChangeset for help on using the changeset viewer.