use of com.tvd12.dahlia.core.factory.CollectionFactory in project dahlia by youngmonkeys.
the class DahliaCoreLoader method doLoad.
protected DahliaCore doLoad() {
Map<String, DatabaseStorage> databaseStoreages = newDatabaseStorages();
Set<String> databaseNames = databaseStoreages.keySet();
Map<String, List<CollectionStorage>> collectionStoragesMap = newDatabaseColectionsStorages(databaseNames);
Map<String, DatabaseSetting> databaseSettings = readDatabaseSettings(databaseStoreages);
Map<String, List<CollectionSetting>> collectionSettingsMap = readCollectionSettings(collectionStoragesMap);
Storage storage = newStorage(databaseStoreages, collectionStoragesMap, databaseSettings, collectionSettingsMap);
RuntimeSetting runtimeSetting = storage.readRuntimeSetting();
DatabaseFactory databaseFactory = new DatabaseFactory(runtimeSetting.getMaxDatabaseId());
CollectionFactory collectionFactory = new CollectionFactory(runtimeSetting.getMaxCollectionId());
Databases databases = newDatabases(databaseFactory, collectionFactory, databaseSettings, collectionSettingsMap);
loadAllCollections(databases, storage);
DahliaCore dahlia = DahliaCore.builder().storage(storage).databases(databases).runtimeSetting(runtimeSetting).databaseFactory(databaseFactory).collectionFactory(collectionFactory).databaseStorageFactory(databaseStorageFactory).collectionStorageFactory(collectionStorageFactory).build();
return dahlia;
}
use of com.tvd12.dahlia.core.factory.CollectionFactory in project dahlia by youngmonkeys.
the class DahliaCoreLoader method newDatabases.
protected Databases newDatabases(DatabaseFactory databaseFactory, CollectionFactory collectionFactory, Map<String, DatabaseSetting> databaseSettings, Map<String, List<CollectionSetting>> collectionSettingsMap) {
Databases databases = new Databases();
for (String databaseName : databaseSettings.keySet()) {
DatabaseSetting databaseSetting = databaseSettings.get(databaseName);
Database database = databaseFactory.createDatabase(databaseSetting);
List<CollectionSetting> collectionSettings = collectionSettingsMap.get(databaseName);
for (CollectionSetting collectionSetting : collectionSettings) {
Collection collection = collectionFactory.createCollection(collectionSetting);
database.addCollection(collection);
databases.addCollection(collection);
}
databases.addDatabase(database);
}
return databases;
}
Aggregations