use of org.bimserver.models.store.RevisionSummary in project BIMserver by opensourceBIM.
the class SummaryMap method toRevisionSummary.
public RevisionSummary toRevisionSummary(DatabaseSession databaseSession) throws BimserverDatabaseException {
RevisionSummary revisionSummary = databaseSession.create(RevisionSummary.class);
RevisionSummaryContainer revisionSummaryContainerEntities = databaseSession.create(RevisionSummaryContainer.class);
revisionSummaryContainerEntities.setName("IFC Entities");
revisionSummary.getList().add(revisionSummaryContainerEntities);
RevisionSummaryContainer revisionSummaryContainerRelations = databaseSession.create(RevisionSummaryContainer.class);
revisionSummaryContainerRelations.setName("IFC Relations");
revisionSummary.getList().add(revisionSummaryContainerRelations);
RevisionSummaryContainer revisionSummaryContainerPrimitives = databaseSession.create(RevisionSummaryContainer.class);
revisionSummaryContainerPrimitives.setName("IFC Primitives");
revisionSummary.getList().add(revisionSummaryContainerPrimitives);
RevisionSummaryContainer revisionSummaryContainerOther = databaseSession.create(RevisionSummaryContainer.class);
revisionSummaryContainerOther.setName("Rest");
revisionSummary.getList().add(revisionSummaryContainerOther);
for (EClass eClass : summaryMap.keySet()) {
RevisionSummaryContainer subMap = null;
if (((EClass) packageMetaData.getEPackage().getEClassifier("IfcObject")).isSuperTypeOf(eClass)) {
subMap = revisionSummaryContainerEntities;
} else if (((EClass) packageMetaData.getEPackage().getEClassifier("IfcRelationship")).isSuperTypeOf(eClass)) {
subMap = revisionSummaryContainerRelations;
} else if (eClass.getEAnnotation("wrapped") != null) {
subMap = revisionSummaryContainerPrimitives;
} else {
subMap = revisionSummaryContainerOther;
}
RevisionSummaryType createRevisionSummaryType = databaseSession.create(RevisionSummaryType.class);
createRevisionSummaryType.setSchema(eClass.getEPackage().getName());
createRevisionSummaryType.setCount(summaryMap.get(eClass));
createRevisionSummaryType.setName(eClass.getName());
subMap.getTypes().add(createRevisionSummaryType);
}
return revisionSummary;
}
use of org.bimserver.models.store.RevisionSummary 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;
}
use of org.bimserver.models.store.RevisionSummary in project BIMserver by opensourceBIM.
the class GetRevisionSummaryDatabaseAction method createSummary.
private RevisionSummary createSummary() {
RevisionSummary revisionSummary = StoreFactory.eINSTANCE.createRevisionSummary();
revisionSummaryContainerEntities = StoreFactory.eINSTANCE.createRevisionSummaryContainer();
revisionSummaryContainerEntities.setName("IFC Entities");
revisionSummary.getList().add(revisionSummaryContainerEntities);
revisionSummaryContainerRelations = StoreFactory.eINSTANCE.createRevisionSummaryContainer();
revisionSummaryContainerRelations.setName("IFC Relations");
revisionSummary.getList().add(revisionSummaryContainerRelations);
revisionSummaryContainerPrimitives = StoreFactory.eINSTANCE.createRevisionSummaryContainer();
revisionSummaryContainerPrimitives.setName("IFC Primitives");
revisionSummary.getList().add(revisionSummaryContainerPrimitives);
revisionSummaryContainerOther = StoreFactory.eINSTANCE.createRevisionSummaryContainer();
revisionSummaryContainerOther.setName("Rest");
revisionSummary.getList().add(revisionSummaryContainerOther);
for (EClass eClass : map.keySet()) {
RevisionSummaryContainer subMap = null;
if (Ifc2x3tc1Package.eINSTANCE.getIfcObject().isSuperTypeOf(eClass)) {
subMap = revisionSummaryContainerEntities;
} else if (Ifc2x3tc1Package.eINSTANCE.getIfcRelationship().isSuperTypeOf(eClass)) {
subMap = revisionSummaryContainerRelations;
} else if (eClass.getEAnnotation("wrapped") != null) {
subMap = revisionSummaryContainerPrimitives;
} else {
subMap = revisionSummaryContainerOther;
}
RevisionSummaryType createRevisionSummaryType = StoreFactory.eINSTANCE.createRevisionSummaryType();
createRevisionSummaryType.setSchema(eClass.getEPackage().getName());
createRevisionSummaryType.setCount(map.get(eClass));
createRevisionSummaryType.setName(eClass.getName());
subMap.getTypes().add(createRevisionSummaryType);
}
return revisionSummary;
}
use of org.bimserver.models.store.RevisionSummary in project BIMserver by opensourceBIM.
the class ServiceImpl method getRevisionSummary.
@Override
public SRevisionSummary getRevisionSummary(Long roid) throws ServerException, UserException {
requireAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<RevisionSummary> action = new GetRevisionSummaryDatabaseAction(session, getInternalAccessMethod(), roid);
RevisionSummary revisionSummary = session.executeAndCommitAction(action);
return getBimServer().getSConverter().convertToSObject(revisionSummary);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations