Search in sources :

Example 86 with Project

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

the class TestDatabase method checkLists.

private void checkLists() {
    DatabaseSession session = database.createSession(OperationType.READ_WRITE);
    long uoid = -1;
    try {
        Project p1 = session.create(Project.class);
        p1.setName("p1");
        Project p2 = session.create(Project.class);
        p2.setName("p2");
        User u1 = session.create(User.class);
        uoid = u1.getOid();
        p1.getHasAuthorizedUsers().add(u1);
        p2.getHasAuthorizedUsers().add(u1);
        session.commit();
    } catch (BimserverDatabaseException e) {
        e.printStackTrace();
    } catch (ServiceException e) {
        e.printStackTrace();
    } finally {
        session.close();
        session = database.createSession(OperationType.READ_WRITE);
        try {
            User user = session.get(uoid, OldQuery.getDefault());
            for (Project p : user.getHasRightsOn()) {
                System.out.println(p.getName());
            }
        } catch (BimserverDatabaseException e) {
            e.printStackTrace();
        } finally {
            session.close();
        }
    }
}
Also used : Project(org.bimserver.models.store.Project) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) User(org.bimserver.models.store.User) ServiceException(org.bimserver.shared.exceptions.ServiceException) DatabaseSession(org.bimserver.database.DatabaseSession)

Example 87 with Project

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

the class TestDatabase method create.

private void create() {
    DatabaseSession session = database.createSession(OperationType.READ_WRITE);
    try {
        Project project = session.create(Project.class);
        poid = project.getOid();
        project.setName("testproject");
        User user = session.create(User.class);
        uoid = user.getOid();
        user.setName("testuser");
        project.getHasAuthorizedUsers().add(user);
        session.commit();
    } catch (BimserverDatabaseException e) {
        e.printStackTrace();
    } catch (ServiceException e) {
        e.printStackTrace();
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) User(org.bimserver.models.store.User) ServiceException(org.bimserver.shared.exceptions.ServiceException) DatabaseSession(org.bimserver.database.DatabaseSession)

Aggregations

Project (org.bimserver.models.store.Project)87 UserException (org.bimserver.shared.exceptions.UserException)53 User (org.bimserver.models.store.User)51 DatabaseSession (org.bimserver.database.DatabaseSession)33 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)25 Revision (org.bimserver.models.store.Revision)25 ServerException (org.bimserver.shared.exceptions.ServerException)23 Date (java.util.Date)19 ServiceException (org.bimserver.shared.exceptions.ServiceException)19 SProject (org.bimserver.interfaces.objects.SProject)18 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)15 PackageMetaData (org.bimserver.emf.PackageMetaData)14 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)12 HashSet (java.util.HashSet)12 IfcModelInterface (org.bimserver.emf.IfcModelInterface)12 OldQuery (org.bimserver.database.OldQuery)11 PostCommitAction (org.bimserver.database.PostCommitAction)11 SConverter (org.bimserver.interfaces.SConverter)9 SUser (org.bimserver.interfaces.objects.SUser)9