- Timestamp:
- May 24, 2013, 1:37:30 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130509
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/laptool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130509
- Property svn:mergeinfo changed
/trunk (added) merged: 35566-35570,35572-35574,35576-35581,35583-35586,35590
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130509/ippTools/src
- Property svn:mergeinfo changed
/trunk/ippTools/src (added) merged: 35566-35568,35572-35573
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130509/ippTools/src/laptool.c
r35308 r35594 22 22 // Run level 23 23 static bool definerunMode(pxConfig *config); 24 static bool definerunbyreleaseMode(pxConfig *config); 24 25 static bool pendingrunMode(pxConfig *config); 25 26 static bool updaterunMode(pxConfig *config); 27 26 28 // Exposure level 27 29 static bool pendingexpMode(pxConfig *config); … … 64 66 65 67 MODECASE(LAPTOOL_MODE_DEFINERUN, definerunMode); 68 MODECASE(LAPTOOL_MODE_DEFINERUNBYRELEASE, definerunbyreleaseMode); 66 69 MODECASE(LAPTOOL_MODE_PENDINGRUN, pendingrunMode); 67 70 MODECASE(LAPTOOL_MODE_UPDATERUN, updaterunMode); … … 401 404 } 402 405 406 static bool definerunbyreleaseMode(pxConfig *config) 407 { 408 PS_ASSERT_PTR_NON_NULL(config, false); 409 410 PXOPT_LOOKUP_S64(seq_id, config->args, "-seq_id", true, false); 411 PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false); 412 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 413 PXOPT_LOOKUP_STR(filter, config->args, "-filter", true, false); 414 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 415 PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", false, false); 416 PXOPT_LOOKUP_S64(rel_id, config->args, "-rel_id", false, false); 417 PXOPT_LOOKUP_STR(rel_name, config->args, "-release_name", false, false); 418 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 419 420 // Validate config 421 if ((!rel_name)&&(!rel_id)) { 422 // Die here. 423 } 424 425 lapRunRow *run = lapRunRowAlloc(0, // lap_id 426 seq_id, 427 tess_id, 428 projection_cell, 429 filter, 430 "registered", // state 431 label, 432 dist_group, 433 NULL, // registered 434 0, // fault 435 INT64_MAX, // quick_sass_id 436 INT64_MAX // final_sass_id 437 ); 438 if (!run) { 439 psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object"); 440 return(true); 441 } 442 443 if (!psDBTransaction(config->dbh)) { 444 psError(PS_ERR_UNKNOWN, false, "database error"); 445 return(false); 446 } 447 448 if (!lapRunInsertObject(config->dbh, run)) { 449 if (!psDBRollback(config->dbh)) { 450 psError(PS_ERR_UNKNOWN, false, "database error"); 451 } 452 psError(PS_ERR_UNKNOWN, false, "database error"); 453 psFree(run); 454 return(false); 455 } 456 457 if (!lapRunPrintObject(stdout, run, !simple)) { 458 if (!psDBRollback(config->dbh)) { 459 psError(PS_ERR_UNKNOWN, false, "database error"); 460 } 461 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 462 psFree(run); 463 return(false); 464 } 465 466 psS64 lap_id = psDBLastInsertID(config->dbh); 467 468 psString query = pxDataGet("laptool_definerunbyrelease.sql"); 469 if (!query) { 470 if (!psDBRollback(config->dbh)) { 471 psError(PS_ERR_UNKNOWN, false, "database error"); 472 } 473 psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement"); 474 return(false); 475 } 476 477 // Add constraints 478 psMetadata *relWhere = psMetadataAlloc(); 479 PXOPT_COPY_STR(config->args, relWhere, "-filter", "rawExp.filter", "=="); 480 PXOPT_COPY_STR(config->args, relWhere, "-release_name", "ippRelease.release_name", "=="); 481 PXOPT_COPY_S64(config->args, relWhere, "-rel_id", "ippRelease.rel_id", "=="); 482 PXOPT_COPY_TIME(config->args, relWhere, "-dateobs_begin", "rawExp.dateobs", ">="); 483 PXOPT_COPY_TIME(config->args, relWhere, "-dateobs_end", "rawExp.dateobs", "<="); 484 PXOPT_COPY_RADEC(config->args, relWhere, "-ra_min", "rawExp.ra", ">="); 485 PXOPT_COPY_RADEC(config->args, relWhere, "-ra_max", "rawExp.ra", "<"); 486 PXOPT_COPY_RADEC(config->args, relWhere, "-decl_min", "rawExp.decl", ">="); 487 PXOPT_COPY_RADEC(config->args, relWhere, "-decl_max", "rawExp.decl", "<"); 488 489 psMetadata *lapWhere = psMetadataAlloc(); 490 PXOPT_COPY_S64(config->args, lapWhere, "-seq_id", "lapRun.seq_id", "=="); 491 PXOPT_COPY_STR(config->args, lapWhere, "-filter", "lapRun.filter", "=="); 492 493 psString relWhereClause = psDBGenerateWhereConditionSQL(relWhere,NULL); 494 psString lapWhereClause = psDBGenerateWhereConditionSQL(lapWhere,NULL); 495 496 if (relWhereClause) { 497 psStringSubstitute(&query,relWhereClause,"@RELWHERE@"); 498 } 499 if (lapWhereClause) { 500 psStringSubstitute(&query,lapWhereClause,"@LAPWHERE@"); 501 } 502 psFree(relWhere); 503 psFree(lapWhere); 504 505 // Fetch exposures 506 if (!p_psDBRunQuery(config->dbh, query)) { 507 if (!psDBRollback(config->dbh)) { 508 psError(PS_ERR_UNKNOWN, false, "database error"); 509 } 510 511 psError(PS_ERR_UNKNOWN, false, "database error"); 512 psFree(query); 513 return(false); 514 } 515 psFree(query); 516 517 psArray *output = p_psDBFetchResult(config->dbh); 518 if (!output) { 519 if (!psDBRollback(config->dbh)) { 520 psError(PS_ERR_UNKNOWN, false, "database error"); 521 } 522 523 psError(PS_ERR_UNKNOWN, false, "database error"); 524 return(false); 525 } 526 if (!psArrayLength(output)) { 527 if (!psDBRollback(config->dbh)) { 528 psError(PS_ERR_UNKNOWN, false, "database error"); 529 } 530 531 psTrace("laptool", PS_LOG_INFO, "no rows found"); 532 psFree(output); 533 return(true); 534 } 535 536 // Insert the exposure data 537 for (long i = 0; i < output->n; i++) { 538 psMetadata *row = output->data[i]; // Row from select 539 // Add default values from this run: 540 psMetadataAddS64(row, PS_LIST_TAIL, "lap_id", 0, "", lap_id); 541 psMetadataAddS64(row, PS_LIST_TAIL, "pair_id", 0, "", INT64_MAX); 542 psMetadataAddStr(row, PS_LIST_TAIL, "data_state", 0, "", "new"); 543 lapExpRow *lapExp = lapExpObjectFromMetadata(row); 544 lapExp->lap_id = lap_id; 545 546 if (!lapExpInsertObject(config->dbh,lapExp)) { 547 if (!lapExpPrintObject(stdout, lapExp, !simple)) { 548 if (!psDBRollback(config->dbh)) { 549 psError(PS_ERR_UNKNOWN, false, "database error"); 550 } 551 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 552 psFree(run); 553 return false; 554 } 555 556 if (!psDBRollback(config->dbh)) { 557 psError(PS_ERR_UNKNOWN, false, "database error"); 558 } 559 psError(PS_ERR_UNKNOWN, false, "database error"); 560 psFree(output); 561 psFree(lapExp); 562 return(false); 563 } 564 } 565 566 // point of no return 567 if (!psDBCommit(config->dbh)) { 568 psError(PS_ERR_UNKNOWN, false, "database error"); 569 return false; 570 } 571 572 573 psFree(output); 574 return(true); 575 } 576 577 578 579 580 403 581 static bool pendingrunMode(pxConfig *config) 404 582 {
Note:
See TracChangeset
for help on using the changeset viewer.
