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
1bc2d658
Commit
1bc2d658
authored
Dec 03, 2020
by
Matthias Betz
Browse files
implement schematron with different error types
parent
b0f6085c
Pipeline
#1604
failed with stage
in 1 minute and 31 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/Checkable.java
View file @
1bc2d658
...
@@ -65,7 +65,12 @@ public abstract class Checkable implements Serializable {
...
@@ -65,7 +65,12 @@ public abstract class Checkable implements Serializable {
* @param c the check from which the check method is called with the Checkable
* @param c the check from which the check method is called with the Checkable
* instance as parameter.
* instance as parameter.
*/
*/
public
abstract
void
accept
(
Check
c
);
public
void
accept
(
Check
c
)
{
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
setValidated
(
true
);
}
/**
/**
* The GML-ID of the checkable. This is necessary so specific features can be
* The GML-ID of the checkable. This is necessary so specific features can be
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/ErrorId.java
View file @
1bc2d658
...
@@ -101,4 +101,8 @@ public class ErrorId implements Serializable {
...
@@ -101,4 +101,8 @@ public class ErrorId implements Serializable {
return
name
;
return
name
;
}
}
public
String
getIdString
()
{
return
name
;
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/ErrorVisitor.java
View file @
1bc2d658
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
package
de.hft.stuttgart.citydoctor2.check
;
package
de.hft.stuttgart.citydoctor2.check
;
import
de.hft.stuttgart.citydoctor2.check.error.AllPolygonsWrongOrientationError
;
import
de.hft.stuttgart.citydoctor2.check.error.AllPolygonsWrongOrientationError
;
import
de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError
;
import
de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError
;
import
de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError
;
import
de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError
;
import
de.hft.stuttgart.citydoctor2.check.error.DependenciesNotMetError
;
import
de.hft.stuttgart.citydoctor2.check.error.DependenciesNotMetError
;
import
de.hft.stuttgart.citydoctor2.check.error.MultipleConnectedComponentsError
;
import
de.hft.stuttgart.citydoctor2.check.error.MultipleConnectedComponentsError
;
...
@@ -122,5 +124,9 @@ public interface ErrorVisitor {
...
@@ -122,5 +124,9 @@ public interface ErrorVisitor {
public
void
visit
(
SurfaceUnfragmentedError
err
);
public
void
visit
(
SurfaceUnfragmentedError
err
);
public
void
visit
(
TinyEdgeError
err
);
public
void
visit
(
TinyEdgeError
err
);
public
void
visit
(
AttributeMissingError
err
);
public
void
visit
(
AttributeValueWrongError
err
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/AttributeMissingError.java
0 → 100644
View file @
1bc2d658
/*-
* 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.error
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.ErrorId
;
import
de.hft.stuttgart.citydoctor2.check.ErrorReport
;
import
de.hft.stuttgart.citydoctor2.check.ErrorType
;
import
de.hft.stuttgart.citydoctor2.check.ErrorVisitor
;
import
de.hft.stuttgart.citydoctor2.check.HealingMethod
;
import
de.hft.stuttgart.citydoctor2.check.ModificationListener
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlElement
;
public
class
AttributeMissingError
implements
CheckError
{
private
static
final
long
serialVersionUID
=
185026674309965067L
;
public
static
final
ErrorId
ID
=
new
ErrorId
(
"SEM_ATTRIBUTE_MISSING"
);
private
CityObject
co
;
private
boolean
generic
;
private
String
childId
;
private
String
nameOfAttribute
;
public
AttributeMissingError
(
CityObject
co
,
String
childId
,
String
nameOfAttribute
,
boolean
generic
)
{
this
.
co
=
co
;
this
.
childId
=
childId
;
this
.
nameOfAttribute
=
nameOfAttribute
;
this
.
generic
=
generic
;
}
@Override
public
ErrorType
getType
()
{
return
ErrorType
.
ERROR
;
}
@Override
public
ErrorId
getErrorId
()
{
return
ID
;
}
public
String
getChildId
()
{
return
childId
;
}
public
boolean
isGeneric
()
{
return
generic
;
}
public
String
getNameOfAttribute
()
{
return
nameOfAttribute
;
}
@Override
public
GmlElement
getFeature
()
{
return
co
;
}
@Override
public
void
accept
(
ErrorVisitor
errorVisitor
)
{
errorVisitor
.
visit
(
this
);
}
@Override
public
boolean
accept
(
HealingMethod
method
,
ModificationListener
l
)
{
return
method
.
visit
(
this
,
l
);
}
@Override
public
void
report
(
ErrorReport
report
)
{
report
.
add
(
"childId"
,
childId
);
report
.
add
(
"name"
,
nameOfAttribute
);
report
.
add
(
"generic"
,
""
+
generic
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/AttributeValueWrongError.java
0 → 100644
View file @
1bc2d658
/*-
* 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.error
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.ErrorId
;
import
de.hft.stuttgart.citydoctor2.check.ErrorReport
;
import
de.hft.stuttgart.citydoctor2.check.ErrorType
;
import
de.hft.stuttgart.citydoctor2.check.ErrorVisitor
;
import
de.hft.stuttgart.citydoctor2.check.HealingMethod
;
import
de.hft.stuttgart.citydoctor2.check.ModificationListener
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.GmlElement
;
public
class
AttributeValueWrongError
implements
CheckError
{
private
static
final
long
serialVersionUID
=
6106964709204961560L
;
public
static
final
ErrorId
ID
=
new
ErrorId
(
"SEM_ATTRIBUTE_WRONG_VALUE"
);
private
CityObject
co
;
private
boolean
generic
;
private
String
childId
;
private
String
nameOfAttribute
;
public
AttributeValueWrongError
(
CityObject
co
,
String
childId
,
String
nameOfAttribute
,
boolean
generic
)
{
this
.
co
=
co
;
this
.
childId
=
childId
;
this
.
nameOfAttribute
=
nameOfAttribute
;
this
.
generic
=
generic
;
}
@Override
public
ErrorType
getType
()
{
return
ErrorType
.
ERROR
;
}
@Override
public
ErrorId
getErrorId
()
{
return
ID
;
}
@Override
public
GmlElement
getFeature
()
{
return
co
;
}
public
String
getChildId
()
{
return
childId
;
}
public
boolean
isGeneric
()
{
return
generic
;
}
public
String
getNameOfAttribute
()
{
return
nameOfAttribute
;
}
@Override
public
void
accept
(
ErrorVisitor
errorVisitor
)
{
errorVisitor
.
visit
(
this
);
}
@Override
public
boolean
accept
(
HealingMethod
method
,
ModificationListener
l
)
{
return
method
.
visit
(
this
,
l
);
}
@Override
public
void
report
(
ErrorReport
report
)
{
report
.
add
(
"childId"
,
childId
);
report
.
add
(
"name"
,
nameOfAttribute
);
report
.
add
(
"generic"
,
""
+
generic
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/check/error/SchematronError.java
View file @
1bc2d658
...
@@ -31,10 +31,19 @@ public class SchematronError implements CheckError {
...
@@ -31,10 +31,19 @@ public class SchematronError implements CheckError {
private
static
final
long
serialVersionUID
=
-
2964084500589868928L
;
private
static
final
long
serialVersionUID
=
-
2964084500589868928L
;
private
String
text
;
private
String
errorId
;
private
String
gmlId
;
private
String
childId
;
private
String
nameOfAttribute
;
private
boolean
generic
;
public
SchematronError
(
String
text
)
{
this
.
text
=
text
;
public
SchematronError
(
String
errorId
,
String
gmlId
,
String
childId
,
String
nameOfAttribute
,
boolean
generic
)
{
this
.
errorId
=
errorId
;
this
.
gmlId
=
gmlId
;
this
.
childId
=
childId
;
this
.
nameOfAttribute
=
nameOfAttribute
;
this
.
generic
=
generic
;
}
}
@Override
@Override
...
@@ -49,18 +58,34 @@ public class SchematronError implements CheckError {
...
@@ -49,18 +58,34 @@ public class SchematronError implements CheckError {
@Override
@Override
public
void
report
(
ErrorReport
report
)
{
public
void
report
(
ErrorReport
report
)
{
report
.
add
(
"
Description"
,
text
);
report
.
add
(
"
errorId"
,
errorId
);
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"SchematronError [text="
+
text
+
"]"
;
return
"SchematronError [text="
+
errorId
+
"]"
;
}
}
public
String
get
Text
()
{
public
String
get
ChildId
()
{
return
text
;
return
childId
;
}
}
public
String
getGmlId
()
{
return
gmlId
;
}
public
String
getNameOfAttribute
()
{
return
nameOfAttribute
;
}
public
String
getErrorIdString
()
{
return
errorId
;
}
public
boolean
isGeneric
()
{
return
generic
;
}
@Override
@Override
public
ErrorType
getType
()
{
public
ErrorType
getType
()
{
return
ErrorType
.
ERROR
;
return
ErrorType
.
ERROR
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Geometry.java
View file @
1bc2d658
...
@@ -413,11 +413,13 @@ public class Geometry extends GmlElement {
...
@@ -413,11 +413,13 @@ public class Geometry extends GmlElement {
@Override
@Override
public
void
clearMetaInformation
()
{
public
void
clearMetaInformation
()
{
for
(
Vertex
v
:
vertices
)
{
if
(
vertices
!=
null
)
{
v
.
clearAdjacentRings
();
for
(
Vertex
v
:
vertices
)
{
v
.
clearAdjacentRings
();
}
vertices
=
null
;
}
}
edges
=
null
;
edges
=
null
;
vertices
=
null
;
edgeMap
=
null
;
edgeMap
=
null
;
}
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/GmlElement.java
View file @
1bc2d658
...
@@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
...
@@ -25,7 +25,6 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.UncheckedIOException
;
import
java.io.UncheckedIOException
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
/**
/**
...
@@ -54,14 +53,6 @@ public abstract class GmlElement extends Checkable {
...
@@ -54,14 +53,6 @@ public abstract class GmlElement extends Checkable {
}
}
}
}
@Override
public
void
accept
(
Check
c
)
{
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
setValidated
(
true
);
}
public
void
setGmlId
(
GmlId
id
)
{
public
void
setGmlId
(
GmlId
id
)
{
gmlId
=
id
;
gmlId
=
id
;
}
}
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
1bc2d658
...
@@ -47,13 +47,13 @@ import org.apache.logging.log4j.LogManager;
...
@@ -47,13 +47,13 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Document
;
import
de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError
;
import
de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError
;
import
de.hft.stuttgart.citydoctor2.check.error.SchematronError
;
import
de.hft.stuttgart.citydoctor2.check.error.SchematronError
;
import
de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException
;
import
de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException
;
import
de.hft.stuttgart.citydoctor2.checks.Checks
;
import
de.hft.stuttgart.citydoctor2.checks.Checks
;
import
de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler
;
import
de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler
;
import
de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener
;
import
de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.BuildingPart
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.FeatureType
;
import
de.hft.stuttgart.citydoctor2.datastructure.FeatureType
;
...
@@ -111,7 +111,7 @@ public class Checker {
...
@@ -111,7 +111,7 @@ public class Checker {
public
Checks
getChecks
()
{
public
Checks
getChecks
()
{
return
checkConfig
;
return
checkConfig
;
}
}
public
CityDoctorModel
getModel
()
{
public
CityDoctorModel
getModel
()
{
return
model
;
return
model
;
}
}
...
@@ -187,36 +187,47 @@ public class Checker {
...
@@ -187,36 +187,47 @@ public class Checker {
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
if
(
handler
!=
null
)
{
if
(
handler
!=
null
)
{
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
Map
<
String
,
C
heckable
>
featureMap
=
new
HashMap
<>();
Map
<
String
,
C
ityObject
>
featureMap
=
new
HashMap
<>();
model
.
createFeatureStream
().
forEach
(
f
->
featureMap
.
put
(
f
.
getGmlId
().
getGmlString
(),
f
));
model
.
createFeatureStream
().
forEach
(
f
->
featureMap
.
put
(
f
.
getGmlId
().
getGmlString
(),
f
));
for
(
Building
b
:
model
.
getBuildings
())
{
for
(
BuildingPart
bp
:
b
.
getBuildingParts
())
{
featureMap
.
put
(
bp
.
getGmlId
().
getGmlString
(),
bp
);
}
}
handler
.
getFeatureErrors
().
forEach
((
k
,
v
)
->
{
handler
.
getFeatureErrors
().
forEach
((
k
,
v
)
->
{
if
(
k
.
trim
().
isEmpty
())
{
if
(
k
.
trim
().
isEmpty
())
{
// missing gml id, ignore?
// missing gml id, ignore?
return
;
return
;
}
}
C
heckable
checkable
=
featureMap
.
get
(
k
);
C
ityObject
co
=
featureMap
.
get
(
k
);
if
(
c
heckable
==
null
)
{
if
(
c
o
==
null
)
{
// gml id reported by schematron was not found, add to general errors
// gml id reported by schematron was not found, add to general errors
model
.
addGlobalError
(
v
);
for
(
SchematronError
se
:
v
)
{
model
.
addGlobalError
(
se
);
}
}
else
{
}
else
{
checkable
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_SEM_SCHEMATRON
,
ResultStatus
.
ERROR
,
v
));
int
count
=
0
;
for
(
SchematronError
se
:
v
)
{
CheckError
err
;
if
(
AttributeMissingError
.
ID
.
getIdString
().
equals
(
se
.
getErrorIdString
()))
{
err
=
new
AttributeMissingError
(
co
,
se
.
getChildId
(),
se
.
getNameOfAttribute
(),
se
.
isGeneric
());
}
else
if
(
AttributeValueWrongError
.
ID
.
getIdString
().
equals
(
se
.
getErrorIdString
()))
{
err
=
new
AttributeValueWrongError
(
co
,
se
.
getChildId
(),
se
.
getNameOfAttribute
(),
se
.
isGeneric
());
}
else
{
throw
new
IllegalStateException
(
"Unknown error ID was given in schematron file: "
+
se
.
getErrorIdString
());
}
co
.
addCheckResult
(
new
CheckResult
(
new
CheckId
(
""
+
count
),
ResultStatus
.
ERROR
,
err
));
count
++;
}
}
}
});
});
}
}
isValidated
=
true
;
isValidated
=
true
;
}
}
public
ValidationConfiguration
getConfig
()
{
public
ValidationConfiguration
getConfig
()
{
return
config
;
return
config
;
}
}
public
static
SvrlContentHandler
executeSchematronValidationIfAvailable
(
ValidationConfiguration
config
,
public
static
SvrlContentHandler
executeSchematronValidationIfAvailable
(
ValidationConfiguration
config
,
File
file
)
{
File
file
)
{
if
(
config
.
getSchematronFilePath
()
!=
null
&&
!
config
.
getSchematronFilePath
().
isEmpty
())
{
if
(
config
.
getSchematronFilePath
()
!=
null
&&
!
config
.
getSchematronFilePath
().
isEmpty
())
{
if
(
logger
.
isInfoEnabled
())
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
logger
.
info
(
Localization
.
getText
(
"Checker.schematronValidation"
));
...
@@ -372,7 +383,7 @@ public class Checker {
...
@@ -372,7 +383,7 @@ public class Checker {
}
}
// check every feature
// check every feature
executeChecksForCityObject
(
co
);
executeChecksForCityObject
(
co
);
if
(
config
.
getParserConfiguration
().
useLowMemoryConsumption
())
{
if
(
config
.
getParserConfiguration
().
useLowMemoryConsumption
())
{
// low memory consumption, remove edges again
// low memory consumption, remove edges again
co
.
clearMetaInformation
();
co
.
clearMetaInformation
();
...
@@ -448,10 +459,10 @@ public class Checker {
...
@@ -448,10 +459,10 @@ public class Checker {
public
static
List
<
List
<
Check
>>
buildExecutionLayers
(
List
<
Check
>
checks
)
{
public
static
List
<
List
<
Check
>>
buildExecutionLayers
(
List
<
Check
>
checks
)
{
List
<
List
<
Check
>>
result
=
new
ArrayList
<>();
List
<
List
<
Check
>>
result
=
new
ArrayList
<>();
Set
<
Check
>
availableChecks
=
new
HashSet
<>(
checks
);
Set
<
Check
>
availableChecks
=
new
HashSet
<>(
checks
);
Set
<
CheckId
>
usedChecks
=
new
HashSet
<>();
Set
<
CheckId
>
usedChecks
=
new
HashSet
<>();
while
(!
availableChecks
.
isEmpty
())
{
while
(!
availableChecks
.
isEmpty
())
{
List
<
Check
>
layer
=
new
ArrayList
<>();
List
<
Check
>
layer
=
new
ArrayList
<>();
Iterator
<
Check
>
iterator
=
availableChecks
.
iterator
();
Iterator
<
Check
>
iterator
=
availableChecks
.
iterator
();
...
@@ -464,7 +475,8 @@ public class Checker {
...
@@ -464,7 +475,8 @@ public class Checker {
}
}
}
}
if
(
layer
.
isEmpty
())
{
if
(
layer
.
isEmpty
())
{
throw
new
IllegalStateException
(
"There are checks that have dependencies that are not executed or are unknown"
);
throw
new
IllegalStateException
(
"There are checks that have dependencies that are not executed or are unknown"
);
}
}
result
.
add
(
layer
);
result
.
add
(
layer
);
for
(
Check
c
:
layer
)
{
for
(
Check
c
:
layer
)
{
...
@@ -526,8 +538,10 @@ public class Checker {
...
@@ -526,8 +538,10 @@ public class Checker {
for
(
SchematronError
err
:
handler
.
getGeneralErrors
())
{
for
(
SchematronError
err
:
handler
.
getGeneralErrors
())
{
reporter
.
reportGlobalError
(
err
);
reporter
.
reportGlobalError
(
err
);
}
}
for
(
Entry
<
String
,
SchematronError
>
e
:
handler
.
getFeatureErrors
().
entrySet
())
{
for
(
Entry
<
String
,
List
<
SchematronError
>>
e
:
handler
.
getFeatureErrors
().
entrySet
())
{
reporter
.
addError
(
e
.
getKey
(),
e
.
getValue
());