| 515 | |
| 516 | |
| 517 | void OMSFileStore::storeProcessingSteps_(const IdentificationData& id_data) |
| 518 | { |
| 519 | if (id_data.getProcessingSteps().empty()) return; |
| 520 | |
| 521 | createTable_( |
| 522 | "ID_ProcessingStep", |
| 523 | "id INTEGER PRIMARY KEY NOT NULL, " \ |
| 524 | "software_id INTEGER NOT NULL, " \ |
| 525 | "date_time TEXT, " \ |
| 526 | "search_param_id INTEGER, " \ |
| 527 | "FOREIGN KEY (search_param_id) REFERENCES ID_DBSearchParam (id)"); |
| 528 | // @TODO: add support for processing actions |
| 529 | // @TODO: store primary files in a separate table (like input files)? |
| 530 | // @TODO: store (optional) search param reference in a separate table? |
| 531 | |
| 532 | SQLite::Statement query(*db_, "INSERT INTO ID_ProcessingStep VALUES (" \ |
| 533 | ":id, " \ |
| 534 | ":software_id, " \ |
| 535 | ":date_time, " \ |
| 536 | ":search_param_id)"); |
| 537 | bool any_input_files = false; |
| 538 | Key id = 1; |
| 539 | // use iterator here because we need one to look up the DB search params: |
| 540 | for (ID::ProcessingStepRef step_ref = id_data.getProcessingSteps().begin(); |
| 541 | step_ref != id_data.getProcessingSteps().end(); ++step_ref) |
| 542 | { |
| 543 | const ID::ProcessingStep& step = *step_ref; |
| 544 | if (!step.input_file_refs.empty()) any_input_files = true; |
| 545 | query.bind(":id", id); |
| 546 | query.bind(":software_id", processing_software_keys_[&(*step.software_ref)]); |
| 547 | query.bind(":date_time", step.date_time.get()); |
| 548 | auto pos = id_data.getDBSearchSteps().find(step_ref); |
| 549 | if (pos != id_data.getDBSearchSteps().end()) |
| 550 | { |
| 551 | query.bind(":search_param_id", search_param_keys_[&(*pos->second)]); |
| 552 | } |
| 553 | else |
| 554 | { |
| 555 | query.bind(":search_param_id"); // NULL |
| 556 | } |
| 557 | execWithExceptionAndReset(query, 1, __LINE__, OPENMS_PRETTY_FUNCTION, "error inserting data"); |
| 558 | processing_step_keys_[&step] = id; |
| 559 | ++id; |
| 560 | } |
| 561 | if (any_input_files) |
| 562 | { |
| 563 | createTable_( |
| 564 | "ID_ProcessingStep_InputFile", |
| 565 | "processing_step_id INTEGER NOT NULL, " \ |
| 566 | "input_file_id INTEGER NOT NULL, " \ |
| 567 | "FOREIGN KEY (processing_step_id) REFERENCES ID_ProcessingStep (id), " \ |
| 568 | "FOREIGN KEY (input_file_id) REFERENCES ID_InputFile (id), " \ |
| 569 | "UNIQUE (processing_step_id, input_file_id)"); |
| 570 | |
| 571 | SQLite::Statement query2(*db_, "INSERT INTO ID_ProcessingStep_InputFile VALUES (" \ |
| 572 | ":processing_step_id, " \ |
| 573 | ":input_file_id)"); |
| 574 | |