Search in sources :

Example 1 with ModelMergerPluginConfiguration

use of org.bimserver.models.store.ModelMergerPluginConfiguration 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)

Example 2 with ModelMergerPluginConfiguration

use of org.bimserver.models.store.ModelMergerPluginConfiguration in project BIMserver by opensourceBIM.

the class DeleteModelMergerDatabaseAction method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    ModelMergerPluginConfiguration object = getDatabaseSession().get(geteClass(), getOid(), OldQuery.getDefault());
    UserSettings settings = object.getUserSettings();
    settings.getModelMergers().remove(object);
    getDatabaseSession().store(settings);
    return super.execute();
}
Also used : ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) UserSettings(org.bimserver.models.store.UserSettings)

Example 3 with ModelMergerPluginConfiguration

use of org.bimserver.models.store.ModelMergerPluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method addModelMerger.

@Override
public Long addModelMerger(SModelMergerPluginConfiguration modelMerger) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ModelMergerPluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(modelMerger, session);
        return session.executeAndCommitAction(new AddModelMergerDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) SModelMergerPluginConfiguration(org.bimserver.interfaces.objects.SModelMergerPluginConfiguration) DatabaseSession(org.bimserver.database.DatabaseSession) AddModelMergerDatabaseAction(org.bimserver.database.actions.AddModelMergerDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 4 with ModelMergerPluginConfiguration

use of org.bimserver.models.store.ModelMergerPluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method updateModelMerger.

@Override
public void updateModelMerger(SModelMergerPluginConfiguration modelMerger) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ModelMergerPluginConfiguration convert = session.get(modelMerger.getOid(), OldQuery.getDefault());
        getBimServer().getSConverter().convertFromSObject(modelMerger, convert, session);
        session.executeAndCommitAction(new UpdateModelMergerDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) SModelMergerPluginConfiguration(org.bimserver.interfaces.objects.SModelMergerPluginConfiguration) UpdateModelMergerDatabaseAction(org.bimserver.database.actions.UpdateModelMergerDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 5 with ModelMergerPluginConfiguration

use of org.bimserver.models.store.ModelMergerPluginConfiguration in project BIMserver by opensourceBIM.

the class GetAllModelMergersDatabaseAction method execute.

@Override
public List<ModelMergerPluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getModelMergerPluginConfiguration());
    Map<Long, ModelMergerPluginConfiguration> result = getDatabaseSession().query(condition, ModelMergerPluginConfiguration.class, OldQuery.getDefault());
    List<ModelMergerPluginConfiguration> mapToList = CollectionUtils.mapToList(result);
    if (onlyEnabled) {
        Iterator<ModelMergerPluginConfiguration> iterator = mapToList.iterator();
        while (iterator.hasNext()) {
            ModelMergerPluginConfiguration modelMerger = iterator.next();
            if (!bimServer.getPluginManager().isEnabled(modelMerger.getPluginDescriptor().getPluginClassName()) || !modelMerger.getEnabled()) {
                iterator.remove();
            }
        }
    }
    return mapToList;
}
Also used : IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) Condition(org.bimserver.database.query.conditions.Condition) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition)

Aggregations

ModelMergerPluginConfiguration (org.bimserver.models.store.ModelMergerPluginConfiguration)5 DatabaseSession (org.bimserver.database.DatabaseSession)3 IOException (java.io.IOException)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 SModelMergerPluginConfiguration (org.bimserver.interfaces.objects.SModelMergerPluginConfiguration)2 UserSettings (org.bimserver.models.store.UserSettings)2 ServerException (org.bimserver.shared.exceptions.ServerException)2 UserException (org.bimserver.shared.exceptions.UserException)2 AddModelMergerDatabaseAction (org.bimserver.database.actions.AddModelMergerDatabaseAction)1 UpdateModelMergerDatabaseAction (org.bimserver.database.actions.UpdateModelMergerDatabaseAction)1 Condition (org.bimserver.database.query.conditions.Condition)1 IsOfTypeCondition (org.bimserver.database.query.conditions.IsOfTypeCondition)1 User (org.bimserver.models.store.User)1 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)1 MergeException (org.bimserver.plugins.modelmerger.MergeException)1 ModelMergerPlugin (org.bimserver.plugins.modelmerger.ModelMergerPlugin)1