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
cee896c7
Commit
cee896c7
authored
Nov 27, 2025
by
Luna Riegel
Browse files
Refactor: Rename class
parent
fe9cb4bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/DatabaseHandler.java
→
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/
Embedded
DatabaseHandler.java
View file @
cee896c7
...
@@ -30,13 +30,13 @@ import java.util.Map;
...
@@ -30,13 +30,13 @@ import java.util.Map;
/**
/**
* Utility class for setup and access of the embedded database.
* Utility class for setup and access of the embedded database.
*/
*/
public
class
DatabaseHandler
{
public
class
Embedded
DatabaseHandler
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
DatabaseHandler
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Embedded
DatabaseHandler
.
class
);
private
static
final
String
DB_NAME
=
"/database/cd_db"
;
private
static
final
String
DB_NAME
=
"/database/cd_db"
;
private
DataSourceWrapper
dataSource
;
private
DataSourceWrapper
dataSource
;
public
DatabaseHandler
(){
public
Embedded
DatabaseHandler
(){
try
{
try
{
String
jdbcurl
=
H2GISDBFactory
.
createDataSource
(
DB_NAME
,
String
jdbcurl
=
H2GISDBFactory
.
createDataSource
(
DB_NAME
,
true
,
";AUTO_SERVER=TRUE"
).
getConnection
().
getMetaData
().
getURL
();
true
,
";AUTO_SERVER=TRUE"
).
getConnection
().
getMetaData
().
getURL
();
...
@@ -88,7 +88,7 @@ public class DatabaseHandler {
...
@@ -88,7 +88,7 @@ public class DatabaseHandler {
}
}
/**
/**
* Saves a CityObject to the embedded database, updating
an existing
entry if it exists.
* Saves a CityObject to the embedded database, updating
the
entry if it
already
exists.
* @param co the CityObject
* @param co the CityObject
*/
*/
public
void
marshallCityObject
(
CityObject
co
)
{
public
void
marshallCityObject
(
CityObject
co
)
{
...
@@ -119,6 +119,11 @@ public class DatabaseHandler {
...
@@ -119,6 +119,11 @@ public class DatabaseHandler {
}
}
}
}
/**
* Tries to save all CityObjects in a Map to the embedded database as a batched statement, updating already existing entries.
* @param map a Map containing the CityObjects
* @return true if the batched statement was successfully created and commited, false otherwise
*/
public
boolean
tryMarshallCityObjectMap
(
Map
<
GmlId
,
CityObject
>
map
)
{
public
boolean
tryMarshallCityObjectMap
(
Map
<
GmlId
,
CityObject
>
map
)
{
// Id String for error logging
// Id String for error logging
String
id
=
""
;
String
id
=
""
;
...
@@ -199,6 +204,10 @@ public class DatabaseHandler {
...
@@ -199,6 +204,10 @@ public class DatabaseHandler {
return
null
;
return
null
;
}
}
/**
* 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
*/
public
List
<
GmlId
>
getIdsOfAllCityObjectsWithErrors
(){
public
List
<
GmlId
>
getIdsOfAllCityObjectsWithErrors
(){
List
<
GmlId
>
ids
=
new
ArrayList
<>();
List
<
GmlId
>
ids
=
new
ArrayList
<>();
try
(
Connection
con
=
dataSource
.
getConnection
()){
try
(
Connection
con
=
dataSource
.
getConnection
()){
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/FeatureCache.java
View file @
cee896c7
...
@@ -33,12 +33,12 @@ public class FeatureCache implements CityObjectCache{
...
@@ -33,12 +33,12 @@ public class FeatureCache implements CityObjectCache{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
FeatureCache
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
FeatureCache
.
class
);
private
final
LoadingCache
<
GmlId
,
CityObject
>
cache
;
private
final
LoadingCache
<
GmlId
,
CityObject
>
cache
;
private
final
DatabaseHandler
handler
;
private
final
Embedded
DatabaseHandler
handler
;
private
final
AtomicInteger
putsCounter
=
new
AtomicInteger
(
0
);
private
final
AtomicInteger
putsCounter
=
new
AtomicInteger
(
0
);
private
boolean
parsingFinished
=
false
;
private
boolean
parsingFinished
=
false
;
FeatureCache
()
{
FeatureCache
()
{
handler
=
new
DatabaseHandler
();
handler
=
new
Embedded
DatabaseHandler
();
cache
=
Caffeine
.
newBuilder
().
maximumSize
(
3000
).
removalListener
((
GmlId
key
,
CityObject
value
,
RemovalCause
cause
)
->
{
cache
=
Caffeine
.
newBuilder
().
maximumSize
(
3000
).
removalListener
((
GmlId
key
,
CityObject
value
,
RemovalCause
cause
)
->
{
if
(
value
!=
null
&&
cause
.
wasEvicted
())
{
if
(
value
!=
null
&&
cause
.
wasEvicted
())
{
handler
.
marshallCityObject
(
value
);
handler
.
marshallCityObject
(
value
);
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/DataBaseHandlerTest.java
View file @
cee896c7
...
@@ -32,12 +32,12 @@ import static org.junit.Assert.fail;
...
@@ -32,12 +32,12 @@ import static org.junit.Assert.fail;
public
class
DataBaseHandlerTest
{
public
class
DataBaseHandlerTest
{
private
DatabaseHandler
handler
;
private
Embedded
DatabaseHandler
handler
;
@Before
@Before
public
void
resetDatabase
()
{
public
void
resetDatabase
()
{
try
{
try
{
handler
=
new
DatabaseHandler
();
handler
=
new
Embedded
DatabaseHandler
();
handler
.
setupFeaturesTable
();
handler
.
setupFeaturesTable
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
fail
(
e
.
getMessage
());
fail
(
e
.
getMessage
());
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/FeatureCacheTest.java
View file @
cee896c7
...
@@ -28,7 +28,7 @@ public class FeatureCacheTest {
...
@@ -28,7 +28,7 @@ public class FeatureCacheTest {
@Test
@Test
public
void
testGet
(){
public
void
testGet
(){
FeatureCache
cache
=
new
FeatureCache
();
FeatureCache
cache
=
new
FeatureCache
();
DatabaseHandler
handler
=
new
DatabaseHandler
();
Embedded
DatabaseHandler
handler
=
new
Embedded
DatabaseHandler
();
Building
b
=
new
Building
();
Building
b
=
new
Building
();
b
.
setGmlId
(
new
GmlId
(
"building"
));
b
.
setGmlId
(
new
GmlId
(
"building"
));
b
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
));
b
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
));
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java
View file @
cee896c7
...
@@ -453,6 +453,7 @@ public class MainWindow extends Application {
...
@@ -453,6 +453,7 @@ public class MainWindow extends Application {
});
});
}
}
@SuppressWarnings
(
"java:S2629"
)
private
void
checkForStartupLoading
()
{
private
void
checkForStartupLoading
()
{
if
(
loadFileAtStartup
)
{
if
(
loadFileAtStartup
)
{
logger
.
info
(
Localization
.
getText
(
"MainWindow.loadGivenFile"
));
logger
.
info
(
Localization
.
getText
(
"MainWindow.loadGivenFile"
));
...
...
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