IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 5, 2013, 2:24:05 PM (13 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20130207
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130207

  • branches/eam_branches/ipp-20130207/ippTools/src

  • branches/eam_branches/ipp-20130207/ippTools/src/bgtool.c

    r35121 r35236  
    285285    psMetadata *where = psMetadataAlloc();
    286286    PXOPT_COPY_S64(config->args,   where, "-chip_id",            "chipRun.chip_id",       "==");
     287    PXOPT_COPY_S64(config->args,   where, "-cam_id",             "camRun.cam_id",         "==");
    287288    PXOPT_COPY_S64(config->args,   where, "-exp_id",             "rawExp.exp_id",         "==");
    288289    PXOPT_COPY_STR(config->args,   where, "-exp_name",           "rawExp.exp_name",       "==");
     
    324325    PXOPT_COPY_F32(config->args,   where, "-sun_angle_min",      "rawExp.sun_angle",      ">=");
    325326    PXOPT_COPY_F32(config->args,   where, "-sun_angle_max",      "rawExp.sun_angle",      "<");
    326     pxAddLabelSearchArgs(config,   where, "-label",              "chipRun.label",         "==");
     327    PXOPT_COPY_STR(config->args,   where, "-label",              "chipRun.label",         "==");
     328    PXOPT_COPY_STR(config->args,   where, "-cam_label",          "camRun.label",          "==");
    327329
    328330    if (!psListLength(where->list)) {
     
    343345    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    344346    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
     347    PXOPT_LOOKUP_STR(cam_label, config->args, "-cam_label", false, false);
     348    PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", false, false);
     349    if (!cam_id && !cam_label) {
     350        psError(PXTOOLS_ERR_CONFIG, true, "either cam_id or cam_label is required");
     351        return false;
     352    }
    345353
    346354    // Get chip runs to promote to chipBackgroundRun
     
    364372    }
    365373
     374    psString labelHook = psStringCopy("");
    366375    if (!rerun) {
    367         psStringAppend(&query, "\nAND chipBackgroundRun.chip_bg_id IS NULL");
    368376        if (label) {
    369             psStringAppend(&query,
    370                            "\nAND (chipBackgroundRun.label = '%s'"
    371                            " OR chipBackgroundRun.label IS NULL)",
    372                            label);
    373         }
    374         if (data_group) {
    375             psStringAppend(&query,
    376                            "\nAND (chipBackgroundRun.data_group = '%s'"
    377                            " OR chipBackgroundRun.data_group IS NULL)",
    378                            data_group);
    379         }
    380         if (dist_group) {
    381             psStringAppend(&query,
    382                            "\nAND (chipBackgroundRun.dist_group = '%s'"
    383                            " OR chipBackgroundRun.dist_group IS NULL)",
    384                            dist_group);
    385         }
     377            // check for run with the newly specified label
     378            psStringAppend(&labelHook, "\nAND (chipBackgroundRun.label = '%s')", label);
     379        }
     380        psStringAppend(&query, "\nAND chip_bg_id IS NULL");
    386381    }
    387382
     
    391386    }
    392387
    393     if (!p_psDBRunQuery(config->dbh, query)) {
     388    if (!p_psDBRunQueryF(config->dbh, query, labelHook)) {
    394389        psError(psErrorCodeLast(), false, "database error");
    395390        psFree(query);
     391        psFree(labelHook);
    396392        if (!psDBRollback(config->dbh)) {
    397393            psError(psErrorCodeLast(), false, "database error");
     
    400396    }
    401397    psFree(query);
     398    psFree(labelHook);
    402399
    403400    psArray *output = p_psDBFetchResult(config->dbh); // Matching rows
     
    420417    if (pretend) {
    421418        // negative simple so the default is true
    422         if (!ippdbPrintMetadatas(stdout, output, "chipRun", !simple)) {
     419        if (!ippdbPrintMetadatas(stdout, output, "chipBackgroundRun", !simple)) {
    423420            psError(psErrorCodeLast(), false, "failed to print array");
    424421            psFree(output);
     
    435432        psMetadata *md = output->data[i];
    436433
    437         chipRunRow *row = chipRunObjectFromMetadata(md);
     434        chipBackgroundRunRow *row = chipBackgroundRunObjectFromMetadata(md);
    438435        if (!row) {
    439436            psError(psErrorCodeLast(), false, "failed to convert metadata into fakeRun");
     
    445442        }
    446443
    447         if (!chipBackgroundRunInsert(config->dbh, 0, row->chip_id, "new",
     444        if (!chipBackgroundRunInsert(config->dbh, 0, row->chip_id, row->cam_id, "new",
    448445                                     workdir     ? workdir    : row->workdir,
    449446                                     label       ? label      : row->label,
     
    560557
    561558    if (psArrayLength(output)) {
    562         if (!ippdbPrintMetadatas(stdout, output, "chipBackgroundRun", !simple)) {
     559        if (!ippdbPrintMetadatas(stdout, output, "pendingchipBackgroundRun", !simple)) {
    563560            psError(psErrorCodeLast(), false, "failed to print array");
    564561            psFree(output);
     
    621618        return true;
    622619    }
    623     if (!ippdbPrintMetadatas(stdout, output, "chipBackgroundImfile", !simple)) {
     620    if (!ippdbPrintMetadatas(stdout, output, "pendingchipBackgroundImfile", !simple)) {
    624621        psError(psErrorCodeLast(), false, "failed to print array");
    625622        psFree(output);
     
    12951292    PXOPT_COPY_F32(config->args,   where, "-sun_angle_max",      "rawExp.sun_angle",      "<");
    12961293    pxAddLabelSearchArgs(config,   where, "-warp_label",         "warpRun.label",         "==");
    1297     pxAddLabelSearchArgs(config,   where, "-chip_label",         "chipBackgroundRun.label", "==");
     1294    pxAddLabelSearchArgs(config,   where, "-chip_bg_label",      "chipBackgroundRun.label", "==");
     1295    pxAddLabelSearchArgs(config,   where, "-chip_label",         "chipRun.label",         "==");
    12981296
    12991297    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    13351333    }
    13361334
     1335    psString labelHook = psStringCopy("");
    13371336    if (!rerun) {
    1338         psStringAppend(&query, "\nAND warpBackgroundRun.warp_bg_id IS NULL");
    13391337        if (label) {
    1340             psStringAppend(&query,
    1341                            "\nAND (warpBackgroundRun.label = '%s'"
    1342                            " OR warpBackgroundRun.label IS NULL)",
    1343                            label);
    1344         }
    1345         if (data_group) {
    1346             psStringAppend(&query,
    1347                            "\nAND (warpBackgroundRun.data_group = '%s'"
    1348                            " OR warpBackgroundRun.data_group IS NULL)",
    1349                            data_group);
    1350         }
    1351         if (dist_group) {
    1352             psStringAppend(&query,
    1353                            "\nAND (warpBackgroundRun.dist_group = '%s'"
    1354                            " OR warpBackgroundRun.dist_group IS NULL)",
    1355                            dist_group);
    1356         }
     1338            // check for run with the newly specified label
     1339            psStringAppend(&labelHook, "\nAND (warpBackgroundRun.label = '%s')", label);
     1340        }
     1341        psStringAppend(&query, "\nAND warp_bg_id IS NULL");
    13571342    }
    13581343
     
    13621347    }
    13631348
    1364     if (!p_psDBRunQuery(config->dbh, query)) {
    1365         psError(psErrorCodeLast(), false, "database error");
     1349    if (!p_psDBRunQueryF(config->dbh, query, labelHook)) {
     1350        psError(psErrorCodeLast(), false, "database error");
     1351        psFree(labelHook);
    13661352        psFree(query);
    13671353        if (!psDBRollback(config->dbh)) {
     
    13701356        return false;
    13711357    }
     1358    psFree(labelHook);
    13721359    psFree(query);
    13731360
     
    13911378    if (pretend) {
    13921379        // negative simple so the default is true
    1393         if (!ippdbPrintMetadatas(stdout, output, "warpRun", !simple)) {
     1380        if (!ippdbPrintMetadatas(stdout, output, "warpBackgroundRun", !simple)) {
    13941381            psError(psErrorCodeLast(), false, "failed to print array");
    13951382            psFree(output);
     
    14081395        psS64 chip_bg_id = psMetadataLookupS64(NULL, md, "chip_bg_id");
    14091396
    1410         warpRunRow *row = warpRunObjectFromMetadata(md);
     1397       
     1398        warpBackgroundRunRow *row = warpBackgroundRunObjectFromMetadata(md);
    14111399        if (!row) {
    1412             psError(psErrorCodeLast(), false, "failed to convert metadata into fakeRun");
     1400            psError(psErrorCodeLast(), false, "failed to convert metadata into warpRun");
    14131401            psFree(output);
    14141402            if (!psDBRollback(config->dbh)) {
     
    16651653
    16661654    psMetadata *where = psMetadataAlloc();
    1667     PXOPT_COPY_S64(config->args, where, "-warp_bg_id",    "warpBackgroundRun.warp_bg_id", "==");
    1668     PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpBackgroundSkyfile.skycell_id", "==");
    1669     pxAddLabelSearchArgs(config, where, "-label",   "warpBackgroundRun.label", "LIKE");
     1655    PXOPT_COPY_S64(config->args, where, "-warp_bg_id",   "warpBackgroundRun.warp_bg_id", "==");
     1656    PXOPT_COPY_S64(config->args, where, "-warp_id",      "warpBackgroundRun.warp_id", "==");
     1657    PXOPT_COPY_S64(config->args, where, "-chip_bg_id",   "warpBackgroundRun.chip_bg_id", "==");
     1658    PXOPT_COPY_STR(config->args, where, "-skycell_id",   "warpBackgroundSkyfile.skycell_id", "==");
     1659    pxAddLabelSearchArgs(config, where, "-label",        "warpBackgroundRun.label", "LIKE");
    16701660    pxAddLabelSearchArgs(config, where, "-data_group",   "warpBackgroundRun.data_group", "LIKE");
    16711661    pxAddLabelSearchArgs(config, where, "-dist_group",   "warpBackgroundRun.data_group", "LIKE");
Note: See TracChangeset for help on using the changeset viewer.