Search in sources :

Example 1 with ModelMergerPlugin

use of org.bimserver.plugins.modelmerger.ModelMergerPlugin in project BIMserver by opensourceBIM.

the class MergerFactory method createMerger.

public org.bimserver.plugins.modelmerger.ModelMerger createMerger(DatabaseSession databaseSession, Long currentUoid) throws MergeException, BimserverDatabaseException {
    DatabaseSession session = bimServer.getDatabase().createSession();
    try {
        User user = databaseSession.get(StorePackage.eINSTANCE.getUser(), currentUoid, OldQuery.getDefault());
        UserSettings userSettings = user.getUserSettings();
        ModelMergerPluginConfiguration modelMergerObject = userSettings.getDefaultModelMerger();
        if (modelMergerObject != null) {
            ModelMergerPlugin modelMergerPlugin = bimServer.getPluginManager().getModelMergerPlugin(modelMergerObject.getPluginDescriptor().getPluginClassName(), true);
            if (modelMergerPlugin != null) {
                org.bimserver.plugins.modelmerger.ModelMerger modelMerger = modelMergerPlugin.createModelMerger(new PluginConfiguration(modelMergerObject.getSettings()));
                return modelMerger;
            } else {
                throw new MergeException("No Model Merger found " + modelMergerObject.getPluginDescriptor().getPluginClassName());
            }
        } else {
            throw new MergeException("No configured Model Merger found");
        }
    } finally {
        session.close();
    }
}
Also used : ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) ModelMergerPlugin(org.bimserver.plugins.modelmerger.ModelMergerPlugin) MergeException(org.bimserver.plugins.modelmerger.MergeException) UserSettings(org.bimserver.models.store.UserSettings) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration)

Aggregations

DatabaseSession (org.bimserver.database.DatabaseSession)1 ModelMergerPluginConfiguration (org.bimserver.models.store.ModelMergerPluginConfiguration)1 User (org.bimserver.models.store.User)1 UserSettings (org.bimserver.models.store.UserSettings)1 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)1 MergeException (org.bimserver.plugins.modelmerger.MergeException)1 ModelMergerPlugin (org.bimserver.plugins.modelmerger.ModelMergerPlugin)1