Skip to content

Commit

Permalink
Set up optional dependency between 'and' and 'dependencies' checkers #…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Jan 29, 2025
1 parent 1ac5675 commit 8c8c685
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class AndChecker extends LogicalChecker {
private static final long serialVersionUID = 1114999259831619599L;
public static final String PREFIX = "and";

/**
* If the values is NA, check dependencies. and that will decide if it passes or not
*/
private boolean ifIsNACheckDependency = false;

/**
* @param field The field
* @param checkers The list of checkers
Expand Down Expand Up @@ -59,10 +64,12 @@ public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, Rule
MinCountChecker minCountChecker = (MinCountChecker) checker;
if (!minCountChecker.isEmptyInstancesAllowed() || minCountChecker.getMinCount() > 0)
allPassed = false;
} else if (checker instanceof DependencyChecker) {
}
else if (ifIsNACheckDependency && checker instanceof DependencyChecker) {
DependencyChecker dependencyChecker = (DependencyChecker) checker;
allPassed = dependencyChecker.getResult(outputType, results);
}

if (!allPassed)
break;
}
Expand All @@ -72,4 +79,8 @@ public void update(Selector cache, FieldCounter<RuleCheckerOutput> results, Rule
if (isDebug())
LOGGER.info(this.getClass().getSimpleName() + " " + this.id + ") result: " + RuleCheckingOutputStatus.create(isNA, allPassed));
}

public void setIfIsNACheckDependency(boolean ifIsNACheckDependency) {
this.ifIsNACheckDependency = ifIsNACheckDependency;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ public void update(Selector cache,
if (globalResults == null)
globalResults = localResults;

var allPassed = true;
var isNA = true;
var allPassed = true;
List<XmlFieldInstance> instances = cache.get(field);
if (instances != null && !instances.isEmpty()) {
for (XmlFieldInstance instance : instances) {
if (instance.hasValue()) {
isNA = false;
allPassed = getResult(outputType, globalResults);
/*
for (String ruleId : dependencies) {
String keyEnd = outputType.equals(RuleCheckingOutputType.BOTH) ? ruleId + ":status" : ruleId;
boolean found = false;
Expand All @@ -78,6 +80,7 @@ public void update(Selector cache,
break;
}
}
*/
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class IdentifierGenerator {

public static String generate() {
String id = PREFIX + String.valueOf(++identifier);
LOGGER.info("Generated identifier " + id);
// LOGGER.info("Generated identifier " + id);
return id;
}

Expand Down

0 comments on commit 8c8c685

Please sign in to comment.