IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2008, 1:11:24 PM (18 years ago)
Author:
jhoblitt
Message:

add warptool -updaterun query support

File:
1 edited

Legend:

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

    r17142 r17180  
    3131bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state)
    3232{
     33    PS_ASSERT_PTR_NON_NULL(config, false);
    3334    PS_ASSERT_PTR_NON_NULL(state, false);
    3435
     
    5152        return false;
    5253    }
     54
     55    return true;
     56}
     57
     58
     59bool pxwarpRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)
     60{
     61    PS_ASSERT_PTR_NON_NULL(config, false);
     62    PS_ASSERT_PTR_NON_NULL(state, false);
     63
     64    // check that state is a valid string value
     65    if (!(
     66            (strncmp(state, "run", 4) == 0)
     67            || (strncmp(state, "stop", 5) == 0)
     68            || (strncmp(state, "reg", 4) == 0)
     69        )
     70    ) {
     71        psError(PS_ERR_UNKNOWN, false,
     72                "invalid chipRun state: %s", state);
     73        return false;
     74    }
     75
     76    psString query = psStringCopy("UPDATE warpRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET state = '%s'");
     77
     78    if (where) {
     79        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     80        psStringAppend(&query, " %s", whereClause);
     81        psFree(whereClause);
     82    }
     83
     84    if (!p_psDBRunQuery(config->dbh, query, state)) {
     85        psFree(query);
     86        psError(PS_ERR_UNKNOWN, false, "database error");
     87        return false;
     88    }
     89
     90    psFree(query);
     91
     92    return true;
     93}
     94
     95
     96bool pxwarpRunSetLabel(pxConfig *config, psS64 warp_id, const char *label)
     97{
     98    PS_ASSERT_PTR_NON_NULL(config, false);
     99    // note label == NULL should be explicitly allowed
     100
     101    char *query = "UPDATE warpRun SET warpRun.label = '%s' WHERE warp_id = %" PRId64;
     102    if (!p_psDBRunQuery(config->dbh, query, label, warp_id)) {
     103        psError(PS_ERR_UNKNOWN, false,
     104                "failed to change label for warp_id %" PRId64, warp_id);
     105        return false;
     106    }
     107
     108    return true;
     109}
     110
     111
     112bool pxwarpRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)
     113{
     114    PS_ASSERT_PTR_NON_NULL(config, false);
     115    // note label == NULL should be explicitly allowed
     116
     117    psString query = psStringCopy("UPDATE warpRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET warpRun.label = '%s'");
     118
     119    if (where) {
     120        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     121        psStringAppend(&query, " %s", whereClause);
     122        psFree(whereClause);
     123    }
     124
     125    if (!p_psDBRunQuery(config->dbh, query, label)) {
     126        psFree(query);
     127        psError(PS_ERR_UNKNOWN, false, "database error");
     128        return false;
     129    }
     130
     131    psFree(query);
    53132
    54133    return true;
Note: See TracChangeset for help on using the changeset viewer.