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/stacktool.c

    r37105 r37823  
    4141static bool sumskyfileMode(pxConfig *config);
    4242static bool sassskyfileMode(pxConfig *config);
     43static bool updatesassMode(pxConfig *config);
    4344static bool revertsumskyfileMode(pxConfig *config);
    4445static bool tosummaryMode(pxConfig *config);
     
    8283        MODECASE(STACKTOOL_MODE_ADDSUMSKYFILE,         addsumskyfileMode);
    8384        MODECASE(STACKTOOL_MODE_SUMSKYFILE,            sumskyfileMode);
    84         MODECASE(STACKTOOL_MODE_SASSSKYFILE,            sassskyfileMode);
     85        MODECASE(STACKTOOL_MODE_SASSSKYFILE,           sassskyfileMode);
     86        MODECASE(STACKTOOL_MODE_UPDATESASS,            updatesassMode);
    8587        MODECASE(STACKTOOL_MODE_REVERTSUMSKYFILE,      revertsumskyfileMode);
    8688        MODECASE(STACKTOOL_MODE_TOSUMMARY,             tosummaryMode);
     
    756758    PXOPT_COPY_STR(config->args, where, "-data_group", "stackRun.data_group", "==");
    757759    PXOPT_COPY_STR(config->args, where, "-state",     "stackRun.state",     "==");
    758     PXOPT_COPY_S64(config->args, where, "-sass_id",   "stackAssociationMap.sass_id",  "==");
     760
    759761    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     762    PXOPT_LOOKUP_S64(sass_id, config->args, "-sass_id", false, false);
     763
     764    if (sass_id) {
     765      PXOPT_COPY_S64(config->args, where, "-sass_id",   "stackAssociationMap.sass_id",  "==");
     766    }
     767   
    760768    if (!psListLength(where->list)) {
    761769        psFree(where);
     
    771779        PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "==");
    772780    }
    773 
     781    if (sass_id) {
     782      psStringAppend(&query, " JOIN stackAssociationMap USING(stack_id)");
     783    }
     784   
    774785    // pxUpdateRun gets parameters from config->args and updates
    775786    bool result = pxUpdateRun(config, where, &query, "stackRun", "stack_id", "stackSumSkyfile", true, false);
     
    12951306    PXOPT_COPY_STR(config->args, where, "-data_group", "stackAssociation.data_group", "LIKE");
    12961307
    1297 //  The following three selectors are incompatible with the sql so omit them
    1298 //    PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "==");
    1299 //     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
    1300 //    PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "==");
    1301 
    13021308    PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
    13031309
     
    13691375}
    13701376
     1377static bool updatesassMode(pxConfig *config)
     1378{
     1379  PS_ASSERT_PTR_NON_NULL(config, false);
     1380
     1381  psMetadata *where = psMetadataAlloc();
     1382  PXOPT_COPY_S64(config->args, where, "-sass_id", "sass_id", "==");
     1383  PXOPT_COPY_STR(config->args, where, "-data_group", "data_group", "==");
     1384  PXOPT_COPY_STR(config->args, where, "-projection_cell", "projection_cell", "==");
     1385  PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
     1386  PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
     1387  if (!psListLength(where->list)) {
     1388    psFree(where);
     1389    psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     1390    return false;
     1391  }
     1392
     1393  psMetadata *values = psMetadataAlloc();
     1394  PXOPT_COPY_STR(config->args, values, "-set_data_group", "data_group", "==");
     1395  if (!psListLength(values->list)) {
     1396    psFree(values);
     1397    psError(PXTOOLS_ERR_CONFIG, false, "data_group to assign not found");
     1398    return false;
     1399  }
     1400
     1401  if (!psDBTransaction(config->dbh)) {
     1402    psError(PS_ERR_UNKNOWN, false, "database error");
     1403    return false;
     1404  }
     1405 
     1406  long rows = psDBUpdateRows(config->dbh, "stackAssociation", where, values);
     1407  psFree(values);
     1408  psFree(where);
     1409
     1410  if (rows != 1) {
     1411    psError(PS_ERR_UNKNOWN, false, "should have updated only one row. updated %ld", rows);
     1412    return false;
     1413  }
     1414
     1415  if (!psDBCommit(config->dbh)) {
     1416    psError(PS_ERR_UNKNOWN, false, "database error");
     1417    return false;
     1418  }
     1419
     1420  return true;
     1421}
    13711422
    13721423static bool revertsumskyfileMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.