use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class DatabaseSession method readWrappedValue.
private IdEObject readWrappedValue(EStructuralFeature feature, ByteBuffer buffer, EClass eClass, QueryInterface query) {
EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature("wrappedValue");
Object primitiveValue = readPrimitiveValue(eStructuralFeature.getEType(), buffer, query);
IdEObject eObject = createInternal(eClass, query);
// We don't want to go lazy load
((IdEObjectImpl) eObject).setLoaded();
// this
eObject.eSet(eStructuralFeature, primitiveValue);
if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
EStructuralFeature strFeature = eClass.getEStructuralFeature("wrappedValueAsString");
Object stringVal = readPrimitiveValue(EcorePackage.eINSTANCE.getEString(), buffer, query);
eObject.eSet(strFeature, stringVal);
}
return eObject;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class CheckoutDatabaseAction method realCheckout.
private IfcModel realCheckout(Project project, Revision revision, DatabaseSession databaseSession, User user) throws BimserverLockConflictException, BimserverDatabaseException, UserException {
PluginConfiguration serializerPluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getPluginConfiguration(), serializerOid, OldQuery.getDefault());
final long totalSize = revision.getSize();
final AtomicLong total = new AtomicLong();
IfcModelSet ifcModelSet = new IfcModelSet();
PackageMetaData lastPackageMetaData = null;
for (ConcreteRevision subRevision : revision.getConcreteRevisions()) {
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(subRevision.getProject().getSchema());
lastPackageMetaData = packageMetaData;
IfcModel subModel = new BasicIfcModel(packageMetaData, null);
int highestStopId = findHighestStopRid(project, subRevision);
OldQuery query = new OldQuery(packageMetaData, subRevision.getProject().getId(), subRevision.getId(), revision.getOid(), null, Deep.YES, highestStopId);
subModel.addChangeListener(new IfcModelChangeListener() {
@Override
public void objectAdded(IdEObject idEObject) {
total.incrementAndGet();
if (totalSize == 0) {
setProgress("Preparing checkout...", 0);
} else {
setProgress("Preparing checkout...", (int) Math.round(100.0 * total.get() / totalSize));
}
}
});
getDatabaseSession().getMap(subModel, query);
try {
checkGeometry(serializerPluginConfiguration, getBimServer().getPluginManager(), subModel, project, subRevision, revision);
} catch (GeometryGeneratingException e) {
throw new UserException(e);
}
subModel.getModelMetaData().setDate(subRevision.getDate());
ifcModelSet.add(subModel);
}
IfcModelInterface ifcModel = new BasicIfcModel(lastPackageMetaData, null);
if (ifcModelSet.size() > 1) {
try {
ifcModel = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid()).merge(revision.getProject(), ifcModelSet, new ModelHelper(getBimServer().getMetaDataManager(), ifcModel));
} catch (MergeException e) {
throw new UserException(e);
}
} else {
ifcModel = ifcModelSet.iterator().next();
}
ifcModel.getModelMetaData().setName(project.getName() + "." + revision.getId());
ifcModel.getModelMetaData().setRevisionId(project.getRevisions().indexOf(revision) + 1);
ifcModel.getModelMetaData().setAuthorizedUser(user.getName());
ifcModel.getModelMetaData().setDate(new Date());
return (IfcModel) ifcModel;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class DownloadByNewJsonQueryDatabaseAction method convertWrapped.
private IdEObject convertWrapped(Revision revision, IfcModelInterface ifcModel, HashMapWrappedVirtualObject hashMapWrappedVirtualObject) throws IfcModelInterfaceException {
IdEObject embeddedObject = ifcModel.create(hashMapWrappedVirtualObject.eClass());
((IdEObjectImpl) embeddedObject).setOid(-1);
((IdEObjectImpl) embeddedObject).setPid(revision.getProject().getId());
for (EAttribute eAttribute : hashMapWrappedVirtualObject.eClass().getEAllAttributes()) {
embeddedObject.eSet(eAttribute, hashMapWrappedVirtualObject.eGet(eAttribute));
}
return embeddedObject;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class DownloadCompareDatabaseAction method createStyledItemStyles.
@SuppressWarnings("unchecked")
private void createStyledItemStyles(IfcModelInterface model, String representationIdentifier, IdEObject ifcStyledItem, IdEObject color) throws IfcModelInterfaceException {
IdEObject ifcPresentationStyleAssignment = model.create(model.getPackageMetaData().getEClass("IfcPresentationStyleAssignment"));
EStructuralFeature stylesFeature = ifcStyledItem.eClass().getEStructuralFeature("Styles");
List<IdEObject> list = (List<IdEObject>) ifcStyledItem.eGet(stylesFeature);
list.add(ifcPresentationStyleAssignment);
createPresentationStyleAssignmentStyles(model, representationIdentifier, ifcPresentationStyleAssignment, color);
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class DownloadCompareDatabaseAction method createPresentationStyleAssignmentStyles.
@SuppressWarnings("unchecked")
private void createPresentationStyleAssignmentStyles(IfcModelInterface model, String representationIdentifier, IdEObject ifcPresentationStyleAssignment, IdEObject color) throws IfcModelInterfaceException {
if (representationIdentifier.equals("Body")) {
IdEObject ifcPresentationStyleSelect = model.create(model.getPackageMetaData().getEClass("IfcSurfaceStyle"));
EStructuralFeature stylesFeature = ifcPresentationStyleAssignment.eClass().getEStructuralFeature("Styles");
List<IdEObject> list = (List<IdEObject>) ifcPresentationStyleAssignment.eGet(stylesFeature);
list.add(ifcPresentationStyleSelect);
createSurfaceStyleStyles(model, representationIdentifier, ifcPresentationStyleSelect, color);
} else {
// Unimplemented
}
}
Aggregations