use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class UndeleteProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User actingUser = getUserByUoid(authorization.getUoid());
final Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("No Project with oid " + poid + " found");
}
if (actingUser.getUserType() == UserType.ADMIN || actingUser.getHasRightsOn().contains(project)) {
project.setState(ObjectState.ACTIVE);
final ProjectUndeleted projectUndeleted = getDatabaseSession().create(ProjectUndeleted.class);
projectUndeleted.setAccessMethod(getAccessMethod());
projectUndeleted.setDate(new Date());
projectUndeleted.setExecutor(actingUser);
projectUndeleted.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(projectUndeleted));
}
});
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("No rights to undelete this project");
}
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class RemoveModelCheckerFromProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
ModelCheckerInstance modelCheckerInstance = getDatabaseSession().get(mcoid, OldQuery.getDefault());
Project project = getDatabaseSession().get(poid, OldQuery.getDefault());
project.getModelCheckers().remove(modelCheckerInstance);
getDatabaseSession().store(project);
return true;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class UpdateProjectDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
final Project project = getProjectByPoid(sProject.getOid());
if (project == null) {
throw new UserException("Project with pid " + sProject.getOid() + " not found");
}
if (sProject.getName().trim().equals("")) {
throw new UserException("Project name cannot be empty");
}
if (!authorization.hasRightsOnProjectOrSuperProjects(actingUser, project)) {
throw new UserException("User has no rights to update project properties");
}
if (project.getParent() == null) {
if (!sProject.getName().equals(project.getName())) {
for (Project p : getProjectsByName(sProject.getName())) {
if (p.getParent() == null) {
throw new UserException("Project name must be unique");
}
}
}
} else {
Project parent = project.getParent();
for (Project subProject : parent.getSubProjects()) {
if (subProject.getName().equals(sProject.getName()) && subProject != project) {
throw new UserException("Project name must be unique within parent project (" + parent.getName() + ")");
}
}
}
project.setSendEmailOnNewRevision(sProject.isSendEmailOnNewRevision());
project.setName(sProject.getName());
project.setDescription(sProject.getDescription());
project.setExportLengthMeasurePrefix(SIPrefix.get(sProject.getExportLengthMeasurePrefix().getOrdinal()));
final ProjectUpdated projectUpdated = getDatabaseSession().create(ProjectUpdated.class);
projectUpdated.setAccessMethod(getAccessMethod());
projectUpdated.setDate(new Date());
projectUpdated.setExecutor(actingUser);
projectUpdated.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(projectUpdated));
}
});
getDatabaseSession().store(project);
return null;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class GenericCheckinDatabaseAction method createNewConcreteRevision.
public CreateRevisionResult createNewConcreteRevision(DatabaseSession session, long size, Project project, User user, String comment) throws BimserverDatabaseException, BimserverLockConflictException {
CreateRevisionResult result = new CreateRevisionResult();
ConcreteRevision concreteRevision = getDatabaseSession().create(ConcreteRevision.class);
concreteRevision.setSize(size);
Date date = new Date();
concreteRevision.setDate(date);
concreteRevision.setId(project.getConcreteRevisions().size() + 1);
concreteRevision.setUser(user);
concreteRevision.setProject(project);
project.setLastConcreteRevision(concreteRevision);
Revision newRevision = createNewVirtualRevision(session, project, concreteRevision, comment, date, user, size);
for (Checkout checkout : project.getCheckouts()) {
if (checkout.getUser() == user) {
checkout.setActive(false);
session.store(checkout);
}
}
project.setLastRevision(newRevision);
Project parent = project.getParent();
result.addRevision(newRevision);
while (parent != null) {
Revision revision = getDatabaseSession().create(Revision.class);
result.addRevision(revision);
revision.setComment("generated for subproject " + project.getName() + ", revision " + concreteRevision.getId() + ", by " + user.getName());
revision.setDate(date);
revision.setUser(getSystemUser());
revision.setProject(parent);
if (parent.getLastRevision() != null) {
Revision lastRevision = parent.getLastRevision();
for (ConcreteRevision oldRevision : lastRevision.getConcreteRevisions()) {
if (oldRevision.getProject() != project && oldRevision.getProject() != parent) {
revision.getConcreteRevisions().add(oldRevision);
revision.setSize(((revision.getSize() == null || revision.getSize() == -1) ? 0 : revision.getSize()) + oldRevision.getSize());
session.store(revision);
session.store(oldRevision);
}
}
}
revision.getConcreteRevisions().add(concreteRevision);
revision.setSize((revision.getSize() == null ? 0 : revision.getSize()) + concreteRevision.getSize());
revision.setLastConcreteRevision(concreteRevision);
if (parent.getLastRevision() == null) {
revision.setId(1);
} else {
revision.setId(parent.getLastRevision().getId() + 1);
}
parent.setLastRevision(revision);
session.store(revision);
session.store(parent);
parent = parent.getParent();
}
session.store(project);
session.store(concreteRevision);
result.setConcreteRevision(concreteRevision);
return result;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class GetCheckinWarningsDatabaseAction method execute.
@Override
public Set<String> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getProjectByPoid(poid);
User user = getUserByUoid(authorization.getUoid());
Set<String> warnings = new HashSet<String>();
checkInterleavingCommits(project, user, warnings);
new GetCheckoutWarningsDatabaseAction(getDatabaseSession(), getAccessMethod(), poid, authorization).checkOtherUsersCheckouts(project, user, warnings);
return warnings;
}
Aggregations