use of org.bimserver.models.store.PluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getPluginSettings.
public SObjectType getPluginSettings(Long poid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
PluginConfiguration pluginConfiguration = session.get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
ObjectType settings = pluginConfiguration.getSettings();
return getBimServer().getSConverter().convertToSObject(settings);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.PluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method setPluginSettings.
@Override
public void setPluginSettings(Long poid, SObjectType settings) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ObjectType convertedSettings = getBimServer().getSConverter().convertFromSObject(settings, session);
SetPluginSettingsDatabaseAction action = new SetPluginSettingsDatabaseAction(session, getInternalAccessMethod(), poid, convertedSettings);
session.executeAndCommitAction(action);
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
session = getBimServer().getDatabase().createSession();
try {
PluginConfiguration pluginConfiguration = session.get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
if (pluginConfiguration instanceof InternalServicePluginConfiguration) {
ServicePlugin servicePlugin = getBimServer().getPluginManager().getServicePlugin(pluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
SInternalServicePluginConfiguration sInternalService = (SInternalServicePluginConfiguration) getBimServer().getSConverter().convertToSObject(pluginConfiguration);
servicePlugin.unregister(sInternalService);
servicePlugin.register(getAuthorization().getUoid(), sInternalService, new org.bimserver.plugins.PluginConfiguration(settings));
}
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.PluginConfiguration in project BIMserver by opensourceBIM.
the class CheckoutDatabaseAction method realCheckout.
private IfcModel realCheckout(Project project, Revision revision, DatabaseSession databaseSession, User user) throws BimserverLockConflictException, BimserverDatabaseException, UserException {
PluginConfiguration serializerPluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getPluginConfiguration(), serializerOid, OldQuery.getDefault());
final long totalSize = revision.getSize();
final AtomicLong total = new AtomicLong();
IfcModelSet ifcModelSet = new IfcModelSet();
PackageMetaData lastPackageMetaData = null;
for (ConcreteRevision subRevision : revision.getConcreteRevisions()) {
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(subRevision.getProject().getSchema());
lastPackageMetaData = packageMetaData;
IfcModel subModel = new BasicIfcModel(packageMetaData, null);
int highestStopId = findHighestStopRid(project, subRevision);
OldQuery query = new OldQuery(packageMetaData, subRevision.getProject().getId(), subRevision.getId(), revision.getOid(), null, Deep.YES, highestStopId);
subModel.addChangeListener(new IfcModelChangeListener() {
@Override
public void objectAdded(IdEObject idEObject) {
total.incrementAndGet();
if (totalSize == 0) {
setProgress("Preparing checkout...", 0);
} else {
setProgress("Preparing checkout...", (int) Math.round(100.0 * total.get() / totalSize));
}
}
});
getDatabaseSession().getMap(subModel, query);
try {
checkGeometry(serializerPluginConfiguration, getBimServer().getPluginManager(), subModel, project, subRevision, revision);
} catch (GeometryGeneratingException e) {
throw new UserException(e);
}
subModel.getModelMetaData().setDate(subRevision.getDate());
ifcModelSet.add(subModel);
}
IfcModelInterface ifcModel = new BasicIfcModel(lastPackageMetaData, null);
if (ifcModelSet.size() > 1) {
try {
ifcModel = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid()).merge(revision.getProject(), ifcModelSet, new ModelHelper(getBimServer().getMetaDataManager(), ifcModel));
} catch (MergeException e) {
throw new UserException(e);
}
} else {
ifcModel = ifcModelSet.iterator().next();
}
ifcModel.getModelMetaData().setName(project.getName() + "." + revision.getId());
ifcModel.getModelMetaData().setRevisionId(project.getRevisions().indexOf(revision) + 1);
ifcModel.getModelMetaData().setAuthorizedUser(user.getName());
ifcModel.getModelMetaData().setDate(new Date());
return (IfcModel) ifcModel;
}
use of org.bimserver.models.store.PluginConfiguration in project BIMserver by opensourceBIM.
the class DeletePluginConfigurationDatabaseAction method execute.
@SuppressWarnings("rawtypes")
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
PluginConfiguration pluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getPluginConfiguration(), oid, OldQuery.getDefault());
UserSettings settings = (UserSettings) pluginConfiguration.eGet(pluginConfiguration.eClass().getEStructuralFeature("userSettings"));
if (settings == null) {
throw new UserException("No user settings found...");
}
for (EReference eReference : settings.eClass().getEAllReferences()) {
if (eReference.getEType() == pluginConfiguration.eClass() && eReference.isMany()) {
List list = (List) settings.eGet(eReference);
list.remove(pluginConfiguration);
}
}
getDatabaseSession().store(settings);
pluginConfiguration.remove();
return null;
}
use of org.bimserver.models.store.PluginConfiguration in project BIMserver by opensourceBIM.
the class SetPluginSettingsDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
PluginConfiguration pluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
pluginConfiguration.setSettings(convertedSettings);
getDatabaseSession().store(convertedSettings, true);
getDatabaseSession().store(pluginConfiguration);
return null;
}
Aggregations