IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2008, 4:24:35 PM (18 years ago)
Author:
jhoblitt
Message:

implement chiptool -updaterun querying

File:
1 edited

Legend:

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

    r17148 r17161  
    22 * pxchip.c
    33 *
    4  * Copyright (C) 2007  Joshua Hoblitt
     4 * Copyright (C) 2007-2008  Joshua Hoblitt
    55 *
    66 * This program is free software; you can redistribute it and/or modify it
     
    5757
    5858
     59bool pxchipRunSetStateByQuery(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 chipRun 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
    5996bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label)
    6097{
     
    73110
    74111
     112bool pxchipRunSetLabelByQuery(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 chipRun JOIN rawExp USING(exp_id) SET 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);
     132
     133    return true;
     134}
     135
     136
    75137psS64 pxchipQueueByExpTag(pxConfig *config,
    76138                         psS64 exp_id,
    77                          char *workdir,
    78                          char *label,
    79                          char *reduction,
    80                          char *expgroup,
    81                          char *dvodb,
    82                          char *tess_id,
    83                          char *end_stage)
     139                         const char *workdir,
     140                         const char *label,
     141                         const char *reduction,
     142                         const char *expgroup,
     143                         const char *dvodb,
     144                         const char *tess_id,
     145                         const char *end_stage)
    84146{
    85147    PS_ASSERT_PTR_NON_NULL(config, false);
Note: See TracChangeset for help on using the changeset viewer.