public CompareResult compare(
     IfcModelInterface model1, IfcModelInterface model2, CompareType compareType)
     throws ModelCompareException {
   CompareResult result = StoreFactory.eINSTANCE.createCompareResult();
   try {
     for (EClassifier eClassifier : Ifc2x3tc1Package.eINSTANCE.getEClassifiers()) {
       if (eClassifier instanceof EClass
           && Ifc2x3tc1Package.eINSTANCE.getIfcRoot().isSuperTypeOf((EClass) eClassifier)) {
         EClass eClass = (EClass) eClassifier;
         for (IdEObject i : model1.getValues()) {
           if (i instanceof IfcWindow) {
             IfcWindow window = (IfcWindow) i;
             for (EStructuralFeature feature : window.eClass().getEStructuralFeatures()) {
               window.eGet(feature);
             }
           }
         }
         for (String guid : model1.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject2 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.DELETE) {
               ObjectRemoved objectRemoved = StoreFactory.eINSTANCE.createObjectRemoved();
               objectRemoved.setDataObject(makeDataObject(eObject1));
               getCompareContainer(eObject1.eClass()).getItems().add(objectRemoved);
             }
           }
         }
         for (String guid : model2.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject1 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.ADD) {
               ObjectAdded objectAdded = StoreFactory.eINSTANCE.createObjectAdded();
               objectAdded.setDataObject(makeDataObject(eObject2));
               getCompareContainer(eObject2.eClass()).getItems().add(objectAdded);
             }
           } else {
             compareEObjects(eClass, eObject1, eObject2, result, compareType);
           }
         }
       }
     }
   } catch (Exception e) {
     throw new ModelCompareException(e);
   }
   for (CompareContainer compareContainer : getMap().values()) {
     result.getItems().add(compareContainer);
   }
   return result;
 }
 private Window createWindow(IfcWindow ifcWindow) throws SerializerException {
   Window window = new Window();
   setName(window.getName(), ifcWindow.getName());
   setGlobalId(window, ifcWindow);
   MultiSurfaceProperty windowMSP = new MultiSurfaceProperty();
   MultiSurface windowMs = new MultiSurface();
   windowMSP.setMultiSurface(windowMs);
   window.setLod4MultiSurface(windowMSP);
   setGeometry(windowMs, ifcWindow);
   DoubleAttribute genericAttributeWidth = new DoubleAttribute();
   genericAttributeWidth.setValue((double) ifcWindow.getOverallWidth());
   genericAttributeWidth.setName("OverallWidth");
   window.addGenericAttribute(genericAttributeWidth);
   DoubleAttribute genericAttributeHeight = new DoubleAttribute();
   genericAttributeHeight.setValue((double) ifcWindow.getOverallHeight());
   genericAttributeHeight.setName("OverallHeight");
   window.addGenericAttribute(genericAttributeHeight);
   return window;
 }
 private void createProperty(
     IfcWindow window, IfcModelInterface model, String name, String description, Object value)
     throws IfcModelInterfaceException {
   IfcRelDefinesByProperties ifcRelDefinesByProperties =
       model.create(IfcRelDefinesByProperties.class);
   window.getIsDefinedBy().add(ifcRelDefinesByProperties);
   IfcPropertySet propertySet = model.create(IfcPropertySet.class);
   ifcRelDefinesByProperties.setRelatingPropertyDefinition(propertySet);
   IfcPropertySingleValue property = model.create(IfcPropertySingleValue.class);
   propertySet.getHasProperties().add(property);
   property.setName(name);
   property.setDescription(description);
   if (value instanceof Boolean) {
     IfcBoolean ifcValue = model.create(IfcBoolean.class);
     ifcValue.setWrappedValue(((Boolean) value) ? Tristate.TRUE : Tristate.FALSE);
     property.setNominalValue(ifcValue);
   } else {
     // Unimplemented
   }
 }
  @Test
  public void test() {
    try {
      // New client
      BimServerClientInterface bimServerClient =
          getFactory()
              .create(new UsernamePasswordAuthenticationInfo("*****@*****.**", "admin"));

      // Create a project
      SProject project =
          bimServerClient
              .getBimsie1ServiceInterface()
              .addProject("test" + Math.random(), "ifc2x3tc1");

      // Look for a deserializer
      SDeserializerPluginConfiguration deserializer =
          bimServerClient
              .getBimsie1ServiceInterface()
              .getSuggestedDeserializerForExtension("ifc", project.getOid());

      bimServerClient.checkin(
          project.getOid(),
          "test",
          deserializer.getOid(),
          false,
          true,
          new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));

      // Refresh project
      project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid());

      // Load model without lazy loading (complete model at once)
      IfcModelInterface model =
          bimServerClient.getModel(project, project.getLastRevisionId(), true, false);

      String propertyName = "BooleanProperty";

      int nrWindowsFirst = 0;
      // Iterate over all projects, there should be 1
      for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
        nrWindowsFirst++;
        createProperty(window, model, propertyName, "Description of property", true);
      }

      model.commit("Added boolean properties to " + nrWindowsFirst + " windows");

      project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid());
      model = bimServerClient.getModel(project, project.getLastRevisionId(), true, false);
      int foundOke = 0;
      int nrWindowsSecond = 0;
      Set<Long> counted = new HashSet<Long>();
      for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
        nrWindowsSecond++;
        for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
          if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
            IfcRelDefinesByProperties ifcRelDefinesByProperties =
                (IfcRelDefinesByProperties) ifcRelDefines;
            IfcPropertySetDefinition relatingPropertyDefinition =
                ifcRelDefinesByProperties.getRelatingPropertyDefinition();
            if (relatingPropertyDefinition instanceof IfcPropertySet) {
              IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
              for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
                if (ifcProperty instanceof IfcPropertySingleValue) {
                  IfcPropertySingleValue ifcPropertySingleValue =
                      (IfcPropertySingleValue) ifcProperty;
                  if (ifcPropertySingleValue.getName().equals(propertyName)) {
                    IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
                    if (nominalValue instanceof IfcBoolean) {
                      if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
                        if (!counted.contains(ifcPropertySingleValue.getOid())) {
                          foundOke++;
                          counted.add(ifcPropertySingleValue.getOid());
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      LOGGER.info("Windows first: " + nrWindowsFirst);
      LOGGER.info("Windows second: " + nrWindowsSecond);
      LOGGER.info("Found Oke: " + foundOke);
      if (foundOke != nrWindowsFirst) {
        fail(foundOke + " / " + nrWindowsFirst);
      }
    } catch (Throwable e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }