IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 14, 2009, 11:06:18 AM (17 years ago)
Author:
bills
Message:

Add data_group, dist_group, and note to the pipeline. These new columns will be used
for some of the tasks that label was used previously.

File:
1 edited

Legend:

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

    r25324 r25835  
    108108    return true;
    109109}
     110
     111// shared code for updating the various strings for a Run
     112bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, bool has_dist_group)
     113{
     114    PS_ASSERT_PTR_NON_NULL(config, false);
     115    PS_ASSERT_PTR_NON_NULL(where, false);
     116    PS_ASSERT_PTR_NON_NULL(pQuery, false);
     117    PS_ASSERT_PTR_NON_NULL(*pQuery, false);
     118
     119    // make sure that -state is not the only selection parameter
     120    PXOPT_LOOKUP_STR(where_state, config->args, "-state", false, false);
     121    if (where_state && (psListLength(where->list) < 2)) {
     122        psError(PXTOOLS_ERR_DATA, true, "selection by -state alone is not allowed");
     123        return false;
     124    }
     125
     126    PXOPT_LOOKUP_STR(state, config->args,       "-set_state", false, false);
     127    PXOPT_LOOKUP_STR(label, config->args,       "-set_label", false, false);
     128    PXOPT_LOOKUP_STR(data_group, config->args,  "-set_data_group", false, false);
     129    PXOPT_LOOKUP_STR(note, config->args,        "-set_note", false, false);
     130
     131    psString dist_group = NULL;
     132    if (has_dist_group) {
     133        PXOPT_LOOKUP_STR(tmp_dist_group, config->args,  "-set_dist_group", false, false);
     134        dist_group = tmp_dist_group;
     135    }
     136
     137    if ((!state) && (!label) && (!data_group) && (has_dist_group && !dist_group) && !(note)) {
     138        psError(PXTOOLS_ERR_DATA, false, "parameters are required");
     139        return false;
     140    }
     141
     142    if (state && ! pxIsValidState(state)) {
     143        psError(PXTOOLS_ERR_DATA, false, "pxIsValidState failed");
     144        return false;
     145    }
     146
     147    // first paramter is added with "SET param = 'value'"
     148    // subseqent ones with ", param = 'value'"
     149    char *separator = " SET ";
     150    char *comma = ",";
     151
     152#   define addColumn(_val) \
     153        do { \
     154            if (_val) { \
     155                psStringAppend(pQuery, "%s %s = '%s'", separator, #_val, _val); \
     156                separator = comma; \
     157            } \
     158        } while (0)
     159
     160    addColumn(state);
     161    addColumn(data_group);
     162    if (has_dist_group) {
     163        addColumn(dist_group);
     164    }
     165    addColumn(note);
     166    addColumn(label);
     167
     168    psString whereClause =  psDBGenerateWhereSQL(where, NULL);
     169    psStringAppend(pQuery, " %s", whereClause);
     170    psFree(whereClause);
     171
     172    if (!p_psDBRunQuery(config->dbh, *pQuery)) {
     173        psError(PS_ERR_UNKNOWN, false, "database error");
     174        return false;
     175    }
     176
     177    return true;
     178}
Note: See TracChangeset for help on using the changeset viewer.