Changeset 35566 for trunk/ippTools/src
- Timestamp:
- May 9, 2013, 12:51:53 PM (13 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/laptool.c
r35308 r35566 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 "new", // 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 483 psMetadata *lapWhere = psMetadataAlloc(); 484 PXOPT_COPY_S64(config->args, lapWhere, "-seq_id", "lapRun.seq_id", "=="); 485 PXOPT_COPY_STR(config->args, lapWhere, "-filter", "lapRun.filter", "=="); 486 487 psString relWhereClause = psDBGenerateWhereConditionSQL(relWhere,NULL); 488 psString lapWhereClause = psDBGenerateWhereConditionSQL(lapWhere,NULL); 489 490 if (relWhereClause) { 491 psStringSubstitute(&query,relWhereClause,"@RELWHERE@"); 492 } 493 if (lapWhereClause) { 494 psStringSubstitute(&query,lapWhereClause,"@LAPWHERE@"); 495 } 496 psFree(relWhere); 497 psFree(lapWhere); 498 499 // Fetch exposures 500 if (!p_psDBRunQuery(config->dbh, query)) { 501 if (!psDBRollback(config->dbh)) { 502 psError(PS_ERR_UNKNOWN, false, "database error"); 503 } 504 505 psError(PS_ERR_UNKNOWN, false, "database error"); 506 psFree(query); 507 return(false); 508 } 509 psFree(query); 510 511 psArray *output = p_psDBFetchResult(config->dbh); 512 if (!output) { 513 if (!psDBRollback(config->dbh)) { 514 psError(PS_ERR_UNKNOWN, false, "database error"); 515 } 516 517 psError(PS_ERR_UNKNOWN, false, "database error"); 518 return(false); 519 } 520 if (!psArrayLength(output)) { 521 if (!psDBRollback(config->dbh)) { 522 psError(PS_ERR_UNKNOWN, false, "database error"); 523 } 524 525 psTrace("laptool", PS_LOG_INFO, "no rows found"); 526 psFree(output); 527 return(true); 528 } 529 530 // Insert the exposure data 531 for (long i = 0; i < output->n; i++) { 532 psMetadata *row = output->data[i]; // Row from select 533 // Add default values from this run: 534 psMetadataAddS64(row, PS_LIST_TAIL, "lap_id", 0, "", lap_id); 535 psMetadataAddS64(row, PS_LIST_TAIL, "pair_id", 0, "", INT64_MAX); 536 psMetadataAddStr(row, PS_LIST_TAIL, "data_state", 0, "", "new"); 537 lapExpRow *lapExp = lapExpObjectFromMetadata(row); 538 lapExp->lap_id = lap_id; 539 540 if (!lapExpInsertObject(config->dbh,lapExp)) { 541 if (!lapExpPrintObject(stdout, lapExp, !simple)) { 542 if (!psDBRollback(config->dbh)) { 543 psError(PS_ERR_UNKNOWN, false, "database error"); 544 } 545 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 546 psFree(run); 547 return false; 548 } 549 550 if (!psDBRollback(config->dbh)) { 551 psError(PS_ERR_UNKNOWN, false, "database error"); 552 } 553 psError(PS_ERR_UNKNOWN, false, "database error"); 554 psFree(output); 555 psFree(lapExp); 556 return(false); 557 } 558 } 559 560 // point of no return 561 if (!psDBCommit(config->dbh)) { 562 psError(PS_ERR_UNKNOWN, false, "database error"); 563 return false; 564 } 565 566 567 psFree(output); 568 return(true); 569 } 570 571 572 573 574 403 575 static bool pendingrunMode(pxConfig *config) 404 576 { -
trunk/ippTools/src/laptool.h
r35308 r35566 13 13 LAPTOOL_MODE_LISTSEQUENCE, 14 14 LAPTOOL_MODE_DEFINERUN, 15 LAPTOOL_MODE_DEFINERUNBYRELEASE, 15 16 LAPTOOL_MODE_PENDINGRUN, 16 17 LAPTOOL_MODE_UPDATERUN, -
trunk/ippTools/src/laptoolConfig.c
r35308 r35566 62 62 63 63 ADD_OPT(Bool,definerunArgs, "-simple", "use the simple output format", false); 64 65 // -definerunbyrelease 66 psMetadata *definerunbyreleaseArgs = psMetadataAlloc(); 67 ADD_OPT(S64, definerunbyreleaseArgs, "-seq_id", "define the LAP sequence for this run (required)", 0); 68 ADD_OPT(Str, definerunbyreleaseArgs, "-projection_cell", "define the projection cell for this run (required)", NULL); 69 ADD_OPT(Str, definerunbyreleaseArgs, "-tess_id", "define the tessellation used (required)", NULL); 70 ADD_OPT(Str, definerunbyreleaseArgs, "-filter", "define the filter used (required)", NULL); 71 ADD_OPT(Str, definerunbyreleaseArgs, "-label", "define the label used", NULL); 72 ADD_OPT(Str, definerunbyreleaseArgs, "-dist_group", "define the distribution group for this data", NULL); 73 ADD_OPT(S64, definerunbyreleaseArgs, "-rel_id", "define the release to copy", 0); 74 ADD_OPT(Str, definerunbyreleaseArgs, "-release_name", "define the release to copy", NULL); 75 76 ADD_OPT(Bool, definerunbyreleaseArgs, "-simple", "use the simple output format", false); 64 77 65 78 // -pendingrun … … 204 217 PXOPT_ADD_MODE("-listsequence", "", LAPTOOL_MODE_LISTSEQUENCE, listsequenceArgs); 205 218 PXOPT_ADD_MODE("-definerun", "", LAPTOOL_MODE_DEFINERUN, definerunArgs); 219 PXOPT_ADD_MODE("-definerunbyrelease", "", LAPTOOL_MODE_DEFINERUNBYRELEASE, definerunbyreleaseArgs); 206 220 PXOPT_ADD_MODE("-pendingrun", "", LAPTOOL_MODE_PENDINGRUN, pendingrunArgs); 207 221 PXOPT_ADD_MODE("-listrun", "", LAPTOOL_MODE_PENDINGRUN, listrunArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
