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

View File

@ -50,7 +50,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
*/
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r5.context.IWorkerContext;
@ -85,7 +85,7 @@ public class BaseValidator {
@Deprecated
protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL);
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL, null);
}
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) {
if (!thePass) {
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;
}
@ -109,7 +109,7 @@ public class BaseValidator {
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) {
if (!thePass) {
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;
}
@ -125,7 +125,7 @@ public class BaseValidator {
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) {
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;
}
@ -140,7 +140,7 @@ public class BaseValidator {
@Deprecated
protected boolean fail(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL, null);
}
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) {
if (!thePass) {
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;
}
@ -174,7 +174,7 @@ public class BaseValidator {
//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) {
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;
}
@ -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) {
if (!thePass) {
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;
}
@ -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) {
if (!thePass) {
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;
}
@ -213,7 +213,7 @@ public class BaseValidator {
if (!thePass) {
String path = toPath(pathParts);
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;
}
@ -227,7 +227,7 @@ public class BaseValidator {
*/
protected boolean hint(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION, null);
}
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) {
if (!thePass) {
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;
}
@ -265,7 +265,7 @@ public class BaseValidator {
protected boolean rule(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) {
if (!thePass) {
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;
}
@ -281,7 +281,7 @@ public class BaseValidator {
if (!thePass) {
String path = toPath(pathParts);
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;
}
@ -297,7 +297,7 @@ public class BaseValidator {
//todo: delete this when finished i18n
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, null);
}
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) {
if (!thePass) {
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;
}
public boolean rule(List<ValidationMessage> errors, Source source, IssueType type, String path, boolean thePass, String msg) {
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;
}
@ -328,7 +328,7 @@ public class BaseValidator {
if (!thePass) {
msg = context.formatMessage(msg, 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;
}
@ -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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING;
addValidationMessage(errors, type, line, col, path, msg, severity);
addValidationMessage(errors, type, line, col, path, nmsg, severity, msg);
}
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;
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) {
ValidationMessage validationMessage = new ValidationMessage(theSource, type, line, col, path, msg, theSeverity);
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).setMessageId(id);
errors.add(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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
errors.add(new ValidationMessage(Source.TerminologyEngine, type, line, col, path, msg, IssueSeverity.WARNING).setTxLink(txLink));
String nmsg = context.formatMessage(msg, theMessageArguments);
errors.add(new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg));
}
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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, msg, isError ? IssueSeverity.ERROR : IssueSeverity.WARNING);
String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, nmsg, isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, msg);
}
return thePass;
@ -425,7 +425,7 @@ public class BaseValidator {
if (!thePass) {
String path = toPath(pathParts);
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;
}
@ -439,7 +439,7 @@ public class BaseValidator {
*/
protected boolean warning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.WARNING);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.WARNING, null);
}
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) {
if (!thePass) {
addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING, null);
}
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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.WARNING);
String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, nmsg, html, IssueSeverity.WARNING, msg);
}
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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION);
String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, line, col, path, nmsg, IssueSeverity.INFORMATION, msg);
}
return thePass;
@ -501,7 +501,7 @@ public class BaseValidator {
if (!thePass) {
String path = toPath(pathParts);
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;
}
@ -515,7 +515,7 @@ public class BaseValidator {
*/
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION);
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.INFORMATION, null);
}
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) {
if (!thePass) {
IssueSeverity severity = IssueSeverity.INFORMATION;
addValidationMessage(errors, type, path, msg, html, severity);
addValidationMessage(errors, type, path, msg, html, severity, null);
}
return thePass;
}
protected void addValidationMessage(List<ValidationMessage> errors, IssueType type, String path, String msg, String html, IssueSeverity theSeverity) {
errors.add(new ValidationMessage(source, type, -1, -1, path, msg, html, 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).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) {
if (!thePass) {
msg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, msg, html, IssueSeverity.INFORMATION);
String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, path, nmsg, html, IssueSeverity.INFORMATION, msg);
}
return thePass;
}

View File

@ -515,7 +515,7 @@ public class QuestionnaireValidator extends BaseValidator {
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());
} 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) {
warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_CODING, e.getMessage());