Changeset 27743 for trunk/ippTools/src/difftool.c
- Timestamp:
- Apr 23, 2010, 11:24:56 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r27723 r27743 57 57 static bool toscrubbedskyfileMode(pxConfig *config); 58 58 static bool tofullskyfileMode(pxConfig *config); 59 static bool listrunMode(pxConfig *config); 59 60 60 61 … … 101 102 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 102 103 MODECASE(DIFFTOOL_MODE_TOFULLSKYFILE, tofullskyfileMode); 104 MODECASE(DIFFTOOL_MODE_LISTRUN, listrunMode); 103 105 104 106 default: … … 194 196 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); 195 197 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 198 PXOPT_COPY_STR(config->args, where, "-data_group","data_group", "=="); 196 199 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 197 200 if (!psListLength(where->list)) { … … 702 705 pxAddLabelSearchArgs (config, where, "-data_group", "diffRun.data_group", "LIKE"); 703 706 707 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 704 708 PXOPT_LOOKUP_BOOL(template, config->args, "-template", false); 705 709 if (!template) { … … 745 749 psFree(where); 746 750 751 if (pstamp_order) { 752 if (template) { 753 psStringAppend(&query, " ORDER BY rawTemplate.exp_id, diff_id DESC"); 754 } else { 755 psStringAppend(&query, " ORDER BY rawInput.exp_id, diff_id DESC"); 756 } 757 } 758 747 759 // treat limit == 0 as "no limit" 748 760 if (limit) { … … 971 983 return false; 972 984 } 973 psS16 diff_mode = 0;985 psS16 diff_mode = IPP_DIFF_MODE_UNDEFINED; 974 986 if ((input_warp_id != PS_MAX_S64) && (template_warp_id != PS_MAX_S64)) { 975 diff_mode = 1;987 diff_mode = IPP_DIFF_MODE_WARP_WARP; 976 988 } 977 989 else if ((input_warp_id != PS_MAX_S64) && (template_stack_id != PS_MAX_S64)) { 978 diff_mode = 2;990 diff_mode = IPP_DIFF_MODE_WARP_STACK; 979 991 } 980 992 else if ((input_stack_id != PS_MAX_S64) && (template_warp_id != PS_MAX_S64)) { 981 diff_mode = 3;993 diff_mode = IPP_DIFF_MODE_STACK_WARP; 982 994 } 983 995 else if ((input_stack_id != PS_MAX_S64) && (template_stack_id != PS_MAX_S64)) { 984 diff_mode = 4;996 diff_mode = IPP_DIFF_MODE_STACK_STACK; 985 997 } 986 998 … … 1431 1443 true, // exposure 1432 1444 0, // magicked 1433 2, // diff_mode for warp-stack difference1445 IPP_DIFF_MODE_WARP_STACK, 1434 1446 note 1435 1447 ); … … 1783 1795 true, // exposure 1784 1796 false, // magicked 1785 1, // diff_mode for warp-warp diff1797 IPP_DIFF_MODE_WARP_WARP, 1786 1798 note); // Run to insert 1787 1799 if (!diffRunInsertObject(config->dbh, run)) { … … 2065 2077 false, // exposure 2066 2078 0, // magicked 2067 4,// diff_mode2079 IPP_DIFF_MODE_STACK_STACK, // diff_mode 2068 2080 note 2069 2081 ); … … 2626 2638 return true; 2627 2639 } 2640 2641 static bool listrunMode(pxConfig *config) 2642 { 2643 PS_ASSERT_PTR_NON_NULL(config, false); 2644 2645 psMetadata *where = psMetadataAlloc(); 2646 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 2647 PXOPT_COPY_STR(config->args, where, "-tess_id", "diffRun.tess_id", "=="); 2648 PXOPT_COPY_S64(config->args, where, "-magicked", "diffRun.magicked", "=="); 2649 pxAddLabelSearchArgs (config, where, "-label", "diffRun.label", "LIKE"); 2650 pxAddLabelSearchArgs (config, where, "-data_group", "diffRun.data_group", "LIKE"); 2651 pxAddLabelSearchArgs (config, where, "-dist_group", "diffRun.dist_group", "LIKE"); 2652 2653 PXOPT_LOOKUP_BOOL(template, config->args, "-template", false); 2654 if (!template) { 2655 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawInput.exp_id", "=="); 2656 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawInput.exp_name", "=="); 2657 PXOPT_COPY_STR(config->args, where, "-warp_id", "warpInput.warp_id", "=="); 2658 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawInput.dateobs", ">="); 2659 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawInput.dateobs", "<="); 2660 PXOPT_COPY_STR(config->args, where, "-filter", "rawInput.filter", "LIKE"); 2661 } else { 2662 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawTemplate.exp_id", "=="); 2663 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawTemplate.exp_name", "=="); 2664 PXOPT_COPY_STR(config->args, where, "-warp_id", "warpTemplate.warp_id", "=="); 2665 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawTemplate.dateobs", ">="); 2666 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawTemplate.dateobs", "<="); 2667 PXOPT_COPY_STR(config->args, where, "-filter", "rawTemplate.filter", "LIKE"); 2668 } 2669 2670 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 2671 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2672 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2673 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 2674 2675 2676 psString where2 = NULL; 2677 pxmagicAddWhere(config, &where2, "diffRun"); 2678 pxspaceAddWhere(config, &where2, template ? "rawTemplate" : "rawInput"); 2679 psString query = pxDataGet("difftool_listrun.sql"); 2680 if (!query) { 2681 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 2682 return false; 2683 } 2684 2685 if (psListLength(where->list)) { 2686 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 2687 psStringAppend(&query, " WHERE %s", whereClause); 2688 psFree(whereClause); 2689 } else if (where2) { 2690 psStringAppend(&query, " WHERE diffRun.diff_id is not null %s", where2); 2691 } else if (!all) { 2692 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 2693 return false; 2694 } 2695 psFree(where); 2696 2697 if (pstamp_order) { 2698 if (template) { 2699 psStringAppend(&query, " ORDER BY rawTemplate.exp_id, diff_id DESC"); 2700 } else { 2701 psStringAppend(&query, " ORDER BY rawInput.exp_id, diff_id DESC"); 2702 } 2703 } 2704 2705 // treat limit == 0 as "no limit" 2706 if (limit) { 2707 psString limitString = psDBGenerateLimitSQL(limit); 2708 psStringAppend(&query, " %s", limitString); 2709 psFree(limitString); 2710 } 2711 2712 if (!p_psDBRunQuery(config->dbh, query)) { 2713 psError(PS_ERR_UNKNOWN, false, "database error"); 2714 psFree(query); 2715 return false; 2716 } 2717 psFree(query); 2718 2719 psArray *output = p_psDBFetchResult(config->dbh); 2720 if (!output) { 2721 psErrorCode err = psErrorCodeLast(); 2722 switch (err) { 2723 case PS_ERR_DB_CLIENT: 2724 psError(PXTOOLS_ERR_SYS, false, "database error"); 2725 case PS_ERR_DB_SERVER: 2726 psError(PXTOOLS_ERR_PROG, false, "database error"); 2727 default: 2728 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 2729 } 2730 2731 return false; 2732 } 2733 if (!psArrayLength(output)) { 2734 psTrace("difftool", PS_LOG_INFO, "no rows found"); 2735 psFree(output); 2736 return true; 2737 } 2738 2739 if (psArrayLength(output)) { 2740 // negative simple so the default is true 2741 if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) { 2742 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2743 psFree(output); 2744 return false; 2745 } 2746 } 2747 2748 psFree(output); 2749 2750 return true; 2751 }
Note:
See TracChangeset
for help on using the changeset viewer.
