| 1293 | |
| 1294 | |
| 1295 | void OMSFileStore::storeFeatures_(const FeatureMap& features) |
| 1296 | { |
| 1297 | if (features.empty()) return; |
| 1298 | |
| 1299 | // create table(s) for BaseFeature parent class: |
| 1300 | // any meta infos on features? |
| 1301 | bool any_metainfo = anyFeaturePredicate_(features, [](const Feature& feature) { |
| 1302 | return !feature.isMetaEmpty(); |
| 1303 | }); |
| 1304 | // any ID observations on features? |
| 1305 | bool any_idmatches = anyFeaturePredicate_(features, [](const Feature& feature) { |
| 1306 | return !feature.getIDMatches().empty(); |
| 1307 | }); |
| 1308 | createTableBaseFeature_(any_metainfo, any_idmatches); |
| 1309 | |
| 1310 | createTable_("FEAT_Feature", |
| 1311 | "feature_id INTEGER NOT NULL, " \ |
| 1312 | "rt_quality REAL, " \ |
| 1313 | "mz_quality REAL, " \ |
| 1314 | "FOREIGN KEY (feature_id) REFERENCES FEAT_BaseFeature (id)"); |
| 1315 | auto query = make_unique<SQLite::Statement>(*db_, |
| 1316 | "INSERT INTO FEAT_Feature VALUES (" \ |
| 1317 | ":feature_id, " \ |
| 1318 | ":rt_quality, " \ |
| 1319 | ":mz_quality)"); |
| 1320 | prepared_queries_.emplace("FEAT_Feature", std::move(query)); |
| 1321 | |
| 1322 | // any convex hulls on features? |
| 1323 | if (anyFeaturePredicate_(features, [](const Feature& feature) { |
| 1324 | return !feature.getConvexHulls().empty(); |
| 1325 | })) |
| 1326 | { |
| 1327 | createTable_("FEAT_ConvexHull", |
| 1328 | "feature_id INTEGER NOT NULL, " \ |
| 1329 | "hull_index INTEGER NOT NULL CHECK (hull_index >= 0), " \ |
| 1330 | "point_index INTEGER NOT NULL CHECK (point_index >= 0), " \ |
| 1331 | "point_x REAL, " \ |
| 1332 | "point_y REAL, " \ |
| 1333 | "FOREIGN KEY (feature_id) REFERENCES FEAT_BaseFeature (id)"); |
| 1334 | auto query2 = make_unique<SQLite::Statement>(*db_, "INSERT INTO FEAT_ConvexHull VALUES (" \ |
| 1335 | ":feature_id, " \ |
| 1336 | ":hull_index, " \ |
| 1337 | ":point_index, " \ |
| 1338 | ":point_x, " \ |
| 1339 | ":point_y)"); |
| 1340 | prepared_queries_.emplace("FEAT_ConvexHull", std::move(query2)); |
| 1341 | } |
| 1342 | |
| 1343 | // features and their subordinates are stored in DFS-like order: |
| 1344 | int feature_id = 0; |
| 1345 | for (const Feature& feat : features) |
| 1346 | { |
| 1347 | storeFeatureAndSubordinates_(feat, feature_id, -1); |
| 1348 | nextProgress(); |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 |
nothing calls this directly
no test coverage detected