Search in sources :

Example 26 with IfcModelInterface

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;
}
Also used : Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ArrayList(java.util.ArrayList) SProjectSmall(org.bimserver.interfaces.objects.SProjectSmall)

Example 27 with IfcModelInterface

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();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) SerializerException(org.bimserver.plugins.serializers.SerializerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) Revision(org.bimserver.models.store.Revision) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 28 with IfcModelInterface

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;
}
Also used : Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) IdEObject(org.bimserver.emf.IdEObject) IfcModelInterface(org.bimserver.emf.IfcModelInterface) HashSet(java.util.HashSet)

Example 29 with IfcModelInterface

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);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IfcModelInterface(org.bimserver.emf.IfcModelInterface)

Example 30 with IfcModelInterface

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;
}
Also used : IdEObject(org.bimserver.emf.IdEObject) IfcModelInterface(org.bimserver.emf.IfcModelInterface)

Aggregations

IfcModelInterface (org.bimserver.emf.IfcModelInterface)58 SProject (org.bimserver.interfaces.objects.SProject)22 UserException (org.bimserver.shared.exceptions.UserException)21 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)20 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)17 Test (org.junit.Test)17 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)16 PackageMetaData (org.bimserver.emf.PackageMetaData)15 URL (java.net.URL)14 Revision (org.bimserver.models.store.Revision)14 User (org.bimserver.models.store.User)14 ModelHelper (org.bimserver.plugins.ModelHelper)13 OldQuery (org.bimserver.database.OldQuery)12 Project (org.bimserver.models.store.Project)12 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 IdEObject (org.bimserver.emf.IdEObject)11 DatabaseSession (org.bimserver.database.DatabaseSession)10 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)10 IfcModelSet (org.bimserver.plugins.IfcModelSet)10