@SuppressWarnings("unchecked") @Override public <T extends IdEObject> T create(EClass eClass, OidProvider oidProvider) throws IfcModelInterfaceException, ObjectAlreadyExistsException { IdEObjectImpl object = (IdEObjectImpl) eClass.getEPackage().getEFactoryInstance().create(eClass); long oid = oidProvider.newOid(eClass); ((IdEObjectImpl) object).setOid(oid); ((IdEObjectImpl) object).setLoadingState(State.LOADED); add(oid, object, false, false); return (T) object; }
private void fixOidsFlat(IdEObject idEObject, OidProvider oidProvider, BiMap<Long, IdEObject> temp) { if (idEObject == null) { return; } if (temp.containsValue(idEObject)) { return; } ((IdEObjectImpl) idEObject).setOid(oidProvider.newOid(idEObject.eClass())); if (objects.containsValue(idEObject)) { temp.put(idEObject.getOid(), idEObject); } }
@SuppressWarnings("rawtypes") private void fixOids(IdEObject idEObject, OidProvider oidProvider, BiMap<Long, IdEObject> temp) { if (idEObject == null) { return; } if (temp.containsValue(idEObject)) { return; } ((IdEObjectImpl) idEObject).setOid(oidProvider.newOid(idEObject.eClass())); if (objects.containsValue(idEObject)) { temp.put(idEObject.getOid(), idEObject); } for (EReference eReference : idEObject.eClass().getEAllReferences()) { Object val = idEObject.eGet(eReference); if (eReference.isMany()) { List list = (List) val; for (Object o : list) { fixOids((IdEObject) o, oidProvider, temp); } } else { fixOids((IdEObject) val, oidProvider, temp); } } }
if (newObject.getOid() == -1) { if (oidProvider != null) { oid = oidProvider.newOid(newObject.eClass()); } else { oid = original.getOid();
@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); } } }