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
239d97de
Commit
239d97de
authored
Nov 25, 2025
by
Luna Riegel
Browse files
Style: Log total time needed for check execution
parent
ed20282c
Changes
4
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/TimeFormatter.java
0 → 100644
View file @
239d97de
package
de.hft.stuttgart.citydoctor2.utils
;
import
java.text.ChoiceFormat
;
public
final
class
TimeFormatter
{
private
TimeFormatter
(){}
private
static
final
String
LESS_THAN_A_SECOND
=
Localization
.
getText
(
"TimeFormatter.lessThanASecond"
);
private
static
final
ChoiceFormat
SECONDS
=
new
ChoiceFormat
(
new
double
[]{
1
,
2
},
new
String
[]{
Localization
.
getText
(
"TimeFormatter.oneSecond"
),
Localization
.
getText
(
"TimeFormatter.seconds"
)}
);
private
static
final
ChoiceFormat
MINUTES
=
new
ChoiceFormat
(
new
double
[]{
1
,
2
},
new
String
[]{
Localization
.
getText
(
"TimeFormatter.oneMinute"
),
Localization
.
getText
(
"TimeFormatter.minutes"
)}
);
private
static
final
ChoiceFormat
HOURS
=
new
ChoiceFormat
(
new
double
[]
{
1
,
2
},
new
String
[]{
Localization
.
getText
(
"TimeFormatter.oneHour"
),
Localization
.
getText
(
"TimeFormatter.hours"
)}
);
/**
* Formats a time measurement in milliseconds as a localized String representation.
*
* <p>
* The String representation will return the time as a rounded down integer of the biggest fitting TimeUnit
* (seconds, minutes or hours), returning "< 1 second" for times under a second.
* <p/>
* @param millis
* @return A localized String representation of the timespan
*/
public
static
String
format
(
long
millis
)
{
if
(
millis
<
1000
)
{
return
LESS_THAN_A_SECOND
;
}
else
if
(
millis
<
60_000
)
{
long
seconds
=
millis
/
1000
;
String
pattern
=
SECONDS
.
format
(
seconds
);
return
pattern
.
replace
(
"{0}"
,
Long
.
toString
(
seconds
));
}
else
if
(
millis
<
3_600_000
){
long
minutes
=
millis
/
60_000
;
String
pattern
=
MINUTES
.
format
(
minutes
);
return
pattern
.
replace
(
"{0}"
,
Long
.
toString
(
minutes
));
}
else
{
long
hours
=
millis
/
3_600_000
;
String
pattern
=
HOURS
.
format
(
hours
);
return
pattern
.
replace
(
"{0}"
,
Long
.
toString
(
hours
));
}
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties
View file @
239d97de
...
...
@@ -34,7 +34,7 @@ CheckDialog.title=Check Configuration
CheckDialog.validationConfiguration
=
Validation Configuration
CheckDialog.xmlReportsOption
=
Create XML reports
Checker.checkFeature
=
Checking feature: {}
Checker.checksFinished
=
Finished executing checks
Checker.checksFinished
=
Finished executing checks
. Total time: {0}
Checker.dbStillUnresponsive
=
Checker still unable to load some CityObjects from database!
Checker.dbUnresponsive
=
Checker could not load some CityObjects from database!
Checker.executeCheck
=
Executing check: {}
...
...
@@ -180,6 +180,13 @@ OpenFileDialog.select=Select CityGML file
OpenFileDialog.selectBtn
=
Select
OpenFileDialog.settingsPane
=
Parser Preferences
OpenFileDialog.xmlValidationLabel
=
Use XML Validation
TimeFormatter.hours
=
{0} hours
TimeFormatter.lessThanASecond
=
< 1 second
TimeFormatter.minutes
=
{0} minutes
TimeFormatter.oneHour
=
1 hour
TimeFormatter.oneMinute
=
1 minute
TimeFormatter.oneSecond
=
1 second
TimeFormatter.seconds
=
{0} seconds
Unit.Degree
=
Degree
Unit.Radian
=
Radian
ValidationConfiguration.missingSchematron
=
{} is not an existing file, disabling schematron check
...
...
CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties
View file @
239d97de
...
...
@@ -34,7 +34,7 @@ CheckDialog.title=Pr\u00fcfungskonfiguration
CheckDialog.validationConfiguration
=
Validierungskonfiguration
CheckDialog.xmlReportsOption
=
XML Berichte erstellen
Checker.checkFeature
=
Pr
\u
00fcfe Feature: {}
Checker.checksFinished
=
Pr
\u
00fcfungen beendet
Checker.checksFinished
=
Durchf
\u
00fchrung der Pr
\u
00fcfungen abgeschlossen. Gesamtzeit: {0}
Checker.dbStillUnresponsive
=
Pr
\u
00fcfung konnte weiterhin einige CityObjects nicht aus der Datenbank laden!
Checker.dbUnresponsive
=
Pr
\u
00fcfung konnte einige CityObjects nicht aus der Datenbank laden!
Checker.executeCheck
=
F
\u
00fchre Pr
\u
00fcfung aus: {}
...
...
@@ -180,6 +180,13 @@ OpenFileDialog.select=W\u00e4hle CityGML Datei aus
OpenFileDialog.selectBtn
=
Ausw
\u
00e4hlen
OpenFileDialog.settingsPane
=
Parser Einstellungen
OpenFileDialog.xmlValidationLabel
=
F
\u
00fchre XML-Validierung aus
TimeFormatter.hours
=
{0} Stunden
TimeFormatter.lessThanASecond
=
< 1 Sekunde
TimeFormatter.minutes
=
{0} Minuten
TimeFormatter.oneHour
=
1 Stunde
TimeFormatter.oneMinute
=
1 Minute
TimeFormatter.oneSecond
=
1 Sekunde
TimeFormatter.seconds
=
{0} Sekunden
Unit.Degree
=
Grad
Unit.Radian
=
Radiant
ValidationConfiguration.missingSchematron
=
{} existiert nicht, deaktiviere Schematron Pr
\u
00fcfung
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
239d97de
...
...
@@ -30,6 +30,7 @@ import de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler;
import
de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener
;
import
de.hft.stuttgart.citydoctor2.database.CacheManager
;
import
de.hft.stuttgart.citydoctor2.database.CityObjectCache
;
import
de.hft.stuttgart.citydoctor2.database.FeatureCache
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.FeatureType
;
...
...
@@ -46,6 +47,7 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlValidationReporter;
import
de.hft.stuttgart.citydoctor2.reporting.pdf.PdfReporter
;
import
de.hft.stuttgart.citydoctor2.reporting.pdf.PdfStreamReporter
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
de.hft.stuttgart.citydoctor2.utils.TimeFormatter
;
import
de.hft.stuttgart.quality.model.enums.RequirementId
;
import
de.hft.stuttgart.quality.model.enums.TopLevelFeatureType
;
import
de.hft.stuttgart.quality.model.properties.CheckingProperty
;
...
...
@@ -79,6 +81,8 @@ import java.io.InputStream;
import
java.io.UncheckedIOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.text.ChoiceFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
...
...
@@ -199,9 +203,6 @@ public class Checker {
});
schematronThread
.
start
();
checkCityModel
(
model
,
l
);
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.checksFinished"
));
}
if
(
schematronThread
.
isAlive
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronStillRunning"
));
if
(
l
!=
null
){
...
...
@@ -221,14 +222,13 @@ public class Checker {
private
void
handleSchematronResults
(
SvrlContentHandler
handler
)
{
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
Map
<
String
,
CityObject
>
featureMap
=
new
HashMap
<>();
model
.
createFeatureStream
().
forEach
(
f
->
featureMap
.
put
(
f
.
getGmlId
().
getGmlString
(),
f
));
FeatureCache
cache
=
CacheManager
.
getFeatureCache
();
handler
.
getFeatureErrors
().
forEach
((
k
,
v
)
->
{
if
(
k
.
trim
().
isEmpty
())
{
// missing gml id, ignore?
return
;
}
CityObject
co
=
featureMap
.
get
(
k
);
CityObject
co
=
cache
.
get
(
new
GmlId
(
k
)
);
if
(
co
==
null
)
{
// gml id reported by schematron was not found, add to general errors
for
(
SchematronError
se
:
v
)
{
...
...
@@ -663,22 +663,20 @@ public class Checker {
List
<
Future
<
GmlId
>>
futures
=
runChecksOnFeatures
(
exec
,
cache
,
features
,
checkedCount
,
l
);
List
<
GmlId
>
missedFeatures
=
getMissedFeatures
(
futures
);
if
(!
missedFeatures
.
isEmpty
()){
logger
.
warn
(
Localization
.
getText
(
"Checker.dbUnresponsive"
));
logger
.
info
(
Localization
.
getText
(
"Checker.waitAndRetry"
));
Thread
.
sleep
(
1000
);
futures
=
runChecksOnFeatures
(
exec
,
cache
,
missedFeatures
,
checkedCount
,
l
);
missedFeatures
=
getMissedFeatures
(
futures
);
if
(!
missedFeatures
.
isEmpty
()){
logger
.
error
(
Localization
.
getText
(
"Checker.dbStillUnresponsive"
));
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
missedFeatures
.
toString
());
}
logger
.
error
(
Localization
.
getText
(
"Checker.dbUnresponsive"
));
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
missedFeatures
.
toString
());
}
}
long
endTime
=
System
.
nanoTime
();
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"Checks finished in {} ms"
,
(
endTime
-
startTime
)
/
1_000_000
);
if
(
logger
.
isInfoEnabled
()){
long
totalTime
=
(
endTime
-
startTime
)
/
1_000_000
;
// Convert ns to ms
String
messageString
=
Localization
.
getText
(
"Checker.checksFinished"
);
String
timeString
=
TimeFormatter
.
format
(
totalTime
);
messageString
=
messageString
.
replace
(
"{0}"
,
timeString
);
logger
.
info
(
messageString
);
}
}
catch
(
InterruptedException
e
){
// No interrupts implemented, so this block should actually never be entered
...
...
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