IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2009, 3:48:25 PM (17 years ago)
Author:
eugene
Message:

fixed up addtool

File:
1 edited

Legend:

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

    r25299 r25789  
    106106
    107107    psMetadata *where = psMetadataAlloc();
    108     pxaddGetSearchArgs (config, where);
    109     pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");
    110     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
     108    pxcamGetSearchArgs (config, where);
     109    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
     110    pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "==");
     111    PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    111112
    112113    if (!psListLength(where->list) &&
     
    121122    PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false);
    122123    PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false);
     124    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
     125    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    123126
    124127    // find the cam_id of all the exposures that we want to queue up.
     
    130133    }
    131134
    132     // use psDBGenerateWhereSQL because the SQL yields an intermediate table
     135    // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE
    133136    if (where && psListLength(where->list)) {
    134137        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     
    136139        psFree(whereClause);
    137140    }
    138 
    139141    psFree(where);
    140142
     
    153155    if (!psArrayLength(output)) {
    154156        psTrace("addtool", PS_LOG_INFO, "no rows found");
     157        psFree(output);
     158        return true;
     159    }
     160
     161    if (pretend) {
     162        // negative simple so the default is true
     163        if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
     164            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     165            psFree(output);
     166            return false;
     167        }
    155168        psFree(output);
    156169        return true;
     
    175188        psMetadata *md = output->data[i];
    176189
    177         addRunRow *row = addRunObjectFromMetadata(md);
     190        camRunRow *row = camRunObjectFromMetadata(md);
    178191        if (!row) {
    179192            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into addRun");
     
    218231
    219232    psMetadata *where = psMetadataAlloc();
    220     pxaddGetSearchArgs (config, where);
    221233    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
     234    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
     235    pxcamGetSearchArgs (config, where); // most search arguments based on camera
     236
    222237    PXOPT_COPY_STR(config->args, where, "-label",     "addRun.label", "==");
    223238    PXOPT_COPY_STR(config->args, where, "-state",     "addRun.state", "==");
     
    267282
    268283    psMetadata *where = psMetadataAlloc();
    269     pxaddGetSearchArgs (config, where);
    270284    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
     285    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
     286    pxcamGetSearchArgs (config, where);
    271287    pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");
    272288    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
     
    325341}
    326342
    327 /* static bool pendingimfileMode(pxConfig *config) */
    328 /* { */
    329 /*     PS_ASSERT_PTR_NON_NULL(config, false); */
    330 
    331 /*     psMetadata *where = psMetadataAlloc(); */
    332 /*     pxaddGetSearchArgs (config, where); */
    333 /*     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",                "=="); */
    334 /*     pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",                 "=="); */
    335 /*     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction",             "=="); */
    336 /*     PXOPT_COPY_S64(config->args, where, "-chip_id",   "addRun.chip_id",              "=="); */
    337 /*     PXOPT_COPY_STR(config->args, where, "-class_id",  "addProcessedExp.class_id", "=="); */
    338 
    339 /*     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); */
    340 
    341 /*     psString query = pxDataGet("addtool_find_pendingimfile.sql"); */
    342 /*     if (!query) { */
    343 /*         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); */
    344 /*         return false; */
    345 /*     } */
    346 
    347 /*     // use psDBGenerateWhereSQL because the SQL yields an intermediate table */
    348 /*     if (psListLength(where->list)) { */
    349 /*         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); */
    350 /*         psStringAppend(&query, " AND %s", whereClause); */
    351 /*         psFree(whereClause); */
    352 /*     } */
    353 /*     psFree(where); */
    354 
    355 /*     if (!p_psDBRunQuery(config->dbh, query)) { */
    356 /*         psError(PS_ERR_UNKNOWN, false, "database error"); */
    357 /*         psFree(query); */
    358 /*         return false; */
    359 /*     } */
    360 /*     psFree(query); */
    361 
    362 /*     psArray *output = p_psDBFetchResult(config->dbh); */
    363 /*     if (!output) { */
    364 /*         psError(PS_ERR_UNKNOWN, false, "database error"); */
    365 /*         return false; */
    366 /*     } */
    367 /*     if (!psArrayLength(output)) { */
    368 /*         psTrace("addtool", PS_LOG_INFO, "no rows found"); */
    369 /*         psFree(output); */
    370 /*         return true; */
    371 /*     } */
    372 
    373 /*     // negate simple so the default is true */
    374 /*     if (!ippdbPrintMetadatas(stdout, output, "addProcessedExp", !simple)) { */
    375 /*         psError(PS_ERR_UNKNOWN, false, "failed to print array"); */
    376 /*         psFree(output); */
    377 /*         return false; */
    378 /*     } */
    379 
    380 /*     psFree(output); */
    381 
    382 /*     return true; */
    383 /* } */
    384 
    385343static bool addprocessedexpMode(pxConfig *config)
    386344{
     
    392350    // optional
    393351    PXOPT_LOOKUP_F32(dtime_addstar, config->args,  "-dtime_addstar", false, false);
    394 
    395352    PXOPT_LOOKUP_S32(n_stars, config->args,        "-n_stars", false, false);
    396 
    397353    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
    398 
    399354    PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false);
    400355
     
    469424        return false;
    470425    }
    471 
    472     // NULL for end_stage means go as far as possible
    473     // EAM : skip here if fault != 0
    474     // Also, we can run fake even if tess_id is not defined
    475 /*     if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "add"))) { */
    476 /*         psFree(row); */
    477 /*         psFree(pendingRow); */
    478 /*         if (!psDBCommit(config->dbh)) { */
    479 /*             psError(PS_ERR_UNKNOWN, false, "database error"); */
    480 /*             return false; */
    481 /*         } */
    482 /*         return true; */
    483 /*     } */
    484426    psFree(row);
    485     // else continue on...
    486 
    487 /*     if (!pxfakeQueueByAddID(config, */
    488 /*             pendingRow->add_id, */
    489 /*             pendingRow->workdir, */
    490 /*             pendingRow->label, */
    491 /*             pendingRow->reduction, */
    492 /*             pendingRow->expgroup, */
    493 /*             pendingRow->dvodb, */
    494 /*             pendingRow->tess_id, */
    495 /*             pendingRow->end_stage */
    496 /*     )) { */
    497 /*         // rollback */
    498 /*         if (!psDBRollback(config->dbh)) { */
    499 /*             psError(PS_ERR_UNKNOWN, false, "database error"); */
    500 /*         } */
    501 /*         psError(PS_ERR_UNKNOWN, false, "failed to queue new fakeRun"); */
    502 /*         psFree(pendingRow); */
    503 /*         return false; */
    504 /*     } */
    505427    psFree(pendingRow);
    506428
     
    524446    // generate restrictions
    525447    psMetadata *where = psMetadataAlloc();
    526     pxaddGetSearchArgs (config, where);
    527448    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",    "==");
     449    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",    "==");
     450    pxcamGetSearchArgs (config, where);
    528451    pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
    529452    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
     
    613536
    614537    psMetadata *where = psMetadataAlloc();
    615     pxaddGetSearchArgs (config, where);
    616538    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",         "==");
     539    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",         "==");
     540    pxcamGetSearchArgs (config, where);
    617541    pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
    618542    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction",      "==");
    619 /*     PXOPT_COPY_S16(config->args, where, "-fault", "addProcessedExp.fault", "=="); */
    620543
    621544    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    710633    PXOPT_COPY_S64(config->args, where, "-add_id",   "add_id",   "==");
    711634    PXOPT_COPY_S64(config->args, where, "-cam_id",  "cam_id",  "==");
    712 /*     PXOPT_COPY_STR(config->args, where, "-class",    "class",    "=="); */
    713 /*     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); */
    714635
    715636    if (!pxSetFaultCode(config->dbh, "addProcessedExp", where, fault)) {
     
    776697    return true;
    777698}
    778 
    779699
    780700static bool unblockMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.