Search in sources :

Example 31 with Project

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

the class ServiceImpl method getSubProjectByName.

@Override
public SProject getSubProjectByName(Long parentProjectId, String name) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Project> action = new GetSubProjectByNameDatabaseAction(session, getInternalAccessMethod(), parentProjectId, name, getAuthorization());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) DatabaseSession(org.bimserver.database.DatabaseSession) GetSubProjectByNameDatabaseAction(org.bimserver.database.actions.GetSubProjectByNameDatabaseAction) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 32 with Project

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

the class NewRevisionNotification method process.

@Override
public void process() throws BimserverDatabaseException, UserException, ServerException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Project project = session.get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
        if (project == null) {
            LOGGER.error("Project with oid " + poid + " not found");
            return;
        }
        Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        if (revision == null) {
            LOGGER.error("Revision with roid " + roid + " not found");
            return;
        }
        if (project.isSendEmailOnNewRevision() && sendEmail) {
            sendEmail(session, project, revision);
        }
        for (NewService newService : project.getNewServices()) {
            if (soid == -1 || newService.getOid() == soid) {
                triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, newService);
            }
        }
        for (Service service : project.getServices()) {
            if (soid == -1 || service.getOid() == soid) {
                triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, service);
            }
        }
        if (soid == -1) {
            // Only execute if we are not triggering a specific service with this notification
            NewRevisionTopic newRevisionTopic = getBimServer().getNotificationsManager().getNewRevisionTopic();
            if (newRevisionTopic != null) {
                newRevisionTopic.process(session, poid, roid, this);
            }
            NewRevisionOnSpecificProjectTopic newRevisionOnSpecificProjectTopic = getBimServer().getNotificationsManager().getNewRevisionOnSpecificProjectTopic(new NewRevisionOnSpecificProjectTopicKey(poid));
            if (newRevisionOnSpecificProjectTopic != null) {
                newRevisionOnSpecificProjectTopic.process(session, poid, roid, this);
            }
        }
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) Revision(org.bimserver.models.store.Revision) DatabaseSession(org.bimserver.database.DatabaseSession) Service(org.bimserver.models.store.Service) NewService(org.bimserver.models.store.NewService) NewService(org.bimserver.models.store.NewService)

Example 33 with Project

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

the class NewRevisionNotification method getUsers.

private Set<User> getUsers(DatabaseSession session, Project project) {
    Set<Project> relatedProjects = getRelatedProjects(project);
    Set<User> users = new HashSet<User>();
    for (Project relatedProject : relatedProjects) {
        for (User user : relatedProject.getHasAuthorizedUsers()) {
            users.add(user);
        }
    }
    return users;
}
Also used : Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) HashSet(java.util.HashSet)

Example 34 with Project

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

the class GetAllRelatedProjectsDatabaseAction method addProjects.

private void addProjects(List<SProjectSmall> list, Project project, User user) {
    if (project.getState() == ObjectState.DELETED && !(authorization instanceof AdminAuthorization)) {
        return;
    }
    list.add(GetAllProjectsSmallDatabaseAction.createSmallProject(authorization, bimServer, project, user));
    List<Project> subProjects = new ArrayList<Project>(project.getSubProjects());
    Collections.sort(subProjects, new Comparator<Project>() {

        @Override
        public int compare(Project o1, Project o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    for (Project subProject : subProjects) {
        addProjects(list, subProject, user);
    }
}
Also used : Project(org.bimserver.models.store.Project) ArrayList(java.util.ArrayList) AdminAuthorization(org.bimserver.webservices.authorization.AdminAuthorization)

Example 35 with Project

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

the class GetAllRelatedProjectsDatabaseAction method execute.

@Override
public List<SProjectSmall> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    List<SProjectSmall> list = new ArrayList<SProjectSmall>();
    Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
    Project rootProject = getRootProject(project);
    User user = getUserByUoid(authorization.getUoid());
    addProjects(list, rootProject, user);
    return list;
}
Also used : Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) ArrayList(java.util.ArrayList) SProjectSmall(org.bimserver.interfaces.objects.SProjectSmall)

Aggregations

Project (org.bimserver.models.store.Project)80 UserException (org.bimserver.shared.exceptions.UserException)48 User (org.bimserver.models.store.User)46 DatabaseSession (org.bimserver.database.DatabaseSession)25 Revision (org.bimserver.models.store.Revision)23 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)22 ServerException (org.bimserver.shared.exceptions.ServerException)20 Date (java.util.Date)18 ArrayList (java.util.ArrayList)14 SProject (org.bimserver.interfaces.objects.SProject)14 IOException (java.io.IOException)13 PackageMetaData (org.bimserver.emf.PackageMetaData)13 HashSet (java.util.HashSet)12 IfcModelInterface (org.bimserver.emf.IfcModelInterface)12 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)11 OldQuery (org.bimserver.database.OldQuery)10 PostCommitAction (org.bimserver.database.PostCommitAction)10 SConverter (org.bimserver.interfaces.SConverter)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 MalformedURLException (java.net.MalformedURLException)8