public <T extends IdEObject> T create(Class<T> clazz) throws IfcModelInterfaceException { T object = model.create(clazz); if (object instanceof IfcRoot) { ((IfcRoot)object).setGlobalId(GuidCompressor.getNewIfcGloballyUniqueId()); if (defaultOwnerHistory != null) { ((IfcRoot)object).setOwnerHistory(defaultOwnerHistory); } } if (addOnCreate) { model.add(object.getOid(), object); } return object; }
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); } } } }