Fix exceptions when constraints are not or incorrectly provided

This commit is contained in:
Antonin Delpeuch 2018-01-11 11:33:06 +00:00
parent 6c6151ca43
commit 2687741263
2 changed files with 8 additions and 1 deletions

View File

@ -187,7 +187,11 @@ public class ConstraintFetcher {
protected List<Statement> getConstraintStatements(PropertyIdValue pid) {
PropertyDocument doc = (PropertyDocument) EntityCache.getEntityDocument(pid);
StatementGroup group = doc.findStatementGroup(WIKIDATA_CONSTRAINT_PID);
return group.getStatements();
if (group != null) {
return group.getStatements();
} else {
return new ArrayList<Statement>();
}
}
/**

View File

@ -53,6 +53,9 @@ public class FormatConstraintScrutinizer extends SnakScrutinizer {
String value = ((StringValue) snak.getValue()).getString();
PropertyIdValue pid = snak.getPropertyId();
Pattern pattern = getPattern(pid);
if (pattern == null) {
return;
}
if (!pattern.matcher(value).matches()) {
if (added) {
QAWarning issue = new QAWarning(