IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10227


Ignore:
Timestamp:
Nov 28, 2006, 11:30:28 AM (20 years ago)
Author:
jhoblitt
Message:

implement -detrunsummary

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r10223 r10227  
    47494749    PS_ASSERT_PTR_NON_NULL(config, false);
    47504750
     4751    psString query = psStringCopy(
     4752        "SELECT DISTINCT\n"
     4753        "   detRunSummary.*,\n"
     4754        "   detRun.det_type,\n"
     4755        "   detRun.mode\n"
     4756        " FROM detRun\n"
     4757        " JOIN detRunSummary\n"
     4758        "   USING(det_id, iteration)\n"
     4759        " WHERE\n"
     4760        "   detRun.state = 'run'\n"
     4761        );
     4762
     4763    if (config->where) {
     4764        psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     4765        psStringAppend(&query, " AND %s", whereClause);
     4766        psFree(whereClause);
     4767    }
     4768
     4769    if (!p_psDBRunQuery(config->dbh, query)) {
     4770        psError(PS_ERR_UNKNOWN, false, "database error");
     4771        psFree(query);
     4772        return false;
     4773    }
     4774    psFree(query);
     4775
     4776    psArray *output = p_psDBFetchResult(config->dbh);
     4777    if (!output) {
     4778        psError(PS_ERR_UNKNOWN, false, "database error");
     4779        return false;
     4780    }
     4781    if (!psArrayLength(output)) {
     4782        psError(PS_ERR_UNKNOWN, false, "no detRunSummary rows found");
     4783        psFree(output);
     4784        return true;
     4785    }
     4786
     4787    bool simple = false;
     4788    {
     4789        bool status = false;
     4790        simple = psMetadataLookupBool(&status, config->args, "-simple");
     4791        if (!status) {
     4792            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     4793            return false;
     4794        }
     4795    }
     4796
     4797    // negative simple so the default is true
     4798    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     4799        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     4800        psFree(output);
     4801        return false;
     4802    }
     4803
     4804    psFree(output);
     4805
    47514806    return true;
    47524807}
  • trunk/ippTools/src/dettoolConfig.c

    r10223 r10227  
    545545    psMetadata *detrunsummaryArgs = psMetadataAlloc();
    546546    psMetadataAddStr(detrunsummaryArgs, PS_LIST_TAIL, "-det_id",  0,
    547         "search for detrend ID", NULL);
     547            "search for detrend ID", NULL);
    548548    psMetadataAddS32(detrunsummaryArgs, PS_LIST_TAIL, "-iteration",  0,
    549         "search for iteration number", 0);
     549            "search for iteration number", 0);
     550    psMetadataAddBool(detrunsummaryArgs, PS_LIST_TAIL, "-simple",  0,
     551            "use the simple output format", false);
    550552
    551553    // -updatedetrun
Note: See TracChangeset for help on using the changeset viewer.