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
76cdabcb
Commit
76cdabcb
authored
Nov 07, 2025
by
Luna Riegel
Browse files
Refactor: Make Schematron run in background thread
parent
58f0a808
Changes
1
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
76cdabcb
...
@@ -191,13 +191,26 @@ public class Checker {
...
@@ -191,13 +191,26 @@ public class Checker {
if
(
config
==
null
)
{
if
(
config
==
null
)
{
config
=
ValidationConfiguration
.
loadStandardValidationConfig
();
config
=
ValidationConfiguration
.
loadStandardValidationConfig
();
}
}
Thread
schematronThread
=
new
Thread
(()
->
{
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
if
(
handler
!=
null
)
{
handleSchematronResults
(
handler
);
}
});
schematronThread
.
start
();
checkCityModel
(
model
,
l
);
checkCityModel
(
model
,
l
);
if
(
logger
.
isInfoEnabled
())
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.checksFinished"
));
logger
.
info
(
Localization
.
getText
(
"Checker.checksFinished"
));
}
}
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
if
(
schematronThread
.
isAlive
())
{
if
(
handler
!=
null
)
{
//TODO: Localize String
handleSchematronResults
(
handler
);
logger
.
info
(
"Schematron thread still running, waiting for completion. This may take some time"
);
try
{
schematronThread
.
join
();
}
catch
(
InterruptedException
e
)
{
logger
.
error
(
"Main Thread was interrupted while waiting for Schematron"
,
e
);
schematronThread
.
interrupt
();
}
}
}
model
.
setValidated
(
createValidationPlan
());
model
.
setValidated
(
createValidationPlan
());
}
}
...
@@ -443,6 +456,7 @@ public class Checker {
...
@@ -443,6 +456,7 @@ public class Checker {
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
}
}
if
(!
Files
.
exists
(
Path
.
of
(
config
.
getSchematronFilePath
())))
{
if
(!
Files
.
exists
(
Path
.
of
(
config
.
getSchematronFilePath
())))
{
//TODO: Localize String
logger
.
warn
(
"Schematron file {} could not be found"
,
config
.
getSchematronFilePath
());
logger
.
warn
(
"Schematron file {} could not be found"
,
config
.
getSchematronFilePath
());
return
null
;
return
null
;
}
}
...
@@ -563,6 +577,7 @@ public class Checker {
...
@@ -563,6 +577,7 @@ public class Checker {
for
(
Entry
<
String
,
RequirementConfiguration
>
e
:
config
.
getRequirements
().
entrySet
())
{
for
(
Entry
<
String
,
RequirementConfiguration
>
e
:
config
.
getRequirements
().
entrySet
())
{
de
.
hft
.
stuttgart
.
citydoctor2
.
check
.
Requirement
req
=
Checks
.
getAvailableRequirements
().
get
(
e
.
getKey
());
de
.
hft
.
stuttgart
.
citydoctor2
.
check
.
Requirement
req
=
Checks
.
getAvailableRequirements
().
get
(
e
.
getKey
());
if
(
req
==
null
)
{
if
(
req
==
null
)
{
//TODO: Localize String
logger
.
warn
(
"Could not find any check that satisfies requirement {}, it will not be checked"
,
logger
.
warn
(
"Could not find any check that satisfies requirement {}, it will not be checked"
,
e
.
getKey
());
e
.
getKey
());
}
else
{
}
else
{
...
@@ -638,7 +653,6 @@ public class Checker {
...
@@ -638,7 +653,6 @@ public class Checker {
AtomicInteger
missingCount
=
new
AtomicInteger
(
0
);
AtomicInteger
missingCount
=
new
AtomicInteger
(
0
);
// clear global errors
// clear global errors
model
.
getGlobalErrors
().
clear
();
model
.
getGlobalErrors
().
clear
();
CheckerThreadsSynchronizer
sync
=
new
CheckerThreadsSynchronizer
(
model
,
l
);
int
threadCount
=
Runtime
.
getRuntime
().
availableProcessors
()
*
5
;
int
threadCount
=
Runtime
.
getRuntime
().
availableProcessors
()
*
5
;
ExecutorService
exec
=
new
ThreadPoolExecutor
ExecutorService
exec
=
new
ThreadPoolExecutor
...
@@ -669,9 +683,13 @@ public class Checker {
...
@@ -669,9 +683,13 @@ public class Checker {
try
{
try
{
exec
.
awaitTermination
(
30
,
TimeUnit
.
DAYS
);
exec
.
awaitTermination
(
30
,
TimeUnit
.
DAYS
);
long
endTime
=
System
.
nanoTime
();
long
endTime
=
System
.
nanoTime
();
logger
.
info
(
"Checks finished in "
+
(
endTime
-
startTime
)
/
1_000_000
+
" ms"
);
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"Checks finished in {} ms"
,
(
endTime
-
startTime
)
/
1_000_000
);
}
if
(
missingCount
.
get
()
>
0
)
{
if
(
missingCount
.
get
()
>
0
)
{
int
missing
=
missingCount
.
get
();
int
missing
=
missingCount
.
get
();
//TODO: Localize String
String
msg
=
String
.
format
(
"Checker could not load %d/%.0f features (%.2f%%)"
,
missing
,
featureSum
,
(
missing
/
featureSum
)
*
100
);
String
msg
=
String
.
format
(
"Checker could not load %d/%.0f features (%.2f%%)"
,
missing
,
featureSum
,
(
missing
/
featureSum
)
*
100
);
logger
.
warn
(
msg
);
logger
.
warn
(
msg
);
}
}
...
...
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