use of org.bimserver.emf.IfcModelInterface in project BIMserver by opensourceBIM.
the class GetAllProjectsSmallDatabaseAction method execute.
@Override
public List<SProjectSmall> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
List<SProjectSmall> list = new ArrayList<SProjectSmall>();
User user = getUserByUoid(authorization.getUoid());
IfcModelInterface model = getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getProject(), OldQuery.getDefault());
List<Project> projects = model.getAll(Project.class);
for (Project project : projects) {
if (project.getParent() == null && !project.getName().equals(Database.STORE_PROJECT_NAME)) {
Project rootProject = getRootProject(project);
addProjects(list, rootProject, user);
}
}
return list;
}
use of org.bimserver.emf.IfcModelInterface in project BIMserver by opensourceBIM.
the class LongDownloadOrCheckoutAction method executeAction.
protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
try {
if (action == null) {
checkoutResult = new SCheckoutResult();
checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
} else {
Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
if (revision == null) {
throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
}
// Little hack to make
revision.getProject().getGeoTag().load();
// sure this is
// lazily loaded,
// because after the
// executeAndCommitAction
// the session won't
// be usable
IfcModelInterface ifcModel = session.executeAndCommitAction(action);
// Session is closed after this
DatabaseSession newSession = getBimServer().getDatabase().createSession();
RenderEnginePlugin renderEnginePlugin = null;
try {
PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
if (serializerPluginConfiguration != null) {
if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
try {
messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
} catch (SerializerException e) {
e.printStackTrace();
}
} else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
if (renderEngine != null) {
renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
}
checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
}
}
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
newSession.close();
}
}
} finally {
done();
}
}
use of org.bimserver.emf.IfcModelInterface in project BIMserver by opensourceBIM.
the class GetAllWritableProjectsDatabaseAction method execute.
@Override
public Set<Project> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(authorization.getUoid());
IfcModelInterface projectsModel = getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getProject(), OldQuery.getDefault());
Set<Project> result = new HashSet<Project>();
for (IdEObject idEObject : projectsModel.getValues()) {
if (idEObject instanceof Project) {
Project project = (Project) idEObject;
if (!project.getName().equals("INT-Store")) {
if ((user.getUserType() == UserType.ADMIN || (project.getState() == ObjectState.ACTIVE) && authorization.hasRightsOnProjectOrSuperProjects(user, project))) {
result.add(project);
}
}
}
}
return result;
}
use of org.bimserver.emf.IfcModelInterface in project BIMserver by opensourceBIM.
the class DatabaseSession method getAll.
public <T extends IdEObject> List<T> getAll(Class<T> class1) throws BimserverDatabaseException {
EClass eClass = getEClass(class1.getPackage().getName(), class1.getSimpleName());
IfcModelInterface allOfType = getAllOfType(eClass, OldQuery.getDefault());
return allOfType.getAll(class1);
}
use of org.bimserver.emf.IfcModelInterface in project BIMserver by opensourceBIM.
the class DatabaseSession method get.
@SuppressWarnings("unchecked")
public <T extends IdEObject> T get(long oid, QueryInterface query) throws BimserverDatabaseException {
checkOpen();
TodoList todoList = new TodoList();
IfcModelInterface model = createModel(query);
IdEObject idEObject = get(null, oid, model, query, todoList);
processTodoList(model, todoList, query);
return (T) idEObject;
}
Aggregations