IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10771 for trunk/ippTools/src


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

implement -towarpedimfile

File:
1 edited

Legend:

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

    r10770 r10771  
    507507    PS_ASSERT_PTR_NON_NULL(config, NULL);
    508508
     509    psString query = psStringCopy(
     510        " SELECT DISTINCT"
     511        "   p4InputImfile.p4_id,"
     512        "   p2ProcessedImfile.*"
     513        " FROM p4Run"
     514        " JOIN p4WarpedImfile"
     515        "   USING(p4_id)"
     516        " LEFT JOIN p4StackedImfile"
     517        "   USING(p4_id, class_id)"
     518        " WHERE"
     519        "   p4Run.state = 'run'"
     520        "   AND p4StackedImfile.p4_id IS NULL"
     521        "   AND p4Stackedmfile.class_id IS NULL"
     522    );
     523
     524    if (config->where) {
     525        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4WarpedImfile");
     526        psStringAppend(&query, " AND %s", whereClause);
     527        psFree(whereClause);
     528    }
     529
     530    if (!p_psDBRunQuery(config->dbh, query)) {
     531        psError(PS_ERR_UNKNOWN, false, "database error");
     532        psFree(query);
     533        return false;
     534    }
     535    psFree(query);
     536
     537    psArray *output = p_psDBFetchResult(config->dbh);
     538    if (!output) {
     539        psError(PS_ERR_UNKNOWN, false, "database error");
     540        return false;
     541    }
     542    if (!psArrayLength(output)) {
     543        // XXX check psError here
     544        psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found");
     545        psFree(output);
     546        return true;
     547    }
     548
     549    bool simple = false;
     550    {
     551        bool status = false;
     552        simple = psMetadataLookupBool(&status, config->args, "-simple");
     553        if (!status) {
     554            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     555            return false;
     556        }
     557    }
     558
     559    // negative simple so the default is true
     560    if (!ippdbPrintMetadatas(stdout, output, "p4WarpedImfile", !simple)) {
     561        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     562        psFree(output);
     563        return false;
     564    }
     565
     566    psFree(output);
     567
    509568    return true;
    510569}
Note: See TracChangeset for help on using the changeset viewer.