| 458 | |
| 459 | |
| 460 | void OMSFileLoad::loadParentGroupSets_(IdentificationData& id_data) |
| 461 | { |
| 462 | if (!db_->tableExists("ID_ParentGroupSet")) return; |
| 463 | |
| 464 | // "grouping_order" column was removed in schema version 3: |
| 465 | String order_by = version_number_ > 2 ? "id" : "grouping_order"; |
| 466 | |
| 467 | SQLite::Statement query(*db_, "SELECT * FROM ID_ParentGroupSet ORDER BY " + order_by + " ASC"); |
| 468 | // @TODO: can we combine handling of meta info and applied processing steps? |
| 469 | SQLite::Statement subquery_info(*db_, ""); |
| 470 | bool have_meta_info = prepareQueryMetaInfo_(subquery_info, |
| 471 | "ID_ParentGroupSet"); |
| 472 | SQLite::Statement subquery_step(*db_, ""); |
| 473 | bool have_applied_steps = |
| 474 | prepareQueryAppliedProcessingStep_(subquery_step, |
| 475 | "ID_ParentGroupSet"); |
| 476 | |
| 477 | SQLite::Statement subquery_group(*db_, "SELECT * FROM ID_ParentGroup WHERE grouping_id = :id"); |
| 478 | |
| 479 | SQLite::Statement subquery_parent(*db_, "SELECT parent_id FROM ID_ParentGroup_ParentSequence WHERE group_id = :id"); |
| 480 | |
| 481 | while (query.executeStep()) |
| 482 | { |
| 483 | ID::ParentGroupSet grouping(query.getColumn("label").getString()); |
| 484 | Key grouping_id = query.getColumn("id").getInt64(); |
| 485 | if (have_meta_info) |
| 486 | { |
| 487 | handleQueryMetaInfo_(subquery_info, grouping, grouping_id); |
| 488 | } |
| 489 | if (have_applied_steps) |
| 490 | { |
| 491 | handleQueryAppliedProcessingStep_(subquery_step, grouping, grouping_id); |
| 492 | } |
| 493 | |
| 494 | subquery_group.bind(":id", grouping_id); |
| 495 | // get all groups in this grouping: |
| 496 | map<Key, ID::ParentGroup> groups_map; |
| 497 | while (subquery_group.executeStep()) |
| 498 | { |
| 499 | Key group_id = subquery_group.getColumn("id").getInt64(); |
| 500 | auto score_type_id = subquery_group.getColumn("score_type_id"); |
| 501 | if (score_type_id.isNull()) // no scores |
| 502 | { |
| 503 | groups_map[group_id]; // insert empty group |
| 504 | } |
| 505 | else |
| 506 | { |
| 507 | ID::ScoreTypeRef ref = score_type_refs_[score_type_id.getInt64()]; |
| 508 | groups_map[group_id].scores[ref] = |
| 509 | subquery_group.getColumn("score").getDouble(); |
| 510 | } |
| 511 | } |
| 512 | subquery_group.reset(); // get ready for new executeStep() |
| 513 | // get parent sequences in each group: |
| 514 | for (auto& pair : groups_map) |
| 515 | { |
| 516 | subquery_parent.bind(":id", pair.first); |
| 517 | while (subquery_parent.executeStep()) |
nothing calls this directly
no test coverage detected