Improved rendering of filtered messages and group messages by type in qa.html

This commit is contained in:
Grahame Grieve 2020-04-11 19:29:52 +10:00
parent 8431a12195
commit c08bbc02e4
3 changed files with 95 additions and 85 deletions

View File

@ -482,6 +482,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
private int col; private int col;
private String location; // fhirPath private String location; // fhirPath
private String message; private String message;
private String messageId; // source, for grouping
private IssueType type; private IssueType type;
private IssueSeverity level; private IssueSeverity level;
private String html; private String html;
@ -765,5 +766,14 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
this.sliceHtml = sliceHtml; this.sliceHtml = sliceHtml;
} }
public String getMessageId() {
return messageId;
}
public ValidationMessage setMessageId(String messageId) {
this.messageId = messageId;
return this;
}
} }

View File

@ -85,7 +85,7 @@ public class BaseValidator {
@Deprecated @Deprecated
protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) { protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL); addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL, null);
} }
return thePass; return thePass;
} }
@ -93,7 +93,7 @@ public class BaseValidator {
protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String msg = context.formatMessage(theMessage, theMessageArguments); String msg = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL); addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL, theMessage);
} }
return thePass; return thePass;
} }
@ -109,7 +109,7 @@ public class BaseValidator {
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) { protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL, null);
} }
return thePass; return thePass;
} }
@ -125,7 +125,7 @@ public class BaseValidator {
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
addValidationMessage(errors, type, -1, -1, path, context.formatMessage(theMessage, theMessageArguments), IssueSeverity.FATAL); addValidationMessage(errors, type, -1, -1, path, context.formatMessage(theMessage, theMessageArguments), IssueSeverity.FATAL, theMessage);
} }
return thePass; return thePass;
} }
@ -140,7 +140,7 @@ public class BaseValidator {
@Deprecated @Deprecated
protected boolean fail(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean fail(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL, null);
} }
return thePass; return thePass;
} }
@ -159,7 +159,7 @@ public class BaseValidator {
protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) { protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
String message = context.formatMessage(msg); String message = context.formatMessage(msg);
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION); addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, msg);
} }
return thePass; return thePass;
} }
@ -174,7 +174,7 @@ public class BaseValidator {
//FIXME: formatMessage should be done here //FIXME: formatMessage should be done here
protected boolean slicingHint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, String html) { protected boolean slicingHint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, String html) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION).setSlicingHint(true).setSliceHtml(html); addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION, null).setSlicingHint(true).setSliceHtml(html);
} }
return thePass; return thePass;
} }
@ -189,7 +189,7 @@ public class BaseValidator {
protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION); addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage);
} }
return thePass; return thePass;
} }
@ -197,7 +197,7 @@ public class BaseValidator {
protected boolean txHint(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean txHint(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, Source.TerminologyEngine).setTxLink(txLink); addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, Source.TerminologyEngine, theMessage).setTxLink(txLink);
} }
return thePass; return thePass;
} }
@ -213,7 +213,7 @@ public class BaseValidator {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.INFORMATION); addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage);
} }
return thePass; return thePass;
} }
@ -227,7 +227,7 @@ public class BaseValidator {
*/ */
protected boolean hint(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean hint(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION, null);
} }
return thePass; return thePass;
} }
@ -242,7 +242,7 @@ public class BaseValidator {
protected boolean rule(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.ERROR); addValidationMessage(errors, type, line, col, path, message, IssueSeverity.ERROR, theMessage);
} }
return thePass; return thePass;
} }
@ -265,7 +265,7 @@ public class BaseValidator {
protected boolean rule(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) { protected boolean rule(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, null);
} }
return thePass; return thePass;
} }
@ -281,7 +281,7 @@ public class BaseValidator {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.ERROR); addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage);
} }
return thePass; return thePass;
} }
@ -297,7 +297,7 @@ public class BaseValidator {
//todo: delete this when finished i18n //todo: delete this when finished i18n
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, null);
} }
return thePass; return thePass;
} }
@ -305,14 +305,14 @@ public class BaseValidator {
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.ERROR); addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage);
} }
return thePass; return thePass;
} }
public boolean rule(List<ValidationMessage> errors, Source source, IssueType type, String path, boolean thePass, String msg) { public boolean rule(List<ValidationMessage> errors, Source source, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, source); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, source, null);
} }
return thePass; return thePass;
} }
@ -328,7 +328,7 @@ public class BaseValidator {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, null); msg = context.formatMessage(msg, null);
html = context.formatMessage(html, null); html = context.formatMessage(html, null);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.ERROR); addValidationMessage(errors, type, path, msg, html, IssueSeverity.ERROR, null);
} }
return thePass; return thePass;
} }
@ -370,21 +370,21 @@ public class BaseValidator {
*/ */
protected boolean warning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING; IssueSeverity severity = IssueSeverity.WARNING;
addValidationMessage(errors, type, line, col, path, msg, severity); addValidationMessage(errors, type, line, col, path, nmsg, severity, msg);
} }
return thePass; return thePass;
} }
protected ValidationMessage addValidationMessage(List<ValidationMessage> errors, IssueType type, int line, int col, String path, String msg, IssueSeverity theSeverity) { protected ValidationMessage addValidationMessage(List<ValidationMessage> errors, IssueType type, int line, int col, String path, String msg, IssueSeverity theSeverity, String id) {
Source source = this.source; Source source = this.source;
return addValidationMessage(errors, type, line, col, path, msg, theSeverity, source); return addValidationMessage(errors, type, line, col, path, msg, theSeverity, source, id);
} }
protected ValidationMessage addValidationMessage(List<ValidationMessage> errors, IssueType type, int line, int col, String path, String msg, IssueSeverity theSeverity, Source theSource) { protected ValidationMessage addValidationMessage(List<ValidationMessage> errors, IssueType type, int line, int col, String path, String msg, IssueSeverity theSeverity, Source theSource, String id) {
ValidationMessage validationMessage = new ValidationMessage(theSource, type, line, col, path, msg, theSeverity); ValidationMessage validationMessage = new ValidationMessage(theSource, type, line, col, path, msg, theSeverity).setMessageId(id);
errors.add(validationMessage); errors.add(validationMessage);
return validationMessage; return validationMessage;
} }
@ -398,8 +398,8 @@ public class BaseValidator {
*/ */
protected boolean txWarning(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean txWarning(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
errors.add(new ValidationMessage(Source.TerminologyEngine, type, line, col, path, msg, IssueSeverity.WARNING).setTxLink(txLink)); errors.add(new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg));
} }
return thePass; return thePass;
@ -407,8 +407,8 @@ public class BaseValidator {
protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, msg, isError ? IssueSeverity.ERROR : IssueSeverity.WARNING); addValidationMessage(errors, type, line, col, path, nmsg, isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, msg);
} }
return thePass; return thePass;
@ -425,7 +425,7 @@ public class BaseValidator {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.WARNING); addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.WARNING, theMessage);
} }
return thePass; return thePass;
} }
@ -439,7 +439,7 @@ public class BaseValidator {
*/ */
protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.WARNING); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.WARNING, null);
} }
return thePass; return thePass;
} }
@ -453,7 +453,7 @@ public class BaseValidator {
*/ */
protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) { protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING); addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING, null);
} }
return thePass; return thePass;
} }
@ -467,8 +467,8 @@ public class BaseValidator {
*/ */
protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING); addValidationMessage(errors, type, path, nmsg, html, IssueSeverity.WARNING, msg);
} }
return thePass; return thePass;
} }
@ -483,8 +483,8 @@ public class BaseValidator {
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION); addValidationMessage(errors, type, line, col, path, nmsg, IssueSeverity.INFORMATION, msg);
} }
return thePass; return thePass;
@ -501,7 +501,7 @@ public class BaseValidator {
if (!thePass) { if (!thePass) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.INFORMATION); addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage);
} }
return thePass; return thePass;
} }
@ -515,7 +515,7 @@ public class BaseValidator {
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION, null);
} }
return thePass; return thePass;
} }
@ -530,13 +530,13 @@ public class BaseValidator {
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) { protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) {
if (!thePass) { if (!thePass) {
IssueSeverity severity = IssueSeverity.INFORMATION; IssueSeverity severity = IssueSeverity.INFORMATION;
addValidationMessage(errors, type, path, msg, html, severity); addValidationMessage(errors, type, path, msg, html, severity, null);
} }
return thePass; return thePass;
} }
protected void addValidationMessage(List<ValidationMessage> errors, IssueType type, String path, String msg, String html, IssueSeverity theSeverity) { protected void addValidationMessage(List<ValidationMessage> errors, IssueType type, String path, String msg, String html, IssueSeverity theSeverity, String id) {
errors.add(new ValidationMessage(source, type, -1, -1, path, msg, html, theSeverity)); errors.add(new ValidationMessage(source, type, -1, -1, path, msg, html, theSeverity).setMessageId(id));
} }
/** /**
@ -548,8 +548,8 @@ public class BaseValidator {
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) { protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) {
if (!thePass) { if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.INFORMATION); addValidationMessage(errors, type, path, nmsg, html, IssueSeverity.INFORMATION, msg);
} }
return thePass; return thePass;
} }

View File

@ -515,7 +515,7 @@ public class QuestionnaireValidator extends BaseValidator {
if (!res.isOk()) { if (!res.isOk()) {
txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_BADOPTION, c.getSystem(), c.getCode()); txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_BADOPTION, c.getSystem(), c.getCode());
} else if (res.getSeverity() != null) { } else if (res.getSeverity() != null) {
super.addValidationMessage(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity(), Source.TerminologyEngine); super.addValidationMessage(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity(), Source.TerminologyEngine, null);
} }
} catch (Exception e) { } catch (Exception e) {
warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_CODING, e.getMessage()); warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_CODING, e.getMessage());