IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 20, 2009, 11:48:09 AM (17 years ago)
Author:
watersc1
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup/ippTools/src/pstamptool.c

    r25051 r25149  
    315315    PS_ASSERT_PTR_NON_NULL(config, false);
    316316
    317     PXOPT_LOOKUP_S64(req_id,  config->args, "-req_id", true, false);
     317    psMetadata *where = psMetadataAlloc();
     318    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
     319    PXOPT_COPY_STR(config->args, where, "-name", "name", "==");
     320
    318321    PXOPT_LOOKUP_U64(limit,   config->args, "-limit",  false, false);
    319322    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    320323
    321     psString query = NULL;
    322     psStringAppend(&query, "SELECT * from pstampRequest WHERE req_id = %" PRId64, req_id);
     324    if (!psListLength(where->list)) {
     325        psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied");
     326        return false;
     327    }
     328
     329    psString query = psStringCopy("SELECT * from pstampRequest");
     330
     331    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     332    psStringAppend(&query, " WHERE %s", whereClause);
     333    psFree(whereClause);
     334    psFree(where);
    323335   
    324336    // treat limit == 0 as "no limit"
     
    342354    }
    343355    if (!psArrayLength(output)) {
    344         psTrace("pstamptool", PS_LOG_INFO, "no rows found");
    345         psFree(output);
    346         return true;
     356        psTrace("pstamptool", PS_LOG_INFO, "request not found");
     357        // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for
     358        psError(PXTOOLS_ERR_DATA, true, "request not found");
     359        psFree(output);
     360        // we return false so that the caller can determine that a request does not exist
     361        return false;
    347362    }
    348363
     
    496511{
    497512    bool    stampJob = false;
    498     char   *query = NULL;
    499513
    500514    PS_ASSERT_PTR_NON_NULL(config, false);
     
    503517    PXOPT_LOOKUP_STR(rownum,      config->args, "-rownum",     true, false);
    504518    PXOPT_LOOKUP_STR(job_type,    config->args, "-job_type",   false, false);
    505     PXOPT_LOOKUP_STR(outputBase,  config->args, "-outputBase", true,  false);
     519    PXOPT_LOOKUP_STR(outputBase,  config->args, "-outputBase", false,  false);
    506520    PXOPT_LOOKUP_STR(stateString, config->args, "-state",      false, false);
    507     PXOPT_LOOKUP_STR(fault,       config->args, "-fault",      false, false);
     521    PXOPT_LOOKUP_S16(fault,       config->args, "-fault",      false, false);
    508522    PXOPT_LOOKUP_S64(exp_id,      config->args, "-exp_id",     false, false);
    509523
     524    // unless the job is being inserted with stop state require outputBase
     525    if (strcmp(stateString, "stop") && !outputBase) {
     526        psError(PS_ERR_UNKNOWN, true, "-outputBase is required");
     527        return false;
     528    }
     529
    510530    // default value for job_type is defined in pstamptoolConfig.c
    511     if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query")) {
     531    if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query") || !strcmp(job_type, "none")) {
    512532        stampJob = false;
    513533    } else if (!strcmp(job_type, "stamp")) {
     
    517537        return false;
    518538    }
    519     if (stampJob) {
    520         query = pxDataGet("pstamptool_addjob_stampjob.sql");
    521     } else {
    522         query = pxDataGet("pstamptool_addjob_otherjob.sql");
    523     }
    524     if (!query) {
    525         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    526         return false;
    527     }
    528 
    529     if (!p_psDBRunQueryF(config->dbh, query, req_id, rownum, stateString, job_type, exp_id, outputBase, fault)) {
     539    if (!pstampJobInsert(config->dbh,
     540            0, // job_id
     541            req_id,
     542            rownum,
     543            stateString,
     544            job_type,
     545            fault,
     546            exp_id,
     547            outputBase
     548            )) {
    530549        psError(PS_ERR_UNKNOWN, false, "database error");
    531550        return false;
Note: See TracChangeset for help on using the changeset viewer.