use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class AddModelCheckerToProjectDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
project.getModelCheckers().add(modelChecker);
getDatabaseSession().store(modelChecker);
getDatabaseSession().store(project);
return null;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class AddNewServiceToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
// service.setUser(user);
for (org.bimserver.models.store.Service existing : project.getServices()) {
if (existing.getName().equals(service.getName())) {
throw new UserException("Service name \"" + service.getName() + "\" already used in this project");
}
}
service.setAction(action);
service.setStatus(ServiceStatus.NEW);
if (service.getAuthorizationUrl() == null) {
service.setStatus(ServiceStatus.NO_AUTHENTICATION);
}
project.getNewServices().add(service);
service.setProject(project);
long serviceOid = getDatabaseSession().store(service);
getDatabaseSession().store(action);
getDatabaseSession().store(project);
return serviceOid;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class AddServiceToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
service.setUser(user);
for (org.bimserver.models.store.Service existing : project.getServices()) {
if (existing.getName().equals(service.getName())) {
throw new UserException("Service name \"" + service.getName() + "\" already used in this project");
}
}
project.getServices().add(service);
service.setProject(project);
long serviceOid = getDatabaseSession().store(service);
getDatabaseSession().store(project);
return serviceOid;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class BranchToExistingProjectDatabaseAction method execute.
@Override
public ConcreteRevision execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision oldRevision = getDatabaseSession().get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
Project oldProject = oldRevision.getProject();
User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
if (!authorization.hasRightsOnProjectOrSuperProjectsOrSubProjects(user, oldProject)) {
throw new UserException("User has insufficient rights to download revisions from this project");
}
IfcModelSet ifcModelSet = new IfcModelSet();
PackageMetaData lastMetaData = null;
for (ConcreteRevision subRevision : oldRevision.getConcreteRevisions()) {
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(subRevision.getProject().getSchema());
IfcModel subModel = new BasicIfcModel(packageMetaData, null);
getDatabaseSession().getMap(subModel, new OldQuery(packageMetaData, subRevision.getProject().getId(), subRevision.getId(), -1, Deep.YES));
subModel.getModelMetaData().setDate(subRevision.getDate());
ifcModelSet.add(subModel);
lastMetaData = packageMetaData;
}
IfcModelInterface model = new BasicIfcModel(lastMetaData, null);
try {
model = bimServer.getMergerFactory().createMerger(getDatabaseSession(), authorization.getUoid()).merge(oldRevision.getProject(), ifcModelSet, new ModelHelper(bimServer.getMetaDataManager(), model));
} catch (MergeException e) {
throw new UserException(e);
}
model.resetOids();
CheckinDatabaseAction checkinDatabaseAction = new CheckinDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), destPoid, authorization, model, comment, comment, false, -1);
return checkinDatabaseAction.execute();
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class CountDatabaseAction method execute.
@Override
public Integer execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision revision = getRevisionByRoid(roid);
if (revision == null) {
throw new UserException("Revision with roid " + roid + " not found");
}
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
Project project = revision.getProject();
if (revision.getConcreteRevisions().size() == 1 && revision.getConcreteRevisions().get(0).getSummary() != null) {
RevisionSummary summary = revision.getConcreteRevisions().get(0).getSummary();
SummaryMap summaryMap = new SummaryMap(packageMetaData, summary);
if (className.equals("[ALL]")) {
return summaryMap.count();
} else {
return summaryMap.count(getDatabaseSession().getEClass(project.getSchema(), className));
}
}
return null;
}
Aggregations