IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7128


Ignore:
Timestamp:
May 16, 2006, 6:05:00 PM (20 years ago)
Author:
jhoblitt
Message:

partial addstacked implimentation

File:
1 edited

Legend:

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

    r7114 r7128  
    1616
    1717static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id);
     18static psArray *searchRawImfiles(pxConfig *config);
    1819
    1920int main(int argc, char **argv)
     
    157158    PS_ASSERT_PTR_NON_NULL(config, false);
    158159
     160    // search from rawImfiles
     161    psArray *rawImfiles = searchRawImfiles(config);
     162
     163    // print imfile list
     164    psMetadata *output = psMetadataAlloc();
     165    for (long i = 0; i < psArrayLength(rawImfiles); i++) {
     166        psMetadata *md = rawImfileMetadataFromObject(rawImfiles->data[i]);
     167        psMetadataAddMetadata(
     168            output, PS_LIST_TAIL, "rawImfile",  PS_META_DUPLICATE_OK, NULL, md);
     169    }
     170
     171    psString str = psMetadataConfigFormat(output);
     172    psFree(output);
     173    fprintf(stdout, "%s\n", str);
     174    psFree(str);
     175
     176    return true;
     177}
     178
     179static psArray *searchRawImfiles(pxConfig *config)
     180{
     181    PS_ASSERT_PTR_NON_NULL(config, NULL);
     182
    159183    // select exp_ids from detInputExp matching det_idp
    160184    // where query should be pre-generated
     
    163187    if (!detInputExp) {
    164188        psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
    165         return false;
     189        return NULL;
    166190    }
    167191
     
    176200            psFree(detInputExp);
    177201            psFree(where_exp_ids);
    178             return false;
     202            return NULL;
    179203        }
    180204    }
     
    187211    if (!rawImfiles) {
    188212        psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found");
    189         return false;
    190     }
    191 
    192     // print imfile list
    193     psMetadata *output = psMetadataAlloc();
    194     for (long i = 0; i < psArrayLength(rawImfiles); i++) {
    195         psMetadata *md = rawImfileMetadataFromObject(rawImfiles->data[i]);
    196         psMetadataAddMetadata(
    197             output, PS_LIST_TAIL, "rawImfile",  PS_META_DUPLICATE_OK, NULL, md);
    198     }
    199 
    200     psString str = psMetadataConfigFormat(output);
    201     psFree(output);
    202     fprintf(stdout, "%s\n", str);
    203     psFree(str);
    204 
    205     return true;
     213        return NULL;
     214    }
     215
     216    return rawImfiles;
    206217}
    207218
     
    310321    PS_ASSERT_PTR_NON_NULL(config, false);
    311322
     323    // det_id, class_id, uri, & recipe are required
     324    bool status = false;
     325    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     326    if (!status) {
     327        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     328        return false;
     329    }
     330    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     331    if (!status) {
     332        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
     333        return false;
     334    }
     335    psString uri    = psMetadataLookupStr(&status, config->args, "-uri");
     336    if (!status) {
     337        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
     338        return false;
     339    }
     340    psString recipe = psMetadataLookupStr(&status, config->args, "-recipe");
     341    if (!status) {
     342        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
     343        return false;
     344    }
     345    psString stats = psMetadataLookupStr(&status, config->args, "-stats");
     346    if (!status) {
     347        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");
     348        return false;
     349    }
     350
     351    // correlate the class_id against the input exposure(s)
     352    psArray *rawImfiles = searchRawImfiles(config);
     353
     354    bool valid_class_id = false;
     355    for (long i = 0; i < psArrayLength(rawImfiles); i++) {
     356        if (class_id == ((rawImfileRow *)rawImfiles->data[i])->class_id) {
     357            valid_class_id = true;
     358            break;
     359        }
     360    }
     361    psFree(rawImfiles);
     362
     363    if (!valid_class_id) {
     364        psError(PS_ERR_UNKNOWN, true,
     365            "class_id can not be correlated with the input exposures");
     366        return false;
     367    }
     368
     369    // create a new detStackedImfile object
     370    detStackedImfileRow *stackedImfile = detStackedImfileRowAlloc(
     371        (psS32)atol(det_id), class_id, uri, stats, recipe
     372    );   
     373    psFree(rawImfiles);
     374
     375    // insert the new row into the detProcessedImfile table
     376    if (!detStackedImfileInsertObject(config->dbh, stackedImfile)) {
     377        psError(PS_ERR_UNKNOWN, false, "database error");
     378        return false;
     379    }
     380
    312381    return true;
    313382}
Note: See TracChangeset for help on using the changeset viewer.