Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
6e669d57
Commit
6e669d57
authored
Jan 26, 2026
by
Luna Riegel
Browse files
Fix: Fix various bugs in error filter
parent
a69cad26
Changes
6
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/CityObjectCache.java
View file @
6e669d57
...
@@ -3,6 +3,7 @@ package de.hft.stuttgart.citydoctor2.database;
...
@@ -3,6 +3,7 @@ package de.hft.stuttgart.citydoctor2.database;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -21,6 +22,8 @@ public interface CityObjectCache {
...
@@ -21,6 +22,8 @@ public interface CityObjectCache {
*/
*/
CityObject
get
(
GmlId
id
);
CityObject
get
(
GmlId
id
);
Collection
<
CityObject
>
getAll
(
List
<
GmlId
>
ids
);
/**
/**
* Replaces a CityObject with another one
* Replaces a CityObject with another one
* @param id GmlID of the CityObject that is to be replaced
* @param id GmlID of the CityObject that is to be replaced
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/EmbeddedDatabaseHandler.java
View file @
6e669d57
...
@@ -30,8 +30,10 @@ import java.sql.PreparedStatement;
...
@@ -30,8 +30,10 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
/**
/**
* Utility class for setup and access of the embedded database.
* Utility class for setup and access of the embedded database.
...
@@ -142,8 +144,7 @@ public class EmbeddedDatabaseHandler {
...
@@ -142,8 +144,7 @@ public class EmbeddedDatabaseHandler {
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"MERGE INTO features VALUES (?, ?, ?, ?)"
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"MERGE INTO features VALUES (?, ?, ?, ?)"
))
{
ps
.
setString
(
1
,
co
.
getGmlId
().
toString
());
ps
.
setString
(
1
,
co
.
getGmlId
().
toString
());
String
bbox
=
BoundingBox
.
of
(
co
).
to2DWkt
();
ps
.
setString
(
2
,
co
.
getBbox
().
to2DWkt
());
ps
.
setString
(
2
,
bbox
);
ps
.
setBoolean
(
4
,
co
.
containsAnyError
());
ps
.
setBoolean
(
4
,
co
.
containsAnyError
());
if
(
logger
.
isDebugEnabled
())
{
if
(
logger
.
isDebugEnabled
())
{
...
@@ -254,6 +255,42 @@ public class EmbeddedDatabaseHandler {
...
@@ -254,6 +255,42 @@ public class EmbeddedDatabaseHandler {
return
null
;
return
null
;
}
}
public
Map
<
GmlId
,
CityObject
>
unmarshallAllIds
(
Set
<?
extends
GmlId
>
ids
){
try
(
Connection
con
=
dataSource
.
getConnection
())
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT data FROM features WHERE ARRAY_CONTAINS(? ,gmlid)"
))
{
ps
.
setObject
(
1
,
ids
);
ResultSet
rs
=
ps
.
executeQuery
();
Map
<
GmlId
,
CityObject
>
objects
=
new
HashMap
<>();
while
(
rs
.
next
())
{
try
(
InputStream
is
=
rs
.
getBinaryStream
(
"data"
))
{
CityObject
co
=
SerializationUtils
.
deserialize
(
is
);
// Rebuild the adjacency maps
co
.
accept
(
new
CheckableUtilsVisitor
()
{
@Override
public
void
check
(
Geometry
geom
)
{
geom
.
updateVertices
();
}
});
objects
.
put
(
co
.
getGmlId
(),
co
);
}
catch
(
InvalidClassException
|
ClassCastException
|
SerializationException
e
){
//TODO: change this log to reflect ids map
String
msg
=
String
.
format
(
"Deserialization of CityObject \"%s\" failed"
,
ids
);
logger
.
error
(
msg
,
e
);
}
}
return
objects
;
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
catch
(
SQLException
e
)
{
logger
.
error
(
Localization
.
getText
(
"DatabaseHandler.unmarshallingFailure"
),
ids
);
logger
.
error
(
e
.
getMessage
());
}
return
null
;
}
/**
/**
* Retrieves a List of GmlIds of CityObjects that contain any {@link de.hft.stuttgart.citydoctor2.check.CheckError CheckError}.
* Retrieves a List of GmlIds of CityObjects that contain any {@link de.hft.stuttgart.citydoctor2.check.CheckError CheckError}.
* @return a List of GmlIds of CityObjects containing any CheckError
* @return a List of GmlIds of CityObjects containing any CheckError
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/FeatureCache.java
View file @
6e669d57
...
@@ -8,6 +8,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
...
@@ -8,6 +8,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -115,6 +117,11 @@ public class FeatureCache implements CityObjectCache{
...
@@ -115,6 +117,11 @@ public class FeatureCache implements CityObjectCache{
return
cache
.
get
(
id
);
return
cache
.
get
(
id
);
}
}
@Override
public
Collection
<
CityObject
>
getAll
(
List
<
GmlId
>
ids
){
Map
<
GmlId
,
CityObject
>
map
=
cache
.
getAll
(
ids
,
handler:
:
unmarshallAllIds
);
return
map
.
values
();
}
@Override
@Override
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/UnconnectedCache.java
View file @
6e669d57
...
@@ -5,6 +5,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
...
@@ -5,6 +5,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlId
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -37,6 +38,12 @@ public class UnconnectedCache implements CityObjectCache{
...
@@ -37,6 +38,12 @@ public class UnconnectedCache implements CityObjectCache{
return
cache
.
get
(
id
);
return
cache
.
get
(
id
);
}
}
@Override
public
Collection
<
CityObject
>
getAll
(
List
<
GmlId
>
ids
)
{
return
ids
.
stream
().
map
(
cache:
:
get
).
toList
();
}
@Override
@Override
public
void
replace
(
GmlId
id
,
CityObject
cityObject
)
{
public
void
replace
(
GmlId
id
,
CityObject
cityObject
)
{
cache
.
put
(
id
,
cityObject
);
cache
.
put
(
id
,
cityObject
);
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java
View file @
6e669d57
...
@@ -1379,7 +1379,9 @@ public class CityDoctorController {
...
@@ -1379,7 +1379,9 @@ public class CityDoctorController {
if
(
model
==
null
)
{
if
(
model
==
null
)
{
return
;
return
;
}
}
buildTrees
();
mainWindow
.
rebuildErrorFilterTrees
();
// buildTrees();
}
}
public
Series
<
String
,
Number
>
createErrorSeries
()
{
public
Series
<
String
,
Number
>
createErrorSeries
()
{
...
@@ -1414,7 +1416,8 @@ public class CityDoctorController {
...
@@ -1414,7 +1416,8 @@ public class CityDoctorController {
List
<
GmlId
>
idList
=
model
.
getBuildingIds
();
List
<
GmlId
>
idList
=
model
.
getBuildingIds
();
foundBuildings
.
removeIf
(
gmlId
->
(!
idList
.
contains
(
gmlId
)));
foundBuildings
.
removeIf
(
gmlId
->
(!
idList
.
contains
(
gmlId
)));
Supplier
<
Stream
<
Building
>>
supply
=
()
->
model
.
getCache
().
getStream
(
foundBuildings
).
map
(
co
->
(
Building
)
co
);
//Supplier<Stream<Building>> supply = () -> model.getCache().getStream(foundBuildings).map(co -> (Building) co);
Supplier
<
Stream
<
Building
>>
supply
=
()
->
model
.
getCache
().
getAll
(
foundBuildings
).
stream
().
map
(
co
->
(
Building
)
co
);
buildBuildingTreeFromList
(
supply
,
root
);
buildBuildingTreeFromList
(
supply
,
root
);
updateTree
(
root
);
updateTree
(
root
);
addMoreButtonForBuildings
(
buildingsView
,
root
,
buildingChunkNr
,
supply
,
foundBuildings
.
size
());
addMoreButtonForBuildings
(
buildingsView
,
root
,
buildingChunkNr
,
supply
,
foundBuildings
.
size
());
...
@@ -1659,6 +1662,8 @@ public class CityDoctorController {
...
@@ -1659,6 +1662,8 @@ public class CityDoctorController {
public
void
errorFilterIndexChanged
(
Number
newV
)
{
public
void
errorFilterIndexChanged
(
Number
newV
)
{
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
mainWindow
.
unselectEverything
();
mainWindow
.
unselectEverything
();
mainWindow
.
resetSearchBar
();
renderer
.
clearCurrentRender
();
if
(
newV
.
intValue
()
==
0
)
{
// Error filter was set to "All"
if
(
newV
.
intValue
()
==
0
)
{
// Error filter was set to "All"
buildTrees
();
buildTrees
();
updateFeatureTrees
();
updateFeatureTrees
();
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java
View file @
6e669d57
...
@@ -592,6 +592,10 @@ public class MainWindow extends Application {
...
@@ -592,6 +592,10 @@ public class MainWindow extends Application {
showCityObjectsCombo
.
getSelectionModel
().
selectedIndexProperty
().
addListener
(
filterChangeListener
);
showCityObjectsCombo
.
getSelectionModel
().
selectedIndexProperty
().
addListener
(
filterChangeListener
);
}
}
public
void
rebuildErrorFilterTrees
(){
controller
.
errorFilterIndexChanged
(
showCityObjectsCombo
.
getSelectionModel
().
getSelectedIndex
());
}
private
ChangeListener
<
Number
>
setupFilterSelectionListener
()
{
private
ChangeListener
<
Number
>
setupFilterSelectionListener
()
{
return
(
obs
,
oldV
,
newV
)
->
controller
.
errorFilterIndexChanged
(
newV
);
return
(
obs
,
oldV
,
newV
)
->
controller
.
errorFilterIndexChanged
(
newV
);
}
}
...
...
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