IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 8, 2006, 5:43:01 PM (20 years ago)
Author:
jhoblitt
Message:

first pass implementation of -addprocessed

File:
1 edited

Legend:

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

    r7088 r7094  
    210210    PS_ASSERT_PTR_NON_NULL(config, false);
    211211
     212    // det_id, exp_id, class_id, uri, & recipe are required
     213    bool status = false;
     214    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     215    if (!status) {
     216        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     217        return false;
     218    }
     219    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     220    if (!status) {
     221        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     222        return false;
     223    }
     224    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     225    if (!status) {
     226        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
     227        return false;
     228    }
     229    psString uri    = psMetadataLookupStr(&status, config->args, "-uri");
     230    if (!status) {
     231        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
     232        return false;
     233    }
     234    psString recipe = psMetadataLookupStr(&status, config->args, "-recipe");
     235    if (!status) {
     236        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
     237        return false;
     238    }
     239
     240    // find the matching rawImfile by exp_id/class_id
     241    psMetadata *where = psMetadataAlloc();
     242    if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
     243        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     244        psFree(where);
     245        return false;
     246    }
     247    if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) {
     248        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     249        psFree(where);
     250        return false;
     251    }
     252
     253    psArray *rawImfiles = rawImfileSelectRowObjects(config->dbh, where, 0);
     254    psFree(where);
     255    if (!rawImfiles) {
     256        psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found ");
     257        return false;
     258    }
     259
     260    // create a new detProcessedImfile object
     261    psString stats = ((rawImfileRow *)rawImfiles->data[0])->stats;
     262    detProcessedImfileRow *detRow = detProcessedImfileRowAlloc(
     263        det_id, exp_id, class_id, uri, stats, recipe
     264    );   
     265    psFree(rawImfiles);
     266
     267    // insert the new row into the detProcessedImfile table
     268    if (!detProcessedImfileInsertObject(config->dbh, detRow)) {
     269        psError(PS_ERR_UNKNOWN, false, "database error");
     270        return false;
     271    }
     272
    212273    return true;
    213274}
Note: See TracChangeset for help on using the changeset viewer.