use of org.bimserver.models.store.Project 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.models.store.Project in project BIMserver by opensourceBIM.
the class GetCheckinWarningsDatabaseAction method checkInterleavingCommits.
private void checkInterleavingCommits(Project project, User user, Set<String> warnings) {
Checkout lastOwnActiveCheckout = null;
for (Checkout checkout : project.getCheckouts()) {
if (checkout.getUser() == user && checkout.getActive()) {
lastOwnActiveCheckout = checkout;
}
}
if (lastOwnActiveCheckout != null) {
Project mainProject = project;
while (mainProject.getParent() != null) {
mainProject = mainProject.getParent();
}
int newRevisionsAfterCheckout = 0;
for (Revision virtualRevision : mainProject.getRevisions()) {
if (lastOwnActiveCheckout.getDate().before(virtualRevision.getDate()) && lastOwnActiveCheckout.getRevision() != virtualRevision) {
newRevisionsAfterCheckout++;
}
}
if (newRevisionsAfterCheckout == 1) {
warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), a new revision has been checked-in");
} else if (newRevisionsAfterCheckout > 1) {
warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), " + newRevisionsAfterCheckout + " new revisions have been checked-in");
}
}
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class GetGeometryInfoDatabaseAction method execute.
@Override
public SGeometryInfo execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault());
Project project = revision.getProject();
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(project.getSchema());
IdEObject ifcProduct = getDatabaseSession().get(oid, new OldQuery(packageMetaData, project.getId(), revision.getId(), revision.getOid()));
if (ifcProduct == null) {
throw new UserException("Object with oid " + oid + " not found");
}
EStructuralFeature geometryFeature = packageMetaData.getEClass("IfcProduct").getEStructuralFeature("geometry");
GeometryInfo geometry = (GeometryInfo) ifcProduct.eGet(geometryFeature);
SGeometryInfo convertToSObject = bimServer.getSConverter().convertToSObject(geometry);
return convertToSObject;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class GetProjectByPoidDatabaseAction method execute.
@Override
public Project execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("Project with oid " + poid + " does not exist");
}
User user = getUserByUoid(authorization.getUoid());
if (user == null) {
throw new UserException("Authenticated user required");
}
if (project.getState() == ObjectState.DELETED && user.getUserType() != UserType.ADMIN) {
throw new UserException("Project has been deleted");
}
if (authorization.hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project)) {
return project;
} else {
throw new UserException("User '" + user.getUsername() + "' has no rights on this project");
}
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class GetSubProjectsDatabaseAction method execute.
@Override
public Set<Project> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(authorization.getUoid());
Project project = getProjectByPoid(poid);
if (!authorization.hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project)) {
throw new UserException("User has no rights on project");
}
Set<Project> subProjects = new HashSet<Project>();
for (Project subProject : project.getSubProjects()) {
if (subProject.getState() == ObjectState.ACTIVE || authorization instanceof AdminAuthorization) {
subProjects.add(subProject);
}
}
return subProjects;
}
Aggregations