Search in sources :

Example 21 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetDataObjectByGuidDatabaseAction method execute.

@Override
public DataObject execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Revision virtualRevision = getRevisionByRoid(roid);
    ObjectIdentifier objectIdentifier = null;
    for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
        objectIdentifier = getDatabaseSession().getOidOfGuid(concreteRevision.getProject().getSchema(), guid, concreteRevision.getProject().getId(), concreteRevision.getId());
        if (objectIdentifier != null) {
            long oidOfGuid = objectIdentifier.getOid();
            if (oidOfGuid != -1) {
                break;
            }
        }
    }
    if (objectIdentifier == null) {
        throw new UserException("Guid " + guid + " not found in this revision/project");
    }
    return new GetDataObjectByOidDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), roid, objectIdentifier.getOid(), authorization).execute();
}
Also used : Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) UserException(org.bimserver.shared.exceptions.UserException) ObjectIdentifier(org.bimserver.database.ObjectIdentifier)

Example 22 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetExtendedDataByIdDatabaseAction method execute.

@Override
public ExtendedData execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    ExtendedData extendedData = super.execute();
    if (authorization == null) {
        throw new UserException("Authorization required for this call");
    }
    if (extendedData.getRevision() != null) {
        Revision revision = extendedData.getRevision();
        authorization.canReadExtendedData(revision.getOid());
    } else if (extendedData.getProject() != null) {
    // Project project = extendedData.getProject();
    // TODO check auth
    }
    return extendedData;
}
Also used : ExtendedData(org.bimserver.models.store.ExtendedData) Revision(org.bimserver.models.store.Revision) UserException(org.bimserver.shared.exceptions.UserException)

Example 23 with Revision

use of org.bimserver.models.store.Revision 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;
}
Also used : SGeometryInfo(org.bimserver.interfaces.objects.SGeometryInfo) Project(org.bimserver.models.store.Project) Revision(org.bimserver.models.store.Revision) IdEObject(org.bimserver.emf.IdEObject) PackageMetaData(org.bimserver.emf.PackageMetaData) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) SGeometryInfo(org.bimserver.interfaces.objects.SGeometryInfo) UserException(org.bimserver.shared.exceptions.UserException) OldQuery(org.bimserver.database.OldQuery)

Example 24 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetNrPrimitivesDatabaseAction method execute.

@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault());
    PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
    if (packageMetaData == null) {
        throw new UserException("Schema not fond");
    }
    try {
        Query query = new Query("test", packageMetaData);
        QueryPart queryPart = query.createQueryPart();
        queryPart.addType(packageMetaData.getEClassIncludingDependencies("GeometryInfo"), true);
        QueryObjectProvider queryObjectProvider = new QueryObjectProvider(getDatabaseSession(), bimServer, query, java.util.Collections.singleton(roid), packageMetaData);
        HashMapVirtualObject next = queryObjectProvider.next();
        long totalPrimitives = 0;
        while (next != null) {
            int nrPrimitives = (int) next.get("primitiveCount");
            totalPrimitives += nrPrimitives;
            next = queryObjectProvider.next();
        }
        return totalPrimitives;
    } catch (QueryException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
    } catch (JsonMappingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : OldQuery(org.bimserver.database.OldQuery) Query(org.bimserver.database.queries.om.Query) PackageMetaData(org.bimserver.emf.PackageMetaData) QueryPart(org.bimserver.database.queries.om.QueryPart) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) QueryException(org.bimserver.database.queries.om.QueryException) Revision(org.bimserver.models.store.Revision) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) QueryObjectProvider(org.bimserver.database.queries.QueryObjectProvider) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) UserException(org.bimserver.shared.exceptions.UserException)

Example 25 with Revision

use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.

the class GetOidByGuidDatabaseAction method execute.

@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Revision virtualRevision = getRevisionByRoid(roid);
    ObjectIdentifier objectIdentifier = null;
    for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
        objectIdentifier = getDatabaseSession().getOidOfGuid(concreteRevision.getProject().getSchema(), guid, concreteRevision.getProject().getId(), concreteRevision.getId());
        if (objectIdentifier != null) {
            long oidOfGuid = objectIdentifier.getOid();
            if (oidOfGuid != -1) {
                break;
            }
        }
    }
    if (objectIdentifier == null) {
        throw new UserException("Guid " + guid + " not found in this revision/project");
    }
    return objectIdentifier.getOid();
}
Also used : Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) UserException(org.bimserver.shared.exceptions.UserException) ObjectIdentifier(org.bimserver.database.ObjectIdentifier)

Aggregations

Revision (org.bimserver.models.store.Revision)52 UserException (org.bimserver.shared.exceptions.UserException)39 Project (org.bimserver.models.store.Project)23 PackageMetaData (org.bimserver.emf.PackageMetaData)22 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)20 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)18 OldQuery (org.bimserver.database.OldQuery)17 User (org.bimserver.models.store.User)16 DatabaseSession (org.bimserver.database.DatabaseSession)15 IfcModelInterface (org.bimserver.emf.IfcModelInterface)14 ServerException (org.bimserver.shared.exceptions.ServerException)14 IOException (java.io.IOException)12 Date (java.util.Date)11 ModelHelper (org.bimserver.plugins.ModelHelper)10 HashMap (java.util.HashMap)9 SRevision (org.bimserver.interfaces.objects.SRevision)9 IfcModelSet (org.bimserver.plugins.IfcModelSet)9 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)9 MergeException (org.bimserver.plugins.modelmerger.MergeException)9 SerializerException (org.bimserver.plugins.serializers.SerializerException)8