IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2015, 12:31:04 PM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pv3-20140717-merge/ippTools/src/laptool.c

    r36555 r37823  
    2525static bool pendingrunMode(pxConfig *config);
    2626static bool updaterunMode(pxConfig *config);
     27static bool revertsassMode(pxConfig *config);
    2728
    2829// Exposure level
     
    6970    MODECASE(LAPTOOL_MODE_PENDINGRUN,    pendingrunMode);
    7071    MODECASE(LAPTOOL_MODE_UPDATERUN,     updaterunMode);
    71 
     72    MODECASE(LAPTOOL_MODE_REVERTSASS,    revertsassMode);
     73   
    7274    MODECASE(LAPTOOL_MODE_PENDINGEXP,    pendingexpMode);
    7375    MODECASE(LAPTOOL_MODE_EXPOSURES,     exposuresMode);
     
    695697}
    696698
     699static bool revertsassMode(pxConfig *config)
     700{
     701  PS_ASSERT_PTR_NON_NULL(config, false);
     702
     703  psMetadata *where = psMetadataAlloc();
     704  PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "==");
     705  PXOPT_COPY_S64(config->args, where, "-sass_id", "final_sass_id", "==");
     706  if (!psListLength(where->list)) {
     707    psFree(where);
     708    psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     709    return false;
     710  }
     711
     712  psString query = pxDataGet("laptool_revertsass.sql");
     713  if (!query) {
     714    psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     715    return(false);
     716  }
     717  psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     718  psStringAppend(&query, "\n WHERE %s", whereClause);
     719  psFree(whereClause);
     720
     721  if (!psDBTransaction(config->dbh)) {
     722    psError(PS_ERR_UNKNOWN, false, "database error");
     723    return false;
     724  }
     725 
     726  if (!p_psDBRunQuery(config->dbh, query)) {
     727    psError(PS_ERR_UNKNOWN, false, "database error");
     728    psFree(query);
     729    return false;
     730  }
     731  psFree(query);
     732
     733  long numUpdated = psDBAffectedRows(config->dbh);
     734  if (numUpdated != 1) {
     735    psError(PS_ERR_UNKNOWN, false, "should have updated only one row. updated %ld", numUpdated);
     736    return false;
     737  }
     738
     739  if (!psDBCommit(config->dbh)) {
     740    psError(PS_ERR_UNKNOWN, false, "database error");
     741    return false;
     742  }
     743 
     744  return true;
     745}
    697746// Exposure level
    698747
Note: See TracChangeset for help on using the changeset viewer.