Changeset 27838 for branches/tap_branches/ippTools/src/addtool.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/addtool.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/ippTools/src
- Property svn:ignore
-
old new 16 16 difftool 17 17 disttool 18 dqstatstool 18 19 faketool 19 20 flatcorr
-
- Property svn:ignore
-
branches/tap_branches/ippTools/src/addtool.c
r25840 r27838 98 98 pxcamGetSearchArgs (config, where); 99 99 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 100 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 100 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 101 pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label 101 102 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 102 103 103 if (!psListLength(where->list) && 104 !psMetadataLookupBool(NULL, config->args, "-all")) { 104 if (!psListLength(where->list)) { 105 105 psFree(where); 106 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");106 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 107 107 return false; 108 108 } … … 115 115 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 116 116 PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false); 117 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false); 117 118 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 118 119 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 119 120 120 121 // find the cam_id of all the exposures that we want to queue up. 121 psString query = pxDataGet("addtool_find_cam_id.sql");122 if (! query) {123 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");122 psString bare_query = pxDataGet("addtool_find_cam_id.sql"); 123 if (!bare_query) { 124 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 124 125 psFree(where); 125 126 return false; 126 127 } 128 129 // prevent queueing an addRun if a given exposure has already been added to 130 // the given dvo database 131 psString dvodb_string = NULL; 132 if (dvodb) { 133 // user supplied dvodb 134 psStringAppend(&dvodb_string, "(previous_dvodb = '%s')", dvodb); 135 } else { 136 // inherit dvodb from camRun, avoid matching NULL 137 psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)"); 138 } 139 // Take the bare query and add the dvodb selector 140 psString query = NULL; 141 psStringAppend(&query, bare_query, dvodb_string); 142 psFree(dvodb_string); 143 psFree(bare_query); 127 144 128 145 // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE … … 131 148 psStringAppend(&query, " AND %s", whereClause); 132 149 psFree(whereClause); 150 } else { 151 psError(PS_ERR_UNKNOWN, true, "search parameters are required"); 152 return false; 133 153 } 134 154 psFree(where); 155 156 if (destreaked) { 157 psStringAppend(&query, " AND (camRun.magicked > 0)"); 158 } 135 159 136 160 if (!p_psDBRunQuery(config->dbh, query)) { … … 214 238 // queue the exp 215 239 if (!pxaddQueueByCamID(config, 216 row->cam_id,217 workdir ? workdir : row->workdir,218 reduction ? reduction : row->reduction,219 label ? label : row->label,220 data_group ? data_group : (label ? label : row->label),221 dvodb ? dvodb : row->dvodb,240 row->cam_id, 241 workdir ? workdir : row->workdir, 242 reduction ? reduction : row->reduction, 243 label ? label : row->label, 244 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 245 dvodb ? dvodb : row->dvodb, 222 246 note ? note : NULL, 223 image_only247 image_only 224 248 )) { 225 249 if (!psDBRollback(config->dbh)) { … … 256 280 PXOPT_COPY_STR(config->args, where, "-state", "addRun.state", "=="); 257 281 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 282 PXOPT_COPY_STR(config->args, where, "-dvodb", "addRun.dvodb", "=="); 258 283 259 284 if (!psListLength(where->list)) { 260 285 psFree(where); 261 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");286 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 262 287 return false; 263 288 } … … 266 291 267 292 // pxUpdateRun gets parameters from config->args and runs the update query 268 bool result = pxUpdateRun(config, where, &query, "addRun", false); 293 bool result = pxUpdateRun(config, where, &query, "addRun", "add_id", 294 "addProcessedExp", false); 269 295 270 296 psFree(query); … … 272 298 273 299 return result; 274 275 276 #ifdef notdef277 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);278 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);279 280 if ((!state) && (!label)) {281 psError(PXTOOLS_ERR_DATA, false, "parameters are required");282 psFree(where);283 return false;284 }285 286 if (state) {287 // set addRun.state to state288 if (!pxaddRunSetStateByQuery(config, where, state)) {289 psFree(where);290 return false;291 }292 }293 294 if (label) {295 // set addRun.label to label296 if (!pxaddRunSetLabelByQuery(config, where, label)) {297 psFree(where);298 return false;299 }300 }301 302 psFree(where);303 304 return true;305 #endif306 300 } 307 301 … … 322 316 psString query = pxDataGet("addtool_find_pendingexp.sql"); 323 317 if (!query) { 324 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");318 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 325 319 return false; 326 320 } … … 388 382 psString query = pxDataGet("addtool_find_pendingexp.sql"); 389 383 if (!query) { 390 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");384 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 391 385 return false; 392 386 } … … 430 424 dtime_addstar, 431 425 path_base, 432 fault426 fault 433 427 ); 434 428 … … 482 476 !psMetadataLookupBool(NULL, config->args, "-all")) { 483 477 psFree(where); 484 psError(PXTOOLS_ERR_ DATA, false, "search parameters (or -all) are required");478 psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required"); 485 479 return false; 486 480 } … … 488 482 psString query = pxDataGet("addtool_find_processedexp.sql"); 489 483 if (!query) { 490 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");484 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 491 485 return false; 492 486 } … … 496 490 psStringAppend(&query, " WHERE %s", whereClause); 497 491 psFree(whereClause); 498 } 492 } 499 493 500 494 // we either add AND (condition) or WHERE (condition): … … 502 496 // list only faulted rows 503 497 psStringAppend(&query, " %s", " AND addProcessedExp.fault != 0"); 504 } 498 } 505 499 if (where->list && !faulted) { 506 500 // don't list faulted rows … … 510 504 // list only faulted rows 511 505 psStringAppend(&query, " %s", " WHERE addProcessedExp.fault != 0"); 512 } 506 } 513 507 if (!where->list && !faulted) { 514 508 // don't list faulted rows … … 571 565 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { 572 566 psFree(where); 573 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");567 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 574 568 return false; 575 569 } … … 584 578 psString query = pxDataGet("addtool_reset_faulted_runs.sql"); 585 579 if (!query) { 586 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");580 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 587 581 psFree(where); 588 582 return false; … … 616 610 psError(PS_ERR_UNKNOWN, false, "database error"); 617 611 } 618 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");612 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 619 613 psFree(where); 620 614 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
