- Timestamp:
- Dec 22, 2019, 4:11:49 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ccl_branches/ipponly-20191108/ippTools/src/addtool.c
r41072 r41211 118 118 psMetadata *where = psMetadataAlloc(); 119 119 // pxcamGetSearchArgs (config, where); 120 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "==");121 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id","==");120 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 121 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 122 122 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 123 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");124 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id","==");125 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id","==");123 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 124 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 125 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 126 126 127 127 // PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 128 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir",false, false);129 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb",false, false);130 PXOPT_LOOKUP_STR(label, config->args, "-set_label",false, false);131 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group",false, false);132 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction",false, false);133 PXOPT_LOOKUP_STR(note, config->args, "-set_note",false, false);134 PXOPT_LOOKUP_ STR(minidvodb_name, config->args, "-set_minidvodb_name", false,false);128 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 129 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 130 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 131 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 132 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 133 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 134 PXOPT_LOOKUP_BOOL(minidvodb, config->args, "-set_minidvodb", false); 135 135 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false); 136 PXOPT_LOOKUP_ BOOL(image_only, config->args, "-image_only", false);137 PXOPT_LOOKUP_ BOOL(minidvodb, config->args, "-set_minidvodb", false);138 PXOPT_LOOKUP_BOOL( destreaked, config->args, "-destreaked",false);139 PXOPT_LOOKUP_BOOL( uncensored, config->args, "-uncensored",false);140 141 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 142 143 PXOPT_LOOKUP_BOOL( pretend, config->args, "-pretend",false);144 PXOPT_LOOKUP_ BOOL(simple, config->args, "-simple", false);136 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 137 PXOPT_LOOKUP_STR(minidvodb_host, config->args, "-set_minidvodb_host", false, false); 138 PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false); 139 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false); 140 PXOPT_LOOKUP_BOOL(uncensored, config->args, "-uncensored", false); 141 142 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 143 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 144 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 145 145 146 PXOPT_LOOKUP_F32(minra, config->args, "-set_minra",false, false);147 PXOPT_LOOKUP_F32(maxra, config->args, "-set_maxra",false, false);148 PXOPT_LOOKUP_F32(mindec, config->args, "-set_mindec", false, false);149 PXOPT_LOOKUP_F32(maxdec, config->args, "-set_maxdec", false, false);146 PXOPT_LOOKUP_F32(minra, config->args, "-set_minra", false, false); 147 PXOPT_LOOKUP_F32(maxra, config->args, "-set_maxra", false, false); 148 PXOPT_LOOKUP_F32(mindec, config->args, "-set_mindec", false, false); 149 PXOPT_LOOKUP_F32(maxdec, config->args, "-set_maxdec", false, false); 150 150 151 151 // Handle stages … … 153 153 if (strcmp(stage, "cam") == 0) { 154 154 pxcamGetSearchArgs (config, where); 155 pxAddLabelSearchArgs (config, where, "-label","camRun.label", "=="); // define using camRun label156 pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group", "=="); // define using camRun label157 PXOPT_COPY_STR(config->args, where, "-reduction","camRun.reduction", "==");155 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 156 pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group", "=="); // define using camRun label 157 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 158 158 } 159 159 else if (strcmp(stage, "stack") == 0) { 160 pxAddLabelSearchArgs (config, where, "-label","stackRun.label", "=="); // define using camRun label161 pxAddLabelSearchArgs (config, where, "-data_group", "stackRun.data_group", "=="); // define using camRun label162 PXOPT_COPY_STR(config->args, where, "-reduction","stackRun.reduction", "==");163 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label160 pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "=="); // define using camRun label 161 pxAddLabelSearchArgs (config, where, "-data_group", "stackRun.data_group", "=="); // define using camRun label 162 PXOPT_COPY_STR(config->args, where, "-reduction", "stackRun.reduction", "=="); 163 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 164 164 } 165 165 else if (strcmp(stage, "staticsky") == 0) { 166 pxAddLabelSearchArgs (config, where, "-label","staticskyRun.label", "=="); // define using camRun label167 pxAddLabelSearchArgs (config, where, "-data_group", "staticskyRun.data_group", "=="); // define using camRun label168 PXOPT_COPY_STR(config->args, where, "-reduction","staticskyRun.reduction", "==");166 pxAddLabelSearchArgs (config, where, "-label", "staticskyRun.label", "=="); // define using camRun label 167 pxAddLabelSearchArgs (config, where, "-data_group", "staticskyRun.data_group", "=="); // define using camRun label 168 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyRun.reduction", "=="); 169 169 //no filter here 170 170 } 171 171 else if (strcmp(stage, "skycal") == 0) { 172 pxAddLabelSearchArgs (config, where, "-label","skycalRun.label", "=="); //define using skycalRun label173 pxAddLabelSearchArgs (config, where, "-data_group", "skycalRun.data_group", "==");174 PXOPT_COPY_STR(config->args, where, "-reduction", "skycalRun.reduction","==");172 pxAddLabelSearchArgs (config, where, "-label", "skycalRun.label", "=="); //define using skycalRun label 173 pxAddLabelSearchArgs (config, where, "-data_group", "skycalRun.data_group", "=="); 174 PXOPT_COPY_STR(config->args, where, "-reduction", "skycalRun.reduction", "=="); 175 175 } 176 176 else if (strcmp(stage, "diff") == 0) { 177 177 pxAddLabelSearchArgs (config, where, "-label", "diffRun.label", "=="); //define using diffRun label 178 178 pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "=="); 179 PXOPT_COPY_STR(config->args, where,"-reduction", "diffRun.reduction", "==");179 PXOPT_COPY_STR(config->args, where, "-reduction", "diffRun.reduction", "=="); 180 180 } 181 181 else if (strcmp(stage, "fullforce") == 0) { 182 182 pxAddLabelSearchArgs (config, where, "-label", "fullForceRun.label", "=="); //define using fullForceRun label 183 183 pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "=="); 184 PXOPT_COPY_STR(config->args, where,"-reduction", "fullForceRun.reduction", "==");184 PXOPT_COPY_STR(config->args, where, "-reduction", "fullForceRun.reduction", "=="); 185 185 } 186 186 else if (strcmp(stage, "fullforce_summary")==0) { … … 201 201 //if one of destreaked and uncensored is true, but not both 202 202 if (destreaked) { 203 psTrace("addtool.c", PS_LOG_INFO, "using -destreaked\n");203 psTrace("addtool.c", PS_LOG_INFO, "using -destreaked\n"); 204 204 } else { 205 psTrace("addtool.c", PS_LOG_INFO, "using -unscensored\n");205 psTrace("addtool.c", PS_LOG_INFO, "using -unscensored\n"); 206 206 } 207 207 } else { 208 208 if (destreaked && uncensored) { 209 psError(PS_ERR_UNKNOWN, false, "Both -destreaked and -uncensored are selected. Please use one or the other, not both, \n");210 return false;209 psError(PS_ERR_UNKNOWN, false, "Both -destreaked and -uncensored are selected. Please use one or the other, not both, \n"); 210 return false; 211 211 } 212 212 if (!destreaked && !uncensored) { 213 psError(PS_ERR_UNKNOWN, false, "Neither -destreaked or -uncensored are selected. Please use one.\n");214 return false;213 psError(PS_ERR_UNKNOWN, false, "Neither -destreaked or -uncensored are selected. Please use one.\n"); 214 return false; 215 215 } 216 216 } 217 217 if ((strcmp(stage,"diff") == 0) || 218 (strcmp(stage,"fullforce") == 0) ||219 (strcmp(stage,"fullforce_summary") == 0)) {218 (strcmp(stage,"fullforce") == 0) || 219 (strcmp(stage,"fullforce_summary") == 0)) { 220 220 if (! (dvodb)) { 221 psError(PS_ERR_UNKNOWN, false, "The SQL is not correctly written to handle this case (-set_dvodb not specified), so stopping here.");222 return(false);221 psError(PS_ERR_UNKNOWN, false, "The SQL is not correctly written to handle this case (-set_dvodb not specified), so stopping here."); 222 return(false); 223 223 } 224 224 } … … 232 232 if (strcmp(stage,"cam") == 0 ) { 233 233 if (dvodb) { 234 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);234 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage); 235 235 // find the cam_id of all the exposures that we want to queue up. 236 236 bare_query = pxDataGet("addtool_find_cam_id_dvo.sql"); 237 // user supplied dvodb238 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);237 // user supplied dvodb 238 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 239 239 } else { 240 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);240 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage); 241 241 // find the cam_id of all the exposures that we want to queue up. 242 242 bare_query = pxDataGet("addtool_find_cam_id.sql"); … … 248 248 else if (strcmp(stage,"stack") == 0) { 249 249 if (dvodb) { 250 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);250 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage); 251 251 // find the cam_id of all the exposures that we want to queue up. 252 252 bare_query = pxDataGet("addtool_find_stack_id_dvo.sql"); 253 // user supplied dvodb254 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);253 // user supplied dvodb 254 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 255 255 } else { 256 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);256 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage); 257 257 // find the cam_id of all the exposures that we want to queue up. 258 258 bare_query = pxDataGet("addtool_find_stack_id.sql"); … … 264 264 else if (strcmp(stage,"staticsky") == 0) { 265 265 if (dvodb ) { 266 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);266 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage); 267 267 // find the cam_id of all the exposures that we want to queue up. 268 268 bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql"); 269 // user supplied dvodb270 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);269 // user supplied dvodb 270 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 271 271 } else { 272 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);272 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage); 273 273 // find the cam_id of all the exposures that we want to queue up. 274 274 bare_query = pxDataGet("addtool_find_sky_id_multi.sql"); … … 291 291 // inherit dvodb from skycalRun, avoid matching NULL 292 292 psStringAppend(&dvodb_string, "(skycalRun.dvodb IS NOT NULL AND previous_dvodb = skycalRun.dvodb)"); 293 // this is silly, there is no dvodb in skycalRun...?293 // this is silly, there is no dvodb in skycalRun...? 294 294 } 295 295 } … … 308 308 // inherit dvodb from skycalRun, avoid matching NULL 309 309 psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)"); 310 // this is silly, there is no dvodb in skycalRun...?310 // this is silly, there is no dvodb in skycalRun...? 311 311 } 312 312 } … … 325 325 // inherit dvodb from skycalRun, avoid matching NULL 326 326 psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)"); 327 // this is silly, there is no dvodb in skycalRun...?327 // this is silly, there is no dvodb in skycalRun...? 328 328 } 329 329 } … … 341 341 // inherit dvodb from skycalRun, avoid matching NULL 342 342 psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)"); 343 // this is silly, there is no dvodb in skycalRun...?343 // this is silly, there is no dvodb in skycalRun...? 344 344 } 345 345 } … … 347 347 if (!bare_query) { 348 348 psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement"); 349 psFree(where);350 return false;349 psFree(where); 350 return false; 351 351 } 352 352 … … 362 362 psStringAppend(&query, " AND %s", whereClause); 363 363 364 if ((strcmp(stage,"diff") == 0)|| 365 (strcmp(stage,"fullforce") == 0)|| 366 (strcmp(stage,"fullforce_summary") == 0)) { 367 //diff needs the ra /deg stuff 368 //ff needs the ra /deg stuff 369 //ff summary needs the ra /deg stuff 370 psStringAppend(&query, " AND radeg >= %f", minra); 371 psStringAppend(&query, " AND radeg <= %f", maxra); 372 psStringAppend(&query, " AND decdeg >= %f", mindec); 373 psStringAppend(&query, " AND decdeg <= %f", maxdec); 374 } 375 364 if ((strcmp(stage,"diff") == 0)|| 365 (strcmp(stage,"fullforce") == 0)|| 366 (strcmp(stage,"fullforce_summary") == 0)) { 367 //diff needs the ra /deg stuff 368 //ff needs the ra /deg stuff 369 //ff summary needs the ra /deg stuff 370 psStringAppend(&query, " AND radeg >= %f", minra); 371 psStringAppend(&query, " AND radeg <= %f", maxra); 372 psStringAppend(&query, " AND decdeg >= %f", mindec); 373 psStringAppend(&query, " AND decdeg <= %f", maxdec); 374 } 376 375 psFree(whereClause); 377 376 } else { … … 384 383 //This picks the magicked/censored ones 385 384 if ((strcmp(stage,"cam") == 0)|| 386 (strcmp(stage,"stack") == 0)) {385 (strcmp(stage,"stack") == 0)) { 387 386 psStringAppend(&query, " AND (camRun.magicked > 0)"); 388 387 } … … 391 390 //This picks only the unmagicked/uncensored ones 392 391 //if (strcmp(stage,"cam") == 0) { 393 //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored.392 //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored. 394 393 //psStringAppend(&query, " AND (camRun.magicked = 0)"); 395 //}394 //} 396 395 if (strcmp(stage,"stack") == 0) { 397 psStringAppend(&query, " AND (stackRun.magicked = 0)");396 psStringAppend(&query, " AND (stackRun.magicked = 0)"); 398 397 } 399 398 } … … 457 456 // negative simple so the default is true 458 457 if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) { 459 psError(PS_ERR_UNKNOWN, false, "failed to print array");460 psFree(output);461 return false;458 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 459 psFree(output); 460 return false; 462 461 } 463 462 psFree(output); … … 469 468 for (long i = 0; i < psArrayLength(output); i++) { 470 469 psMetadata *md = output->data[i]; 471 472 camRunRow *row = camRunObjectFromMetadata(md);473 470 471 camRunRow *row = camRunObjectFromMetadata(md); 472 474 473 if (!row) { 475 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");476 psFree(output);477 return false;478 } 479 474 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 475 psFree(output); 476 return false; 477 } 478 480 479 if (!dvodb && !row->dvodb) { 481 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);482 psFree(output);483 return false;480 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id); 481 psFree(output); 482 return false; 484 483 } 485 484 if (!workdir && !row->workdir) { 486 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);487 psFree(output);488 return false;489 } 490 485 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id); 486 psFree(output); 487 return false; 488 } 489 491 490 psFree(row); 492 491 } … … 495 494 for (long i = 0; i < psArrayLength(output); i++) { 496 495 psMetadata *md = output->data[i]; 497 498 stackRunRow *row = stackRunObjectFromMetadata(md);499 496 497 stackRunRow *row = stackRunObjectFromMetadata(md); 498 500 499 if (!row) { 501 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");502 psFree(output);503 return false;504 } 505 500 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 501 psFree(output); 502 return false; 503 } 504 506 505 if (!dvodb && !row->dvodb) { 507 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);508 psFree(output);509 return false;506 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id); 507 psFree(output); 508 return false; 510 509 } 511 510 if (!workdir && !row->workdir) { 512 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);513 psFree(output);514 return false;515 } 516 511 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id); 512 psFree(output); 513 return false; 514 } 515 517 516 psFree(row); 518 517 } … … 521 520 for (long i = 0; i < psArrayLength(output); i++) { 522 521 psMetadata *md = output->data[i]; 523 bool status = false;524 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");525 if (!status) {526 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");527 return false;528 }529 if (num_inputs < 0) {530 psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");531 return false;532 }533 534 staticskyRunRow *row = staticskyRunObjectFromMetadata(md);535 522 bool status = false; 523 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 524 if (!status) { 525 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs"); 526 return false; 527 } 528 if (num_inputs < 0) { 529 psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs"); 530 return false; 531 } 532 533 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 534 536 535 if (!row) { 537 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");538 psFree(output);539 return false;540 } 541 536 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 537 psFree(output); 538 return false; 539 } 540 542 541 if (!dvodb) { //there's no staticsky.dvodb 543 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);544 psFree(output);545 return false;542 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id); 543 psFree(output); 544 return false; 546 545 } 547 546 if (!workdir && !row->workdir) { 548 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);549 psFree(output);550 return false;551 } 552 547 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id); 548 psFree(output); 549 return false; 550 } 551 553 552 psFree(row); 554 553 } … … 557 556 for (long i = 0; i < psArrayLength(output); i++) { 558 557 psMetadata *md = output->data[i]; 559 558 560 559 skycalRunRow *row = skycalRunObjectFromMetadata(md); 561 560 562 561 if (!row) { 563 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");564 psFree(output);565 return false;566 } 567 568 if (!dvodb) { // there's no skycalRun.dvodb569 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);570 psFree(output);571 return false;562 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 563 psFree(output); 564 return false; 565 } 566 567 if (!dvodb) { // there's no skycalRun.dvodb 568 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id); 569 psFree(output); 570 return false; 572 571 } 573 572 if (!workdir && !row->workdir) { 574 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);575 psFree(output);576 return false;577 } 578 573 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id); 574 psFree(output); 575 return false; 576 } 577 579 578 psFree(row); 580 579 } … … 583 582 for (long i = 0; i < psArrayLength(output); i++) { 584 583 psMetadata *md = output->data[i]; 585 584 586 585 diffRunRow *row = diffRunObjectFromMetadata(md); 587 586 588 587 if (!row) { 589 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");590 psFree(output);591 return false;592 } 593 594 if (!dvodb) { // there's no skycalRun.dvodb595 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);596 psFree(output);597 return false;588 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun"); 589 psFree(output); 590 return false; 591 } 592 593 if (!dvodb) { // there's no skycalRun.dvodb 594 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id); 595 psFree(output); 596 return false; 598 597 } 599 598 if (!workdir && !row->workdir) { 600 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);601 psFree(output);602 return false;603 } 604 599 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id); 600 psFree(output); 601 return false; 602 } 603 605 604 psFree(row); 606 605 } … … 609 608 for (long i = 0; i < psArrayLength(output); i++) { 610 609 psMetadata *md = output->data[i]; 611 610 612 611 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 613 612 614 613 if (!row) { 615 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");616 psFree(output);617 return false;618 } 619 620 if (!dvodb) { // there's no skycalRun.dvodb621 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);622 psFree(output);623 return false;614 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun"); 615 psFree(output); 616 return false; 617 } 618 619 if (!dvodb) { // there's no skycalRun.dvodb 620 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id); 621 psFree(output); 622 return false; 624 623 } 625 624 if (!workdir && !row->workdir) { 626 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);627 psFree(output);628 return false;629 } 630 625 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id); 626 psFree(output); 627 return false; 628 } 629 631 630 psFree(row); 632 631 } … … 635 634 for (long i = 0; i < psArrayLength(output); i++) { 636 635 psMetadata *md = output->data[i]; 637 //i believe this is correct for ff_summary as well:636 //i believe this is correct for ff_summary as well: 638 637 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 639 638 640 639 if (!row) { 641 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");642 psFree(output);643 return false;644 } 645 646 if (!dvodb) { // there's no skycalRun.dvodb647 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);648 psFree(output);649 return false;640 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun"); 641 psFree(output); 642 return false; 643 } 644 645 if (!dvodb) { // there's no skycalRun.dvodb 646 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id); 647 psFree(output); 648 return false; 650 649 } 651 650 if (!workdir && !row->workdir) { 652 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);653 psFree(output);654 return false;655 } 656 651 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id); 652 psFree(output); 653 return false; 654 } 655 657 656 psFree(row); 658 657 } … … 678 677 for (long i = 0; i < psArrayLength(output); i++) { 679 678 psMetadata *md = output->data[i]; 680 psS64 stage_id =0;681 682 camRunRow *row = camRunObjectFromMetadata(md);683 stage_id = row->cam_id;684 679 psS64 stage_id =0; 680 681 camRunRow *row = camRunObjectFromMetadata(md); 682 stage_id = row->cam_id; 683 685 684 if (!row) { 686 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");687 psFree(output);688 return false;689 } 690 685 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 686 psFree(output); 687 return false; 688 } 689 691 690 // queue the exp 692 691 if (!pxaddQueueByCamID(config, 693 stage,692 stage, 694 693 stage_id, 695 0,694 0, 696 695 workdir ? workdir : row->workdir, 697 696 reduction ? reduction : row->reduction, … … 703 702 minidvodb, 704 703 minidvodb_group, 705 minidvodb_name 706 )) { 707 if (!psDBRollback(config->dbh)) { 708 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 709 } 710 psError(PS_ERR_UNKNOWN, false, 711 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 712 psFree(row); 713 psFree(output); 714 return false; 704 minidvodb_name, 705 minidvodb_host 706 )) { 707 if (!psDBRollback(config->dbh)) { 708 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 709 } 710 psError(PS_ERR_UNKNOWN, false, 711 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 712 psFree(row); 713 psFree(output); 714 return false; 715 715 } 716 716 psFree(row); … … 720 720 for (long i = 0; i < psArrayLength(output); i++) { 721 721 psMetadata *md = output->data[i]; 722 psS64 stage_id =0;723 724 stackRunRow *row = stackRunObjectFromMetadata(md);725 stage_id = row->stack_id;726 722 psS64 stage_id =0; 723 724 stackRunRow *row = stackRunObjectFromMetadata(md); 725 stage_id = row->stack_id; 726 727 727 if (!row) { 728 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");729 psFree(output);730 return false;731 } 732 728 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 729 psFree(output); 730 return false; 731 } 732 733 733 // queue the exp 734 734 if (!pxaddQueueByCamID(config, 735 stage,735 stage, 736 736 stage_id, 737 0,737 0, 738 738 workdir ? workdir : row->workdir, 739 739 reduction ? reduction : row->reduction, … … 745 745 minidvodb, 746 746 minidvodb_group, 747 minidvodb_name 748 )) { 749 if (!psDBRollback(config->dbh)) { 750 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 751 } 752 psError(PS_ERR_UNKNOWN, false, 753 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 754 psFree(row); 755 psFree(output); 756 return false; 747 minidvodb_name, 748 minidvodb_host 749 )) { 750 if (!psDBRollback(config->dbh)) { 751 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 752 } 753 psError(PS_ERR_UNKNOWN, false, 754 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 755 psFree(row); 756 psFree(output); 757 return false; 757 758 } 758 759 psFree(row); … … 762 763 for (long i = 0; i < psArrayLength(output); i++) { 763 764 psMetadata *md = output->data[i]; 764 psS64 stage_id =0;765 bool status = false;766 //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");767 psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");768 769 if (!status) {770 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");771 return false;772 }773 staticskyRunRow *row = staticskyRunObjectFromMetadata(md);774 stage_id = row->sky_id;775 765 psS64 stage_id =0; 766 bool status = false; 767 //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 768 psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id"); 769 770 if (!status) { 771 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id"); 772 return false; 773 } 774 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 775 stage_id = row->sky_id; 776 776 777 if (!row) { 777 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");778 psFree(output);779 return false;780 } 781 778 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 779 psFree(output); 780 return false; 781 } 782 782 783 // queue the exp 783 //for (int filter_id = 0; filter_id < num_inputs; filter_id++) {784 if (!pxaddQueueByCamID(config,785 stage,786 stage_id,787 stack_id,784 //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 785 if (!pxaddQueueByCamID(config, 786 stage, 787 stage_id, 788 stack_id, 788 789 workdir ? workdir : row->workdir, 789 790 reduction ? reduction : row->reduction, … … 795 796 minidvodb, 796 797 minidvodb_group, 797 minidvodb_name 798 )) { 799 if (!psDBRollback(config->dbh)) { 800 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 801 } 802 psError(PS_ERR_UNKNOWN, false, 803 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 804 psFree(row); 805 psFree(output); 806 return false; 807 } 808 //} 798 minidvodb_name, 799 minidvodb_host 800 )) { 801 if (!psDBRollback(config->dbh)) { 802 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 803 } 804 psError(PS_ERR_UNKNOWN, false, 805 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 806 psFree(row); 807 psFree(output); 808 return false; 809 } 810 //} 809 811 psFree(row); 810 812 } … … 813 815 for (long i = 0; i < psArrayLength(output); i++) { 814 816 psMetadata *md = output->data[i]; 815 psS64 stage_id =0;816 817 skycalRunRow *row = skycalRunObjectFromMetadata(md);818 stage_id = row->skycal_id;819 817 psS64 stage_id =0; 818 819 skycalRunRow *row = skycalRunObjectFromMetadata(md); 820 stage_id = row->skycal_id; 821 820 822 if (!row) { 821 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");822 psFree(output);823 return false;824 } 825 823 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 824 psFree(output); 825 return false; 826 } 827 826 828 // queue the exp 827 829 if (!pxaddQueueByCamID(config, 828 stage,830 stage, 829 831 stage_id, 830 0,832 0, 831 833 workdir ? workdir : row->workdir, 832 834 reduction ? reduction : row->reduction, … … 838 840 minidvodb, 839 841 minidvodb_group, 840 minidvodb_name 841 )) { 842 if (!psDBRollback(config->dbh)) { 843 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 844 } 845 psError(PS_ERR_UNKNOWN, false, 846 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 847 psFree(row); 848 psFree(output); 849 return false; 842 minidvodb_name, 843 minidvodb_host 844 )) { 845 if (!psDBRollback(config->dbh)) { 846 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 847 } 848 psError(PS_ERR_UNKNOWN, false, 849 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 850 psFree(row); 851 psFree(output); 852 return false; 850 853 } 851 854 psFree(row); … … 855 858 for (long i = 0; i < psArrayLength(output); i++) { 856 859 psMetadata *md = output->data[i]; 857 psS64 stage_id =0;858 //psS64 stage_extra1 = 0;859 diffRunRow *row = diffRunObjectFromMetadata(md);860 stage_id = row->diff_id;861 bool status = false;862 psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");863 if (!status) {864 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");865 return false;866 }867 860 psS64 stage_id =0; 861 // psS64 stage_extra1 = 0; 862 diffRunRow *row = diffRunObjectFromMetadata(md); 863 stage_id = row->diff_id; 864 bool status = false; 865 psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id"); 866 if (!status) { 867 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id"); 868 return false; 869 } 870 868 871 if (!row) { 869 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");870 psFree(output);871 return false;872 } 873 872 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 873 psFree(output); 874 return false; 875 } 876 874 877 // queue the exp 875 878 if (!pxaddQueueByCamID(config, 876 stage,879 stage, 877 880 stage_id, 878 stage_extra1,881 stage_extra1, 879 882 workdir ? workdir : row->workdir, 880 883 reduction ? reduction : row->reduction, … … 886 889 minidvodb, 887 890 minidvodb_group, 888 minidvodb_name 889 )) { 890 if (!psDBRollback(config->dbh)) { 891 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 892 } 893 psError(PS_ERR_UNKNOWN, false, 894 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 895 psFree(row); 896 psFree(output); 897 return false; 891 minidvodb_name, 892 minidvodb_host 893 )) { 894 if (!psDBRollback(config->dbh)) { 895 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 896 } 897 psError(PS_ERR_UNKNOWN, false, 898 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 899 psFree(row); 900 psFree(output); 901 return false; 898 902 } 899 903 psFree(row); … … 903 907 for (long i = 0; i < psArrayLength(output); i++) { 904 908 psMetadata *md = output->data[i]; 905 psS64 stage_id =0;906 907 fullForceRunRow *row = fullForceRunObjectFromMetadata(md);908 stage_id = row->ff_id;909 bool status = false;910 psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");911 if (!status) {912 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");913 return false;914 }915 909 psS64 stage_id =0; 910 911 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 912 stage_id = row->ff_id; 913 bool status = false; 914 psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id"); 915 if (!status) { 916 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id"); 917 return false; 918 } 919 916 920 if (!row) { 917 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");918 psFree(output);919 return false;920 } 921 921 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 922 psFree(output); 923 return false; 924 } 925 922 926 // queue the exp 923 927 if (!pxaddQueueByCamID(config, 924 stage,928 stage, 925 929 stage_id, 926 stage_extra1,930 stage_extra1, 927 931 workdir ? workdir : row->workdir, 928 932 reduction ? reduction : row->reduction, … … 934 938 minidvodb, 935 939 minidvodb_group, 936 minidvodb_name 937 )) { 938 if (!psDBRollback(config->dbh)) { 939 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 940 } 941 psError(PS_ERR_UNKNOWN, false, 942 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 943 psFree(row); 944 psFree(output); 945 return false; 940 minidvodb_name, 941 minidvodb_host 942 )) { 943 if (!psDBRollback(config->dbh)) { 944 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 945 } 946 psError(PS_ERR_UNKNOWN, false, 947 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 948 psFree(row); 949 psFree(output); 950 return false; 946 951 } 947 952 psFree(row); … … 951 956 for (long i = 0; i < psArrayLength(output); i++) { 952 957 psMetadata *md = output->data[i]; 953 psS64 stage_id =0;954 955 fullForceRunRow *row = fullForceRunObjectFromMetadata(md);956 stage_id = row->ff_id;957 958 psS64 stage_id =0; 959 960 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 961 stage_id = row->ff_id; 962 958 963 if (!row) { 959 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");960 psFree(output);961 return false;962 } 963 964 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun"); 965 psFree(output); 966 return false; 967 } 968 964 969 // queue the exp 965 970 if (!pxaddQueueByCamID(config, 966 stage,971 stage, 967 972 stage_id, 968 0,973 0, 969 974 workdir ? workdir : row->workdir, 970 975 reduction ? reduction : row->reduction, … … 976 981 minidvodb, 977 982 minidvodb_group, 978 minidvodb_name 979 )) { 980 if (!psDBRollback(config->dbh)) { 981 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 982 } 983 psError(PS_ERR_UNKNOWN, false, 984 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 985 psFree(row); 986 psFree(output); 987 return false; 983 minidvodb_name, 984 minidvodb_host 985 )) { 986 if (!psDBRollback(config->dbh)) { 987 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 988 } 989 psError(PS_ERR_UNKNOWN, false, 990 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 991 psFree(row); 992 psFree(output); 993 return false; 988 994 } 989 995 psFree(row); … … 1006 1012 1007 1013 psMetadata *where = psMetadataAlloc(); 1008 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "==");1009 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "==");1010 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id","==");1014 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 1015 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 1016 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 1011 1017 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 1012 1018 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 1013 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id","==");1014 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id","==");1019 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 1020 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 1015 1021 1016 1022 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 1017 1023 pxcamGetSearchArgs (config, where); // most search arguments based on camera 1018 PXOPT_COPY_STR(config->args, where, "-label", "addRun.label", "==");1019 PXOPT_COPY_STR(config->args, where, "-state", "addRun.state", "==");1024 PXOPT_COPY_STR(config->args, where, "-label", "addRun.label", "=="); 1025 PXOPT_COPY_STR(config->args, where, "-state", "addRun.state", "=="); 1020 1026 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 1021 PXOPT_COPY_STR(config->args, where, "-dvodb", "addRun.dvodb","==");1027 PXOPT_COPY_STR(config->args, where, "-dvodb", "addRun.dvodb", "=="); 1022 1028 1023 1029 if (!psListLength(where->list)) { … … 1135 1141 //this group by is needed to join against all the warps (to get camera) 1136 1142 if (multiadd) { 1137 psStringAppend(&query, " GROUP BY %s", "diff_id");1143 psStringAppend(&query, " GROUP BY %s", "diff_id"); 1138 1144 } else { 1139 psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1");1145 psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1"); 1140 1146 } 1141 1147 } … … 1143 1149 //this group by is needed to join against all the warps (to get camera) 1144 1150 if (multiadd) { 1145 psStringAppend(&query, "GROUP BY %s", "ff_id");1151 psStringAppend(&query, "GROUP BY %s", "ff_id"); 1146 1152 } else { 1147 psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1");1153 psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1"); 1148 1154 } 1149 1155 } … … 1199 1205 1200 1206 // optional 1201 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base",false, false);1202 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar",false, false);1203 PXOPT_LOOKUP_STR(dvodb_path, config->args, "-dvodb_path",false, false);1207 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 1208 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false); 1209 PXOPT_LOOKUP_STR(dvodb_path, config->args, "-dvodb_path", false, false); 1204 1210 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-minidvodb_name", false, false); 1205 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1206 PXOPT_LOOKUP_S64(stage_extra1, config->args, "-stage_extra1", false, false); 1207 1208 PXOPT_LOOKUP_BOOL(multiadd, config->args, "-multiadd", false); 1211 PXOPT_LOOKUP_STR(minidvodb_host, config->args, "-minidvodb_host", false, false); 1212 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1213 PXOPT_LOOKUP_S64(stage_extra1, config->args, "-stage_extra1", false, false); 1214 1215 PXOPT_LOOKUP_BOOL(multiadd, config->args, "-multiadd", false); 1209 1216 // generate restrictions 1210 1217 psMetadata *where = psMetadataAlloc(); … … 1247 1254 PXOPT_LOOKUP_STR(stage_extra1_list, config->args, "-stage_extra1_list", false, false); 1248 1255 if (stage_extra1_list) { 1249 psStringAppend(&query, " AND stage_extra1 IN (%s)", stage_extra1_list);1256 psStringAppend(&query, " AND stage_extra1 IN (%s)", stage_extra1_list); 1250 1257 } 1251 1258 } … … 1286 1293 1287 1294 addProcessedExpRow *row = addProcessedExpRowAlloc( 1288 pendingRow->add_id,1289 dtime_addstar,1290 path_base,1291 dvodb_path,1292 fault1293 );1295 pendingRow->add_id, 1296 dtime_addstar, 1297 path_base, 1298 dvodb_path, 1299 fault 1300 ); 1294 1301 1295 1302 if (!addProcessedExpInsertObject(config->dbh, row)) { 1296 1303 // rollback 1297 1304 if (!psDBRollback(config->dbh)) { 1298 psError(PS_ERR_UNKNOWN, false, "database error");1305 psError(PS_ERR_UNKNOWN, false, "database error"); 1299 1306 } 1300 1307 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1306 1313 //if there is a minidvodb_name, set it in addRun (it's not known until it is processed) 1307 1314 if (minidvodb_name) { 1308 psString setName = NULL; 1309 psStringAppend (&setName, "UPDATE addRun set minidvodb_name = '%s' where add_id = %" PRId64, minidvodb_name, row->add_id); 1310 if (!p_psDBRunQuery(config->dbh, setName)) { 1311 if (!psDBRollback(config->dbh)) { 1312 psError(PS_ERR_UNKNOWN, false, "database error"); 1313 } 1314 psError(PS_ERR_UNKNOWN, false, "database error"); 1315 1316 return false; 1317 } 1318 } 1315 psString setName = NULL; 1316 psStringAppend (&setName, "UPDATE addRun set minidvodb_name = '%s' where add_id = %" PRId64, minidvodb_name, row->add_id); 1317 if (!p_psDBRunQuery(config->dbh, setName)) { 1318 if (!psDBRollback(config->dbh)) { 1319 psError(PS_ERR_UNKNOWN, false, "database error"); 1320 } 1321 psError(PS_ERR_UNKNOWN, false, "database error"); 1322 1323 return false; 1324 } 1325 } 1326 1327 //if there is a minidvodb_host, set it in addRun (it's not known until it is processed) 1328 if (minidvodb_host) { 1329 psString setName = NULL; 1330 psStringAppend (&setName, "UPDATE addRun set minidvodb_host = '%s' where add_id = %" PRId64, minidvodb_host, row->add_id); 1331 if (!p_psDBRunQuery(config->dbh, setName)) { 1332 if (!psDBRollback(config->dbh)) { 1333 psError(PS_ERR_UNKNOWN, false, "database error"); 1334 } 1335 psError(PS_ERR_UNKNOWN, false, "database error"); 1336 1337 return false; 1338 } 1339 } 1340 1319 1341 //if there is a stage_extra1, set it in addRun (it's not known until it is processed) 1320 1342 if (stage_extra1) { 1321 psString setExtra = NULL; 1322 psStringAppend (&setExtra, "UPDATE addRun set stage_extra1 = %" PRId64, stage_extra1); 1323 psStringAppend (&setExtra, " where add_id = %" PRId64, row->add_id); 1324 1325 if (!p_psDBRunQuery(config->dbh, setExtra)) { 1326 if (!psDBRollback(config->dbh)) { 1327 psError(PS_ERR_UNKNOWN, false, "database error"); 1328 } 1329 psError(PS_ERR_UNKNOWN, false, "database error"); 1330 1331 return false; 1332 } 1333 } 1334 1335 1336 1343 psString setExtra = NULL; 1344 psStringAppend (&setExtra, "UPDATE addRun set stage_extra1 = %" PRId64, stage_extra1); 1345 psStringAppend (&setExtra, " where add_id = %" PRId64, row->add_id); 1346 1347 if (!p_psDBRunQuery(config->dbh, setExtra)) { 1348 if (!psDBRollback(config->dbh)) { 1349 psError(PS_ERR_UNKNOWN, false, "database error"); 1350 } 1351 psError(PS_ERR_UNKNOWN, false, "database error"); 1352 1353 return false; 1354 } 1355 } 1337 1356 1338 1357 // since there is only one exp per 'new' set addRun.state = 'full' … … 1340 1359 1341 1360 if (!fault) { 1342 if (!pxaddRunSetState(config, row->add_id, "full")) {1343 psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id);1344 psFree(row);1345 psFree(pendingRow);1346 return false;1347 }1361 if (!pxaddRunSetState(config, row->add_id, "full")) { 1362 psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id); 1363 psFree(row); 1364 psFree(pendingRow); 1365 return false; 1366 } 1348 1367 } 1349 1368 psFree(row); … … 1506 1525 psString query = NULL; 1507 1526 if (strcmp(stage, "cam") == 0) { 1508 query = pxDataGet("addtool_revertprocessedexp_cam.sql");1527 query = pxDataGet("addtool_revertprocessedexp_cam.sql"); 1509 1528 } 1510 1529 else if (strcmp(stage, "stack") == 0) { 1511 query = pxDataGet("addtool_revertprocessedexp_stack.sql");1530 query = pxDataGet("addtool_revertprocessedexp_stack.sql"); 1512 1531 } 1513 1532 else if (strcmp(stage, "staticsky") == 0) { 1514 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");1533 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql"); 1515 1534 } 1516 1535 else if (strcmp(stage, "skycal") == 0) { 1517 query = pxDataGet("addtool_revertprocessedexp_skycal.sql");1536 query = pxDataGet("addtool_revertprocessedexp_skycal.sql"); 1518 1537 } 1519 1538 else if (strcmp(stage, "diff") == 0) { 1520 query = pxDataGet("addtool_revertprocessedexp_diff.sql");1539 query = pxDataGet("addtool_revertprocessedexp_diff.sql"); 1521 1540 } 1522 1541 else if (strcmp(stage, "fullforce") == 0) { 1523 query = pxDataGet("addtool_revertprocessedexp_ff.sql");1542 query = pxDataGet("addtool_revertprocessedexp_ff.sql"); 1524 1543 } 1525 1544 else if (strcmp(stage, "fullforce_summary") == 0) { 1526 query = pxDataGet("addtool_revertprocessedexp_ffsummary.sql");1545 query = pxDataGet("addtool_revertprocessedexp_ffsummary.sql"); 1527 1546 } 1528 1547 1529 1548 if (!query) { 1530 // rollback1531 if (!psDBRollback(config->dbh)) {1532 psError(PS_ERR_UNKNOWN, false, "database error");1533 }1534 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");1535 psFree(where);1536 return false;1549 // rollback 1550 if (!psDBRollback(config->dbh)) { 1551 psError(PS_ERR_UNKNOWN, false, "database error"); 1552 } 1553 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1554 psFree(where); 1555 return false; 1537 1556 } 1538 1557 1539 1558 // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE 1540 1559 if (where && psListLength(where->list)) { 1541 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);1542 psStringAppend(&query, " AND %s", whereClause);1543 psFree(whereClause);1560 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1561 psStringAppend(&query, " AND %s", whereClause); 1562 psFree(whereClause); 1544 1563 } 1545 1564 1546 1565 if (!p_psDBRunQuery(config->dbh, query)) { 1547 // rollback1548 if (!psDBRollback(config->dbh)) {1549 psError(PS_ERR_UNKNOWN, false, "database error");1550 }1551 psError(PS_ERR_UNKNOWN, false, "database error");1552 psFree(query);1553 psFree(where);1554 return false;1566 // rollback 1567 if (!psDBRollback(config->dbh)) { 1568 psError(PS_ERR_UNKNOWN, false, "database error"); 1569 } 1570 psError(PS_ERR_UNKNOWN, false, "database error"); 1571 psFree(query); 1572 psFree(where); 1573 return false; 1555 1574 } 1556 1575 psFree(query); … … 1663 1682 // required 1664 1683 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", true, false); 1665 1684 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", true, false); 1685 PXOPT_LOOKUP_STR(minidvodb_host, config->args, "-set_minidvodb_host", true, false); 1666 1686 //optional 1667 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name",false, false);1668 PXOPT_LOOKUP_STR( minidvodb_path, config->args, "-set_minidvodb_path",false, false);1669 PXOPT_LOOKUP_STR( state, config->args, "-set_state",false, false);1687 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 1688 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1689 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 1670 1690 1671 1672 1691 if (!psDBTransaction(config->dbh)) { 1673 1692 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1675 1694 } 1676 1695 1677 psString minidvodbpath = "NULL";1696 // psString minidvodbpath = "NULL"; 1678 1697 1679 1698 // I don't know how to get around the complaints of minidvodb_path can't be null. this 'fixes' it, but someone smarter can fix it properly. 1680 if (minidvodb_path) {1681 minidvodbpath = minidvodb_path;1682 } else {1683 psError(PS_ERR_UNKNOWN, false, "require minidvodb_path");1684 return false;1685 }1699 // if (minidvodb_path) { 1700 // minidvodbpath = minidvodb_path; 1701 // } else { 1702 // psError(PS_ERR_UNKNOWN, false, "require minidvodb_path"); 1703 // return false; 1704 // } 1686 1705 1687 1706 if (!minidvodbRunInsert(config->dbh, 1688 0, // job_id 1689 minidvodb_name, 1690 minidvodb_group, 1691 minidvodbpath, 1692 "new", 1693 0 1694 )) { 1707 0, // job_id 1708 minidvodb_name, 1709 minidvodb_group, 1710 minidvodb_path, 1711 minidvodb_host, 1712 "new", 1713 note, 1714 0 1715 )) { 1695 1716 psError(PS_ERR_UNKNOWN, false, "database error"); 1696 1717 return false; … … 1746 1767 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 1747 1768 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false); 1769 PXOPT_LOOKUP_STR(minidvodb_host, config->args, "-set_minidvodb_host", false, false); 1748 1770 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1749 1771 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false); … … 1766 1788 if (minidvodb_path) { 1767 1789 if (cnt) { 1768 psStringAppend(&query, "%s", comma);1790 psStringAppend(&query, "%s", comma); 1769 1791 } 1770 1792 1771 1793 psStringAppend(&query, " minidvodb_path = '%s'", minidvodb_path); 1794 cnt++; 1795 } 1796 1797 if (minidvodb_host) { 1798 if (cnt) { 1799 psStringAppend(&query, "%s", comma); 1800 } 1801 1802 psStringAppend(&query, " minidvodb_host = '%s'", minidvodb_host); 1772 1803 cnt++; 1773 1804 } … … 2115 2146 psFree(output); 2116 2147 minidvodbProcessedRow *row = minidvodbProcessedRowAlloc( 2117 pendingRow->minidvodb_id,2118 dtime_resort,2119 dtime_relphot,2120 dtime_script,2121 epoch,2122 fault2123 );2148 pendingRow->minidvodb_id, 2149 dtime_resort, 2150 dtime_relphot, 2151 dtime_script, 2152 epoch, 2153 fault 2154 ); 2124 2155 2125 2156 if (!minidvodbProcessedInsertObject(config->dbh, row)) {
Note:
See TracChangeset
for help on using the changeset viewer.
