- Timestamp:
- Apr 21, 2014, 5:42:34 AM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (2 props)
-
ippTools/src/stacktool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/ippTools/src
- Property svn:ignore
-
old new 47 47 sctool 48 48 releasetool 49 fftool 50 remotetool 51
-
- Property svn:mergeinfo deleted
- Property svn:ignore
-
branches/eam_branches/ps2-tc3-20130727/ippTools/src/stacktool.c
r35856 r36680 44 44 static bool tosummaryMode(pxConfig *config); 45 45 static bool addsummaryMode(pxConfig *config); 46 static bool revertsummaryMode(pxConfig *config); 47 static bool summaryMode(pxConfig *config); 46 48 static bool pendingcleanuprunMode(pxConfig *config); 47 49 static bool pendingcleanupskyfileMode(pxConfig *config); … … 84 86 MODECASE(STACKTOOL_MODE_TOSUMMARY, tosummaryMode); 85 87 MODECASE(STACKTOOL_MODE_ADDSUMMARY, addsummaryMode); 88 MODECASE(STACKTOOL_MODE_REVERTSUMMARY, revertsummaryMode); 89 MODECASE(STACKTOOL_MODE_SUMMARY, summaryMode); 86 90 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 87 91 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); … … 748 752 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 749 753 PXOPT_COPY_STR(config->args, where, "-label", "stackRun.label", "=="); 754 PXOPT_COPY_STR(config->args, where, "-data_group", "stackRun.data_group", "=="); 750 755 PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "=="); 751 756 PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociationMap.sass_id", "=="); … … 1567 1572 } 1568 1573 1574 static bool revertsummaryMode(pxConfig *config) { 1575 PS_ASSERT_PTR_NON_NULL(config, NULL); 1576 PXOPT_LOOKUP_S64(sass_id, config->args, "-sass_id", true, false); 1577 1578 psString query = pxDataGet("stacktool_revertsummary.sql"); 1579 if (!query) { 1580 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1581 return(false); 1582 } 1583 if (!p_psDBRunQueryF(config->dbh, query, sass_id)) { 1584 psError(PS_ERR_UNKNOWN, false, "database error"); 1585 psFree(query); 1586 return(false); 1587 } 1588 psS64 numUpdated = psDBAffectedRows(config->dbh); 1589 1590 if (numUpdated != 1) { 1591 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 1592 psFree(query); 1593 return(false); 1594 } 1595 psLogMsg("stacktool", PS_LOG_INFO, "Deleted %ld rows", numUpdated); 1596 1597 psFree(query); 1598 1599 return(true); 1600 } 1601 1602 static bool summaryMode(pxConfig *config) 1603 { 1604 PS_ASSERT_PTR_NON_NULL(config, false); 1605 1606 psMetadata *where = psMetadataAlloc(); 1607 PXOPT_COPY_S64(config->args, where, "-sass_id", "stackSummary.sass_id", "=="); 1608 PXOPT_COPY_STR(config->args, where, "-projection_cell", "stackAssociation.projection_cell", "=="); 1609 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackAssociation.tess_id", "LIKE"); 1610 PXOPT_COPY_STR(config->args, where, "-filter", "stackAssociation.filter", "LIKE"); 1611 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "=="); 1612 pxAddLabelSearchArgs(config, where, "-data_group", "stackAssociation.data_group", "LIKE"); 1613 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "LIKE"); 1614 // PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "=="); 1615 pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "LIKE"); 1616 // PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "=="); 1617 // PXOPT_COPY_F64(config->args, where, "-mjd_obs_begin", "stackSumSkyfile.mjd_obs", ">="); 1618 // PXOPT_COPY_F64(config->args, where, "-mjd_obs_end", "stackSumSkyfile.mjd_obs", "<="); 1619 // PXOPT_COPY_S16(config->args, where, "-background_model","stackSumSkyfile.background_model", "=="); 1620 1621 // PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1622 1623 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1624 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1625 1626 psString query = pxDataGet("stacktool_summary.sql"); 1627 if (!query) { 1628 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1629 return false; 1630 } 1631 1632 if (psListLength(where->list)) { 1633 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1634 psStringAppend(&query, " WHERE %s", whereClause); 1635 psFree(whereClause); 1636 } else { 1637 psError(PXTOOLS_ERR_CONFIG, true, "search parameters are required"); 1638 return false; 1639 } 1640 1641 psFree(where); 1642 1643 // treat limit == 0 as "no limit" 1644 if (limit) { 1645 psString limitString = psDBGenerateLimitSQL(limit); 1646 psStringAppend(&query, " %s", limitString); 1647 psFree(limitString); 1648 } 1649 1650 if (!p_psDBRunQuery(config->dbh, query)) { 1651 psError(PS_ERR_UNKNOWN, false, "database error"); 1652 psFree(query); 1653 return false; 1654 } 1655 psFree(query); 1656 1657 psArray *output = p_psDBFetchResult(config->dbh); 1658 if (!output) { 1659 psErrorCode err = psErrorCodeLast(); 1660 switch (err) { 1661 case PS_ERR_DB_CLIENT: 1662 psError(PXTOOLS_ERR_SYS, false, "database error"); 1663 case PS_ERR_DB_SERVER: 1664 psError(PXTOOLS_ERR_PROG, false, "database error"); 1665 default: 1666 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1667 } 1668 1669 return false; 1670 } 1671 if (!psArrayLength(output)) { 1672 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 1673 psFree(output); 1674 return true; 1675 } 1676 1677 if (psArrayLength(output)) { 1678 if (!ippdbPrintMetadatas(stdout, output, "stackSummary", !simple)) { 1679 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1680 psFree(output); 1681 return false; 1682 } 1683 } 1684 1685 psFree(output); 1686 1687 return true; 1688 } 1689 1569 1690 static bool pendingcleanuprunMode(pxConfig *config) 1570 1691 {
Note:
See TracChangeset
for help on using the changeset viewer.
