Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
54df2199
Commit
54df2199
authored
Nov 02, 2020
by
Matthias Betz
Browse files
Added more translation
parent
fb27a687
Pipeline
#1143
passed with stage
in 1 minute and 57 seconds
Changes
16
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/Checkable.java
View file @
54df2199
...
...
@@ -38,7 +38,7 @@ public abstract class Checkable implements Serializable {
private
static
final
long
serialVersionUID
=
-
1707871839265057882L
;
private
static
Logger
logger
=
LogManager
.
getLogger
(
Checkable
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Checkable
.
class
);
private
EnumMap
<
CheckId
,
CheckResult
>
checkResults
=
new
EnumMap
<>(
CheckId
.
class
);
private
boolean
isValidated
=
false
;
...
...
@@ -168,9 +168,9 @@ public abstract class Checkable implements Serializable {
*/
public
void
addCheckResult
(
CheckResult
cr
)
{
checkResults
.
put
(
cr
.
getCheckIdentifier
(),
cr
);
if
(
cr
.
getResultStatus
()
==
ResultStatus
.
ERROR
)
{
if
(
cr
.
getResultStatus
()
==
ResultStatus
.
ERROR
&&
logger
.
isDebugEnabled
()
)
{
logger
.
debug
(
"{} has found an error of type {}"
,
cr
.
getCheckIdentifier
(),
cr
.
getError
().
getErrorId
());
}
else
if
(
cr
.
getResultStatus
()
==
ResultStatus
.
WARNING
)
{
}
else
if
(
cr
.
getResultStatus
()
==
ResultStatus
.
WARNING
&&
logger
.
isDebugEnabled
()
)
{
logger
.
debug
(
"{} has found a warning of type {}"
,
cr
.
getCheckIdentifier
(),
cr
.
getError
().
getErrorId
());
}
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/Unit.java
View file @
54df2199
...
...
@@ -18,6 +18,8 @@
*/
package
de.hft.stuttgart.citydoctor2.check
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
/**
* A unit description. Used in the parameters of a check to specify what type of
* value is required.
...
...
@@ -27,7 +29,7 @@ package de.hft.stuttgart.citydoctor2.check;
*/
public
enum
Unit
{
KWH
(
"kWh"
),
METER
(
"m"
),
SQUARE_METER
(
"m²"
),
CUBIC_METER
(
"m³"
),
RADIAN
(
"
Radian"
),
NONE
(
""
),
DEGREE
(
"
Degree"
);
KWH
(
"kWh"
),
METER
(
"m"
),
SQUARE_METER
(
"m²"
),
CUBIC_METER
(
"m³"
),
RADIAN
(
Localization
.
getText
(
"Unit.
Radian"
)
)
,
NONE
(
""
),
DEGREE
(
Localization
.
getText
(
"Unit.
Degree"
)
)
;
private
String
representation
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/FeatureMapper.java
View file @
54df2199
...
...
@@ -80,6 +80,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import
de.hft.stuttgart.citydoctor2.datastructure.WaterObject
;
import
de.hft.stuttgart.citydoctor2.math.graph.KDTree
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
de.hft.stuttgart.citydoctor2.utils.Pair
;
/**
...
...
@@ -91,7 +92,7 @@ import de.hft.stuttgart.citydoctor2.utils.Pair;
*/
public
class
FeatureMapper
extends
FeatureWalker
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
FeatureMapper
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
FeatureMapper
.
class
);
private
CityDoctorModel
model
;
private
ParserConfiguration
config
;
...
...
@@ -142,7 +143,9 @@ public class FeatureMapper extends FeatureWalker {
for
(
Pair
<
String
,
Geometry
>
link
:
linkedPolygons
)
{
ConcretePolygon
concPoly
=
polygons
.
get
(
link
.
getValue0
());
if
(
concPoly
==
null
)
{
logger
.
warn
(
"Polygon {} is referenced but not found in feature polygons"
,
link
.
getValue0
());
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"FeatureMapper.polygonUnreferenced"
),
link
.
getValue0
());
}
continue
;
}
LinkedPolygon
lPoly
=
new
LinkedPolygon
(
concPoly
,
link
.
getValue1
());
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/GeometryMapper.java
View file @
54df2199
...
...
@@ -54,6 +54,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import
de.hft.stuttgart.citydoctor2.datastructure.Lod
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
de.hft.stuttgart.citydoctor2.utils.Pair
;
/**
...
...
@@ -63,7 +64,7 @@ import de.hft.stuttgart.citydoctor2.utils.Pair;
*/
public
class
GeometryMapper
extends
GeometryWalker
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
GeometryMapper
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
GeometryMapper
.
class
);
private
Geometry
geom
;
private
ParserConfiguration
config
;
...
...
@@ -128,14 +129,13 @@ public class GeometryMapper extends GeometryWalker {
@Override
public
void
visit
(
org
.
citygml4j
.
model
.
gml
.
geometry
.
primitives
.
Polygon
gmlPoly
)
{
if
(!
gmlPoly
.
isSetExterior
())
{
logger
.
warn
(
"Found polygon without exterior ring, ignoring"
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"GeometryMapper.emptyPolygon"
));
}
return
;
}
ConcretePolygon
cdPoly
=
new
ConcretePolygon
();
if
(
gmlPoly
.
isSetId
())
{
cdPoly
.
setGmlId
(
new
GmlId
(
gmlPoly
.
getId
()));
polygons
.
put
(
gmlPoly
.
getId
(),
cdPoly
);
}
addPolygonToAvailablePolygons
(
gmlPoly
,
cdPoly
);
geom
.
addPolygon
(
cdPoly
);
if
(
bs
!=
null
)
{
// polygon is part of a boundary surface
...
...
@@ -167,6 +167,14 @@ public class GeometryMapper extends GeometryWalker {
}
}
private
void
addPolygonToAvailablePolygons
(
org
.
citygml4j
.
model
.
gml
.
geometry
.
primitives
.
Polygon
gmlPoly
,
ConcretePolygon
cdPoly
)
{
if
(
gmlPoly
.
isSetId
())
{
cdPoly
.
setGmlId
(
new
GmlId
(
gmlPoly
.
getId
()));
polygons
.
put
(
gmlPoly
.
getId
(),
cdPoly
);
}
}
private
void
mapRing
(
AbstractRingProperty
gmlRing
,
LinearRing
cdRing
)
{
AbstractRing
ringGeometry
=
gmlRing
.
getRing
();
if
(
ringGeometry
.
isSetId
())
{
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/parser/CityGmlParser.java
View file @
54df2199
...
...
@@ -72,6 +72,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.mapper.FeatureMapper
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
/**
* Utility class to parse CityGML files.
...
...
@@ -97,12 +98,12 @@ public class CityGmlParser {
// urn:adv:crs:ETRS89_UTM32*DE_DHHN92_NH
private
static
final
Pattern
P_URN
=
Pattern
.
compile
(
"urn:adv:crs:([^\\*]+)"
);
private
static
SAXParserFactory
factory
;
private
static
final
SAXParserFactory
FACTORY
;
static
{
factory
=
SAXParserFactory
.
newInstance
();
FACTORY
=
SAXParserFactory
.
newInstance
();
try
{
factory
.
setFeature
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
,
true
);
FACTORY
.
setFeature
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
,
true
);
}
catch
(
SAXNotRecognizedException
|
SAXNotSupportedException
|
ParserConfigurationException
e
)
{
logger
.
catching
(
e
);
}
...
...
@@ -142,13 +143,15 @@ public class CityGmlParser {
mapper
.
setCityModel
(
cModel
);
}
}
logger
.
info
(
"Parsed model with {} objects"
,
mapper
.
getModel
().
getNumberOfFeatures
());
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"CityGmlParser.parsedObjects"
),
mapper
.
getModel
().
getNumberOfFeatures
());
}
return
mapper
.
getModel
();
}
}
}
catch
(
CityGMLReadException
e
)
{
if
(
e
.
getCause
()
instanceof
SAXParseException
)
{
throw
new
InvalidGmlFileException
(
"This is not a valid GML-
File
\n
"
+
e
.
getCause
().
getMessage
(),
e
);
throw
new
InvalidGmlFileException
(
Localization
.
getText
(
"CityGmlParser.notValidGml
File"
)
+
e
.
getCause
().
getMessage
(),
e
);
}
throw
new
CityGmlParseException
(
e
);
}
catch
(
IOException
|
CityGMLBuilderException
|
ParserConfigurationException
|
SAXException
|
ADEException
e
)
{
...
...
@@ -159,7 +162,9 @@ public class CityGmlParser {
// fallback solution is to parse the whole file at once
// problems with memory consumption may arise
try
{
logger
.
warn
(
"Failed to read GML file in chunks, falling back to reading the complete file"
,
e
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"CityGmlParser.chunkReadFailed"
),
e
);
}
return
parseCityGmlFileComplete
(
file
,
config
,
l
);
}
catch
(
CityGMLBuilderException
|
CityGMLReadException
|
IOException
e1
)
{
throw
new
CityGmlParseException
(
e1
);
...
...
@@ -249,7 +254,7 @@ public class CityGmlParser {
}
readFeatures
(
file
,
config
,
inputFactory
,
queue
,
ois
,
stream
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"Error while reading city gml file\n{}"
,
e
.
getMessage
());
logger
.
error
(
Localization
.
getText
(
"CityGmlParser.errorReadingGmlFile"
)
,
e
.
getMessage
());
logger
.
catching
(
Level
.
ERROR
,
e
);
}
});
...
...
@@ -377,7 +382,7 @@ public class CityGmlParser {
queue
.
put
(
FeatureStream
.
POISON
);
logger
.
debug
(
"End of gml file stream"
);
}
catch
(
CityGMLReadException
e
)
{
logger
.
error
(
"Error while reading city gml file\n"
+
e
.
getMessage
(),
e
);
logger
.
error
(
Localization
.
getText
(
"CityGmlParser.errorReadingGmlFile"
),
e
.
getMessage
(),
e
);
}
catch
(
InterruptedException
e
)
{
logger
.
warn
(
"Interrupted while streaming gml file"
);
Thread
.
currentThread
().
interrupt
();
...
...
@@ -393,61 +398,71 @@ public class CityGmlParser {
private
static
void
parseEpsgCodeFromStream
(
InputStream
is
,
ParserConfiguration
config
)
throws
ParserConfigurationException
,
SAXException
{
SAXParser
parser
=
factory
.
newSAXParser
();
SAXParser
parser
=
FACTORY
.
newSAXParser
();
CityGmlHandler
handler
=
new
CityGmlHandler
();
try
{
parser
.
parse
(
new
InputSource
(
is
),
handler
);
}
catch
(
EnvelopeFoundException
e
)
{
try
{
if
(
handler
.
getEpsg
()
==
null
)
{
return
;
}
CoordinateReferenceSystem
crs
=
crsFromSrsName
(
handler
.
getEpsg
());
if
(
crs
==
null
)
{
// could not find a coordinate system for srsName
// assuming metric system
return
;
}
ProjectionUnitExtractor
extractor
=
new
ProjectionUnitExtractor
(
crs
.
getProjection
());
if
(
extractor
.
getUnit
()
==
Units
.
METRES
)
{
// coordinate system is in meters, do not convert
logger
.
info
(
"Coordinate system is in meters, no conversion done"
);
return
;
}
parseMeterConversion
(
config
,
crs
);
Vector3d
low
=
handler
.
getLowerCorner
();
Vector3d
up
=
handler
.
getUpperCorner
();
double
centerLong
=
low
.
getX
()
+
((
up
.
getX
()
-
low
.
getX
())
/
2
);
double
centerLat
=
low
.
getY
()
+
((
up
.
getY
()
-
low
.
getY
())
/
2
);
if
(!
crs
.
getName
().
equals
(
"EPSG:4326"
))
{
// need to convert coordinates first to WGS84, then find UTM Zone
CoordinateReferenceSystem
wgs84
=
crsFromSrsName
(
"EPSG:4326"
);
ProjCoordinate
p1
=
new
ProjCoordinate
();
p1
.
setValue
(
centerLong
,
centerLat
);
ProjCoordinate
p2
=
new
ProjCoordinate
();
BasicCoordinateTransform
bct
=
new
BasicCoordinateTransform
(
crs
,
wgs84
);
bct
.
transform
(
p1
,
p2
);
centerLong
=
p2
.
x
;
centerLat
=
p2
.
y
;
}
int
zone
=
(
int
)
(
31
+
Math
.
round
(
centerLong
/
6
));
CoordinateReferenceSystem
utm
;
if
(
centerLat
<
0
)
{
// south
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
+
" +south"
);
}
else
{
// north
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
);
}
config
.
setCoordinateSystem
(
crs
,
utm
);
parseCoordinateSystem
(
config
,
handler
);
}
catch
(
Exception
e2
)
{
logger
.
debug
(
"Exception while parsing for EPSG code"
,
e2
);
logger
.
warn
(
"Could not read EPSG code, assuming metric system"
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"CityGmlParser.noEPSG"
));
}
}
}
catch
(
Exception
e
)
{
logger
.
debug
(
"Exception while parsing for EPSG code"
,
e
);
logger
.
warn
(
"Could not read EPSG code, assuming metric system"
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"CityGmlParser.noEPSG"
));
}
}
}
private
static
void
parseCoordinateSystem
(
ParserConfiguration
config
,
CityGmlHandler
handler
)
{
if
(
handler
.
getEpsg
()
==
null
)
{
return
;
}
CoordinateReferenceSystem
crs
=
crsFromSrsName
(
handler
.
getEpsg
());
if
(
crs
==
null
)
{
// could not find a coordinate system for srsName
// assuming metric system
return
;
}
ProjectionUnitExtractor
extractor
=
new
ProjectionUnitExtractor
(
crs
.
getProjection
());
if
(
extractor
.
getUnit
()
==
Units
.
METRES
)
{
// coordinate system is in meters, do not convert
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"CityGmlParser.noConversionNeeded"
));
}
return
;
}
parseMeterConversion
(
config
,
crs
);
Vector3d
low
=
handler
.
getLowerCorner
();
Vector3d
up
=
handler
.
getUpperCorner
();
double
centerLong
=
low
.
getX
()
+
((
up
.
getX
()
-
low
.
getX
())
/
2
);
double
centerLat
=
low
.
getY
()
+
((
up
.
getY
()
-
low
.
getY
())
/
2
);
if
(!
crs
.
getName
().
equals
(
"EPSG:4326"
))
{
// need to convert coordinates first to WGS84, then find UTM Zone
CoordinateReferenceSystem
wgs84
=
crsFromSrsName
(
"EPSG:4326"
);
ProjCoordinate
p1
=
new
ProjCoordinate
();
p1
.
setValue
(
centerLong
,
centerLat
);
ProjCoordinate
p2
=
new
ProjCoordinate
();
BasicCoordinateTransform
bct
=
new
BasicCoordinateTransform
(
crs
,
wgs84
);
bct
.
transform
(
p1
,
p2
);
centerLong
=
p2
.
x
;
centerLat
=
p2
.
y
;
}
int
zone
=
(
int
)
(
31
+
Math
.
round
(
centerLong
/
6
));
CoordinateReferenceSystem
utm
;
if
(
centerLat
<
0
)
{
// south
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
+
" +south"
);
}
else
{
// north
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
);
}
config
.
setCoordinateSystem
(
crs
,
utm
);
}
private
static
void
parseMeterConversion
(
ParserConfiguration
config
,
CoordinateReferenceSystem
crs
)
{
...
...
CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties
View file @
54df2199
...
...
@@ -78,4 +78,32 @@ ValidationConfiguration.reenable={} has been disabled but {} depends on it, reen
ValidationConfiguration.missingSchematron
=
{} is not an existing file, disabling schematron check
CheckContainer.error
=
Unexpected exception while executing check: {}
Checks.missingCheck
=
Could not find check for id: {}
OpenFileDialog.cancelBtn
=
Cancel
\ No newline at end of file
OpenFileDialog.cancelBtn
=
Cancel
CheckDialog.checksTab
=
Checks
CheckDialog.filterTab
=
Filter
CheckDialog.globalParametersLabel
=
Global Parameters
CheckDialog.availableChecksLabel
=
Available Checks
CheckDialog.geometricChecksLabel
=
Geometric Checks
CheckDialog.semanticChecksLabel
=
Semantic Checks
CheckDialog.schematronFileLabel
=
Schematron File:
CheckDialog.selectBtn
=
Select
CheckDialog.checkBtn
=
Check
CheckDialog.cancelBtn
=
Cancel
WriteReportDialog.writeBtn
=
Save
WriteReportDialog.cancelBtn
=
Cancel
WriteReportDialog.errorStatisticsLabel
=
Error Statistics
WriteReportDialog.saveImageBtn
=
Save Image...
WriteReportDialog.selectPdfBtn
=
Select
WriteReportDialog.selectXmlFile
=
Select
WriteReportDialog.xAxisLabel
=
Error
WriteReportDialog.yAxisLabel
=
Count
Unit.Radian
=
Radian
Unit.Degree
=
Degree
FeatureMapper.polygonUnreferenced
=
Polygon {} is referenced but not found in feature polygons
GeometryMapper.emptyPolygon
=
Found polygon without exterior ring, ignoring
CityGmlParser.parsedObjects
=
Parsed model with {} objects
CityGmlParser.chunkReadFailed
=
Failed to read GML file in chunks, falling back to reading the complete file
CityGmlParser.notValidGmlFile
=
This is not a valid GML-File
\n
CityGmlParser.errorReadingGmlFile
=
Error while reading city gml file
\n
{}
CityGmlParser.noConversionNeeded
=
Coordinate system is in meters, no conversion done
CityGmlParser.noEPSG
=
Could not read EPSG code, assuming metric system
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties
View file @
54df2199
...
...
@@ -76,4 +76,32 @@ ValidationConfiguration.reenable={} ist deaktiviert wird aber von {} ben\u00f6ti
ValidationConfiguration.missingSchematron
=
{} existiert nicht, deaktiviere Schematron Pr
\u
00fcfung
CheckContainer.error
=
Unerwarteter Fehler bei der Ausf
\u
00fchrung von Pr
\u
00fcfung: {}
Checks.missingCheck
=
Konnte keine Pr
\u
00fcfung f
\u
00fcr id {} finden
OpenFileDialog.cancelBtn
=
Abbrechen
\ No newline at end of file
OpenFileDialog.cancelBtn
=
Abbrechen
CheckDialog.checksTab
=
Pr
\u
00fcfungen
CheckDialog.filterTab
=
Filter
CheckDialog.globalParametersLabel
=
Globale Parameter
CheckDialog.availableChecksLabel
=
Verf
\u
00fcgbare Pr
\u
00fcfungen
CheckDialog.geometricChecksLabel
=
Geometrische Pr
\u
00fcfungen
CheckDialog.semanticChecksLabel
=
Semantische Pr
\u
00fcfungen
CheckDialog.schematronFileLabel
=
Schematron Datei
CheckDialog.selectBtn
=
Ausw
\u
00e4hlen
CheckDialog.checkBtn
=
Pr
\u
00fcfen
CheckDialog.cancelBtn
=
Abbrechen
WriteReportDialog.writeBtn
=
Speichern
WriteReportDialog.cancelBtn
=
Abbrechen
WriteReportDialog.errorStatisticsLabel
=
Fehler Statistik
WriteReportDialog.saveImageBtn
=
Bild Speichern
WriteReportDialog.selectPdfBtn
=
Ausw
\u
00e4hlen
WriteReportDialog.selectXmlFile
=
Ausw
\u
00e4hlen
WriteReportDialog.xAxisLabel
=
Fehler
WriteReportDialog.yAxisLabel
=
Anzahl
Unit.Radian
=
Radiant
Unit.Degree
=
Grad
FeatureMapper.polygonUnreferenced
=
Polygon {} ist referenziert wurde aber nicht in gefunden
GeometryMapper.emptyPolygon
=
Polygon ohne externen Ring gefunden, ignoriere
CityGmlParser.parsedObjects
=
Modell mit {} Objekten gelesen
CityGmlParser.chunkReadFailed
=
Konnte Datei nicht in St
\u
00fccken lesen, versuche komplett zu lesen
CityGmlParser.notValidGmlFile
=
Dies ist keine korrekte CityGML Datei
\n
CityGmlParser.errorReadingGmlFile
=
Fehler beim lesen der CityGML Datei
\n
{}
CityGmlParser.noConversionNeeded
=
Koordinatensystem in Metern, keine Konvertierung notwendig
CityGmlParser.noEPSG
=
Konnte EPSG Code nicht lesen, nehme metrisches System an
\ No newline at end of file
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
54df2199
...
...
@@ -181,7 +181,9 @@ public class Checker {
config
=
ValidationConfiguration
.
loadStandardValidationConfig
();
}
checkCityModel
(
model
,
l
);
logger
.
info
(
Localization
.
getText
(
"Checker.checksFinished"
));
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.checksFinished"
));
}
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
if
(
handler
!=
null
)
{
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
...
...
@@ -212,7 +214,9 @@ public class Checker {
private
static
SvrlContentHandler
executeSchematronValidationIfAvailable
(
ValidationConfiguration
config
,
File
file
)
{
if
(
config
.
getSchematronFilePath
()
!=
null
&&
!
config
.
getSchematronFilePath
().
isEmpty
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
}
Processor
processor
=
new
Processor
(
false
);
XsltCompiler
xsltCompiler
=
processor
.
newXsltCompiler
();
xsltCompiler
.
setURIResolver
(
new
URIResolver
()
{
...
...
@@ -254,7 +258,9 @@ public class Checker {
Destination
dest
=
new
SAXDestination
(
handler
);
schematronTransformer
.
setDestination
(
dest
);
schematronTransformer
.
transform
();
logger
.
info
(
Localization
.
getText
(
"Checker.finishedSchematron"
));
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.finishedSchematron"
));
}
return
handler
;
}
catch
(
SaxonApiException
|
ParserConfigurationException
e
)
{
logger
.
catching
(
e
);
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/ValidationConfiguration.java
View file @
54df2199
...
...
@@ -35,12 +35,6 @@ import org.apache.logging.log4j.Logger;
import
org.yaml.snakeyaml.DumperOptions
;
import
org.yaml.snakeyaml.Yaml
;
import
org.yaml.snakeyaml.constructor.Constructor
;
import
org.yaml.snakeyaml.introspector.Property
;
import
org.yaml.snakeyaml.nodes.CollectionNode
;
import
org.yaml.snakeyaml.nodes.MappingNode
;
import
org.yaml.snakeyaml.nodes.Node
;
import
org.yaml.snakeyaml.nodes.NodeTuple
;
import
org.yaml.snakeyaml.nodes.SequenceNode
;
import
org.yaml.snakeyaml.nodes.Tag
;
import
org.yaml.snakeyaml.representer.Representer
;
...
...
@@ -108,40 +102,7 @@ public class ValidationConfiguration implements Serializable {
DumperOptions
options
=
new
DumperOptions
();
options
.
setDefaultFlowStyle
(
DumperOptions
.
FlowStyle
.
BLOCK
);
options
.
setPrettyFlow
(
true
);
Representer
rep
=
new
Representer
()
{
@Override
protected
NodeTuple
representJavaBeanProperty
(
Object
javaBean
,
Property
property
,
Object
propertyValue
,
Tag
customTag
)
{
if
(
propertyValue
==
null
)
{
return
null
;
}
else
{
NodeTuple
tuple
=
super
.
representJavaBeanProperty
(
javaBean
,
property
,
propertyValue
,
customTag
);
Node
valueNode
=
tuple
.
getValueNode
();
if
(
Tag
.
NULL
.
equals
(
valueNode
.
getTag
()))
{
// skip 'null' values
return
null
;
}
if
(
valueNode
instanceof
CollectionNode
)
{
if
(
Tag
.
SEQ
.
equals
(
valueNode
.
getTag
()))
{
SequenceNode
seq
=
(
SequenceNode
)
valueNode
;
if
(
seq
.
getValue
().
isEmpty
())
{
// skip empty lists
return
null
;
}
}
if
(
Tag
.
MAP
.
equals
(
valueNode
.
getTag
()))
{
MappingNode
seq
=
(
MappingNode
)
valueNode
;
if
(
seq
.
getValue
().
isEmpty
())
{
// skip empty maps
return
null
;
}
}
}
return
tuple
;
}
}
};
Representer
rep
=
new
ValidationConfigurationRepresenter
();
rep
.
addClassTag
(
ValidationConfiguration
.
class
,
Tag
.
MAP
);
Yaml
yaml
=
new
Yaml
(
rep
,
options
);
try
(
BufferedWriter
bw
=
new
BufferedWriter
(
new
FileWriter
(
f
)))
{
...
...
@@ -201,6 +162,19 @@ public class ValidationConfiguration implements Serializable {
return
cConfig
;
});
}
reenableNecessaryChecks
();
if
(
schematronFilePath
!=
null
&&
!
schematronFilePath
.
isEmpty
())
{
File
f
=
new
File
(
schematronFilePath
);
if
(!
f
.
exists
()
||
!
f
.
isFile
())
{
schematronFilePath
=
null
;
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"ValidationConfiguration.missingSchematron"
),
f
.
getAbsolutePath
());
}
}
}
}
private
void
reenableNecessaryChecks
()
{
for
(
java
.
util
.
Map
.
Entry
<
CheckId
,
CheckConfiguration
>
e
:
checks
.
entrySet
())
{
if
(!
e
.
getValue
().
isEnabled
())
{
continue
;
...
...
@@ -210,18 +184,13 @@ public class ValidationConfiguration implements Serializable {
CheckConfiguration
checkConfig
=
checks
.
get
(
dep
);
if
(!
checkConfig
.
isEnabled
())
{
checkConfig
.
setEnabled
(
true
);
logger
.
warn
(
Localization
.
getText
(
"ValidationConfiguration.reenable"
),
dep
,
c
.
getCheckId
());
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"ValidationConfiguration.reenable"
),
dep
,
c
.
getCheckId
());
}
}
}
insertMissingParametersWithDefaultParameters
(
e
,
c
);
}
if
(
schematronFilePath
!=
null
&&
!
schematronFilePath
.
isEmpty
())
{
File
f
=
new
File
(
schematronFilePath
);
if
(!
f
.
exists
()
||
!
f
.
isFile
())
{
schematronFilePath
=
null
;
logger
.
warn
(
Localization
.
getText
(
"ValidationConfiguration.missingSchematron"
),
f
.
getAbsolutePath
());
}
}
}
private
void
insertMissingParametersWithDefaultParameters
(
java
.
util
.
Map
.
Entry
<
CheckId
,
CheckConfiguration
>
e
,
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/ValidationConfigurationRepresenter.java
0 → 100644
View file @
54df2199
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package
de.hft.stuttgart.citydoctor2.check
;
import
org.yaml.snakeyaml.introspector.Property
;
import
org.yaml.snakeyaml.nodes.CollectionNode
;
import
org.yaml.snakeyaml.nodes.MappingNode
;
import
org.yaml.snakeyaml.nodes.Node
;
import
org.yaml.snakeyaml.nodes.NodeTuple
;
import
org.yaml.snakeyaml.nodes.SequenceNode
;
import
org.yaml.snakeyaml.nodes.Tag
;
import
org.yaml.snakeyaml.representer.Representer
;
/**
* Representer for configuration yaml files. Removing null and empty values as
* well as class annotations
*
* @author Matthias Betz
*
*/
public
class
ValidationConfigurationRepresenter
extends
Representer
{
@Override
protected
NodeTuple
representJavaBeanProperty
(
Object
javaBean
,
Property
property
,
Object
propertyValue
,