IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

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

    r18336 r18561  
    4545    // -newExp
    4646    psMetadata *newExpArgs = psMetadataAlloc();
    47     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_exp_name",  0,
    48             "define the exp_name (required)", NULL);
    49     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_inst",  0,
    50             "define the camera name (required)", NULL);
    51     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_telescope",  0,
    52             "define the telescope name (required)", NULL);
    53     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-workdir",  0,
    54             "define workdir (required)", 0);
    55     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-reduction",  0,
    56             "define reduction class", NULL);
    57     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-dvodb",  0,
    58             "define the dvodb for the next processing step", NULL);
    59     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tess_id",  0,
    60             "define the tess_id for the next processing step", NULL);
    61     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-end_stage",  0,
    62             "define the end goal processing step", NULL);
    63     psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-label",  0,
    64             "define a label (carried to chip stage)", NULL);
    65     psMetadataAddBool(newExpArgs, PS_LIST_TAIL, "-simple",  0,
    66             "use the simple output format", false);
     47    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_exp_name",  0,            "define the exp_name (required)", NULL);
     48    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_inst",  0,            "define the camera name (required)", NULL);
     49    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tmp_telescope",  0,            "define the telescope name (required)", NULL);
     50    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-workdir",  0,            "define workdir (required)", 0);
     51    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-reduction",  0,            "define reduction class", NULL);
     52    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-dvodb",  0,            "define the dvodb for the next processing step", NULL);
     53    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-tess_id",  0,            "define the tess_id for the next processing step", NULL);
     54    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-end_stage",  0,            "define the end goal processing step", NULL);
     55    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-label",  0,            "define a label (carried to chip stage)", NULL);
     56    psMetadataAddBool(newExpArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
    6757
    6858    // -newImfile
    6959    psMetadata *newImfileArgs = psMetadataAlloc();
    70     psMetadataAddS64(newImfileArgs, PS_LIST_TAIL, "-exp_id",  0,
    71             "define the exp_id (required)", 0);
    72     psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-tmp_class_id",  0,
    73             "define the class ID (required)", NULL);
    74     psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-uri",  0,
    75             "define the URI (required)", NULL);
     60    psMetadataAddS64(newImfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "define the exp_id (required)", 0);
     61    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-tmp_class_id",  0,            "define the class ID (required)", NULL);
     62    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-uri",  0,            "define the URI (required)", NULL);
    7663
    7764    // -updatenewExp
    7865    psMetadata *updatenewExpArgs = psMetadataAlloc();
    79     psMetadataAddS64(updatenewExpArgs, PS_LIST_TAIL, "-exp_id",  0,
    80             "define the exp_id (required)", 0);
    81     psMetadataAddStr(updatenewExpArgs, PS_LIST_TAIL, "-state", 0,
    82             "set state (required)", NULL);
    83 
     66    psMetadataAddS64(updatenewExpArgs, PS_LIST_TAIL, "-exp_id",  0,            "define the exp_id (required)", 0);
     67    psMetadataAddStr(updatenewExpArgs, PS_LIST_TAIL, "-state", 0,            "set state (required)", NULL);
    8468
    8569    psMetadata *argSets = psMetadataAlloc();
     
    10185    psFree(modes);
    10286
    103     // setup search criterion
    104 #define addWhereStr(name) \
    105 { \
    106     psString str = NULL; \
    107     bool status = false; \
    108     if ((str = psMetadataLookupStr(&status, config->args, "-" #name))) { \
    109         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    110             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    111             psFree(config); \
    112             return NULL; \
    113         } \
    114     } \
    115 }
    116 
    117     // generate SQL where clause
    118     config->where = psMetadataAlloc();
    119 
    120     addWhereStr(det_id);
    121     {
    122         int n = 0;
    123         bool status = false;
    124         if ((n = psMetadataLookupS32(&status, config->args, "-iteration"))) {
    125             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
    126                 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
    127                 psFree(config);
    128                 return NULL;
    129             }
    130         }
    131     }
    132     addWhereStr(det_type);
    133     addWhereStr(exp_id);
    134     addWhereStr(class_id);
    135     // convert '-inst' to 'camera'
    136     {
    137         psString str = NULL;
    138         bool status = false;
    139         if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
    140             if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    141                 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    142                 psFree(config);
    143                 return NULL;
    144             }
    145         }
    146     }
    147     addWhereStr(telescope);
    148     {
    149         int n = 0;
    150         bool status = false;
    151         if ((n = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
    152             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
    153                 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
    154                 psFree(config);
    155                 return NULL;
    156             }
    157         }
    158     }
    159     addWhereStr(filter);
    160     addWhereStr(stats);
    161     addWhereStr(recipe);
    162     {
    163         int n = 0;
    164         bool status = false;
    165         if ((n = psMetadataLookupS32(&status, config->args, "-guide_version"))) {
    166             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "guide_version", 0, "==", n)) {
    167                 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_version");
    168                 psFree(config);
    169                 return NULL;
    170             }
    171         }
    172     }
    173     {
    174         bool boolean = false;
    175         bool status = false;
    176 
    177         if ((boolean = psMetadataLookupBool(&status, config->args, "-accept"))) {
    178             if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
    179                 psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
    180                 psFree(config);
    181                 return NULL;
    182             }
    183         }
    184     }
    185 
    186     if (config->where->list->n < 1) {
    187         psFree(config->where);
    188         config->where = NULL;
    189     }
    190 
    19187    // define Database handle, if used
    19288    // do this last so we don't setup a connection before CLI options are
Note: See TracChangeset for help on using the changeset viewer.