Commit b0d4a3f9 authored by Rushikesh Padsala's avatar Rushikesh Padsala
Browse files

support for importing-exporting CityObjectRelation

parent d88e3a9c
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="liberica-17" project-jdk-type="JavaSDK" /> <component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
<file type="web" url="file://$PROJECT_DIR$/../energy-ade-3-citygml4j" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="liberica-17" project-jdk-type="JavaSDK" />
</project> </project>
\ No newline at end of file
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../energy-ade-3-citygml4j" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -12,7 +12,7 @@ Currently, there are _no plans to migrate_ the Energy ADE 3 importer-exporter AP ...@@ -12,7 +12,7 @@ Currently, there are _no plans to migrate_ the Energy ADE 3 importer-exporter AP
The following modules are supported at the moment: The following modules are supported at the moment:
- Core (AbstractBuilding, RefurbishmentMeasures, WeatherData) - Core (AbstractBuilding, RefurbishmentMeasures, WeatherData, CityObjectRelation)
- Resource - Resource
- UrbanFunctionArea - UrbanFunctionArea
- WeatherStation - WeatherStation
......
...@@ -8,8 +8,8 @@ plugins { ...@@ -8,8 +8,8 @@ plugins {
} }
group = 'de.stuttgart.hft' group = 'de.stuttgart.hft'
version = 'beta7-0.3' version = 'beta7-0.4'
description 'Energy ADE 3 (beta 7) extension for the 3DCityDB - release 0.3' description 'Energy ADE 3 (beta 7) extension for the 3DCityDB - release 0.4'
repositories { repositories {
maven { maven {
......
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--
-- CityGML Energy ADE 3.0 (beta 7)
--
-- Last update: 2025-10-14
--
-- This DDL script uninstalls the 3DCityDB schema for the Energy ADE. It must be run
-- from within the ADE Manager plugin of the 3DCityDB Importer/Exporter.
--
-- This script was first automatically generated using the 3DCityDB ADE Manager
-- and successively edited and restructured by:
--
-- Dr. Giorgio Agugiaro
-- 3D Geoinformation group
-- Delft University of Technology
-- The Netherlands
--
-- https://3d.bk.tudelft.nl/gagugiaro/
--
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- ******************************* DROP_ADE_DB.SQL execution START ************************
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- *********************************** Drop foreign keys **********************************
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ALTER TABLE ng3_address_to_building_unit DROP CONSTRAINT ng3_addr_to_bdgu_fk1;
ALTER TABLE ng3_address_to_building_unit DROP CONSTRAINT ng3_addr_to_bdgu_fk2;
ALTER TABLE ng3_building DROP CONSTRAINT ng3_bdg_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_bdg_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_lod1_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_lod2_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_lod3_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_oc_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_sched_fk1;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_sched_fk2;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_sched_fk3;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_tz_fk;
ALTER TABLE ng3_building_partition DROP CONSTRAINT ng3_bdgp_uz_fk;
ALTER TABLE ng3_cityobject DROP CONSTRAINT ng3_cto_fk;
ALTER TABLE ng3_cityobject DROP CONSTRAINT ng3_cto_lcns_fk;
ALTER TABLE ng3_ctyobj_relation DROP CONSTRAINT ng3_cto_rel_fk1;
ALTER TABLE ng3_ctyobj_relation DROP CONSTRAINT ng3_cto_rel_fk2;
ALTER TABLE ng3_device DROP CONSTRAINT ng3_dev_fk;
ALTER TABLE ng3_device DROP CONSTRAINT ng3_dev_ng3_cto_fk;
ALTER TABLE ng3_device DROP CONSTRAINT ng3_dev_oc_fk;
ALTER TABLE ng3_device DROP CONSTRAINT ng3_dev_opt_fk;
ALTER TABLE ng3_device_operation DROP CONSTRAINT ng3_dev_opr_fk;
ALTER TABLE ng3_device_operation DROP CONSTRAINT ng3_dev_opr_dev_fk;
ALTER TABLE ng3_device_operation DROP CONSTRAINT ng3_dev_opr_sched_fk;
ALTER TABLE ng3_energy_perf_cert DROP CONSTRAINT ng3_epc_fk;
ALTER TABLE ng3_energy_perf_cert DROP CONSTRAINT ng3_epc_bdg_fk;
ALTER TABLE ng3_energy_perf_cert DROP CONSTRAINT ng3_epc_bdg_part_fk;
ALTER TABLE ng3_layer DROP CONSTRAINT ng3_lyr_fk;
ALTER TABLE ng3_layer DROP CONSTRAINT ng3_lyr_lcns_fk;
ALTER TABLE ng3_layer DROP CONSTRAINT ng3_lyr_mat_fk;
ALTER TABLE ng3_layered_construction DROP CONSTRAINT ng3_lcns_fk;
ALTER TABLE ng3_layered_construction DROP CONSTRAINT ng3_lcns_lcns_fk;
ALTER TABLE ng3_layered_construction DROP CONSTRAINT ng3_lcns_oc_fk;
ALTER TABLE ng3_layered_construction DROP CONSTRAINT ng3_lcns_lib_fk;
ALTER TABLE ng3_library DROP CONSTRAINT ng3_lib_fk;
ALTER TABLE ng3_library DROP CONSTRAINT ng3_lib_oc_fk;
ALTER TABLE ng3_material DROP CONSTRAINT ng3_mat_fk;
ALTER TABLE ng3_material DROP CONSTRAINT ng3_mat_lib_fk;
ALTER TABLE ng3_occupants DROP CONSTRAINT ng3_occ_fk;
ALTER TABLE ng3_occupants DROP CONSTRAINT ng3_occ_ng3_bdgp_fk;
ALTER TABLE ng3_occupants DROP CONSTRAINT ng3_occ_sched_fk;
ALTER TABLE ng3_opening DROP CONSTRAINT ng3_opn_fk;
ALTER TABLE ng3_optical_property DROP CONSTRAINT ng3_optpty_lcns_fk;
ALTER TABLE ng3_optical_property DROP CONSTRAINT ng3_optpty_oc_fk;
ALTER TABLE ng3_qualified_attribute DROP CONSTRAINT ng3_qatt_oc_fk;
ALTER TABLE ng3_qualified_attribute DROP CONSTRAINT ng3_qatt_bdg_fk;
ALTER TABLE ng3_qualified_attribute DROP CONSTRAINT ng3_qatt_bdg_part_fk;
ALTER TABLE ng3_refurbishment_measure DROP CONSTRAINT ng3_refurb_fk;
ALTER TABLE ng3_refurbishment_measure DROP CONSTRAINT ng3_refurb_bdg_fk;
ALTER TABLE ng3_refurbishment_measure DROP CONSTRAINT ng3_refurb_bdg_part_fk;
ALTER TABLE ng3_resource DROP CONSTRAINT ng3_res_fk;
ALTER TABLE ng3_resource DROP CONSTRAINT ng3_res_oc_fk;
ALTER TABLE ng3_resource DROP CONSTRAINT ng3_res_ts_fk;
ALTER TABLE ng3_resource DROP CONSTRAINT ng3_res_cto_fk;
ALTER TABLE ng3_schedule DROP CONSTRAINT ng3_sched_fk;
ALTER TABLE ng3_schedule DROP CONSTRAINT ng3_sched_oc_fk;
ALTER TABLE ng3_schedule DROP CONSTRAINT ng3_sched_ts_fk;
ALTER TABLE ng3_schedule DROP CONSTRAINT ng3_sched_lib_fk;
ALTER TABLE ng3_schedule_component DROP CONSTRAINT ng3_sched_comp_fk;
ALTER TABLE ng3_schedule_component DROP CONSTRAINT ng3_sched_comp_sched_fk1;
ALTER TABLE ng3_schedule_component DROP CONSTRAINT ng3_sched_comp_sched_fk2;
ALTER TABLE ng3_solar_collector DROP CONSTRAINT ng3_sol_coll_fk;
ALTER TABLE ng3_solar_collector DROP CONSTRAINT ng3_sol_coll_oc_fk;
ALTER TABLE ng3_solar_collector DROP CONSTRAINT ng3_sol_coll_lod2_fk;
ALTER TABLE ng3_solar_collector DROP CONSTRAINT ng3_sol_coll_lod3_fk;
ALTER TABLE ng3_storage_device DROP CONSTRAINT ng3_sto_dev_fk;
ALTER TABLE ng3_storage_device DROP CONSTRAINT ng3_sto_dev_oc_fk;
ALTER TABLE ng3_suitability DROP CONSTRAINT ng3_suit_cto_fk;
ALTER TABLE ng3_suitability DROP CONSTRAINT ng3_suit_sched_fk;
ALTER TABLE ng3_them_surf_to_thermal_zone DROP CONSTRAINT ng3_thm_surf_to_tz_fk1;
ALTER TABLE ng3_them_surf_to_thermal_zone DROP CONSTRAINT ng3_thm_surf_to_tz_fk2;
ALTER TABLE ng3_thematic_surface DROP CONSTRAINT ng3_them_surf_fk;
ALTER TABLE ng3_time_series DROP CONSTRAINT ng3_ts_fk;
ALTER TABLE ng3_time_series DROP CONSTRAINT ng3_ts_oc_fk;
ALTER TABLE ng3_urban_function_area DROP CONSTRAINT ng3_ufa_fk;
ALTER TABLE ng3_utl_ntw_connection DROP CONSTRAINT ng3_utl_ntw_con_cto_fk;
ALTER TABLE ng3_utl_ntw_connection DROP CONSTRAINT ng3_utl_ntw_con_fk;
ALTER TABLE ng3_weather_data DROP CONSTRAINT ng3_wth_data_fk;
ALTER TABLE ng3_weather_data DROP CONSTRAINT ng3_wth_data_ng3_cto_fk;
ALTER TABLE ng3_weather_data DROP CONSTRAINT ng3_wth_data_ts_fk;
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- *********************************** Drop tables ***************************************
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DROP TABLE ng3_address_to_building_unit CASCADE;
DROP TABLE ng3_building CASCADE;
DROP TABLE ng3_building_partition CASCADE;
DROP TABLE ng3_cityobject CASCADE;
DROP TABLE ng3_ctyobj_relation CASCADE;
DROP TABLE ng3_device CASCADE;
DROP TABLE ng3_device_operation CASCADE;
DROP TABLE ng3_energy_perf_cert CASCADE;
DROP TABLE ng3_layer CASCADE;
DROP TABLE ng3_layered_construction CASCADE;
DROP TABLE ng3_library CASCADE;
DROP TABLE ng3_material CASCADE;
DROP TABLE ng3_occupants CASCADE;
DROP TABLE ng3_opening CASCADE;
DROP TABLE ng3_optical_property CASCADE;
DROP TABLE ng3_qualified_attribute CASCADE;
DROP TABLE ng3_refurbishment_measure CASCADE;
DROP TABLE ng3_resource CASCADE;
DROP TABLE ng3_schedule CASCADE;
DROP TABLE ng3_schedule_component CASCADE;
DROP TABLE ng3_solar_collector CASCADE;
DROP TABLE ng3_storage_device CASCADE;
DROP TABLE ng3_suitability CASCADE;
DROP TABLE ng3_them_surf_to_thermal_zone CASCADE;
DROP TABLE ng3_thematic_surface CASCADE;
DROP TABLE ng3_time_series CASCADE;
DROP TABLE ng3_urban_function_area CASCADE;
DROP TABLE ng3_utl_ntw_connection CASCADE;
DROP TABLE ng3_weather_data CASCADE;
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- *********************************** Drop Sequences *************************************
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DROP SEQUENCE ng3_ctyobj_relation_seq;
DROP SEQUENCE ng3_optical_property_seq;
DROP SEQUENCE ng3_qualified_attribute_seq;
DROP SEQUENCE ng3_suitability_seq;
\ No newline at end of file
This diff is collapsed.
...@@ -66,6 +66,12 @@ public class CityObjectPropertiesExporter implements ADEExporter { ...@@ -66,6 +66,12 @@ public class CityObjectPropertiesExporter implements ADEExporter {
} }
} }
if (projectionFilter.containsProperty("relatedTo", module)) {
for (CityObjectRelationProperty property : manager.getExporter(CityObjectRelationExporter.class).doExport(objectId)) {
cityObject.addGenericApplicationPropertyOfCityObject(property);
}
}
if (pointObj != null) { if (pointObj != null) {
GeometryObject pointObject = helper.getDatabaseAdapter().getGeometryConverter().getPoint(pointObj); GeometryObject pointObject = helper.getDatabaseAdapter().getGeometryConverter().getPoint(pointObj);
if (pointObject != null) { if (pointObject != null) {
......
package de.stuttgart.hft.ade.energy3.exporter;
import de.stuttgart.hft.ade.energy3.schema.ADETable;
import org.citydb.core.ade.exporter.ADEExporter;
import org.citydb.core.ade.exporter.CityGMLExportHelper;
import org.citydb.core.operation.exporter.CityGMLExportException;
import org.citygml4j.ade.energy3.model.core.CityObjectRelation;
import org.citygml4j.ade.energy3.model.core.CityObjectRelationProperty;
import org.citygml4j.ade.energy3.model.core.RelatedToProperty;
import org.citygml4j.model.gml.basicTypes.Code;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
public class CityObjectRelationExporter implements ADEExporter {
private final PreparedStatement ps;
private final CityGMLExportHelper helper;
public CityObjectRelationExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException {
this.helper = helper;
// Query ng3_ctyobj_relation joined to cityobject to get the target GML ID
ps = connection.prepareStatement(
"SELECT r.relation_type, r.relation_type_codespace, co.gmlid " +
"FROM " + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.CTYOBJ_RELATION)) + " r " +
"JOIN cityobject co ON co.id = r.cityobject_id " +
"WHERE r.ng3_cityobject_id = ?"
);
}
public Collection<CityObjectRelationProperty> doExport(long ng3CityObjectId) throws CityGMLExportException, SQLException {
ps.setLong(1, ng3CityObjectId);
Collection<CityObjectRelationProperty> result = new ArrayList<>();
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
String relationType = rs.getString(1);
String relationTypeCodespace = rs.getString(2);
String targetGmlId = rs.getString(3);
CityObjectRelation relation = new CityObjectRelation();
// Set relationType
if (relationType != null) {
Code code = new Code(relationType);
if (relationTypeCodespace != null)
code.setCodeSpace(relationTypeCodespace);
relation.setRelationType(code);
}
// Set relatedTo as xlink:href pointing to the target city object GML ID
if (targetGmlId != null) {
RelatedToProperty relatedTo = new RelatedToProperty();
relatedTo.setHref("#" + targetGmlId);
relation.setRelatedTo(relatedTo);
}
result.add(new CityObjectRelationProperty(relation));
}
}
return result;
}
@Override
public void close() throws CityGMLExportException, SQLException {
ps.close();
}
}
\ No newline at end of file
...@@ -68,6 +68,8 @@ public class ExportManager implements ADEExportManager { ...@@ -68,6 +68,8 @@ public class ExportManager implements ADEExportManager {
getExporter(ResourceExporter.class).doExport(parentId); getExporter(ResourceExporter.class).doExport(parentId);
else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.BUILDING)) && parent instanceof AbstractBuilding) else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.BUILDING)) && parent instanceof AbstractBuilding)
getExporter(BuildingPropertiesExporter.class).doExport((AbstractBuilding) parent, parentId, parentType, projectionFilter); getExporter(BuildingPropertiesExporter.class).doExport((AbstractBuilding) parent, parentId, parentType, projectionFilter);
else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CTYOBJ_RELATION)) && parent instanceof AbstractCityObject)
getExporter(CityObjectRelationExporter.class).doExport(parentId);
} }
@Override @Override
...@@ -106,6 +108,8 @@ public class ExportManager implements ADEExportManager { ...@@ -106,6 +108,8 @@ public class ExportManager implements ADEExportManager {
exporter = new AbstractQualifiedAttributeExporter(connection, helper, this); exporter = new AbstractQualifiedAttributeExporter(connection, helper, this);
else if (type == RefurbishmentMeasureExporter.class) else if (type == RefurbishmentMeasureExporter.class)
exporter = new RefurbishmentMeasureExporter(connection, helper, this); exporter = new RefurbishmentMeasureExporter(connection, helper, this);
else if (type == CityObjectRelationExporter.class)
exporter = new CityObjectRelationExporter(connection, helper, this);
if (exporter == null) if (exporter == null)
throw new SQLException("Failed to build ADE exporter of type " + type.getName() + "."); throw new SQLException("Failed to build ADE exporter of type " + type.getName() + ".");
......
...@@ -48,7 +48,7 @@ public class ResourceExporter implements ADEExporter { ...@@ -48,7 +48,7 @@ public class ResourceExporter implements ADEExporter {
} }
ObjectType objectType = helper.getObjectType(objectClassId); ObjectType objectType = helper.getObjectType(objectClassId);
ProjectionFilter projectionFilter = helper.getProjectionFilter(objectType); ProjectionFilter projectionFilter = (objectType != null) ? helper.getProjectionFilter(objectType) : null;
// Set AbstractResource properties // Set AbstractResource properties
String statusValue = rs.getString(7); String statusValue = rs.getString(7);
......
...@@ -13,6 +13,7 @@ import org.citygml4j.ade.energy3.model.core.*; ...@@ -13,6 +13,7 @@ import org.citygml4j.ade.energy3.model.core.*;
import org.citygml4j.ade.energy3.model.supportingClasses.*; import org.citygml4j.ade.energy3.model.supportingClasses.*;
import org.citygml4j.model.citygml.core.AbstractCityObject; import org.citygml4j.model.citygml.core.AbstractCityObject;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -96,8 +97,41 @@ public class CityObjectPropertiesImporter implements ADEImporter { ...@@ -96,8 +97,41 @@ public class CityObjectPropertiesImporter implements ADEImporter {
} }
} }
} }
if (properties.contains(CityObjectRelationProperty.class)) {
for (CityObjectRelationProperty propertyElement : properties.getAll(CityObjectRelationProperty.class)) {
CityObjectRelation relation = propertyElement.getObject();
if (relation != null && relation.isSetRelatedTo()) {
RelatedToProperty relatedTo = relation.getRelatedTo();
if (relatedTo.isSetHref()) {
// Strip leading # from href to get the GML ID
String targetGmlId = relatedTo.getHref();
if (targetGmlId.startsWith("#"))
targetGmlId = targetGmlId.substring(1);
// Look up target city object ID by GML ID
long targetId = resolveCityObjectId(targetGmlId);
if (targetId > 0)
manager.getImporter(CityObjectRelationImporter.class)
.doImport(relation, parentId, targetId);
}
}
}
}
} }
private long resolveCityObjectId(String gmlId) throws SQLException {
try (java.sql.PreparedStatement stmt = connection.prepareStatement(
"SELECT id FROM cityobject WHERE gmlid = ?")) {
stmt.setString(1, gmlId);
try (java.sql.ResultSet rs = stmt.executeQuery()) {
if (rs.next())
return rs.getLong(1);
}
}
return 0;
}
@Override @Override
public void executeBatch() throws CityGMLImportException, SQLException { public void executeBatch() throws CityGMLImportException, SQLException {
if (batchCounter > 0) { if (batchCounter > 0) {
......
...@@ -6,7 +6,6 @@ import org.citydb.core.ade.importer.CityGMLImportHelper; ...@@ -6,7 +6,6 @@ import org.citydb.core.ade.importer.CityGMLImportHelper;
import org.citydb.core.ade.importer.ForeignKeys; import org.citydb.core.ade.importer.ForeignKeys;
import org.citydb.core.database.schema.mapping.AbstractObjectType; import org.citydb.core.database.schema.mapping.AbstractObjectType;
import org.citydb.core.operation.importer.CityGMLImportException; import org.citydb.core.operation.importer.CityGMLImportException;
import org.citydb.core.operation.importer.util.GeometryConverter;
import org.citygml4j.ade.energy3.model.core.CityObjectRelation; import org.citygml4j.ade.energy3.model.core.CityObjectRelation;
import java.sql.Connection; import java.sql.Connection;
...@@ -17,40 +16,37 @@ public class CityObjectRelationImporter implements ADEImporter { ...@@ -17,40 +16,37 @@ public class CityObjectRelationImporter implements ADEImporter {
private final Connection connection; private final Connection connection;
private final CityGMLImportHelper helper; private final CityGMLImportHelper helper;
private final ImportManager manager;
private GeometryConverter geometryConverter;
private PreparedStatement ps; private PreparedStatement ps;
private int batchCounter; private int batchCounter;
public CityObjectRelationImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { public CityObjectRelationImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException {
this.connection = connection; this.connection = connection;
this.helper = helper; this.helper = helper;
this.manager = manager;
ps = connection.prepareStatement("INSERT INTO " + ps = connection.prepareStatement("INSERT INTO " +
helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.UTL_NTW_CONNECTION)) + " " + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.CTYOBJ_RELATION)) + " " +
"(id, ng2_cityobject_id, cityobject_id, relation_type, relation_type_codespace) " + "(id, ng3_cityobject_id, cityobject_id, relation_type, relation_type_codespace) " +
"VALUES (?, ?, ?, ?, ?)"); "VALUES (nextval('" + manager.getSchemaMapper().getSequenceName(de.stuttgart.hft.ade.energy3.schema.ADESequence.CTYOBJ_RELATION_SEQ) + "'), ?, ?, ?, ?)");
geometryConverter = helper.getGeometryConverter();
} }
public void doImport(CityObjectRelation cityObjectRelation, long objectId, AbstractObjectType<?> objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { public void doImport(CityObjectRelation cityObjectRelation, long ng3CityObjectId, long targetCityObjectId) throws CityGMLImportException, SQLException {
ps.setLong(1, objectId); ps.setLong(1, ng3CityObjectId);
ps.setLong(2, targetCityObjectId);
if (cityObjectRelation.isSetRelation()) { if (cityObjectRelation.isSetRelation()) {
ps.setString(4, cityObjectRelation.getRelationType().getValue()); ps.setString(3, cityObjectRelation.getRelationType().getValue());
ps.setString(5, cityObjectRelation.getRelationType().getCodeSpace()); ps.setString(4, cityObjectRelation.getRelationType().getCodeSpace());
} else {
ps.setNull(3, java.sql.Types.VARCHAR);
ps.setNull(4, java.sql.Types.VARCHAR);
} }
//set correctly
ps.setLong(2, objectType.getObjectClassId());
ps.setLong(3, objectType.getObjectClassId());
ps.addBatch(); ps.addBatch();
if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize())
helper.executeBatch(objectType); helper.executeBatch(manager.getSchemaMapper().getTableName(ADETable.CTYOBJ_RELATION));
} }
@Override @Override
...@@ -65,4 +61,4 @@ public class CityObjectRelationImporter implements ADEImporter { ...@@ -65,4 +61,4 @@ public class CityObjectRelationImporter implements ADEImporter {
public void close() throws CityGMLImportException, SQLException { public void close() throws CityGMLImportException, SQLException {
ps.close(); ps.close();
} }
} }
\ No newline at end of file
...@@ -123,6 +123,8 @@ public class ImportManager implements ADEImportManager { ...@@ -123,6 +123,8 @@ public class ImportManager implements ADEImportManager {
importer = new BuildingPropertiesImporter(connection, helper, this); importer = new BuildingPropertiesImporter(connection, helper, this);
else if (type == AbstractQualifiedAttributeImporter.class) else if (type == AbstractQualifiedAttributeImporter.class)
importer = new AbstractQualifiedAttributeImporter(connection, helper, this); importer = new AbstractQualifiedAttributeImporter(connection, helper, this);
else if (type == CityObjectRelationImporter.class)
importer = new CityObjectRelationImporter(connection, helper, this);
else throw new SQLException("Failed to build ADE importer of type " + type.getName() + "."); else throw new SQLException("Failed to build ADE importer of type " + type.getName() + ".");
......
...@@ -3,6 +3,7 @@ package de.stuttgart.hft.ade.energy3.schema; ...@@ -3,6 +3,7 @@ package de.stuttgart.hft.ade.energy3.schema;
public enum ADESequence { public enum ADESequence {
//VOLUMETYPE_SEQ, //VOLUMETYPE_SEQ,
//FLOORAREA_SEQ, //FLOORAREA_SEQ,
CTYOBJ_RELATION_SEQ,
QUALIFIED_ATTRIBUTE_SEQ, QUALIFIED_ATTRIBUTE_SEQ,
//HEATEXCHANGETYPE_SEQ, //HEATEXCHANGETYPE_SEQ,
//TRANSMITTANCE_SEQ, //TRANSMITTANCE_SEQ,
......
...@@ -8,7 +8,7 @@ public enum ADETable { ...@@ -8,7 +8,7 @@ public enum ADETable {
BUILDING(BuildingPropertiesImporter.class), BUILDING(BuildingPropertiesImporter.class),
BUILDING_PARTITION(null), BUILDING_PARTITION(null),
CITYOBJECT(CityObjectPropertiesImporter.class), CITYOBJECT(CityObjectPropertiesImporter.class),
CTYOBJ_RELATION(null), CTYOBJ_RELATION(CityObjectRelationImporter.class),
DEVICE(AbstractDeviceImporter.class), DEVICE(AbstractDeviceImporter.class),
DEVICE_OPERATION(DeviceOperationImporter.class), DEVICE_OPERATION(DeviceOperationImporter.class),
ENERGY_PERF_CERT(EnergyPerformanceCertificateImporter.class), ENERGY_PERF_CERT(EnergyPerformanceCertificateImporter.class),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment