private void setGlobalId(AbstractCityObject cityObject, IfcRoot ifcRoot) {
   if (ifcRoot != null && ifcRoot.getGlobalId() != null && ifcRoot.getGlobalId() != null) {
     GlobalIdType globalId = new GlobalIdType();
     globalId.setValue(ifcRoot.getGlobalId());
     for (Element element : globalId.get_ADEComponent()) {
       ADEComponent adeComponent = new ADEComponent(element);
       cityObject.addGenericApplicationPropertyOfCityObject(adeComponent);
     }
   }
 }
  public void read(AbstractCityObject cityObject, long cityObjectId, HashSet<Long> generalizesToSet)
      throws SQLException {
    for (Long generalizationId : generalizesToSet) {
      ResultSet rs = null;

      try {
        psGeneralization.setLong(1, generalizationId);
        rs = psGeneralization.executeQuery();

        if (rs.next()) {
          String gmlId = rs.getString("GMLID");
          if (rs.wasNull() || gmlId == null) continue;

          int classId = rs.getInt("CLASS_ID");
          CityGMLClass type = Util.classId2cityObject(classId);
          PGgeometry pgGeom = (PGgeometry) rs.getObject("ENVELOPE");

          if (!rs.wasNull() && pgGeom != null && boundingBoxFilter.isActive()) {
            Geometry geom = pgGeom.getGeometry();
            Envelope env = new EnvelopeImpl();

            Point lower =
                new Point(geom.getFirstPoint().x, geom.getFirstPoint().y, geom.getFirstPoint().z);
            Point upper = new Point(geom.getPoint(2).x, geom.getPoint(2).y, geom.getPoint(2).z);

            env.setLowerCorner(lower);
            env.setUpperCorner(upper);

            if (boundingBoxFilter.filter(env)) continue;
          }

          if (featureGmlIdFilter.isActive() && featureGmlIdFilter.filter(gmlId)) continue;

          if (featureClassFilter.isActive() && featureClassFilter.filter(type)) continue;

          if (featureGmlNameFilter.isActive()) {
            // we need to get the gml:name of the feature
            // we only check top-level features
            TableEnum table = null;

            switch (type) {
              case BUILDING:
                table = TableEnum.BUILDING;
                break;
              case CITY_FURNITURE:
                table = TableEnum.CITY_FURNITURE;
                break;
              case LAND_USE:
                table = TableEnum.LAND_USE;
                break;
              case WATER_BODY:
                table = TableEnum.WATERBODY;
                break;
              case PLANT_COVER:
                table = TableEnum.SOLITARY_VEGETAT_OBJECT;
                break;
              case SOLITARY_VEGETATION_OBJECT:
                table = TableEnum.PLANT_COVER;
                break;
              case TRANSPORTATION_COMPLEX:
              case ROAD:
              case RAILWAY:
              case TRACK:
              case SQUARE:
                table = TableEnum.TRANSPORTATION_COMPLEX;
                break;
              case RELIEF_FEATURE:
                table = TableEnum.RELIEF_FEATURE;
                break;
              case GENERIC_CITY_OBJECT:
                table = TableEnum.GENERIC_CITYOBJECT;
                break;
              case CITY_OBJECT_GROUP:
                table = TableEnum.CITYOBJECTGROUP;
                break;
            }

            if (table != null) {
              Statement stmt = null;
              ResultSet nameRs = null;

              try {
                String query =
                    "select NAME from " + table.toString() + " where ID=" + generalizationId;
                stmt = connection.createStatement();

                nameRs = stmt.executeQuery(query);
                if (nameRs.next()) {
                  String gmlName = nameRs.getString("NAME");
                  if (gmlName != null && featureGmlNameFilter.filter(gmlName)) continue;
                }

              } catch (SQLException sqlEx) {
                continue;
              } finally {
                if (nameRs != null) {
                  try {
                    nameRs.close();
                  } catch (SQLException sqlEx) {
                    //
                  }

                  nameRs = null;
                }

                if (stmt != null) {
                  try {
                    stmt.close();
                  } catch (SQLException sqlEx) {
                    //
                  }

                  stmt = null;
                }
              }
            }
          }

          GeneralizationRelation generalizesTo = new GeneralizationRelationImpl();
          generalizesTo.setHref("#" + gmlId);
          cityObject.addGeneralizesTo(generalizesTo);
        }
      } finally {
        if (rs != null) rs.close();
      }
    }
  }