Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Energy ADE
Energy ADE 3 3DCityDB
Commits
d618bc60
Commit
d618bc60
authored
Jan 14, 2026
by
PrabithaPrabhakaran
Browse files
Fix AbstractADEFeatureExporter and Importer
parent
86bff7d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/stuttgart/hft/ade/energy3/exporter/AbstractADEFeatureExporter.java
View file @
d618bc60
...
...
@@ -6,18 +6,11 @@ import org.citydb.core.ade.exporter.CityGMLExportHelper;
import
org.citydb.core.database.schema.mapping.ObjectType
;
import
org.citydb.core.operation.exporter.CityGMLExportException
;
import
org.citydb.core.query.filter.projection.ProjectionFilter
;
import
org.citygml4j.ade.energy3.model.core.AbstractResource
;
import
org.citygml4j.ade.energy3.model.supportingClasses.*
;
import
org.citygml4j.model.gml.basicTypes.Code
;
import
org.citygml4j.model.gml.basicTypes.Measure
;
import
org.sig3d.citygml.energyADE3beta8.ResourceStatusValueType
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.GregorianCalendar
;
...
...
@@ -58,12 +51,21 @@ public class AbstractADEFeatureExporter implements ADEExporter {
ProjectionFilter
projectionFilter
=
helper
.
getProjectionFilter
(
objectType
);
// Set AbstractADEFeature properties
String
identifierValue
=
rs
.
getString
(
2
);
String
identifierCodespace
=
rs
.
getString
(
3
);
if
(
identifierValue
!=
null
||
identifierCodespace
!=
null
)
{
// adeFeature.getExternalReference(); check with uml
//externalReference ----------> fix
// String external_reference = rs.getString(3);
// if (external_reference != null) {
// adeFeature.setExternalReference(external_reference);
// }
Timestamp
creation_date
=
rs
.
getTimestamp
(
9
);
Timestamp
termination_date
=
rs
.
getTimestamp
(
10
);
if
(
creation_date
!=
null
||
termination_date
!=
null
)
{
adeFeature
.
setCreationDate
(
toXMLGregorianCalendar
(
creation_date
));
adeFeature
.
setTerminationDate
(
toXMLGregorianCalendar
(
termination_date
));
}
String
valid_from
=
rs
.
getString
(
4
);
String
valid_to
=
rs
.
getString
(
5
);
...
...
@@ -95,17 +97,25 @@ public class AbstractADEFeatureExporter implements ADEExporter {
}
}
private
XMLGregorianCalendar
toXMLGregorianCalendar
(
Timestamp
ts
)
{
if
(
ts
==
null
)
return
null
;
GregorianCalendar
cal
=
new
GregorianCalendar
();
cal
.
setTimeInMillis
(
ts
.
getTime
());
try
{
return
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
cal
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Error converting Timestamp to XMLGregorianCalendar"
,
e
);
}
}
@Override
public
void
close
()
throws
CityGMLExportException
,
SQLException
{
ps
.
close
();
}
private
String
getColumnNames
()
{
return
"id, objectclass_id, type, type_codespace, enduse, enduse_codespace, status, operation_type,"
+
" operation_type_codespace, year, amount_type, amount_type_codespace, amount, "
+
"amount_uom, time_series_id, is_amount_normalized, normalization_param, normalization_value, "
+
"normalization_value_uom, co2_equivalent, co2_equivalent_uom, costs_money, costs_money_uom, "
+
"yields_money, yields_money_uom, energy_carrier, energy_carrier_codespace, maximum_load, "
+
"maximum_load_uom, source, source_codespace, is_dangerous, is_recyclable, cityobject_id"
;
return
"id, objectclass_id, gmlid, gmlid_codespace, name, name_codespace, description, envelope, creation_date,"
+
" termination_date, relative_to_terrain, relative_to_water, last_modification_date, updating_person, "
+
"reason_for_update, lineage, xml_source"
;
}
}
src/main/java/de/stuttgart/hft/ade/energy3/importer/AbstractADEFeatureImporter.java
View file @
d618bc60
...
...
@@ -27,14 +27,9 @@ public class AbstractADEFeatureImporter implements ADEImporter {
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"INSERT INTO "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
FEATURE_WITH_LIFE_SPAN
))
+
"(id, objectclass_id, type, type_codespace, enduse, enduse_codespace, status, "
+
"operation_type, operation_type_codespace, year, amount_type, amount_type_codespace, amount, "
+
"amount_uom, time_series_id, is_amount_normalized, normalization_param, normalization_value, "
+
"normalization_value_uom, co2_equivalent, co2_equivalent_uom, costs_money, costs_money_uom, "
+
"yields_money, yields_money_uom, energy_carrier, energy_carrier_codespace, maximum_load, "
+
"maximum_load_uom, source, source_codespace, is_dangerous, is_recyclable, cityobject_id) "
+
"VALUES ("
+
String
.
join
(
", "
,
Collections
.
nCopies
(
34
,
"?"
))
+
")"
"INSERT INTO "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
CITYOBJECT
))
+
"(id, objectclass_id, gmlid, gmlid_codespace, name, name_codespace, description, envelope, creation_date, termination_date, relative_to_terrain, relative_to_water, last_modification_date, updating_person, reason_for_update, lineage, xml_source) "
+
"VALUES ("
+
String
.
join
(
", "
,
Collections
.
nCopies
(
17
,
"?"
))
+
")"
);
geometryConverter
=
helper
.
getGeometryConverter
();
...
...
@@ -55,27 +50,26 @@ public class AbstractADEFeatureImporter implements ADEImporter {
private
void
setAbstractADEFeatureToNull
()
throws
SQLException
{
ps
.
setNull
(
1
,
Types
.
BIGINT
);
// id
ps
.
setNull
(
2
,
Types
.
INTEGER
);
// objectclass_id
ps
.
setNull
(
3
,
Types
.
VARCHAR
);
// Identifier value
ps
.
setNull
(
5
,
Types
.
TIMESTAMP
);
// creationDate
ps
.
setNull
(
6
,
Types
.
TIMESTAMP
);
// terminationDate
ps
.
setNull
(
9
,
Types
.
TIMESTAMP
);
// creationDate
ps
.
setNull
(
10
,
Types
.
TIMESTAMP
);
// terminationDate
}
private
void
setAbstractADEFeatureProperties
(
AbstractADEFeature
abstractADEFeature
)
throws
SQLException
{
if
(
abstractADEFeature
.
getExternalReference
()
!=
null
)
{
// ps.setString(
3
, abstractADEFeature.getExternalReference());
// ps.setString(
9
, abstractADEFeature.getExternalReference());
}
if
(
abstractADEFeature
.
getCreationDate
()!=
null
){
XMLGregorianCalendar
xmlCal
=
abstractADEFeature
.
getCreationDate
();
Timestamp
timestamp
=
new
Timestamp
(
xmlCal
.
toGregorianCalendar
().
getTimeInMillis
());
ps
.
setTimestamp
(
5
,
timestamp
);
ps
.
setTimestamp
(
9
,
timestamp
);
}
if
(
abstractADEFeature
.
getTerminationDate
()!=
null
){
XMLGregorianCalendar
xmlCal
=
abstractADEFeature
.
getTerminationDate
();
Timestamp
timestamp
=
new
Timestamp
(
xmlCal
.
toGregorianCalendar
().
getTimeInMillis
());
ps
.
setTimestamp
(
10
,
timestamp
);
}
// if (abstractADEFeature.getTerminationDate()!= null){
// XMLGregorianCalendar xmlCal = abstractADEFeature.getTerminationDate()));
// Timestamp timestamp = new Timestamp(xmlCal.toGregorianCalendar().getTimeInMillis());
// ps.setTimestamp(6, timestamp);
// }
}
@Override
...
...
src/main/java/de/stuttgart/hft/ade/energy3/importer/CityObjectPropertiesImporter.java
View file @
d618bc60
...
...
@@ -32,10 +32,9 @@ public class CityObjectPropertiesImporter implements ADEImporter {
this
.
manager
=
manager
;
this
.
connection
=
connection
;
ps
=
connection
.
prepareStatement
(
"insert into "
+
helper
.
getTableNameWithSchema
(
schemaMapper
.
getTableName
(
ADETable
.
CITYOBJECT
))
+
" "
+
"(id, ref_point) "
+
"values (?,?)"
);
ps
=
connection
.
prepareStatement
(
"INSERT INTO "
+
helper
.
getTableNameWithSchema
(
schemaMapper
.
getTableName
(
ADETable
.
CITYOBJECT
))
+
" (id, objectclass_id, gmlid, gmlid_codespace, name, name_codespace, description, envelope, creation_date, termination_date, relative_to_terrain, relative_to_water, last_modification_date, updating_person, reason_for_update, lineage, xml_source) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
);
}
public
void
doImport
(
ADEPropertyCollection
properties
,
AbstractCityObject
parent
,
long
parentId
,
FeatureType
parentType
)
throws
CityGMLImportException
,
SQLException
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment