Search in sources :

Example 11 with Project

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;
}
Also used : Project(org.bimserver.models.store.Project)

Example 12 with Project

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;
}
Also used : Project(org.bimserver.models.store.Project) UserException(org.bimserver.shared.exceptions.UserException)

Example 13 with Project

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;
}
Also used : Project(org.bimserver.models.store.Project) User(org.bimserver.models.store.User) Service(org.bimserver.models.store.Service) UserException(org.bimserver.shared.exceptions.UserException)

Example 14 with Project

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();
}
Also used : User(org.bimserver.models.store.User) ModelHelper(org.bimserver.plugins.ModelHelper) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) OldQuery(org.bimserver.database.OldQuery) Project(org.bimserver.models.store.Project) IfcModel(org.bimserver.ifc.IfcModel) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) MergeException(org.bimserver.plugins.modelmerger.MergeException) IfcModelSet(org.bimserver.plugins.IfcModelSet) UserException(org.bimserver.shared.exceptions.UserException)

Example 15 with Project

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;
}
Also used : Project(org.bimserver.models.store.Project) Revision(org.bimserver.models.store.Revision) SummaryMap(org.bimserver.SummaryMap) PackageMetaData(org.bimserver.emf.PackageMetaData) RevisionSummary(org.bimserver.models.store.RevisionSummary) UserException(org.bimserver.shared.exceptions.UserException)

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