Skip to content

Commit 04963b6

Browse files
committed
RAP-93 Re-correct logic to set Drools UUID and Severity in DroolsRulesValidationService
1 parent ec2d8bd commit 04963b6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main/java/org/ihtsdo/rvf/core/service/DroolsRulesValidationService.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ private void loadAndConvertDroolsRulesToAssertions() {
105105
private void convertDroolsRuleToAssertion(File droolsRulesSubfile) throws IOException {
106106
try (final BufferedReader reader = Files.newBufferedReader(droolsRulesSubfile.toPath())) {
107107
String line;
108+
UUID uuid;
108109
Assertion assertion = null;
109110
boolean severityWarning = false;
110111
boolean severityError = false;
111-
UUID uuid = null;
112112
String group = getAssertionGroup(droolsRulesSubfile.getAbsolutePath());
113113
while ((line = reader.readLine()) != null) {
114114
if (line.startsWith("rule") && !line.contains("Always passes")) {
@@ -125,20 +125,16 @@ private void convertDroolsRuleToAssertion(File droolsRulesSubfile) throws IOExce
125125
assertions.add(assertion);
126126
}
127127
}
128-
if (line.contains("new InvalidContent")) {
128+
if (assertion != null && line.contains("new InvalidContent")) {
129129
uuid = extractUuid(line);
130+
assertion.setUuid(uuid);
130131
}
131132
// check for severity
132-
if (line.contains("Severity.WARNING")) {
133-
severityWarning = true;
133+
severityWarning = severityWarning || detectSeverity(line, "Severity.WARNING");
134+
severityError = severityError || detectSeverity(line, "Severity.ERROR");
135+
if (assertion != null && "end".equals(line.trim())) {
136+
assertion.setSeverity(buildSeverity(severityWarning, severityError));
134137
}
135-
if (line.contains("Severity.ERROR")) {
136-
severityError = true;
137-
}
138-
}
139-
if (assertion != null) {
140-
assertion.setUuid(uuid);
141-
assertion.setSeverity(buildSeverity(severityWarning, severityError));
142138
}
143139
}
144140
}
@@ -151,6 +147,10 @@ private static UUID extractUuid(String line) {
151147
return null;
152148
}
153149

150+
private static boolean detectSeverity(String line, String type) {
151+
return line.contains(type);
152+
}
153+
154154
@NotNull
155155
private static String buildSeverity(boolean severityWarning, boolean severityError) {
156156
Set<String> severities = new HashSet<>();

0 commit comments

Comments
 (0)