Changeset 28003 for branches/pap/ippTools/src/chiptool.c
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/chiptool.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippTools/src/chiptool.c
r27391 r28003 60 60 static bool runstateMode(pxConfig *config); 61 61 static bool setimfiletoupdateMode(pxConfig *config); 62 static bool listrunMode(pxConfig *config); 62 63 63 64 # define MODECASE(caseName, func) \ … … 103 104 MODECASE(CHIPTOOL_MODE_RUNSTATE, runstateMode); 104 105 MODECASE(CHIPTOOL_MODE_SETIMFILETOUPDATE, setimfiletoupdateMode); 106 MODECASE(CHIPTOOL_MODE_LISTRUN, listrunMode); 105 107 default: 106 108 psAbort("invalid option (this should not happen)"); … … 420 422 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 421 423 // we only allow a single label to match (do not use pxAddLabelSearchArgs here) 422 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", " ==");424 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE"); 423 425 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 424 PXOPT_COPY_STR(config->args, where, "-data_group", "chipRun.data_group", " ==");425 PXOPT_COPY_STR(config->args, where, "-dist_group", "chipRun.dist_group", " ==");426 PXOPT_COPY_STR(config->args, where, "-data_group", "chipRun.data_group", "LIKE"); 427 PXOPT_COPY_STR(config->args, where, "-dist_group", "chipRun.dist_group", "LIKE"); 426 428 427 429 if (!psListLength(where->list)) { … … 469 471 } 470 472 psFree(where); 473 474 psStringAppend(&query, "\nORDER BY priority DESC, chip_id"); 471 475 472 476 // treat limit == 0 as "no limit" … … 699 703 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 700 704 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 705 PXOPT_LOOKUP_BOOL(allfiles, config->args, "-allfiles", false); 706 if (allfiles) { 707 faulted = false; 708 } 701 709 702 710 psMetadata *where = psMetadataAlloc(); … … 740 748 // list only faulted rows 741 749 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault != 0"); 742 } else {750 } else if (!allfiles) { 743 751 // don't list faulted rows 744 752 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0"); … … 807 815 return false; 808 816 } 817 psString query_update = pxDataGet("chiptool_revertupdatedimfile.sql"); 818 if (!query) { 819 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 820 psFree(where); 821 return false; 822 } 809 823 810 824 if (where && psListLength(where->list)) { 811 825 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 812 826 psStringAppend(&query, " AND %s", whereClause); 827 psStringAppend(&query_update, " AND %s", whereClause); 813 828 psFree(whereClause); 814 829 } … … 822 837 } 823 838 psFree(query); 839 if (!p_psDBRunQuery(config->dbh, query_update)) { 840 psError(PS_ERR_UNKNOWN, false, "database error"); 841 psFree(query_update); 842 return false; 843 } 844 psFree(query_update); 824 845 825 846 return true; … … 1414 1435 } 1415 1436 1416 char *set_magicked_imfile = "";1417 char *set_magicked_run = "";1437 psString set_magicked_imfile = psStringCopy(""); 1438 psString set_magicked_run = psStringCopy(""); 1418 1439 if (!strcmp(data_state, "full")) { 1419 1440 // if (chipProcessedImfile.magicked < 0 and rawImfile.magicked = 0) leave magicked unchanged. This will … … 1421 1442 // otherwise copy magicked from the rawImfile 1422 1443 // Same thing for chipRun/rawExp 1423 set_magicked_imfile = "\n , chipProcessedImfile.magicked = IF((chipProcessedImfile.magicked < 0 AND rawImfile.magicked = 0), chipProcessedImfile.magicked, rawImfile.magicked)"; 1424 set_magicked_run = "\n , chipRun.magicked = IF((chipRun.magicked < 0 AND rawExp.magicked = 0), chipRun.magicked, rawExp.magicked)"; 1444 psStringAppend(&set_magicked_imfile, "\n , chipProcessedImfile.magicked = IF((chipProcessedImfile.magicked < 0" 1445 " AND rawImfile.magicked = 0), chipProcessedImfile.magicked, rawImfile.magicked)"); 1446 psStringAppend(&set_magicked_run, "\n , chipRun.magicked = IF((chipRun.magicked < 0 AND rawExp.magicked = 0), " 1447 " chipRun.magicked, rawExp.magicked)"); 1448 1425 1449 } else if (!strcmp(data_state, "cleaned") || !strcmp(data_state, "purged")) { 1426 1450 // if magicked is non-zero set it to -1 1427 set_magicked_imfile = "\n, chipProcessedImfile.magicked = IF(chipProcessedImfile.magicked = 0, 0, -1)"; 1428 set_magicked_run = "\n, chipRun.magicked = IF(chipRun.magicked = 0, 0, -1)"; 1451 // Once one imfile has been cleaned, the chipRun is no longer 'magicked' 1452 psStringAppend(&set_magicked_imfile, "\n, chipProcessedImfile.magicked = IF(chipProcessedImfile.magicked = 0, 0, -1)," 1453 " chipRun.magicked = IF(chipRun.magicked = 0, 0, -1)"); 1429 1454 } 1430 1455 … … 1440 1465 } 1441 1466 psFree(query); 1467 psFree(set_magicked_imfile); 1468 psFree(set_magicked_run); 1442 1469 if (psDBAffectedRows(config->dbh) < 1) { 1443 1470 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); … … 1757 1784 return true; 1758 1785 } 1786 1787 static bool listrunMode(pxConfig *config) 1788 { 1789 PS_ASSERT_PTR_NON_NULL(config, NULL); 1790 1791 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1792 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1793 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 1794 1795 psMetadata *where = psMetadataAlloc(); 1796 pxchipGetSearchArgs (config, where); // chipRun, chipProcessedImfile, rawExp 1797 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1798 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 1799 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 1800 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "LIKE"); 1801 pxAddLabelSearchArgs (config, where, "-data_group", "chipRun.data_group", "LIKE"); 1802 pxAddLabelSearchArgs (config, where, "-dist_group", "chipRun.dist_group", "LIKE"); 1803 PXOPT_COPY_S64(config->args, where, "-magicked", "chipRun.magicked", "=="); 1804 1805 psString where2 = NULL; 1806 pxmagicAddWhere(config, &where2, "chipRun"); 1807 // add cuts on ra and decl if supplied 1808 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 1809 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 1810 return false; 1811 } 1812 1813 psString query = pxDataGet("chiptool_listrun.sql"); 1814 if (!query) { 1815 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1816 return false; 1817 } 1818 1819 if (psListLength(where->list)) { 1820 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1821 psStringAppend(&query, " WHERE %s %s", whereClause, where2 ? where2 : ""); 1822 psFree(whereClause); 1823 } else if (psMetadataLookupBool(NULL, config->args, "-all") || where2) { 1824 psStringAppend(&query, " WHERE chipRun.chip_id IS NOT NULL %s", where2 ? where2 : ""); 1825 } else { 1826 psFree(where); 1827 psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required"); 1828 return false; 1829 } 1830 psFree(where); 1831 1832 if (pstamp_order) { 1833 // put runs in order of exposure id with newest chip Runs first 1834 // The postage stamp parser depends on this behavior 1835 psStringAppend(&query, "\nORDER by exp_id, chip_id DESC"); 1836 } 1837 1838 // treat limit == 0 as "no limit" 1839 if (limit) { 1840 psString limitString = psDBGenerateLimitSQL(limit); 1841 psStringAppend(&query, " %s", limitString); 1842 psFree(limitString); 1843 } 1844 1845 if (!p_psDBRunQuery(config->dbh, query)) { 1846 psError(PS_ERR_UNKNOWN, false, "database error"); 1847 psFree(query); 1848 return false; 1849 } 1850 psFree(query); 1851 1852 psArray *output = p_psDBFetchResult(config->dbh); 1853 if (!output) { 1854 psError(PS_ERR_UNKNOWN, false, "database error"); 1855 return false; 1856 } 1857 if (!psArrayLength(output)) { 1858 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1859 psFree(output); 1860 return true; 1861 } 1862 1863 // negative simple so the default is true 1864 if (!ippdbPrintMetadatas(stdout, output, "chipRun", !simple)) { 1865 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1866 psFree(output); 1867 return false; 1868 } 1869 1870 psFree(output); 1871 1872 return true; 1873 }
Note:
See TracChangeset
for help on using the changeset viewer.
