Search in sources :

Example 1 with CollectionFactory

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;
}
Also used : CollectionFactory(com.tvd12.dahlia.core.factory.CollectionFactory) RuntimeSetting(com.tvd12.dahlia.core.setting.RuntimeSetting) Storage(com.tvd12.dahlia.core.storage.Storage) DatabaseStorage(com.tvd12.dahlia.core.storage.DatabaseStorage) CollectionStorage(com.tvd12.dahlia.core.storage.CollectionStorage) Databases(com.tvd12.dahlia.core.entity.Databases) DatabaseFactory(com.tvd12.dahlia.core.factory.DatabaseFactory) DatabaseSetting(com.tvd12.dahlia.core.setting.DatabaseSetting) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseStorage(com.tvd12.dahlia.core.storage.DatabaseStorage)

Example 2 with CollectionFactory

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;
}
Also used : CollectionSetting(com.tvd12.dahlia.core.setting.CollectionSetting) Databases(com.tvd12.dahlia.core.entity.Databases) Database(com.tvd12.dahlia.core.entity.Database) DatabaseSetting(com.tvd12.dahlia.core.setting.DatabaseSetting) Collection(com.tvd12.dahlia.core.entity.Collection)

Aggregations

Databases (com.tvd12.dahlia.core.entity.Databases)2 DatabaseSetting (com.tvd12.dahlia.core.setting.DatabaseSetting)2 Collection (com.tvd12.dahlia.core.entity.Collection)1 Database (com.tvd12.dahlia.core.entity.Database)1 CollectionFactory (com.tvd12.dahlia.core.factory.CollectionFactory)1 DatabaseFactory (com.tvd12.dahlia.core.factory.DatabaseFactory)1 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)1 RuntimeSetting (com.tvd12.dahlia.core.setting.RuntimeSetting)1 CollectionStorage (com.tvd12.dahlia.core.storage.CollectionStorage)1 DatabaseStorage (com.tvd12.dahlia.core.storage.DatabaseStorage)1 Storage (com.tvd12.dahlia.core.storage.Storage)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1