IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/ippTools/src/disttool.c

    r26997 r27517  
    137137
    138138    // optional
    139     PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id",  false, false);
     139    PXOPT_LOOKUP_BOOL(use_alternate, config->args, "-use_alternate", false);
    140140    PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false);
    141141    PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false);
     142    PXOPT_LOOKUP_STR(set_data_group, config->args, "-set_data_group", false, false);
    142143    PXOPT_LOOKUP_STR(set_note, config->args, "-set_note", false, false);
    143144
     
    145146    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    146147
    147     PXOPT_LOOKUP_BOOL(dry_run, config->args, "-dry_run", false);
     148    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
     149
     150    if (use_alternate) {
     151        if (strcmp(stage, "raw")) {
     152            psError(PXTOOLS_ERR_SYS, true, "alternate inputs only supported for raw stage");
     153            return false;
     154        }
     155        if (no_magic) {
     156            psError(PXTOOLS_ERR_SYS, true, "no_magic forbidden with alternate inputs");
     157            return false;
     158        }
     159    }
    148160
    149161    // select arguments
     
    161173    psString runJoinStr = NULL;
    162174    if (!strcmp(stage, "raw")) {
    163         magicRunType = "rawExp";
    164         runJoinStr = "rawExp.exp_id";
     175        if (! use_alternate ) {
     176            magicRunType = "rawExp";
     177            runJoinStr = "rawExp.exp_id";
     178        } else {
     179            magicRunType = "camRun";
     180            runJoinStr = "camRun.exp_id";
     181        }
    165182        query = pxDataGet("disttool_definebyquery_raw.sql");
    166183        if (!query) {
     
    170187        }
    171188
    172         // for raw stage we select by chipRun.label because raw labels typically aren't set
     189        // for raw stage we select by camRun.label and dist_group because rawExp doesn't have those columns
    173190        if (label) {
    174             psStringAppend(&query, " AND (chipRun.label = '%s')", label);
     191            psStringAppend(&query, " AND (magicDSRun.label = '%s')", label);
    175192        }
    176193        if (dist_group) {
    177             psStringAppend(&query, " AND (chipRun.dist_group = '%s')", dist_group);
     194            psStringAppend(&query, " AND (camRun.dist_group = '%s')", dist_group);
    178195        }
    179196    } else if (!strcmp(stage, "chip")) {
     
    301318    }
    302319
     320    if (!strcmp(stage, "raw")) {
     321        if (!no_magic) {
     322            psStringAppend(&query, " AND (magicDSRun.re_place = %d)", !use_alternate);
     323            psStringAppend(&query, " AND (camRun.state = 'full')");
     324        }
     325    }
     326
    303327    if (psListLength(where->list)) {
    304328        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     
    311335
    312336    if (!no_magic) {
    313         psStringAppend(&query, " AND (%s.magicked)", magicRunType);
    314 
    315         // is selecting by magic_ds_id really interesting?
    316         if (magic_ds_id) {
    317             if (!runJoinStr) {
    318                 psError(PS_ERR_PROGRAMMING, true, "cannot select by magic_ds_id for stage: %s", stage);
    319                 psFree(query);
    320                 return false;
    321             }
    322             psStringAppend(&joinHook, "\nJOIN magicDSRun ON magicDSRun.stage = distTarget.stage"
    323                                               " AND magicDSRun.stage_id = %s", runJoinStr);
    324             psStringAppend(&query, " AND (magicDSRun.state = 'full' AND magicDSRun.re_place AND (magicDSRun.magic_ds_id = %" PRId64 "))", magic_ds_id);
    325         }
     337        psStringAppend(&query, " AND (%s.magicked > 0)", magicRunType);
    326338    }
    327339
     
    352364
    353365
    354     if (dry_run) {
     366    if (pretend) {
    355367        if (!ippdbPrintMetadatas(stdout, output, "newdistRuns", true)) {
    356368            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     
    376388        psS64 target_id = psMetadataLookupS64(NULL, md, "target_id");
    377389        psString stage_label = psMetadataLookupStr(NULL, md, "label");
    378         psString data_group = psMetadataLookupStr(NULL, md, "data_group");
     390        psString stage_data_group = psMetadataLookupStr(NULL, md, "data_group");
    379391        bool clean = psMetadataLookupBool(NULL, md, "clean");
    380392
     
    388400            new_label = stage_label;
    389401        }
     402        psString new_data_group;
     403        if (set_data_group != NULL) {
     404            new_data_group = set_data_group;
     405        } else {
     406            new_data_group = stage_data_group;
     407        }
     408
    390409        distRunRow *row = distRunRowAlloc(
    391410                0,      // dist_id
     
    399418                clean,
    400419                no_magic,
     420                use_alternate,
    401421                "new",
    402422                NULL,    // time_stamp
    403423                0,       // fault
    404                 data_group,
     424                new_data_group,
    405425                set_note // note does not propagate
    406426                );
     
    448468    PXOPT_COPY_STR(config->args, where, "-state", "distRun.state", "==");
    449469    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    450     PXOPT_COPY_STR(config->args, where, "-data_group", "distRun.data_group", "==");
     470    PXOPT_COPY_STR(config->args, where, "-data_group", "distRun.data_group", "LIKE");
    451471    PXOPT_COPY_STR(config->args, where, "-dist_group", "distTarget.dist_group", "==");
    452472    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     
    460480    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    461481    PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
     482    PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false);
    462483    PXOPT_LOOKUP_STR(outdir, config->args, "-set_outdir", false, false);
    463484    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    464 
    465     if ((!state) && (!label) && (!fault)) {
    466         psError(PXTOOLS_ERR_CONFIG, false, "parameters (-fault or -set_state or -set_label) are required");
     485    PXOPT_LOOKUP_STR(set_note, config->args, "-set_note", false, false);
     486
     487    if ((!state) && (!label) && (!fault) &&(!data_group)) {
     488        psError(PXTOOLS_ERR_CONFIG, false, "parameters (-fault or -set_state or -set_label -set_data_group) are required");
    467489        psFree(where);
    468490        return false;
     
    485507        psStringAppend(&query, " , distRun.fault = %d", fault);
    486508    }
     509
     510    if (data_group) {
     511        psStringAppend(&query, " , distRun.data_group = '%s'", data_group);
     512    }
     513
     514    if (set_note) {
     515        psStringAppend(&query, " , distRun.note = '%s'", set_note);
     516    }
     517
    487518
    488519    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
Note: See TracChangeset for help on using the changeset viewer.