Skip to content

Commit

Permalink
BaseQuantities und PropertySet Namen http://bitnami/issues/5598
Browse files Browse the repository at this point in the history
  • Loading branch information
WeltWeitBau committed Feb 8, 2022
1 parent 0ff32a2 commit 2328596
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 44 deletions.
2 changes: 1 addition & 1 deletion BimServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,56 +606,155 @@ private void includeProperties(HashMapVirtualObject object) throws BimserverData
* Added by WWB.
*
* Searches a PropertySet for properties to be included in the current HashMapVirtualObject
*
* @param databaseSession
* @param includedProperties
* @param ifcPropertySetDefinition
* @throws BimserverDatabaseException
*/
@SuppressWarnings("unchecked")
private void processPropertySet(DatabaseSession databaseSession, HashMap<String, String> includedProperties, Long ifcPropertySetDefinition) throws BimserverDatabaseException {
private void processPropertySet(DatabaseSession databaseSession, HashMap<String, String> includedProperties,
Long ifcPropertySetDefinition) throws BimserverDatabaseException {
Map<String, Set<String>> includeProperties = getQueryPart().getIncludeProperties();

Set<String> propertiesToIncludeAll = includeProperties.get("ALL");

EClass eClassForOid = databaseSession.getEClassForOid(ifcPropertySetDefinition);
if (getPackageMetaData().getEClass("IfcPropertySet").isSuperTypeOf(eClassForOid)) {
HashMapVirtualObject ifcPropertySet = getByOid(ifcPropertySetDefinition);
String propertySetName = (String) ifcPropertySet.get("Name");

Set<String> propertiesToInclude = includeProperties.get(propertySetName);

if(propertiesToInclude == null && propertiesToIncludeAll == null) {
return;
} else if(propertiesToInclude == null) {
propertiesToInclude = propertiesToIncludeAll;

HashMapVirtualObject ifcPropertySet = getByOid(ifcPropertySetDefinition);
if(ifcPropertySet.has("Name") == false) {
return;
}

String propertySetName = (String) ifcPropertySet.get("Name");
Set<String> propertiesToInclude = includeProperties.get(propertySetName);

if (propertiesToInclude == null && propertiesToIncludeAll == null) {
return;
} else if (propertiesToInclude == null) {
propertiesToInclude = propertiesToIncludeAll;
propertySetName = "ALL";
}

if (matchesType(eClassForOid, "IfcElementQuantity")) {
processQuantities(databaseSession, includedProperties, ifcPropertySet, propertySetName, propertiesToInclude);
return;
}

if (matchesType(eClassForOid, "IfcPropertySet") == false) {
return;
}

List<Long> properties = (List<Long>) ifcPropertySet.get("HasProperties");
for (long propertyOid : properties) {
eClassForOid = databaseSession.getEClassForOid(propertyOid);
if (matchesType(eClassForOid, "IfcPropertySingleValue") == false) {
LOGGER.info("processPropertySet: Type not supported! - " + eClassForOid.getName());
continue;
}

List<Long> properties = (List<Long>) ifcPropertySet.get("HasProperties");
for (long propertyOid : properties) {
if (getPackageMetaData().getEClass("IfcPropertySingleValue").isSuperTypeOf(databaseSession.getEClassForOid(propertyOid)) == false) {
continue;
}
HashMapVirtualObject property = getByOid(propertyOid);
String name = (String) property.get("Name");
HashMapVirtualObject property = getByOid(propertyOid);
includePropertySingleValue(property, propertySetName, propertiesToInclude, includedProperties);
}
}

/**
* Added by WWB.
*
* add a IfcPropertySingleValue to the included properties
*
* @param property
* @param propertySetName
* @param propertiesToInclude
* @param includedProperties
*/
private void includePropertySingleValue(HashMapVirtualObject property, String propertySetName, Set<String> propertiesToInclude, HashMap<String, String> includedProperties) {
String name = (String) property.get("Name");

if (propertiesToInclude.contains(name) == false) {
continue;
}
if (propertiesToInclude.contains(name) == false) {
return;
}

HashMapWrappedVirtualObject value = (HashMapWrappedVirtualObject) property.get("NominalValue");

if(value == null) {
continue;
}
HashMapWrappedVirtualObject value = (HashMapWrappedVirtualObject) property.get("NominalValue");

Object wrappedValue = value.eGet(value.eClass().getEStructuralFeature("wrappedValue"));
if (value.eClass().getName().equals("IfcBoolean")) {
Enumerator tristate = (Enumerator) wrappedValue;
includedProperties.put(name, tristate.getName().toLowerCase());
} else {
includedProperties.put(name, wrappedValue.toString());
}
if (value == null) {
return;
}

Object wrappedValue = value.eGet(value.eClass().getEStructuralFeature("wrappedValue"));
if (value.eClass().getName().equals("IfcBoolean")) {
Enumerator tristate = (Enumerator) wrappedValue;
includedProperties.put(propertySetName + ":" + name, tristate.getName().toLowerCase());
} else {
includedProperties.put(propertySetName + ":" + name, wrappedValue.toString());
}
}

/**
* Added by WWB.
*
* Searches a Quantity Set for quantities to be included in the current HashMapVirtualObject
*
* @param databaseSession
* @param includedProperties
* @param ifcQuantities
* @param quantitySetName
* @param propertiesToInclude
* @throws BimserverDatabaseException
*/
@SuppressWarnings("unchecked")
private void processQuantities(DatabaseSession databaseSession, HashMap<String, String> includedProperties,
HashMapVirtualObject ifcQuantities, String quantitySetName, Set<String> propertiesToInclude)
throws BimserverDatabaseException {
EClass eClassForOid = null;
List<Long> quantities = (List<Long>) ifcQuantities.get("Quantities");
for (long quantityOid : quantities) {
eClassForOid = databaseSession.getEClassForOid(quantityOid);
if (matchesType(eClassForOid, "IfcPhysicalQuantity") == false) {
LOGGER.info("processQuantities: Type not supported! - " + eClassForOid.getName());
continue;
}

HashMapVirtualObject quantity = getByOid(quantityOid);
includeQuantity(quantity, quantitySetName, propertiesToInclude, includedProperties);
}
}

/**
* Added by WWB.
*
* add a IfcPhysicalQuantity value to the included properties
*
* @param quantity
* @param quantitySetName
* @param propertiesToInclude
* @param includedProperties
*/
private void includeQuantity(HashMapVirtualObject quantity, String quantitySetName, Set<String> propertiesToInclude, HashMap<String, String> includedProperties) {
String name = (String) quantity.get("Name");

if (propertiesToInclude.contains(name) == false) {
return;
}

String strQuantityType = quantity.eClass().getName().replace("IfcQuantity", "");
Object value = quantity.get(strQuantityType + "Value");

if (value == null) {
return;
}

includedProperties.put(quantitySetName + ":" + name, value.toString());
}

/**
* Added by WWB.
*
* is subClass the same or a child of strSuper?
*
* @param subClass
* @param strSuper
* @return true if subClass inherits from strSuper or is the same as strSuper
*/
private boolean matchesType(EClass subClass, String strSuper) {
return getPackageMetaData().getEClass(strSuper).isSuperTypeOf(subClass);
}
}
2 changes: 1 addition & 1 deletion BimServerClientLib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<properties>
<jetty.version>9.4.19.v20190610</jetty.version>
Expand Down
2 changes: 1 addition & 1 deletion BimServerJar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<properties>
<jetty.version>9.4.19.v20190610</jetty.version>
Expand Down
2 changes: 1 addition & 1 deletion BimServerWar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
2 changes: 1 addition & 1 deletion PluginBase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
2 changes: 1 addition & 1 deletion Shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
4 changes: 2 additions & 2 deletions Tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>de.weltweitbau</groupId>
<artifactId>bimserverjar</artifactId>
<version>1.0.0</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.weltweitbau</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<packaging>pom</packaging>
<description>This is the parent pom, no idea why this is being released</description>
<properties>
Expand Down

0 comments on commit 2328596

Please sign in to comment.