Search in sources :

Example 1 with Properties

use of org.bimserver.database.queries.om.Properties in project BIMserver by opensourceBIM.

the class QueryPropertiesAndTypesStackFrame method processPropertySet.

@SuppressWarnings("unchecked")
private void processPropertySet(DatabaseSession databaseSession, Set<String> propertyKeysMatched, Long ifcPropertySetDefinition) throws BimserverDatabaseException {
    EClass eClassForOid = databaseSession.getEClassForOid(ifcPropertySetDefinition);
    if (getPackageMetaData().getEClass("IfcPropertySet").isSuperTypeOf(eClassForOid)) {
        HashMapVirtualObject ifcPropertySet = getByOid(ifcPropertySetDefinition);
        String propertySetName = (String) ifcPropertySet.get("Name");
        Properties propertiesObject = (Properties) properties.get(propertySetName);
        if (propertiesObject != null) {
            List<Long> properties = (List<Long>) ifcPropertySet.get("HasProperties");
            for (long propertyOid : properties) {
                if (getPackageMetaData().getEClass("IfcPropertySingleValue").isSuperTypeOf(databaseSession.getEClassForOid(propertyOid))) {
                    HashMapVirtualObject property = getByOid(propertyOid);
                    String name = (String) property.get("Name");
                    HashMapWrappedVirtualObject value = (HashMapWrappedVirtualObject) property.get("NominalValue");
                    if (propertiesObject.has(name)) {
                        Object queryPropertyValue = propertiesObject.get(name);
                        Object wrappedValue = value.eGet(value.eClass().getEStructuralFeature("wrappedValue"));
                        if (value.eClass().getName().equals("IfcBoolean")) {
                            Enumerator tristate = (Enumerator) wrappedValue;
                            if (tristate.getName().toLowerCase().equals(queryPropertyValue.toString())) {
                                propertyKeysMatched.add(propertySetName + "___" + name);
                            }
                        } else if (wrappedValue.equals(queryPropertyValue)) {
                            propertyKeysMatched.add(propertySetName + "___" + name);
                        }
                    }
                }
            }
        }
    } else if (getPackageMetaData().getEClass("IfcPropertySetDefinition").isSuperTypeOf(eClassForOid)) {
        HashMapVirtualObject ifcPropertySet = getByOid(ifcPropertySetDefinition);
        Properties propertiesObject = (Properties) properties.get(ifcPropertySet.eClass().getName());
        if (propertiesObject != null) {
            for (String key : propertiesObject.keys()) {
                if (ifcPropertySet.has(key)) {
                    if (ifcPropertySet.get(key).toString().equals(propertiesObject.get(key))) {
                        propertyKeysMatched.add(ifcPropertySet.eClass().getName() + "___" + key);
                    }
                }
            }
        }
    } else {
        LOGGER.info(eClassForOid.getName());
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) Enumerator(org.eclipse.emf.common.util.Enumerator) List(java.util.List) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) Properties(org.bimserver.database.queries.om.Properties)

Aggregations

List (java.util.List)1 Properties (org.bimserver.database.queries.om.Properties)1 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)1 HashMapWrappedVirtualObject (org.bimserver.shared.HashMapWrappedVirtualObject)1 Enumerator (org.eclipse.emf.common.util.Enumerator)1 EClass (org.eclipse.emf.ecore.EClass)1