public void read(BridgeRoom room, long parentId) throws SQLException {
    ResultSet rs = null;

    try {
      psBridgeRoomInstallation.setLong(1, parentId);
      rs = psBridgeRoomInstallation.executeQuery();

      while (rs.next()) {
        long installationId = rs.getLong(1);

        int classId = rs.getInt(2);
        if (rs.wasNull()
            || classId == 0
            || Util.classId2cityObject(classId) != CityGMLClass.INT_BRIDGE_INSTALLATION) continue;

        IntBridgeInstallation intBridgeInstallation = new IntBridgeInstallation();

        String clazz = rs.getString(3);
        if (clazz != null) {
          Code code = new Code(clazz);
          code.setCodeSpace(rs.getString(4));
          intBridgeInstallation.setClazz(code);
        }

        String function = rs.getString(5);
        String functionCodeSpace = rs.getString(6);
        if (function != null)
          intBridgeInstallation.setFunction(Util.string2codeList(function, functionCodeSpace));

        String usage = rs.getString(7);
        String usageCodeSpace = rs.getString(8);
        if (usage != null)
          intBridgeInstallation.setUsage(Util.string2codeList(usage, usageCodeSpace));

        // boundarySurface
        // geometry objects of _BoundarySurface elements have to be referenced by lod4Geometry
        // So we first export all _BoundarySurfaces
        thematicSurfaceExporter.read(intBridgeInstallation, installationId);

        // geometry
        long surfaceGeometryId = rs.getLong(11);
        Object geomObj = rs.getObject(14);
        if (surfaceGeometryId != 0 || geomObj != null) {
          GeometryProperty<AbstractGeometry> geometryProperty = null;
          if (surfaceGeometryId != 0) {
            DBSurfaceGeometryResult geometry = surfaceGeometryExporter.read(surfaceGeometryId);
            if (geometry != null) {
              geometryProperty = new GeometryProperty<AbstractGeometry>();
              if (geometry.getAbstractGeometry() != null)
                geometryProperty.setGeometry(geometry.getAbstractGeometry());
              else geometryProperty.setHref(geometry.getTarget());
            }
          } else {
            GeometryObject geometry =
                dbExporterManager.getDatabaseAdapter().getGeometryConverter().getGeometry(geomObj);
            if (geometry != null) {
              geometryProperty = new GeometryProperty<AbstractGeometry>();
              geometryProperty.setGeometry(
                  geometryExporter.getPointOrCurveGeometry(geometry, true));
            }
          }

          if (geometryProperty != null) intBridgeInstallation.setLod4Geometry(geometryProperty);
        }

        // implicit geometry
        long implicitGeometryId = rs.getLong(17);
        if (implicitGeometryId != 0) {
          GeometryObject referencePoint = null;
          Object referencePointObj = rs.getObject(20);
          if (!rs.wasNull() && referencePointObj != null)
            referencePoint =
                dbExporterManager
                    .getDatabaseAdapter()
                    .getGeometryConverter()
                    .getPoint(referencePointObj);

          String transformationMatrix = rs.getString(23);

          ImplicitGeometry implicit =
              implicitGeometryExporter.read(
                  implicitGeometryId, referencePoint, transformationMatrix);
          if (implicit != null) {
            ImplicitRepresentationProperty implicitProperty = new ImplicitRepresentationProperty();
            implicitProperty.setObject(implicit);
            intBridgeInstallation.setLod4ImplicitRepresentation(implicitProperty);
          }
        }

        cityObjectReader.read(intBridgeInstallation, installationId);

        IntBridgeInstallationProperty intInstProp = new IntBridgeInstallationProperty();
        intInstProp.setObject(intBridgeInstallation);
        room.addBridgeRoomInstallation(intInstProp);
      }
    } finally {
      if (rs != null) rs.close();
    }
  }
 private Code createName(String value) {
   Code code = new Code();
   code.setValue(value);
   return code;
 }
  public void read(AbstractBridge bridge, long parentId, ProjectionPropertyFilter projectionFilter)
      throws SQLException {
    ResultSet rs = null;

    try {
      psBridgeInstallation.setLong(1, parentId);
      rs = psBridgeInstallation.executeQuery();

      while (rs.next()) {
        long installationId = rs.getLong(1);

        int classId = rs.getInt(2);
        if (rs.wasNull() || classId == 0) continue;

        BridgeInstallation bridgeInstallation = null;
        IntBridgeInstallation intBridgeInstallation = null;

        CityGMLClass type = Util.classId2cityObject(classId);
        switch (type) {
          case BRIDGE_INSTALLATION:
            if (projectionFilter.pass(CityGMLModuleType.BRIDGE, "outerBridgeInstallation"))
              bridgeInstallation = new BridgeInstallation();
            break;
          case INT_BRIDGE_INSTALLATION:
            if (projectionFilter.pass(CityGMLModuleType.BRIDGE, "interiorBridgeInstallation"))
              intBridgeInstallation = new IntBridgeInstallation();
            break;
          default:
            continue;
        }

        if (bridgeInstallation == null && intBridgeInstallation == null) return;

        String clazz = rs.getString(3);
        if (clazz != null) {
          Code code = new Code(clazz);
          code.setCodeSpace(rs.getString(4));
          if (bridgeInstallation != null) bridgeInstallation.setClazz(code);
          else intBridgeInstallation.setClazz(code);
        }

        String function = rs.getString(5);
        String functionCodeSpace = rs.getString(6);
        if (function != null) {
          if (bridgeInstallation != null)
            bridgeInstallation.setFunction(Util.string2codeList(function, functionCodeSpace));
          else intBridgeInstallation.setFunction(Util.string2codeList(function, functionCodeSpace));
        }

        String usage = rs.getString(7);
        String usageCodeSpace = rs.getString(8);
        if (usage != null) {
          if (bridgeInstallation != null)
            bridgeInstallation.setUsage(Util.string2codeList(usage, usageCodeSpace));
          else intBridgeInstallation.setUsage(Util.string2codeList(usage, usageCodeSpace));
        }

        // boundarySurface
        // geometry objects of _BoundarySurface elements have to be referenced by lodXGeometry
        // So we first export all _BoundarySurfaces
        if (bridgeInstallation != null)
          thematicSurfaceExporter.read(bridgeInstallation, installationId);
        else thematicSurfaceExporter.read(intBridgeInstallation, installationId);

        // geometry
        for (int lod = 0; lod < 3; lod++) {
          long surfaceGeometryId = rs.getLong(9 + lod);
          Object geomObj = rs.getObject(12 + lod);
          if (surfaceGeometryId == 0 && geomObj == null) continue;

          GeometryProperty<AbstractGeometry> geometryProperty = null;

          if (surfaceGeometryId != 0) {
            DBSurfaceGeometryResult geometry = surfaceGeometryExporter.read(surfaceGeometryId);
            if (geometry != null) {
              geometryProperty = new GeometryProperty<AbstractGeometry>();
              if (geometry.getAbstractGeometry() != null)
                geometryProperty.setGeometry(geometry.getAbstractGeometry());
              else geometryProperty.setHref(geometry.getTarget());
            }
          } else {
            GeometryObject geometry =
                dbExporterManager.getDatabaseAdapter().getGeometryConverter().getGeometry(geomObj);
            if (geometry != null) {
              geometryProperty = new GeometryProperty<AbstractGeometry>();
              geometryProperty.setGeometry(
                  geometryExporter.getPointOrCurveGeometry(geometry, true));
            }
          }

          if (geometryProperty != null) {
            switch (lod) {
              case 0:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod2Geometry(geometryProperty);
                break;
              case 1:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod3Geometry(geometryProperty);
                break;
              case 2:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod4Geometry(geometryProperty);
                else intBridgeInstallation.setLod4Geometry(geometryProperty);
                break;
            }
          }
        }

        // implicit geometry
        for (int lod = 0; lod < 3; lod++) {
          long implicitGeometryId = rs.getLong(15 + lod);
          if (rs.wasNull()) continue;

          GeometryObject referencePoint = null;
          Object referencePointObj = rs.getObject(18 + lod);
          if (!rs.wasNull() && referencePointObj != null)
            referencePoint =
                dbExporterManager
                    .getDatabaseAdapter()
                    .getGeometryConverter()
                    .getPoint(referencePointObj);

          String transformationMatrix = rs.getString(21 + lod);

          ImplicitGeometry implicit =
              implicitGeometryExporter.read(
                  implicitGeometryId, referencePoint, transformationMatrix);
          if (implicit != null) {
            ImplicitRepresentationProperty implicitProperty = new ImplicitRepresentationProperty();
            implicitProperty.setObject(implicit);

            switch (lod) {
              case 0:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod2ImplicitRepresentation(implicitProperty);
                break;
              case 1:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod3ImplicitRepresentation(implicitProperty);
                break;
              case 2:
                if (bridgeInstallation != null)
                  bridgeInstallation.setLod4ImplicitRepresentation(implicitProperty);
                else intBridgeInstallation.setLod4ImplicitRepresentation(implicitProperty);
                break;
            }
          }
        }

        if (bridgeInstallation != null) {
          cityObjectReader.read(bridgeInstallation, installationId);

          BridgeInstallationProperty bridgeInstProp = new BridgeInstallationProperty();
          bridgeInstProp.setObject(bridgeInstallation);
          bridge.addOuterBridgeInstallation(bridgeInstProp);
        } else {
          cityObjectReader.read(intBridgeInstallation, installationId);

          IntBridgeInstallationProperty intInstProp = new IntBridgeInstallationProperty();
          intInstProp.setObject(intBridgeInstallation);
          bridge.addInteriorBridgeInstallation(intInstProp);
        }
      }
    } finally {
      if (rs != null) rs.close();
    }
  }