@SuppressWarnings({ "rawtypes", "unchecked" }) public void apply(IdEObject value) { if (eStructuralFeature.isMany()) { List list = (List)newObject.eGet(eStructuralFeature); list.add(value); } else { newObject.eSet(eStructuralFeature, value); } } }
private void setColour(IdEObject color, IdEObject ifcSurfaceStyleRendering) { if (color != null) { EStructuralFeature diffuseColourFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("DiffuseColour"); EStructuralFeature reflectionColourFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("ReflectionColour"); EStructuralFeature specularColourFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("SpecularColour"); EStructuralFeature surfaceColourFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("SurfaceColour"); EStructuralFeature transmissionColourFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("TransmissionColour"); ifcSurfaceStyleRendering.eSet(diffuseColourFeature, color); ifcSurfaceStyleRendering.eSet(reflectionColourFeature, color); ifcSurfaceStyleRendering.eSet(specularColourFeature, color); ifcSurfaceStyleRendering.eSet(surfaceColourFeature, color); ifcSurfaceStyleRendering.eSet(transmissionColourFeature, color); } else { EStructuralFeature transparancyFeature = ifcSurfaceStyleRendering.eClass().getEStructuralFeature("Transparency"); ifcSurfaceStyleRendering.eSet(transparancyFeature, 0.5D); } }
private int fixMisMatchInstance(Mismatch mismatch, IdEObject entityToBeFixed, IdEObject referenced) { int nrFixes = 0; for(EReference inverse: mismatch.inverse) if(inverse.getEContainingClass().isInstance(referenced)){ if(inverse.isMany()) ((EList<IdEObject>) referenced.eGet(inverse)).add(entityToBeFixed); else referenced.eSet(inverse, entityToBeFixed); nrFixes++; } return nrFixes; }
@SuppressWarnings("unchecked") public <T> T create(EClass eClass, int pid, int rid) throws BimserverDatabaseException { checkOpen(); IdEObject idEObject = createInternal(eClass, null); EStructuralFeature uuidFeature = eClass.getEStructuralFeature("uuid"); if (uuidFeature != null) { if (idEObject.eGet(uuidFeature) == null) { idEObject.eSet(uuidFeature, UUID.randomUUID().toString()); } } store(idEObject, pid, rid); return (T) idEObject; }
private IdEObject readEmbeddedValue(EStructuralFeature feature, ByteBuffer buffer, EClass eClass, QueryInterface query) throws BimserverDatabaseException { IdEObject eObject = createInternal(eClass, query); for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { if (eStructuralFeature.isMany()) { // Not implemented } else { if (eStructuralFeature.getEType() instanceof EDataType) { Object primitiveValue = readPrimitiveValue(eStructuralFeature.getEType(), buffer, query); ((IdEObjectImpl) eObject).setLoaded(); eObject.eSet(eStructuralFeature, primitiveValue); } else { buffer.order(ByteOrder.LITTLE_ENDIAN); short cid = buffer.getShort(); buffer.order(ByteOrder.BIG_ENDIAN); if (cid == -1) { // null, do nothing } else if (cid < 0) { // non minus one and negative cid means value is embedded in record EClass referenceClass = database.getEClassForCid((short) (-cid)); eObject.eSet(eStructuralFeature, readEmbeddedValue(eStructuralFeature, buffer, referenceClass, query)); } } } } return eObject; }
@Override public Reference reAttach(IdEObject mainObject) { // System.out.println("Re-attaching S " + getReferredObject() + " to " + mainObject + " on " + getIdEObject() + "." + geteReference().getName()); getIdEObject().eSet(geteReference(), mainObject); return new SingleReference(getIdEObject(), mainObject, geteReference()); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) private void setDoubleAsStringValues(IdEObject idEObject) { for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) { if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { EStructuralFeature asStringFeature = idEObject.eClass().getEStructuralFeature(eAttribute.getName() + "AsString"); if (asStringFeature != null) { if (eAttribute.isMany()) { List list = (List) idEObject.eGet(eAttribute); List listAsString = (List) idEObject.eGet(asStringFeature); for (int i = 0; i < list.size(); i++) { listAsString.set(i, "" + list.get(i)); } } else { idEObject.eSet(asStringFeature, "" + idEObject.eGet(eAttribute)); } } } } }
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); ((IdEObjectImpl) eObject).setLoaded(); // We don't want to go lazy load // 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; }
red.eSet(nameFeature, "red"); red.eSet(redFeature, 0.5D); red.eSet(greenFeature, 0.0D); red.eSet(blueFeature, 0.0D); green.eSet(nameFeature, "green"); green.eSet(redFeature, 0D); green.eSet(greenFeature, 0.5D); green.eSet(blueFeature, 0D); blue.eSet(nameFeature, "blue"); blue.eSet(redFeature, 0D); blue.eSet(greenFeature, 0D); blue.eSet(blueFeature, 0.5D);
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; }
if (textCharacterAppearance.eClass().getName().equals("IfcTextStyleForDefinedFont")) { textCharacterAppearance.eSet(textCharacterAppearance.eClass().getEStructuralFeature("Colour"), color); ifcPresentationStyleSelect.eSet(ifcPresentationStyleSelect.eClass().getEStructuralFeature("CurveColour"), color); } else if (ifcPresentationStyleSelect.eClass().getName().equals("IfcFillAreaStyle")) { EStructuralFeature fillStylesFeature = ifcPresentationStyleSelect.eClass().getEStructuralFeature("FillStyles"); list.add(color); } else if (ifcPresentationStyleSelect.eClass().getName().equals("IfcSymbolStyle")) { ifcPresentationStyleSelect.eSet(ifcPresentationStyleSelect.eClass().getEStructuralFeature("StyleOfSymbol"), color);
x.eSet(eReference.getEOpposite(), null); resultModel.getByGuid(guid).eSet(eReference, null); } else { if (!(referencedObject instanceof IfcRoot) && !(referencedObject instanceof IfcGloballyUniqueId)) { x.eSet(eReference.getEOpposite(), null); resultModel.getByGuid(guid).eSet(eReference, resultModel.get(referencedIDEObject.getOid())); } else { IdEObject smartCopy = copy(resultModel, referencedIDEObject, true); re.eSet(eReference.getEOpposite(), null); resultModel.getByGuid(guid).eSet(eReference, smartCopy);
if (newModel.containsGuid(oldGuid)) { resultModel.getByGuid(guid).eSet(eReference, null);
@SuppressWarnings("unchecked") public void copyDecomposes(IdEObject ifcObjectDefinition, IdEObject ownerHistory) throws IfcModelInterfaceException, ObjectAlreadyExistsException { IdEObject newObjectDefinition = copy(ifcObjectDefinition, false, skipRepresentation); EStructuralFeature decomposesFeature = newObjectDefinition.eClass().getEStructuralFeature("Decomposes"); for (IdEObject ifcRelDecomposes : (List<IdEObject>)ifcObjectDefinition.eGet(decomposesFeature)) { copy(ifcRelDecomposes, false, skipRepresentation); EStructuralFeature relatingObjectFeature = ifcRelDecomposes.eClass().getEStructuralFeature("RelatingObject"); IdEObject relatingObject = (IdEObject) ifcRelDecomposes.eGet(relatingObjectFeature); if (relatingObject != null) { copyDecomposes(relatingObject, ownerHistory); } } if (ifcObjectDefinition.eClass().getEPackage().getEClassifier("IfcElement").isInstance(ifcObjectDefinition)) { EStructuralFeature containedInStructureFeature = ifcObjectDefinition.eClass().getEStructuralFeature("ContainedInStructure"); for (IdEObject containedInStructure : (List<IdEObject>)ifcObjectDefinition.eGet(containedInStructureFeature)) { IdEObject newContainedInSpatialStructure = getTargetModel().create(containedInStructure.eClass()); newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("GlobalId"), GuidCompressor.getNewIfcGloballyUniqueId()); newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("OwnerHistory"), ownerHistory); EStructuralFeature relatedElementsFeature = newContainedInSpatialStructure.eClass().getEStructuralFeature("RelatedElements"); ((List<IdEObject>)newContainedInSpatialStructure.eGet(relatedElementsFeature)).add(newObjectDefinition); EStructuralFeature relatingStructureFeature = containedInStructure.eClass().getEStructuralFeature("RelatingStructure"); IdEObject newRelatingStructre = copy(((IdEObject)containedInStructure.eGet(relatingStructureFeature)), false, skipRepresentation); newContainedInSpatialStructure.eSet(relatingStructureFeature, newRelatingStructre); getTargetModel().add(oidProvider.newOid(newContainedInSpatialStructure.eClass()), newContainedInSpatialStructure); copyDecomposes((IdEObject)containedInStructure.eGet(relatingStructureFeature), ownerHistory); } } }
private void copyAttributesGuidObjectsAndAddNewObjects() throws IfcModelInterfaceException, ObjectAlreadyExistsException { for (IdEObject idEObject : newModel.getValues()) { if (idEObject instanceof IfcRoot) { IfcRoot ifcRoot = (IfcRoot) idEObject; String guid = ifcRoot.getGlobalId(); if (resultModel.containsGuid(guid)) { // LOGGER.info("Updating attributes for object " + idEObject.eClass().getName() + " " + guid); IfcRoot oldObject = (IfcRoot) resultModel.getByGuid(guid); for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) { Object newValue = idEObject.eGet(eAttribute); oldObject.eSet(eAttribute, newValue); } } else { // LOGGER.info("Adding new GUID object " + idEObject.eClass().getName() + " " + guid); IdEObject newObject = (IdEObject) idEObject.eClass().getEPackage().getEFactoryInstance().create(idEObject.eClass()); ((IdEObjectImpl)newObject).setOid(idEObject.getOid()); ((IfcRoot) newObject).setGlobalId(newGuid(guid)); for (EAttribute eAttribute : newObject.eClass().getEAllAttributes()) { newObject.eSet(eAttribute, idEObject.eGet(eAttribute)); } resultModel.add(newObject.getOid(), newObject); } } } }
private void returnCachedData(IfcModelInterface model, GeometryCache geometryCache, DatabaseSession databaseSession, int pid, int rid, boolean store) throws BimserverDatabaseException, ObjectAlreadyExistsException, IfcModelInterfaceException { EClass productClass = model.getPackageMetaData().getEClass("IfcProduct"); List<IdEObject> products = model.getAllWithSubTypes(productClass); for (IdEObject ifcProduct : products) { GeometryCacheEntry geometryCacheEntry = geometryCache.get(ifcProduct.getExpressId()); if (geometryCacheEntry != null) { GeometryData geometryData = databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(), pid, rid); geometryData.setVertices(createBuffer(model, databaseSession, geometryCacheEntry.getVertices(), store, pid, rid)); geometryData.setNormals(createBuffer(model, databaseSession, geometryCacheEntry.getNormals(), store, pid, rid)); GeometryInfo geometryInfo = databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(), pid, rid); Vector3f min = databaseSession.create(GeometryPackage.eINSTANCE.getVector3f(), pid, rid); min.setX(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getX()); min.setY(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getY()); min.setZ(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getZ()); Vector3f max = databaseSession.create(GeometryPackage.eINSTANCE.getVector3f(), pid, rid); max.setX(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getX()); max.setY(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getY()); max.setZ(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getZ()); Bounds bounds = GeometryFactory.eINSTANCE.createBounds(); bounds.setMin(min); bounds.setMax(max); geometryInfo.setBounds(bounds); geometryInfo.setData(geometryData); ifcProduct.eSet(ifcProduct.eClass().getEStructuralFeature("geometry"), geometryInfo); } } }