IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23181


Ignore:
Timestamp:
Mar 4, 2009, 8:59:47 AM (17 years ago)
Author:
eugene
Message:

allow -updateskyfile to set the state; code or state is required, but not both; change_skyfile_data_state now does not enforce valid transitions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/eam_branch_20090303/ippTools/src/warptool.c

    r21402 r23181  
    5555static bool updateskyfileMode(pxConfig *config);
    5656
     57static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state);
    5758static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    5859static bool isValidMode(pxConfig *config, const char *mode);
     
    16041605// shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
    16051606
     1607// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
     1608// this is getting fairly messy now that we have added a few additional target and
     1609// destination states.  I'm disabling these restrictions for now; is there are better way
     1610// to enforce the allowed state transitions?
     1611
    16061612static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
    16071613{
     
    16191625    }
    16201626
     1627    // XXX this feature is disabled (run_state is ignored)
    16211628    // note only updates if warpRun.state = run_state
    1622     if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
     1629
     1630    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
    16231631        psError(PS_ERR_UNKNOWN, false, "database error");
    16241632        // rollback
     
    16681676    PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
    16691677    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     1678    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    16701679    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    16711680
    1672     psString query = pxDataGet("warptool_updateskyfile.sql");
    1673 
    1674     if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
    1675         psError(PS_ERR_UNKNOWN, false, "database error");
    1676         return false;
    1677     }
    1678     psFree(query);
    1679 
    1680     return true;
    1681 }
     1681    if (state && code) {
     1682        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
     1683        return false;
     1684    }
     1685
     1686    if (state) {
     1687      // make sure that the state string is valid
     1688      if (!pxIsValidState(state)) {
     1689        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     1690        return false;
     1691      }
     1692      if (!change_skyfile_data_state(config, state, "unknown")) {
     1693        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     1694        return false;
     1695      }
     1696      return true;
     1697    }
     1698
     1699    if (code) {
     1700      psString query = pxDataGet("warptool_updateskyfile.sql");
     1701
     1702      if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
     1703        psError(PS_ERR_UNKNOWN, false, "database error");
     1704        return false;
     1705      }
     1706      psFree(query);
     1707      return true;
     1708    }
     1709
     1710    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
     1711    return false;
     1712}
Note: See TracChangeset for help on using the changeset viewer.