IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10769


Ignore:
Timestamp:
Dec 15, 2006, 5:28:19 PM (20 years ago)
Author:
jhoblitt
Message:

implement -towarpedimfile

File:
1 edited

Legend:

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

    r10768 r10769  
    289289    PS_ASSERT_PTR_NON_NULL(config, NULL);
    290290
     291    psString query = psStringCopy(
     292        " SELECT DISTINCT"
     293        "   p4InputImfile.p4_id,"
     294        "   p2ProcessedImfile.*"
     295        " FROM p4Run"
     296        " JOIN p4InputImfile"
     297        "   USING(p4_id)"
     298        " LEFT JOIN p4WarpedImfile"
     299        "   USING(p4_id, exp_tag, p3_version, class_id)"
     300        " JOIN p3ProcessedExp"
     301        "   ON p4InputImfile.exp_tag = p3ProcessedExp.exp_tag"
     302        "   AND p4InputImfile.p3_version = p3ProcessedExp.p3_version"
     303        " JOIN p2ProcessedImfile"
     304        "   ON p4InputImfile.exp_tag = p2ProcessedImfile.exp_tag"
     305        "   AND p3ProcessedExp.p2_version = p2ProcessedImfile.p2_version"
     306        "   AND p4InputImfile.class_id = p2ProcessedImfile.class_id"
     307        " WHERE"
     308        "   p4Run.state = 'run'"
     309        "   AND p4WarpedImfile.p4_id IS NULL"
     310        "   AND p4WarpedImfile.exp_tag IS NULL"
     311        "   AND p4WarpedImfile.p3_version IS NULL"
     312        "   AND p4WarpedImfile.class_id IS NULL"
     313    );
     314
     315    if (config->where) {
     316        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputImfile");
     317        psStringAppend(&query, " AND %s", whereClause);
     318        psFree(whereClause);
     319    }
     320
     321    if (!p_psDBRunQuery(config->dbh, query)) {
     322        psError(PS_ERR_UNKNOWN, false, "database error");
     323        psFree(query);
     324        return false;
     325    }
     326    psFree(query);
     327
     328    psArray *output = p_psDBFetchResult(config->dbh);
     329    if (!output) {
     330        psError(PS_ERR_UNKNOWN, false, "database error");
     331        return false;
     332    }
     333    if (!psArrayLength(output)) {
     334        // XXX check psError here
     335        psError(PS_ERR_UNKNOWN, false, "no p4InputImfile rows found");
     336        psFree(output);
     337        return true;
     338    }
     339
     340    bool simple = false;
     341    {
     342        bool status = false;
     343        simple = psMetadataLookupBool(&status, config->args, "-simple");
     344        if (!status) {
     345            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     346            return false;
     347        }
     348    }
     349
     350    // negative simple so the default is true
     351    if (!ippdbPrintMetadatas(stdout, output, "p4InputImfile", !simple)) {
     352        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     353        psFree(output);
     354        return false;
     355    }
     356
     357    psFree(output);
     358
    291359    return true;
    292360}
Note: See TracChangeset for help on using the changeset viewer.