Skip to content

Commit 8c8c685

Browse files
committed
Set up optional dependency between 'and' and 'dependencies' checkers #215
1 parent 1ac5675 commit 8c8c685

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/main/java/de/gwdg/metadataqa/api/rule/logical/AndChecker.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public class AndChecker extends LogicalChecker {
1818
private static final long serialVersionUID = 1114999259831619599L;
1919
public static final String PREFIX = "and";
2020

21+
/**
22+
* If the values is NA, check dependencies. and that will decide if it passes or not
23+
*/
24+
private boolean ifIsNACheckDependency = false;
25+
2126
/**
2227
* @param field The field
2328
* @param checkers The list of checkers
@@ -59,10 +64,12 @@ public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, Rule
5964
MinCountChecker minCountChecker = (MinCountChecker) checker;
6065
if (!minCountChecker.isEmptyInstancesAllowed() || minCountChecker.getMinCount() > 0)
6166
allPassed = false;
62-
} else if (checker instanceof DependencyChecker) {
67+
}
68+
else if (ifIsNACheckDependency && checker instanceof DependencyChecker) {
6369
DependencyChecker dependencyChecker = (DependencyChecker) checker;
6470
allPassed = dependencyChecker.getResult(outputType, results);
6571
}
72+
6673
if (!allPassed)
6774
break;
6875
}
@@ -72,4 +79,8 @@ public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, Rule
7279
if (isDebug())
7380
LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed));
7481
}
82+
83+
public void setIfIsNACheckDependency(boolean ifIsNACheckDependency) {
84+
this.ifIsNACheckDependency = ifIsNACheckDependency;
85+
}
7586
}

src/main/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/DependencyChecker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ public void update(Selector cache,
5454
if (globalResults == null)
5555
globalResults = localResults;
5656

57-
var allPassed = true;
5857
var isNA = true;
58+
var allPassed = true;
5959
List<XmlFieldInstance> instances = cache.get(field);
6060
if (instances != null && !instances.isEmpty()) {
6161
for (XmlFieldInstance instance : instances) {
6262
if (instance.hasValue()) {
6363
isNA = false;
64+
allPassed = getResult(outputType, globalResults);
65+
/*
6466
for (String ruleId : dependencies) {
6567
String keyEnd = outputType.equals(RuleCheckingOutputType.BOTH) ? ruleId + ":status" : ruleId;
6668
boolean found = false;
@@ -78,6 +80,7 @@ public void update(Selector cache,
7880
break;
7981
}
8082
}
83+
*/
8184
}
8285
}
8386
}

src/main/java/de/gwdg/metadataqa/api/util/IdentifierGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class IdentifierGenerator {
1010

1111
public static String generate() {
1212
String id = PREFIX + String.valueOf(++identifier);
13-
LOGGER.info("Generated identifier " + id);
13+
// LOGGER.info("Generated identifier " + id);
1414
return id;
1515
}
1616

0 commit comments

Comments
 (0)