Changeset 36543 for trunk/ippTools/src/detselect.c
- Timestamp:
- Feb 20, 2014, 5:38:01 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/detselect.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/detselect.c
r31058 r36543 29 29 static bool searchMode(pxConfig *config); 30 30 static bool selectMode(pxConfig *config); 31 static bool showMode(pxConfig *config); 32 31 33 32 34 # define MODECASE(caseName, func) \ … … 50 52 MODECASE(DETSELECT_MODE_SEARCH, searchMode); 51 53 MODECASE(DETSELECT_MODE_SELECT, selectMode); 54 MODECASE(DETSELECT_MODE_SHOW, showMode); 52 55 default: 53 56 psAbort("invalid option (this should not happen)"); … … 241 244 return true; 242 245 } 246 247 static bool showMode(pxConfig *config) 248 { 249 PS_ASSERT_PTR_NON_NULL(config, false); 250 251 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 252 253 psMetadata *where = psMetadataAlloc(); 254 255 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 256 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 257 PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "=="); 258 PXOPT_COPY_STR(config->args, where, "-type", "det_type", "=="); 259 260 psString query = pxDataGet("detselect_show.sql"); 261 if (!query) { 262 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 263 return false; 264 } 265 266 // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE 267 if (where && psListLength(where->list)) { 268 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 269 psStringAppend(&query, " AND %s", whereClause); 270 psFree(whereClause); 271 } 272 psFree(where); 273 274 // we choose the single detrend image which matches all criteria and has 275 // the latest insertion date 276 277 psStringAppend(&query, " ORDER BY registered DESC, iteration DESC, time_begin, time_end"); 278 279 if (!p_psDBRunQuery(config->dbh, query)) { 280 psError(PS_ERR_UNKNOWN, false, "database error"); 281 psFree(query); 282 return false; 283 } 284 psFree(query); 285 286 psArray *output = p_psDBFetchResult(config->dbh); 287 if (!output) { 288 psError(PS_ERR_UNKNOWN, false, "database error"); 289 return false; 290 } 291 if (!psArrayLength(output)) { 292 // XXX check psError here 293 psError(PS_ERR_UNKNOWN, false, "no detRun rows found"); 294 psFree(output); 295 return true; 296 } 297 298 // negative simple so the default is true 299 if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) { 300 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 301 psFree(output); 302 return false; 303 } 304 305 psFree(output); 306 return(true); 307 }
Note:
See TracChangeset
for help on using the changeset viewer.
