Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query with property conditions for entities that do not have property sets assigned #1278

Open
hlg opened this issue Oct 20, 2022 · 1 comment

Comments

@hlg
Copy link
Member

hlg commented Oct 20, 2022

Queries with property conditions will ignore the condition for entities that do not have any property sets assigned. I don't think that is the semantics we want - not 100% sure though.

For example, the following query will include walls without property sets in the result:

{
  "type": {
    "name": "IfcWall",
    "includeAllSubTypes": true
  },
  "properties": {
    "Pset_WallCommon": {
      "IsExternal": false
    }
  }
}
@hlg hlg changed the title Query with property conditions for objects that do not have property sets assigned Query with property conditions for entities that do not have property sets assigned Oct 20, 2022
@hlg
Copy link
Member Author

hlg commented Aug 28, 2024

In the following piece of code, lines 113 and 137-140 should go outside (before and after) the if-condition to have currentObject set to null when there are no property sets at all for the current object, but at least one property condition in the query.

List<Long> isDefinedByOids = (List<Long>) currentObject.get("IsDefinedBy");
int totalQueryProperties = 0;
for (String key : this.properties.keySet()) {
totalQueryProperties += this.properties.get(key).count();
}
if (isDefinedByOids != null) {
Set<String> propertyKeysMatched = new HashSet<>();
for (Long definedByOid : isDefinedByOids) {
EClass eClass = databaseSession.getEClassForOid(definedByOid);
if (getPackageMetaData().getEClass("IfcRelDefinesByProperties").isSuperTypeOf(eClass)) {
HashMapVirtualObject ifcRelDefinesByProperties = getByOid(definedByOid);
Long ifcPropertySetDefinition = (Long) ifcRelDefinesByProperties.get("RelatingPropertyDefinition");
processPropertySet(databaseSession, propertyKeysMatched, ifcPropertySetDefinition);
} else if (getPackageMetaData().getEClass("IfcRelDefinesByType").isSuperTypeOf(eClass)){
HashMapVirtualObject ifcRelDefinesByType = getByOid(definedByOid);
Long relatingTypeId = (Long) ifcRelDefinesByType.get("RelatingType");
EClass eClassForOid = databaseSession.getEClassForOid(relatingTypeId);
if (getPackageMetaData().getEClass("IfcTypeObject").isSuperTypeOf(eClassForOid)) {
HashMapVirtualObject ifcTypeObject = getByOid(relatingTypeId);
List<Long> propertySets = (List<Long>) ifcTypeObject.get("HasPropertySets");
if (propertySets != null) {
for (Long propertySetId : propertySets) {
processPropertySet(databaseSession, propertyKeysMatched, propertySetId);
}
}
}
} else {
LOGGER.info(eClass.getName());
}
}
if (propertyKeysMatched.size() != totalQueryProperties) {
// All properties should have matched, atm all properties provided in the query are evaluated as AND
currentObject = null;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant