IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9117


Ignore:
Timestamp:
Oct 2, 2006, 2:45:50 PM (20 years ago)
Author:
jhoblitt
Message:

reimpliment -raw (w/o options)
minor cleanup of -toprocess

File:
1 edited

Legend:

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

    r9115 r9117  
    798798    PS_ASSERT_PTR_NON_NULL(config, false);
    799799
     800    psString query = psStringCopy(
     801            "SELECT detInputExp.det_id, detRun.det_type, rawImfile.*"
     802            " FROM rawImfile"
     803            " JOIN detInputExp USING(exp_tag) "
     804            " JOIN detRun ON detInputExp.det_id = detRun.position"
     805        );
     806
     807    if (config->where) {
     808        psString whereClause = psDBGenerateWhereSQL(config->where, "rawImfile");
     809        psStringAppend(&query, " %s", whereClause);
     810        psFree(whereClause);
     811    }
     812
     813    if (!p_psDBRunQuery(config->dbh, query)) {
     814        psError(PS_ERR_UNKNOWN, false, "database error");
     815        psFree(query);
     816        return false;
     817    }
     818    psFree(query);
     819
     820    psArray *output = p_psDBFetchResult(config->dbh);
     821    if (!output) {
     822        psError(PS_ERR_UNKNOWN, false, "database error");
     823        psFree(query);
     824    }
     825    if (!psArrayLength(output)) {
     826        // XXX check psError here
     827        psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found");
     828        psFree(output);
     829        return true;
     830    }
     831
     832    bool simple = false;
     833    {
     834        bool status = false;
     835        simple = psMetadataLookupBool(&status, config->args, "-simple");
     836        if (!status) {
     837            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     838            return false;
     839        }
     840    }
     841
     842    // negative simple so the default is true
     843    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
     844        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     845        psFree(output);
     846        return false;
     847    }
     848
     849    psFree(output);
     850
    800851    return true;
    801852}
     
    846897    psArray *output = p_psDBFetchResult(config->dbh);
    847898    if (!output) {
     899        psError(PS_ERR_UNKNOWN, false, "database error");
     900        psFree(query);
     901    }
     902    if (!psArrayLength(output)) {
    848903        // XXX check psError here
    849         psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
    850         return false;
     904        psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found");
     905        psFree(output);
     906        return true;
    851907    }
    852908
     
    862918
    863919    // negative simple so the default is true
    864     if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     920    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
    865921        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    866922        psFree(output);
Note: See TracChangeset for help on using the changeset viewer.