Changeset 9057 for trunk/ippTools/src/dettool.c
- Timestamp:
- Sep 28, 2006, 5:25:54 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (77 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r9046 r9057 127 127 128 128 psString query = psStringCopy("SELECT rawDetrendExp.* FROM rawDetrendExp" 129 " LEFT JOIN detInputExp ON rawDetrendExp.exp_ id = detInputExp.exp_id"130 " WHERE detInputExp.exp_ idIS NULL");129 " LEFT JOIN detInputExp ON rawDetrendExp.exp_tag = detInputExp.exp_tag" 130 " WHERE detInputExp.exp_tag IS NULL"); 131 131 132 132 if (config->where) { … … 190 190 } 191 191 192 // we have to support multipe exp_ ids193 psMetadataItem *item = psMetadataLookup(config->args, "-exp_ id");192 // we have to support multipe exp_tags 193 psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag"); 194 194 if (!item) { 195 195 // this shouldn't actually happen when using psArgs 196 psError(PS_ERR_UNKNOWN, true, "-exp_ idis required");196 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 197 197 return false; 198 198 } 199 199 psMetadata *where = psMetadataAlloc(); 200 200 201 // make sure that -exp_ idwas parsed correctly201 // make sure that -exp_tag was parsed correctly 202 202 // XXX this can be removed someday 203 203 if (item->type == PS_DATA_METADATA_MULTI) { … … 205 205 psMetadataItem *mItem = NULL; 206 206 while ((mItem = psListGetAndIncrement(iter))) { 207 psString exp_ id= mItem->data.V;208 // if exp_ id is NULL then it means that -exp_idhas not been207 psString exp_tag = mItem->data.V; 208 // if exp_tag is NULL then it means that -exp_tag has not been 209 209 // specified 210 if (!exp_ id) {210 if (!exp_tag) { 211 211 psError(PS_ERR_UNKNOWN, true, 212 "at least one -exp_ idis required");212 "at least one -exp_tag is required"); 213 213 psFree(where); 214 214 return false; 215 215 } 216 216 217 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id",218 PS_META_DUPLICATE_OK, "==", exp_ id)) {219 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");217 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 218 PS_META_DUPLICATE_OK, "==", exp_tag)) { 219 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 220 220 psFree(iter); 221 221 psFree(where); … … 226 226 } else { 227 227 psAbort(config->argv[0], 228 "-exp_ idwas not parsed correctly (this should not happen");228 "-exp_tag was not parsed correctly (this should not happen"); 229 229 } 230 230 … … 234 234 } 235 235 236 // check that the specified exp_ ids actually exist236 // check that the specified exp_tags actually exist 237 237 psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0); 238 238 psFree(where); … … 242 242 } 243 243 244 // we should have one rawDetrendExp row per exp_ idspecified244 // we should have one rawDetrendExp row per exp_tag specified 245 245 if (psListLength(item->data.list) != psArrayLength(detrendExps)) { 246 246 psAbort(config->argv[0], 247 "an -exp_ idmatched more then one rawDetrendExp (this should not happen");247 "an -exp_tag matched more then one rawDetrendExp (this should not happen"); 248 248 249 249 } … … 717 717 det_id, 718 718 iteration, 719 rawExp->exp_ id,719 rawExp->exp_tag, 720 720 true // use 721 721 ); … … 729 729 // select rawDetrendExp.* 730 730 // by: 731 // exp_ id731 // exp_tag 732 732 733 733 psString query = psStringCopy( … … 735 735 " FROM detInputExp" 736 736 " JOIN rawDetrendExp" 737 " USING(exp_ id)"737 " USING(exp_tag)" 738 738 ); 739 739 … … 789 789 // 790 790 // det_id is in detInputExp 791 // exp_ idis in detInputExp791 // exp_tag is in detInputExp 792 792 // det_id is not in detProccessedImfile 793 // exp_ idis not in detProccessedImfile793 // exp_tag is not in detProccessedImfile 794 794 // class_is is not in detProccessedImfile 795 795 psString query = psStringCopy( 796 796 "SELECT detInputExp.det_id, detRun.det_type, rawImfile.*" 797 797 " FROM rawImfile" 798 " LEFT JOIN detInputExp USING(exp_ id) "798 " LEFT JOIN detInputExp USING(exp_tag) " 799 799 " LEFT JOIN detRun ON detInputExp.det_id = detRun.position" 800 800 " LEFT JOIN detProcessedImfile" 801 801 " ON detInputExp.det_id = detProcessedImfile.det_id" 802 " AND rawImfile.exp_ id = detProcessedImfile.exp_id"802 " AND rawImfile.exp_tag = detProcessedImfile.exp_tag" 803 803 " AND rawImfile.class_id = detProcessedImfile.class_id" 804 804 " WHERE" 805 805 " detInputExp.det_id IS NOT NULL" 806 " AND detInputExp.exp_ idIS NOT NULL"806 " AND detInputExp.exp_tag IS NOT NULL" 807 807 " AND detProcessedImfile.det_id IS NULL" 808 " AND detProcessedImfile.exp_ idIS NULL"808 " AND detProcessedImfile.exp_tag IS NULL" 809 809 " AND detProcessedImfile.class_id IS NULL" 810 810 ); … … 861 861 } 862 862 863 // select exp_ ids from detInputExp matching det_idp863 // select exp_tags from detInputExp matching det_idp 864 864 // where query should be pre-generated 865 865 psArray *detInputExp = … … 870 870 } 871 871 872 // generate where query with just the exp_ ids873 psMetadata *where_exp_ ids = psMetadataAlloc();872 // generate where query with just the exp_tags 873 psMetadata *where_exp_tags = psMetadataAlloc(); 874 874 for (long i = 0; i < psArrayLength(detInputExp); i++) { 875 875 detInputExpRow *row = detInputExp->data[i]; 876 if (!psMetadataAddStr(where_exp_ ids, PS_LIST_TAIL, "exp_id",877 PS_META_DUPLICATE_OK, "==", row->exp_ id)876 if (!psMetadataAddStr(where_exp_tags, PS_LIST_TAIL, "exp_tag", 877 PS_META_DUPLICATE_OK, "==", row->exp_tag) 878 878 ) { 879 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");879 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 880 880 psFree(detInputExp); 881 psFree(where_exp_ ids);881 psFree(where_exp_tags); 882 882 return NULL; 883 883 } … … 885 885 psFree(detInputExp); 886 886 887 // select rawImfiles with matching exp_ ids887 // select rawImfiles with matching exp_tags 888 888 psArray *rawImfiles = 889 rawImfileSelectRowObjects(config->dbh, where_exp_ ids, 0);890 psFree(where_exp_ ids);889 rawImfileSelectRowObjects(config->dbh, where_exp_tags, 0); 890 psFree(where_exp_tags); 891 891 if (!rawImfiles) { 892 892 psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found"); … … 901 901 PS_ASSERT_PTR_NON_NULL(config, false); 902 902 903 // det_id, exp_ id, class_id, uri, recipe, -bg, -bg_stdev, & -bg_mean_stdev903 // det_id, exp_tag, class_id, uri, recipe, -bg, -bg_stdev, & -bg_mean_stdev 904 904 // are required 905 905 bool status = false; … … 913 913 return false; 914 914 } 915 psString exp_ id = psMetadataLookupStr(&status, config->args, "-exp_id");916 if (!status) { 917 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_ id");918 return false; 919 } 920 if (!exp_ id) {921 psError(PS_ERR_UNKNOWN, true, "-exp_ idis required");915 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 916 if (!status) { 917 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 918 return false; 919 } 920 if (!exp_tag) { 921 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 922 922 return false; 923 923 } … … 988 988 } 989 989 990 // find the matching rawImfile by exp_ id/class_id990 // find the matching rawImfile by exp_tag/class_id 991 991 psMetadata *where = psMetadataAlloc(); 992 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id", 0, "==", exp_id)) {993 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");992 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) { 993 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 994 994 psFree(where); 995 995 return false; … … 1011 1011 detProcessedImfileRow *detRow = detProcessedImfileRowAlloc( 1012 1012 (psS32)atol(det_id), 1013 exp_ id,1013 exp_tag, 1014 1014 class_id, 1015 1015 uri, … … 1044 1044 // by: 1045 1045 // find the current iteration bassed on det_id 1046 // find all exp_ ids in the current det_id/iteration from detInputExp1047 // find all rawImfiles in the current exp_ ids1048 // compare to detProcessedImfiles by det_id/exp_ id1046 // find all exp_tags in the current det_id/iteration from detInputExp 1047 // find all rawImfiles in the current exp_tags 1048 // compare to detProcessedImfiles by det_id/exp_tag 1049 1049 // found how many imfile there are in each class_id 1050 1050 // and: … … 1065 1065 " AND detRun.iteration = detInputExp.iteration" 1066 1066 " JOIN rawDetrendExp" 1067 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"1067 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 1068 1068 " JOIN detProcessedImfile" 1069 1069 " ON detInputExp.det_id = detProcessedImfile.det_id" 1070 " AND detInputExp.exp_ id = detProcessedImfile.exp_id"1070 " AND detInputExp.exp_tag = detProcessedImfile.exp_tag" 1071 1071 " LEFT JOIN detStackedImfile" 1072 1072 " ON detInputExp.det_id = detStackedImfile.det_id" … … 1074 1074 " AND detProcessedImfile.class_id = detStackedImfile.class_id" 1075 1075 " LEFT JOIN rawImfile" 1076 " ON detInputExp.exp_ id = rawImfile.exp_id"1076 " ON detInputExp.exp_tag = rawImfile.exp_tag" 1077 1077 " AND detProcessedImfile.class_id = rawImfile.class_id" 1078 1078 " WHERE" … … 1165 1165 // det_id is not in detStackedImfile 1166 1166 // iteration is not in detStackedImfile 1167 // detProcessedImfile.exp_ idis not in detStackedImfile1167 // detProcessedImfile.exp_tag is not in detStackedImfile 1168 1168 // detProcessedImfile.class_id is not in detStackedImfile 1169 1169 // and detInputExp.include is 1 … … 1180 1180 " ON detRun.position = detInputExp.det_id" 1181 1181 " AND detRun.iteration = detInputExp.iteration" 1182 " AND detProcessedImfile.exp_ id = detInputExp.exp_id"1182 " AND detProcessedImfile.exp_tag = detInputExp.exp_tag" 1183 1183 " LEFT JOIN detStackedImfile" 1184 1184 " ON detRun.position = detStackedImfile.det_id" … … 1267 1267 // remove detStackedImfiles unless -unmask 1268 1268 if (!psMetadataLookupBool(&status, config->args, "-unmask")) { 1269 // detStackedImfiles doesn't have an exp_ idso we have to generate the1269 // detStackedImfiles doesn't have an exp_tag so we have to generate the 1270 1270 // where query ourselves 1271 1271 bool status = false; … … 1293 1293 if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", 1294 1294 (psS32)atoi(det_id))) { 1295 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1295 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 1296 1296 psFree(where); 1297 1297 return false; … … 1582 1582 if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", 1583 1583 (psS32)atoi(det_id))) { 1584 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1584 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 1585 1585 psFree(where); 1586 1586 return false; … … 1794 1794 // by: 1795 1795 // find the current iteration bassed on det_id 1796 // find all exp_ ids in the current det_id/iteration from detInputExp1796 // find all exp_tags in the current det_id/iteration from detInputExp 1797 1797 // sort to detInputExp.imfiles to find the largest value per det_id/iter 1798 1798 // compare imfiles to the number of detStackedImfiles by class_id … … 1812 1812 " AND detRun.iteration = detInputExp.iteration" 1813 1813 " LEFT JOIN rawDetrendExp" 1814 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"1814 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 1815 1815 " LEFT JOIN detStackedImfile" 1816 1816 " ON detInputExp.det_id = detStackedImfile.det_id" … … 1819 1819 " detStackedImfile.normalize = 1" 1820 1820 " GROUP BY" 1821 " rawDetrendExp.exp_ id"1821 " rawDetrendExp.exp_tag" 1822 1822 " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)" 1823 1823 ); … … 2106 2106 psMetadata *where = psMetadataAlloc(); 2107 2107 for (long i = 0; i < psArrayLength(inputExps); i++) { 2108 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id",2108 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 2109 2109 PS_META_DUPLICATE_OK, "==", 2110 ((detInputExpRow *)inputExps->data[i])->exp_ id)) {2111 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");2110 ((detInputExpRow *)inputExps->data[i])->exp_tag)) { 2111 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2112 2112 psFree(inputExps); 2113 2113 psFree(where); … … 2312 2312 " JOIN detProcessedImfile" 2313 2313 " ON detRun.position = detProcessedImfile.det_id" 2314 " AND detInputExp.exp_ id = detProcessedImfile.exp_id"2314 " AND detInputExp.exp_tag = detProcessedImfile.exp_tag" 2315 2315 " JOIN detNormalizedImfile" 2316 2316 " ON detRun.position = detNormalizedImfile.det_id" … … 2320 2320 " ON detRun.position = detResidImfile.det_id" 2321 2321 " AND detRun.iteration = detResidImfile.iteration" 2322 " AND detProcessedImfile.exp_ id = detResidImfile.exp_id"2322 " AND detProcessedImfile.exp_tag = detResidImfile.exp_tag" 2323 2323 " AND detProcessedImfile.class_id = detResidImfile.class_id" 2324 2324 " WHERE" 2325 2325 " detResidImfile.det_id IS NULL" 2326 2326 " AND detResidImfile.iteration IS NULL" 2327 " AND detResidImfile.exp_ idIS NULL"2327 " AND detResidImfile.exp_tag IS NULL" 2328 2328 " AND detResidImfile.class_id IS NULL" 2329 2329 " UNION" … … 2339 2339 " JOIN detProcessedImfile" 2340 2340 " ON detRun.position = detProcessedImfile.det_id" 2341 " AND detInputExp.exp_ id = detProcessedImfile.exp_id"2341 " AND detInputExp.exp_tag = detProcessedImfile.exp_tag" 2342 2342 " JOIN detStackedImfile" 2343 2343 " ON detRun.position = detStackedImfile.det_id" … … 2347 2347 " ON detRun.position = detResidImfile.det_id" 2348 2348 " AND detRun.iteration = detResidImfile.iteration" 2349 " AND detProcessedImfile.exp_ id = detResidImfile.exp_id"2349 " AND detProcessedImfile.exp_tag = detResidImfile.exp_tag" 2350 2350 " AND detStackedImfile.class_id = detResidImfile.class_id" 2351 2351 " WHERE" 2352 2352 " detResidImfile.det_id IS NULL" 2353 2353 " AND detResidImfile.iteration IS NULL" 2354 " AND detResidImfile.exp_ idIS NULL"2354 " AND detResidImfile.exp_tag IS NULL" 2355 2355 " AND detResidImfile.class_id IS NULL" 2356 2356 " AND detStackedImfile.normalize = 0" … … 2571 2571 2572 2572 // make sure that there is a coresponding entry in detNormalizedImfile 2573 // and the exp_ idspecified is valid2573 // and the exp_tag specified is valid 2574 2574 // select * from detNormalizedImfile 2575 2575 // by det_id, iteration, class_id … … 2588 2588 " ON detNormalizedImfile.det_id = detResidImfile.det_id" 2589 2589 " AND detNormalizedImfile.iteration= detResidImfile.iteration" 2590 " AND detInputExp.exp_ id = detResidImfile.exp_id"2590 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 2591 2591 " AND detNormalizedImfile.class_id = detResidImfile.class_id" 2592 2592 " WHERE" 2593 2593 " detResidImfile.det_id IS NULL" 2594 2594 " AND detResidImfile.iteration IS NULL" 2595 " AND detResidImfile.exp_ idIS NULL"2595 " AND detResidImfile.exp_tag IS NULL" 2596 2596 " AND detResidImfile.class_id IS NULL" 2597 " AND detInputExp.exp_ id= '%s'"2597 " AND detInputExp.exp_tag = '%s'" 2598 2598 " UNION" 2599 2599 " SELECT" … … 2608 2608 " ON detStackedImfile.det_id = detResidImfile.det_id" 2609 2609 " AND detStackedImfile.iteration= detResidImfile.iteration" 2610 " AND detInputExp.exp_ id = detResidImfile.exp_id"2610 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 2611 2611 " AND detStackedImfile.class_id = detResidImfile.class_id" 2612 2612 " WHERE" 2613 2613 " detResidImfile.det_id IS NULL" 2614 2614 " AND detResidImfile.iteration IS NULL" 2615 " AND detResidImfile.exp_ idIS NULL"2615 " AND detResidImfile.exp_tag IS NULL" 2616 2616 " AND detResidImfile.class_id IS NULL" 2617 " AND detInputExp.exp_ id= '%s'"2617 " AND detInputExp.exp_tag = '%s'" 2618 2618 " AND detStackedImfile.normalize = 0" 2619 2619 " ) as detNormStackedImfile" … … 2678 2678 } 2679 2679 2680 // exp_ id is manadatory to cross check that this is a exp_idfor this2680 // exp_tag is manadatory to cross check that this is a exp_tag for this 2681 2681 // detRUn 2682 2682 bool status = false; 2683 psString exp_ id = psMetadataLookupStr(&status, config->args, "-exp_id");2684 if (!status) { 2685 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_ id");2683 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 2684 if (!status) { 2685 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 2686 2686 psFree(query); 2687 2687 return false; 2688 2688 } 2689 if (!exp_ id) {2690 psError(PS_ERR_UNKNOWN, true, "-exp_ idis required");2689 if (!exp_tag) { 2690 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 2691 2691 psFree(query); 2692 2692 return false; 2693 2693 } 2694 2694 2695 if (!p_psDBRunQuery(config->dbh, query, exp_ id, exp_id)) {2695 if (!p_psDBRunQuery(config->dbh, query, exp_tag, exp_tag)) { 2696 2696 psError(PS_ERR_UNKNOWN, false, "database error"); 2697 2697 psFree(query); … … 2757 2757 2758 2758 bool status = false; 2759 psString exp_ id = psMetadataLookupStr(&status, config->args, "-exp_id");2760 if (!status) { 2761 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_ id");2762 return false; 2763 } 2764 if (!exp_ id) {2765 psError(PS_ERR_UNKNOWN, true, "-exp_ idis required");2759 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 2760 if (!status) { 2761 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 2762 return false; 2763 } 2764 if (!exp_tag) { 2765 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 2766 2766 return false; 2767 2767 } … … 2827 2827 normalizedImfile->det_id, 2828 2828 normalizedImfile->iteration, 2829 exp_ id,2829 exp_tag, 2830 2830 normalizedImfile->class_id, 2831 2831 uri, … … 2845 2845 // select detResidImfile.* 2846 2846 // by: 2847 // where det_id, iteration, exp_ idis not in detResidExp;2847 // where det_id, iteration, exp_tag is not in detResidExp; 2848 2848 2849 2849 psString query = psStringCopy( … … 2852 2852 " FROM detResidImfile" 2853 2853 " LEFT JOIN detResidExp" 2854 " USING(det_id, iteration, exp_ id)"2854 " USING(det_id, iteration, exp_tag)" 2855 2855 " WHERE" 2856 2856 " detResidExp.det_id IS NULL" 2857 2857 " AND detResidExp.iteration IS NULL" 2858 " AnD detResidExp.exp_ idIS NULL"2858 " AnD detResidExp.exp_tag IS NULL" 2859 2859 ); 2860 2860 … … 2917 2917 // select detRun.iteration 2918 2918 // select detRun.det_type 2919 // select detInputExp.exp_ id2919 // select detInputExp.exp_tag 2920 2920 // select detInputExp.include 2921 2921 // by: 2922 2922 // find the current iteration bassed on det_id 2923 // find all exp_ ids in the current det_id/iteration from detInputExp2923 // find all exp_tags in the current det_id/iteration from detInputExp 2924 2924 // compare to detInputExp.imfiles to derResidImfile by class_id 2925 2925 // and: 2926 // detResidImfile.{det_id, iteration, exp_ id} is not in detResidExp2926 // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp 2927 2927 2928 2928 psString query = psStringCopy( … … 2931 2931 " iteration," 2932 2932 " det_type," 2933 " exp_ id,"2933 " exp_tag," 2934 2934 " include" 2935 2935 " FROM" … … 2938 2938 " detRun.iteration," 2939 2939 " detRun.det_type," 2940 " detInputExp.exp_ id,"2940 " detInputExp.exp_tag," 2941 2941 " detInputExp.include," 2942 2942 " rawDetrendExp.imfiles" … … 2946 2946 " AND detRun.iteration = detInputExp.iteration" 2947 2947 " LEFT JOIN rawDetrendExp" 2948 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"2948 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 2949 2949 " LEFT JOIN detResidImfile" 2950 2950 " ON detRun.position = detResidImfile.det_id" 2951 2951 " AND detRun.iteration = detResidImfile.iteration" 2952 " AND detInputExp.exp_ id = detResidImfile.exp_id"2952 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 2953 2953 " LEFT JOIN detResidExp" 2954 2954 " ON detRun.position = detResidExp.det_id" 2955 2955 " AND detRun.iteration = detResidExp.iteration" 2956 " AND detInputExp.exp_ id = detResidExp.exp_id"2956 " AND detInputExp.exp_tag = detResidExp.exp_tag" 2957 2957 " WHERE" 2958 2958 " detResidExp.det_id IS NULL" 2959 2959 " AND detResidExp.iteration IS NULL" 2960 " AND detResidExp.exp_ idIS NULL"2960 " AND detResidExp.exp_tag IS NULL" 2961 2961 " GROUP BY" 2962 " detInputExp.exp_ id"2962 " detInputExp.exp_tag" 2963 2963 " HAVING" 2964 2964 " rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)" … … 3026 3026 // select detRun.iteration 3027 3027 // select detRun.det_type 3028 // select detInputExp.exp_ id3028 // select detInputExp.exp_tag 3029 3029 // select detInputExp.include 3030 3030 // by: 3031 3031 // find the current iteration bassed on det_id 3032 // find all exp_ ids in the current det_id/iteration from detInputExp3032 // find all exp_tags in the current det_id/iteration from detInputExp 3033 3033 // compare to detInputExp.imfiles to derResidImfile by class_id 3034 3034 // and: 3035 // detResidImfile.{det_id, iteration, exp_ id} is not in detResidExp3035 // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp 3036 3036 3037 3037 psString query = psStringCopy( … … 3039 3039 " det_id," 3040 3040 " iteration," 3041 " exp_ id,"3041 " exp_tag," 3042 3042 " include" 3043 3043 " FROM" … … 3046 3046 " detRun.iteration," 3047 3047 " detRun.det_type," 3048 " detInputExp.exp_ id,"3048 " detInputExp.exp_tag," 3049 3049 " detInputExp.include," 3050 3050 " rawDetrendExp.imfiles" … … 3054 3054 " AND detRun.iteration = detInputExp.iteration" 3055 3055 " LEFT JOIN rawDetrendExp" 3056 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"3056 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3057 3057 " LEFT JOIN detResidImfile" 3058 3058 " ON detRun.position = detResidImfile.det_id" 3059 3059 " AND detRun.iteration = detResidImfile.iteration" 3060 " AND detInputExp.exp_ id = detResidImfile.exp_id"3060 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 3061 3061 " LEFT JOIN detResidExp" 3062 3062 " ON detRun.position = detResidExp.det_id" 3063 3063 " AND detRun.iteration = detResidExp.iteration" 3064 " AND detInputExp.exp_ id = detResidExp.exp_id"3064 " AND detInputExp.exp_tag = detResidExp.exp_tag" 3065 3065 " WHERE" 3066 3066 " detResidExp.det_id IS NULL" 3067 3067 " AND detResidExp.iteration IS NULL" 3068 " AND detResidExp.exp_ idIS NULL"3068 " AND detResidExp.exp_tag IS NULL" 3069 3069 " GROUP BY" 3070 " detInputExp.exp_ id"3070 " detInputExp.exp_tag" 3071 3071 " HAVING" 3072 3072 " rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)" … … 3075 3075 3076 3076 { 3077 // build a query to search by det_id, iteration, exp_ id3077 // build a query to search by det_id, iteration, exp_tag 3078 3078 psMetadata *where = psMetadataAlloc(); 3079 3079 bool status = false; … … 3107 3107 return false; 3108 3108 } 3109 psString exp_ id = psMetadataLookupStr(&status, config->args, "-exp_id");3110 if (!status) { 3111 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_ id");3109 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 3110 if (!status) { 3111 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 3112 3112 psFree(where); 3113 3113 psFree(query); 3114 3114 return false; 3115 3115 } 3116 if (exp_ id) {3117 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id", 0, "==", exp_id)) {3118 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");3116 if (exp_tag) { 3117 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) { 3118 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3119 3119 psFree(where); 3120 3120 psFree(query); … … 3208 3208 return false; 3209 3209 } 3210 psString exp_ id = psMetadataLookupStr(&status, row, "exp_id");3211 if (!status) { 3212 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_ id");3213 return false; 3214 } 3215 if (!exp_ id) {3216 psError(PS_ERR_UNKNOWN, true, "exp_ idis required");3210 psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag"); 3211 if (!status) { 3212 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag"); 3213 return false; 3214 } 3215 if (!exp_tag) { 3216 psError(PS_ERR_UNKNOWN, true, "exp_tag is required"); 3217 3217 return false; 3218 3218 } … … 3283 3283 det_id, 3284 3284 iteration, 3285 exp_ id,3285 exp_tag, 3286 3286 recipe, 3287 3287 bg, … … 3343 3343 // by: 3344 3344 // find the current iteration bassed on det_id 3345 // find all exp_ ids in the current det_id/iteration from detInputExp3346 // find all exp_ ids in the current det_id/iteration from detResidExp3347 // compare the counts of exp_ ids3345 // find all exp_tags in the current det_id/iteration from detInputExp 3346 // find all exp_tags in the current det_id/iteration from detResidExp 3347 // compare the counts of exp_tags 3348 3348 3349 3349 psString query = psStringCopy( … … 3357 3357 " detRun.iteration," 3358 3358 " detRun.det_type," 3359 " detInputExp.exp_ id"3359 " detInputExp.exp_tag" 3360 3360 " FROM detRun" 3361 3361 " LEFT JOIN detInputExp" … … 3363 3363 " AND detRun.iteration = detInputExp.iteration" 3364 3364 " LEFT JOIN rawDetrendExp" 3365 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"3365 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3366 3366 " LEFT JOIN detResidExp" 3367 3367 " ON detRun.position = detResidExp.det_id" 3368 3368 " AND detRun.iteration = detResidExp.iteration" 3369 " AND detInputExp.exp_ id = detResidExp.exp_id"3369 " AND detInputExp.exp_tag = detResidExp.exp_tag" 3370 3370 " GROUP BY" 3371 3371 " detRun.position," 3372 3372 " detRun.iteration" 3373 3373 " HAVING" 3374 " COUNT(detResidExp.exp_ id) = COUNT(detInputExp.exp_id)"3374 " COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)" 3375 3375 " ) AS residdetrun" 3376 3376 ); … … 3425 3425 PS_ASSERT_PTR_NON_NULL(config, false); 3426 3426 3427 // build a query to search by det_id, iteration, exp_ id3427 // build a query to search by det_id, iteration, exp_tag 3428 3428 psMetadata *where = psMetadataAlloc(); 3429 3429 bool status = false; … … 3453 3453 return false; 3454 3454 } 3455 psString exp_ id = psMetadataLookupStr(&status, config->args, "-exp_id");3456 if (!status) { 3457 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_ id");3455 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 3456 if (!status) { 3457 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 3458 3458 psFree(where); 3459 3459 return false; 3460 3460 } 3461 if (exp_ id) {3462 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id", 0, "==", exp_id)) {3463 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");3461 if (exp_tag) { 3462 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) { 3463 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3464 3464 psFree(where); 3465 3465 return false; … … 3468 3468 3469 3469 // find the values we're going to set 3470 // copy everything but det_id, iteration, & exp_ idfrom the args and3470 // copy everything but det_id, iteration, & exp_tag from the args and 3471 3471 // remove the '-' prefix 3472 3472 psMetadata *set = psMetadataAlloc(); … … 3601 3601 // by: 3602 3602 // find the current iteration bassed on det_id 3603 // find all exp_ ids in the current det_id/iteration from detInputExp3604 // find all exp_ ids in the current det_id/iteration from detResidExp3605 // compare the counts of exp_ ids3603 // find all exp_tags in the current det_id/iteration from detInputExp 3604 // find all exp_tags in the current det_id/iteration from detResidExp 3605 // compare the counts of exp_tags 3606 3606 3607 3607 psString query = psStringCopy( … … 3613 3613 " detRun.position AS det_id," 3614 3614 " detRun.iteration," 3615 " detInputExp.exp_ id"3615 " detInputExp.exp_tag" 3616 3616 " FROM detRun" 3617 3617 " LEFT JOIN detInputExp" … … 3619 3619 " AND detRun.iteration = detInputExp.iteration" 3620 3620 " LEFT JOIN rawDetrendExp" 3621 " ON detInputExp.exp_ id = rawDetrendExp.exp_id"3621 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3622 3622 " LEFT JOIN detResidExp" 3623 3623 " ON detRun.position = detResidExp.det_id" 3624 3624 " AND detRun.iteration = detResidExp.iteration" 3625 " AND detInputExp.exp_ id = detResidExp.exp_id"3625 " AND detInputExp.exp_tag = detResidExp.exp_tag" 3626 3626 " GROUP BY" 3627 3627 " detRun.position," 3628 3628 " detRun.iteration" 3629 3629 " HAVING" 3630 " COUNT(detResidExp.exp_ id) = COUNT(detInputExp.exp_id)"3630 " COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)" 3631 3631 " ) AS residdetrun" 3632 3632 ); 3633 3633 3634 3634 { 3635 // build a query to search by det_id, iteration, exp_ id3635 // build a query to search by det_id, iteration, exp_tag 3636 3636 psMetadata *where = psMetadataAlloc(); 3637 3637 bool status = false; … … 3839 3839 // select detRun.position 3840 3840 // select detRun.iteration 3841 // select detInputExp.exp_ id3841 // select detInputExp.exp_tag 3842 3842 // select detResidExp.accept 3843 3843 // by: 3844 3844 // find the current iteration bassed on det_id 3845 // find all exp_ ids in the current det_id/iteration from detInputExp3846 // find all exp_ ids in the current det_id/iteration from detResidExp3847 // compare the counts of exp_ ids3845 // find all exp_tags in the current det_id/iteration from detInputExp 3846 // find all exp_tags in the current det_id/iteration from detResidExp 3847 // compare the counts of exp_tags 3848 3848 3849 3849 psString query = psStringCopy( … … 3851 3851 " detRun.position AS det_id," 3852 3852 " detRun.iteration," 3853 " detInputExp.exp_ id,"3853 " detInputExp.exp_tag," 3854 3854 " detResidExp.accept" 3855 3855 " FROM detRun" … … 3860 3860 " ON detRun.position = detResidExp.det_id" 3861 3861 " AND detRun.iteration = detResidExp.iteration" 3862 " AND detInputExp.exp_ id = detResidExp.exp_id"3862 " AND detInputExp.exp_tag = detResidExp.exp_tag" 3863 3863 " WHERE" 3864 " detInputExp.exp_ idIS NOT NULL"3864 " detInputExp.exp_tag IS NOT NULL" 3865 3865 " AND detResidExp.accept IS NOT NULL" 3866 3866 " GROUP BY" 3867 3867 " detRun.position," 3868 3868 " detRun.iteration," 3869 " detInputExp.exp_ id"3869 " detInputExp.exp_tag" 3870 3870 " HAVING" 3871 " COUNT(detResidExp.exp_ id) = COUNT(detInputExp.exp_id)"3871 " COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)" 3872 3872 ); 3873 3873 … … 3910 3910 for (long i = 0; i < psArrayLength(output); i++) { 3911 3911 psMetadata *row = output->data[i]; 3912 psString exp_ id = psMetadataLookupStr(&status, row, "exp_id");3912 psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag"); 3913 3913 if (!status) { 3914 3914 // rollback … … 3916 3916 psError(PS_ERR_UNKNOWN, false, "database error"); 3917 3917 } 3918 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_ id");3918 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag"); 3919 3919 psFree(output); 3920 3920 return false; … … 3936 3936 (psS32)atol(det_id), 3937 3937 newIteration, 3938 exp_ id,3938 exp_tag, 3939 3939 accept 3940 3940 ) … … 4098 4098 } 4099 4099 4100 // we have to support multipe exp_ ids4101 psMetadataItem *item = psMetadataLookup(config->args, "-exp_ id");4100 // we have to support multipe exp_tags 4101 psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag"); 4102 4102 if (!item) { 4103 4103 // this shouldn't actually happen when using psArgs 4104 psError(PS_ERR_UNKNOWN, true, "-exp_ idis required");4105 return false; 4106 } 4107 4108 psList *exp_ id_list = item->data.list;4104 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 4105 return false; 4106 } 4107 4108 psList *exp_tag_list = item->data.list; 4109 4109 psMetadata *where = psMetadataAlloc(); 4110 // make sure that -exp_ idwas parsed correctly4110 // make sure that -exp_tag was parsed correctly 4111 4111 // XXX this can be removed someday 4112 4112 if (item->type == PS_DATA_METADATA_MULTI) { … … 4114 4114 psMetadataItem *mItem = NULL; 4115 4115 while ((mItem = psListGetAndIncrement(iter))) { 4116 psString exp_ id= mItem->data.V;4117 // if exp_ id is NULL then it means that -exp_idhas not been4116 psString exp_tag = mItem->data.V; 4117 // if exp_tag is NULL then it means that -exp_tag has not been 4118 4118 // specified 4119 if (!exp_ id) {4119 if (!exp_tag) { 4120 4120 psError(PS_ERR_UNKNOWN, true, 4121 "at least one -exp_ idis required");4121 "at least one -exp_tag is required"); 4122 4122 psFree(where); 4123 4123 return false; 4124 4124 } 4125 4125 4126 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_ id",4127 PS_META_DUPLICATE_OK, "==", exp_ id)) {4128 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");4126 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 4127 PS_META_DUPLICATE_OK, "==", exp_tag)) { 4128 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 4129 4129 psFree(iter); 4130 4130 psFree(where); … … 4135 4135 } else { 4136 4136 psAbort(config->argv[0], 4137 "-exp_ idwas not parsed correctly (this should not happen");4138 } 4139 4140 // check that the specified exp_ ids actually exist in the iteration zero4137 "-exp_tag was not parsed correctly (this should not happen"); 4138 } 4139 4140 // check that the specified exp_tags actually exist in the iteration zero 4141 4141 // detInputExp set 4142 4142 … … 4162 4162 } 4163 4163 4164 // build a hash for the valid exp_ ids4165 psHash *valid_exp_ ids = psHashAlloc(psArrayLength(detrendExps));4164 // build a hash for the valid exp_tags 4165 psHash *valid_exp_tags = psHashAlloc(psArrayLength(detrendExps)); 4166 4166 for (long i = 0; i < psArrayLength(detrendExps); i++) { 4167 psHashAdd(valid_exp_ ids,4168 ((detInputExpRow *)detrendExps->data[i])->exp_ id,4167 psHashAdd(valid_exp_tags, 4168 ((detInputExpRow *)detrendExps->data[i])->exp_tag, 4169 4169 detrendExps->data[i] 4170 4170 ); … … 4176 4176 if (!psDBTransaction(config->dbh)) { 4177 4177 psError(PS_ERR_UNKNOWN, false, "database error"); 4178 psFree(valid_exp_ ids);4178 psFree(valid_exp_tags); 4179 4179 return false; 4180 4180 } … … 4187 4187 psError(PS_ERR_UNKNOWN, false, "database error"); 4188 4188 } 4189 psFree(valid_exp_ ids);4190 return false; 4191 } 4192 4193 // check exp_ ids and build up an array of new detInputExp rows at the same4189 psFree(valid_exp_tags); 4190 return false; 4191 } 4192 4193 // check exp_tags and build up an array of new detInputExp rows at the same 4194 4194 // time 4195 psListIterator *iter = psListIteratorAlloc(exp_ id_list, 0, false);4195 psListIterator *iter = psListIteratorAlloc(exp_tag_list, 0, false); 4196 4196 psMetadataItem *mItem = NULL; 4197 psArray *newInputExps = psArrayAlloc(psListLength(exp_ id_list));4197 psArray *newInputExps = psArrayAlloc(psListLength(exp_tag_list)); 4198 4198 while ((mItem = psListGetAndIncrement(iter))) { 4199 detInputExpRow *inputExp = psHashLookup(valid_exp_ ids,4199 detInputExpRow *inputExp = psHashLookup(valid_exp_tags, 4200 4200 (char *)mItem->data.V); 4201 4201 if (!inputExp) { … … 4204 4204 psError(PS_ERR_UNKNOWN, false, "database error"); 4205 4205 } 4206 // invalid exp_ id4207 psError(PS_ERR_UNKNOWN, false, "exp_ id%s is invalid for det_id %s",4206 // invalid exp_tag 4207 psError(PS_ERR_UNKNOWN, false, "exp_tag %s is invalid for det_id %s", 4208 4208 (char *)mItem->data.V, det_id); 4209 4209 psFree(iter); 4210 psFree(valid_exp_ ids);4210 psFree(valid_exp_tags); 4211 4211 return false; 4212 4212 } … … 4214 4214 (psS32)atol(det_id), 4215 4215 newIteration, 4216 inputExp->exp_ id,4216 inputExp->exp_tag, 4217 4217 true // use 4218 4218 ); … … 4221 4221 } 4222 4222 psFree(iter); 4223 psFree(valid_exp_ ids);4223 psFree(valid_exp_tags); 4224 4224 4225 4225 for (long i = 0; i < psArrayLength(newInputExps); i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
