IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2009, 6:15:31 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ippTools/src

    • Property svn:ignore
      •  

        old new  
        3232flatcorr
        3333pstamptool
         34disttool
  • branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.c

    r23352 r23594  
    319319
    320320    psMetadata *where = psMetadataAlloc();
    321     PXOPT_COPY_S64(config->args, where,  "-exp_id", "exp_id", "==");
    322     PXOPT_COPY_STR(config->args, where,  "-exp_name", "exp_name", "==");
    323     PXOPT_COPY_STR(config->args, where,  "-class_id", "class_id", "==");
     321    PXOPT_COPY_S64(config->args, where,  "-exp_id",        "exp_id",   "==");
     322    PXOPT_COPY_STR(config->args, where,  "-exp_name",      "exp_name", "==");
     323    PXOPT_COPY_STR(config->args, where,  "-class_id",      "class_id", "==");
     324    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs",  ">=");
     325    PXOPT_COPY_TIME(config->args, where, "-dateobs_end",   "dateobs",  "<=");
    324326
    325327    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    407409    PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
    408410    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
     411    PXOPT_COPY_S64(config->args, where,  "-exp_id_begin", "exp_id", ">=");
     412    PXOPT_COPY_S64(config->args, where,  "-exp_id_end", "exp_id", "<=");
    409413
    410414    psString query = pxDataGet("regtool_revertprocessedimfile.sql");
     
    419423        psStringAppend(&query, " AND %s", whereClause);
    420424        psFree(whereClause);
     425    } else {
     426        psFree(where);
     427        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     428        return false;
    421429    }
    422430    psFree(where);
     
    429437    psFree(query);
    430438
    431     if (psDBAffectedRows(config->dbh) < 1) {
    432         psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
    433         return false;
    434     }
     439    int numUpdated = psDBAffectedRows(config->dbh);
     440
     441    psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawImfile", numUpdated);
    435442
    436443    return true;
     
    441448{
    442449    PS_ASSERT_PTR_NON_NULL(config, false);
     450
     451    PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false);
     452    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
     453
     454    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     455    PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false);
     456
     457    if ((code == INT16_MAX) && !isfinite(user_1)) {
     458        psError(PS_ERR_UNKNOWN, false, "one of -code or -user_1 must be selected");
     459        return false;
     460    }
     461    if ((code != INT16_MAX) && isfinite(user_1)) {
     462        psError(PS_ERR_UNKNOWN, false, "only one of -code or -user_1 must be selected");
     463        return false;
     464    }
    443465
    444466    psMetadata *where = psMetadataAlloc();
     
    446468    PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
    447469
    448     PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    449 
    450     if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) {
    451         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    452         psFree (where);
    453         return false;
     470    if (code != INT16_MAX) {
     471        // this is fairly dangerous : can set all if the where is not set...
     472        if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) {
     473            psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     474            psFree (where);
     475            return false;
     476        }
     477    }
     478
     479    if (isfinite(user_1)) {
     480        psString query = pxDataGet("regtool_updateprocessedimfile.sql");
     481        if (!query) {
     482            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     483            return false;
     484        }
     485
     486        if (!p_psDBRunQueryF(config->dbh, query, user_1, exp_id, class_id)) {
     487            psError(PS_ERR_UNKNOWN, false, "database error");
     488            psFree(query);
     489            return false;
     490        }
     491        psFree(query);
    454492    }
    455493    psFree (where);
     
    764802        hostname,
    765803        code,
    766         NULL
     804        NULL,
     805        0
    767806    )) {
    768807        // rollback
     
    806845                exp_id,
    807846                workdir,
    808             label,
     847                label,
    809848                reduction,
    810849                NULL, // expgroup
     
    957996    PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
    958997    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
     998    PXOPT_COPY_S64(config->args, where,  "-exp_id_begin", "exp_id", ">=");
     999    PXOPT_COPY_S64(config->args, where,  "-exp_id_end", "exp_id", "<=");
    9591000
    9601001    psString query = pxDataGet("regtool_revertprocessedexp.sql");
     
    9681009        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp");
    9691010        psStringAppend(&query, " AND %s", whereClause);
     1011        psFree(whereClause);
     1012    } else {
    9701013        psFree(where);
    971         psFree(whereClause);
     1014        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     1015        return false;
    9721016    }
    9731017    psFree(where);
     
    9801024    psFree(query);
    9811025
    982     if (psDBAffectedRows(config->dbh) < 1) {
    983         psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
    984         return false;
    985     }
     1026    int numUpdated = psDBAffectedRows(config->dbh);
     1027
     1028    psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawExp", numUpdated);
    9861029
    9871030    return true;
Note: See TracChangeset for help on using the changeset viewer.