Changeset 8378
- Timestamp:
- Aug 15, 2006, 6:11:18 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
dettool.c (modified) (6 diffs)
-
dettoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r8376 r8378 42 42 static bool mapPositionToDetRun(psArray *mds); 43 43 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile); 44 static detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile); 44 45 static psArray *validDetInputClassIds(pxConfig *config, const char *det_id); 45 46 static psArray *searchInputImfiles(pxConfig *config, const char *det_id); … … 2039 2040 // where det_id, iteration, class_id is not in detNormalizedImfile 2040 2041 psString query = psStringCopy( 2041 "SELECT DISTINCT"2042 "SELECT" 2042 2043 " detNormalizedStatImfile.*" 2043 2044 " FROM detNormalizedStatImfile" 2044 " LEFT JOIN detNormalized StatImfile"2045 " LEFT JOIN detNormalizedImfile" 2045 2046 " USING(det_id, iteration, class_id)" 2046 2047 " WHERE" … … 2050 2051 ); 2051 2052 2052 # if 0 2053 if (config->where) { 2054 psString whereClaus = psDBGenerateWhereConditionSQL(config->where, "detStackedImfile"); 2055 psStringAppend(&query, " AND %s", whereClaus); 2056 psFree(whereClaus); 2057 } 2058 #endif 2053 { 2054 // build a query to search by det_id, iteration, class_id 2055 psMetadata *where = psMetadataAlloc(); 2056 bool status = false; 2057 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 2058 if (!status) { 2059 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 2060 psFree(where); 2061 psFree(query); 2062 return false; 2063 } 2064 if (det_id) { 2065 if (!psMetadataAddStr(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) { 2066 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 2067 psFree(where); 2068 psFree(query); 2069 return false; 2070 } 2071 } 2072 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 2073 if (!status) { 2074 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 2075 psFree(where); 2076 psFree(query); 2077 return false; 2078 } 2079 // always set iteration 2080 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) { 2081 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 2082 psFree(where); 2083 psFree(query); 2084 return false; 2085 } 2086 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 2087 if (!status) { 2088 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 2089 psFree(where); 2090 psFree(query); 2091 return false; 2092 } 2093 if (class_id) { 2094 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 2095 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 2096 psFree(where); 2097 psFree(query); 2098 return false; 2099 } 2100 } 2101 2102 // there's not 2103 psString whereClaus = psDBGenerateWhereConditionSQL(where, "detNormalizedStatImfile"); 2104 psFree(where); 2105 if (whereClaus) { 2106 psStringAppend(&query, " AND %s", whereClaus); 2107 psFree(whereClaus); 2108 } 2109 } 2059 2110 2060 2111 if (!p_psDBRunQuery(config->dbh, query)) { … … 2079 2130 } 2080 2131 2081 #if 02082 2132 for (long i = 0; i < psArrayLength(output); i++) { 2083 2133 psMetadata *row = output->data[i]; 2084 // convert metadata into a det StackedImfile object2085 det StackedImfileRow *stackedImfile = detStackedImfileObjectFromMetadata(row);2086 // convert det StackedImfile object into a detNormalizedStat object2087 detNormalized StatImfileRow *stat = detStackedToDetNormalizedStatImfile(config, stackedImfile);2088 psFree(sta ckedImfile);2089 if (! stat) {2134 // convert metadata into a detNormalizedStatImfile object 2135 detNormalizedStatImfileRow *statImfile = detNormalizedStatImfileObjectFromMetadata(row); 2136 // convert detNormalizedStatImfile object into a detNormalizedImfile 2137 detNormalizedImfileRow *normalizedImfile = detNormalizedStatToDetNormalizedmfile(config, statImfile); 2138 psFree(statImfile); 2139 if (!normalizedImfile) { 2090 2140 if (!psDBRollback(config->dbh)) { 2091 2141 psError(PS_ERR_UNKNOWN, false, "database error"); … … 2096 2146 } 2097 2147 // insert detNormlized Stat object into the database 2098 if (!detNormalized StatImfileInsertObject(config->dbh, stat)) {2148 if (!detNormalizedImfileInsertObject(config->dbh, normalizedImfile)) { 2099 2149 if (!psDBRollback(config->dbh)) { 2100 2150 psError(PS_ERR_UNKNOWN, false, "database error"); 2101 2151 } 2102 2152 psError(PS_ERR_UNKNOWN, false, "database error"); 2103 psFree( stat);2153 psFree(normalizedImfile); 2104 2154 psFree(output); 2105 2155 } 2106 psFree( stat);2156 psFree(normalizedImfile); 2107 2157 } 2108 2158 … … 2115 2165 2116 2166 return true; 2117 #endif 2118 2119 return true; 2167 } 2168 2169 static detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile) 2170 { 2171 PS_ASSERT_PTR_NON_NULL(config, NULL); 2172 PS_ASSERT_PTR_NON_NULL(statImfile, NULL); 2173 2174 bool status = false; 2175 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 2176 if (!status) { 2177 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 2178 return false; 2179 } 2180 if (!uri) { 2181 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 2182 return false; 2183 } 2184 2185 return detNormalizedImfileRowAlloc( 2186 statImfile->det_id, 2187 statImfile->iteration, 2188 statImfile->class_id, 2189 uri 2190 ); 2120 2191 } 2121 2192 -
trunk/ippTools/src/dettoolConfig.c
r8370 r8378 231 231 psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-uri", 0, 232 232 "define URI (required)", NULL); 233 psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-recip", 0,234 "define recipe (required)", NULL);235 233 236 234 // -normalized
Note:
See TracChangeset
for help on using the changeset viewer.
