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();
}
}
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();
}
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();
}
}
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();
}
}
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;
}
Aggregations