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();
}
}
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();
}
}
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;
}
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);
}
}
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;
}
Aggregations