Changeset 9369 for trunk/ippTools/src/dettool.c
- Timestamp:
- Oct 6, 2006, 3:02:28 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r9353 r9369 3130 3130 PS_ASSERT_PTR_NON_NULL(config, false); 3131 3131 3132 // det_id is required 3133 // psString det_id is unused in the first query... it is checked for to 3134 // make sure it is in config->where 3135 bool status = false; 3136 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 3137 if (!status) { 3138 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 3139 return false; 3140 } 3141 if (!det_id) { 3142 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 3143 return false; 3144 } 3145 3146 psArray *normalizedImfiles = 3147 detNormalizedImfileSelectRowObjects(config->dbh, config->where, 0); 3148 if (!normalizedImfiles) { 3132 psString query = psStringCopy( 3133 "SELECT detNormalizedImfile.*" 3134 " FROM detNormalizedImfile" 3135 " JOIN detRun" 3136 " ON detNormalizedImfile.det_id = detRun.position" 3137 " WHERE" 3138 " detRun.state = 'run'" 3139 ); 3140 3141 if (config->where) { 3142 psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL); 3143 psStringAppend(&query, " AND %s", whereClause); 3144 psFree(whereClause); 3145 } 3146 3147 if (!p_psDBRunQuery(config->dbh, query)) { 3148 psError(PS_ERR_UNKNOWN, false, "database error"); 3149 psFree(query); 3150 return false; 3151 } 3152 psFree(query); 3153 3154 psArray *output = p_psDBFetchResult(config->dbh); 3155 if (!output) { 3156 psError(PS_ERR_UNKNOWN, false, "database error"); 3157 return false; 3158 } 3159 if (!psArrayLength(output)) { 3160 // XXX check psError here 3149 3161 psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found"); 3150 return false; 3151 } 3152 3153 // mask out normalized imfiles that have residuals registered for them 3154 psArray *residImfiles = detResidImfileSelectRowObjects(config->dbh, 3155 config->where, 0); 3156 if (residImfiles) { 3157 for (long i = 0; i < psArrayLength(normalizedImfiles); i++) { 3158 for (long j = 0; j < psArrayLength(residImfiles); j++) { 3159 if ( 3160 (((detNormalizedImfileRow *)normalizedImfiles->data[i])->det_id 3161 == 3162 ((detResidImfileRow *)residImfiles->data[j])->det_id) 3163 && 3164 (((detNormalizedImfileRow *)normalizedImfiles->data[i])->iteration 3165 == 3166 ((detResidImfileRow *)residImfiles->data[j])->iteration) 3167 && 3168 (strcmp( 3169 ((detNormalizedImfileRow *)normalizedImfiles->data[i])->class_id, 3170 ((detResidImfileRow *)residImfiles->data[j])->class_id) == 0)) 3171 { 3172 3173 // remove the rawImfiles from the list 3174 psArrayRemove(normalizedImfiles, normalizedImfiles->data[i]); 3175 i--; 3176 break; 3177 } 3178 } 3179 } 3180 psFree(residImfiles); 3162 psFree(output) 3163 return true; 3181 3164 } 3182 3165 … … 3192 3175 3193 3176 // negative simple so the default is true 3194 if (normalizedImfiles->n) { 3195 if (!detNormalizedImfilePrintObjects(stdout, normalizedImfiles, !simple)) { 3196 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 3197 psFree(normalizedImfiles); 3198 return false; 3199 } 3200 } 3201 3202 psFree(normalizedImfiles); 3177 if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) { 3178 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 3179 psFree(output); 3180 return false; 3181 } 3182 3183 psFree(output); 3203 3184 3204 3185 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
