Improved rendering of filtered messages and group messages by type in qa.html
This commit is contained in:
parent
8431a12195
commit
c08bbc02e4
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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,15 +85,15 @@ 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;
|
||||
}
|
||||
|
||||
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,11 +109,11 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#FATAL} validation message if the validation fails
|
||||
*
|
||||
|
@ -125,8 +125,8 @@ 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,8 +140,8 @@ 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;
|
||||
}
|
||||
//TODO: i18n
|
||||
|
@ -159,8 +159,8 @@ 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,11 +174,11 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#INFORMATION} validation message if the validation fails
|
||||
*
|
||||
|
@ -189,15 +189,15 @@ 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;
|
||||
}
|
||||
|
||||
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,8 +213,8 @@ 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,8 +227,8 @@ 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,8 +242,8 @@ 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,8 +265,8 @@ 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,11 +281,11 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#ERROR} validation message if the validation fails
|
||||
*
|
||||
|
@ -297,23 +297,23 @@ 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;
|
||||
}
|
||||
|
||||
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,8 +328,8 @@ 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,26 +370,26 @@ 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);
|
||||
IssueSeverity severity = IssueSeverity.WARNING;
|
||||
addValidationMessage(errors, type, line, col, path, msg, severity);
|
||||
}
|
||||
String nmsg = context.formatMessage(msg, theMessageArguments);
|
||||
IssueSeverity severity = IssueSeverity.WARNING;
|
||||
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) {
|
||||
Source source = this.source;
|
||||
return addValidationMessage(errors, type, line, col, path, msg, theSeverity, source);
|
||||
}
|
||||
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, 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);
|
||||
errors.add(validationMessage);
|
||||
return validationMessage;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
|
||||
*
|
||||
* @param thePass
|
||||
|
@ -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,9 +407,9 @@ 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,8 +425,8 @@ 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,8 +439,8 @@ 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,8 +453,8 @@ 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,9 +467,9 @@ 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,9 +483,9 @@ 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,8 +501,8 @@ 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,8 +515,8 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -529,17 +529,17 @@ 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);
|
||||
}
|
||||
IssueSeverity severity = IssueSeverity.INFORMATION;
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
|
||||
*
|
||||
* @param thePass
|
||||
|
@ -548,13 +548,13 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected ValueSet resolveBindingReference(DomainResource ctxt, String reference, String uri) {
|
||||
if (reference != null) {
|
||||
if (reference.startsWith("#")) {
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue