IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2014, 3:29:41 PM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/ippTools/src/remotetool.c

    r36928 r37026  
    2323
    2424// Update
     25static bool dropcomponentMode(pxConfig *config);
    2526static bool updaterunMode(pxConfig *config);
    2627static bool updatepollMode(pxConfig *config);
     
    4950    MODECASE(REMOTETOOL_MODE_LISTRUN,       listrunMode);
    5051    MODECASE(REMOTETOOL_MODE_LISTCOMPONENT, listcomponentMode);
     52    MODECASE(REMOTETOOL_MODE_DROPCOMPONENT, dropcomponentMode);
    5153    MODECASE(REMOTETOOL_MODE_UPDATERUN,     updaterunMode);
    5254    MODECASE(REMOTETOOL_MODE_UPDATEPOLL,    updatepollMode);
     
    9496
    9597  // Get a list of the things we can insert into a new component
     98  // CZW: these labels no longer need to be linked to the table, as I've split stageRun and remoteRun into sub-queries.
    9699  psString query = NULL;
    97100  psString whereOption = psStringCopy("");
     
    104107   
    105108    if (label) {
    106       psStringAppend(&query, " AND (chipRun.label = '%s')", label);
     109      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    107110    }
    108111  }
     
    115118   
    116119    if (label) {
    117       psStringAppend(&query, " AND (camRun.label = '%s')", label);
     120      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    118121    }
    119122  }   
     
    128131      // Because warp has to check to see if something other than the state is set correctly, I have to use this wonky way to pass the label in.
    129132      //      psStringAppend(&query, " AND (warpRun.label = '%s')", label);
    130       psStringAppend(&whereOption, "\n AND (warpRun.label = '%s')", label);
     133      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    131134    }
    132135  }   
     
    139142   
    140143    if (label) {
    141       psStringAppend(&query, " AND (stackRun.label = '%s')", label);
     144      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    142145    }
    143146  }   
     
    152155    psFree(limitString);
    153156  }
    154   if (!p_psDBRunQueryF(config->dbh, query,whereOption)) {
     157  if (!p_psDBRunQueryF(config->dbh, query,whereOption,whereOption)) { // This needs to be here twice because we need to restrict on label twice.
    155158    psError(PS_ERR_UNKNOWN, false, "database error");
    156159    psFree(query);
     
    313316// Update
    314317
     318static bool dropcomponentMode(pxConfig *config)
     319{
     320  // Assert that we have a unique component to operate on.
     321  PXOPT_LOOKUP_S64(remote_id,config->args, "-remote_id",true, false);
     322  psAssert(remote_id,"This must exist for this mode to be safe.");
     323  PXOPT_LOOKUP_S64(stage_id, config->args, "-stage_id", true, false);
     324  psAssert(stage_id,"This must exist for this mode to be safe.");
     325
     326  psString query = pxDataGet("remotetool_dropcomponent.sql");
     327  if (!query) {
     328    psError(PXTOOLS_ERR_SYS, false, "Failed to retreive SQL statement");
     329    return false;
     330  }
     331 
     332  if (!psDBTransaction(config->dbh)) {
     333    psError(PS_ERR_UNKNOWN, false, "database error");
     334    return false;
     335  }
     336
     337  if (!p_psDBRunQueryF(config->dbh, query, remote_id, stage_id)) {
     338    psError(PS_ERR_UNKNOWN, false, "Database error");
     339    psFree(query);
     340    return false;
     341  }
     342  psFree(query);
     343 
     344 
     345
     346  // point of no return
     347  if (!psDBCommit(config->dbh)) {
     348    psError(PS_ERR_UNKNOWN, false, "database error");
     349    return false;
     350  }
     351 
     352  return true;
     353}
     354
    315355static bool updaterunMode(pxConfig *config)
    316356{
Note: See TracChangeset for help on using the changeset viewer.