IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7158


Ignore:
Timestamp:
May 19, 2006, 3:51:02 PM (20 years ago)
Author:
jhoblitt
Message:

impliment --addmaster

File:
1 edited

Legend:

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

    r7149 r7158  
    173173    psArray *rawImfiles = searchRawImfiles(config, NULL);
    174174
     175    // XXX remove detProcessedImfiles
     176
    175177    // print imfile list
    176178    psMetadata *output = psMetadataAlloc();
     
    580582{
    581583    PS_ASSERT_PTR_NON_NULL(config, false);
    582 
    583     return true;
    584 }
     584 
     585    // det_id, class_id, uri, stats, & recipe are required
     586    bool status = false;
     587    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     588    if (!status) {
     589        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     590        return false;
     591    }
     592    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     593    if (!status) {
     594        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
     595        return false;
     596    }
     597    psString uri    = psMetadataLookupStr(&status, config->args, "-uri");
     598    if (!status) {
     599        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
     600        return false;
     601    }
     602    psString recipe = psMetadataLookupStr(&status, config->args, "-recipe");
     603    if (!status) {
     604        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
     605        return false;
     606    }
     607    psString stats = psMetadataLookupStr(&status, config->args, "-stats");
     608    if (!status) {
     609        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");
     610        return false;
     611    }
     612
     613    // correlate the class_id against the det_id's detStackedImfiles
     614
     615    // we have to generate our own where claus as we want to search only by the
     616    // det_id & class_id
     617    psMetadata *where = psMetadataAlloc();
     618    if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
     619            (psS32)atoi(det_id))) {
     620        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     621        psFree(where);
     622        return false;
     623    }
     624    if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) {
     625        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     626        psFree(where);
     627        return false;
     628    }
     629
     630    psArray *stackedImfiles = detStackedImfileSelectRowObjects(
     631                                config->dbh, where, 0);
     632
     633    bool valid_class_id = false;
     634    if (stackedImfiles) {
     635        for (long i = 0; i < psArrayLength(stackedImfiles); i++) {
     636            if (strcmp(class_id,
     637                ((detStackedImfileRow *)stackedImfiles->data[i])->class_id)
     638            == 0) {
     639                valid_class_id = true;
     640                break;
     641            }
     642        }
     643        psFree(stackedImfiles);
     644    }
     645
     646    if (!valid_class_id) {
     647        psError(PS_ERR_UNKNOWN, true,
     648        "class_id can not be correlated with a detStackedImfile");
     649        return false;
     650    }
     651
     652    // create a new detMasterImfile object
     653    detMasterImfileRow *masterImfile = detMasterImfileRowAlloc(
     654        (psS32)atol(det_id), class_id, uri, stats, recipe
     655    );   
     656
     657    // insert the new row into the detProcessedImfile table
     658    if (!detMasterImfileInsertObject(config->dbh, masterImfile)) {
     659        psError(PS_ERR_UNKNOWN, false, "database error");
     660        return false;
     661    }
     662
     663    return true;
     664}
Note: See TracChangeset for help on using the changeset viewer.