| 680 | |
| 681 | |
| 682 | void OMSFileStore::storeParentGroupSets_(const IdentificationData& id_data) |
| 683 | { |
| 684 | if (id_data.getParentGroupSets().empty()) return; |
| 685 | |
| 686 | createTable_("ID_ParentGroupSet", |
| 687 | "id INTEGER PRIMARY KEY NOT NULL, " \ |
| 688 | "label TEXT UNIQUE"); |
| 689 | |
| 690 | createTable_( |
| 691 | "ID_ParentGroup", |
| 692 | "id INTEGER PRIMARY KEY NOT NULL, " \ |
| 693 | "grouping_id INTEGER NOT NULL, " \ |
| 694 | "score_type_id INTEGER, " \ |
| 695 | "score REAL, " \ |
| 696 | "UNIQUE (id, score_type_id), " \ |
| 697 | "FOREIGN KEY (grouping_id) REFERENCES ID_ParentGroupSet (id)"); |
| 698 | |
| 699 | createTable_( |
| 700 | "ID_ParentGroup_ParentSequence", |
| 701 | "group_id INTEGER NOT NULL, " \ |
| 702 | "parent_id INTEGER NOT NULL, " \ |
| 703 | "UNIQUE (group_id, parent_id), " \ |
| 704 | "FOREIGN KEY (group_id) REFERENCES ID_ParentGroup (id), " \ |
| 705 | "FOREIGN KEY (parent_id) REFERENCES ID_ParentSequence (id)"); |
| 706 | |
| 707 | SQLite::Statement query_grouping(*db_, "INSERT INTO ID_ParentGroupSet VALUES (" \ |
| 708 | ":id, " \ |
| 709 | ":label)"); |
| 710 | |
| 711 | SQLite::Statement query_group(*db_, "INSERT INTO ID_ParentGroup VALUES (" \ |
| 712 | ":id, " \ |
| 713 | ":grouping_id, " \ |
| 714 | ":score_type_id, " \ |
| 715 | ":score)"); |
| 716 | |
| 717 | SQLite::Statement query_parent(*db_, "INSERT INTO ID_ParentGroup_ParentSequence VALUES (" \ |
| 718 | ":group_id, " \ |
| 719 | ":parent_id)"); |
| 720 | |
| 721 | Key grouping_id = 1; |
| 722 | Key group_id = 1; |
| 723 | for (const ID::ParentGroupSet& grouping : id_data.getParentGroupSets()) |
| 724 | { |
| 725 | query_grouping.bind(":id", grouping_id); |
| 726 | query_grouping.bind(":label", grouping.label); |
| 727 | execWithExceptionAndReset(query_grouping, 1, __LINE__, OPENMS_PRETTY_FUNCTION, "error inserting data"); |
| 728 | |
| 729 | for (const ID::ParentGroup& group : grouping.groups) |
| 730 | { |
| 731 | query_group.bind(":id", group_id); |
| 732 | query_group.bind(":grouping_id", grouping_id); |
| 733 | if (group.scores.empty()) // store group with an empty score |
| 734 | { |
| 735 | query_group.bind(":score_type_id"); |
| 736 | query_group.bind(":score"); |
| 737 | execWithExceptionAndReset(query_group, 1, __LINE__, OPENMS_PRETTY_FUNCTION, "error inserting data"); |
| 738 | } |
| 739 | else // store group multiple times with different scores |
nothing calls this directly
no test coverage detected