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();
}
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;
}
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;
}
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;
}
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();
}
Aggregations