public ValidationResult(FhirContext theCtx, List<SingleValidationMessage> theMessages) { boolean successful = true; myCtx = theCtx; myMessages = theMessages; for (SingleValidationMessage next : myMessages) { next.getSeverity(); if (next.getSeverity() == null || next.getSeverity().ordinal() > ResultSeverityEnum.WARNING.ordinal()) { successful = false; } } myIsSuccessful = successful; }
private String toDescription() { StringBuilder b = new StringBuilder(100); if (myMessages.size() > 0) { if (myMessages.get(0).getSeverity() != null) { b.append(myMessages.get(0).getSeverity().name()); b.append(" - "); } b.append(myMessages.get(0).getMessage()); b.append(" - "); b.append(myMessages.get(0).getLocationString()); } else { b.append("No issues"); } return b.toString(); }
@Override public String lookup(String theKey) { if ("line".equals(theKey)) { return toString(myMessage.getLocationLine()); } if ("col".equals(theKey)) { return toString(myMessage.getLocationCol()); } if ("message".equals(theKey)) { return toString(myMessage.getMessage()); } if ("location".equals(theKey)) { return toString(myMessage.getLocationString()); } if ("severity".equals(theKey)) { return myMessage.getSeverity() != null ? myMessage.getSeverity().name() : null; } return ""; }
/** * Populate an operation outcome with the results of the validation */ public void populateOperationOutcome(IBaseOperationOutcome theOperationOutcome) { for (SingleValidationMessage next : myMessages) { String location; if (isNotBlank(next.getLocationString())) { location = next.getLocationString(); } else if (next.getLocationLine() != null || next.getLocationCol() != null) { location = "Line[" + next.getLocationLine() + "] Col[" + next.getLocationCol() + "]"; } else { location = null; } String severity = next.getSeverity() != null ? next.getSeverity().getCode() : null; OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, severity, next.getMessage(), location, Constants.OO_INFOSTATUS_PROCESSING); } if (myMessages.isEmpty()) { String message = myCtx.getLocalizer().getMessage(ValidationResult.class, "noIssuesDetected"); OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, "information", message, null, "informational"); } }
int leftWidth = leftString.length(); b.append(ansi().fg(Color.GREEN)).append(leftString); if (next.getSeverity() != null) { b.append(next.getSeverity()).append(ansi().fg(Color.WHITE)).append(" - ");
System.out.println("Message:"); System.out.println(" * Location: " + next.getLocationString()); System.out.println(" * Severity: " + next.getSeverity()); System.out.println(" * Message : " + next.getMessage());
boolean found = false; for (SingleValidationMessage next : validationResult.getMessages()) { if (next.getSeverity().ordinal() >= myAddResponseIssueHeaderOnSeverity) { addResponseIssueHeader(theRequestDetails, next); found = true; if (next.getSeverity().ordinal() >= myFailOnSeverity) { postProcessResultOnFailure(theRequestDetails, validationResult); fail(theRequestDetails, validationResult); IBaseOperationOutcome outcome = null; for (SingleValidationMessage next : validationResult.getMessages()) { if (next.getSeverity().ordinal() >= myAddResponseOutcomeHeaderOnSeverity) { outcome = validationResult.toOperationOutcome(); break;
System.out.println(" Next issue " + next.getSeverity() + " - " + next.getLocationString() + " - " + next.getMessage());
public ValidationResult(FhirContext theCtx, List<SingleValidationMessage> theMessages) { boolean successful = true; myCtx = theCtx; myMessages = theMessages; for (SingleValidationMessage next : myMessages) { next.getSeverity(); if (next.getSeverity() == null || next.getSeverity().ordinal() > ResultSeverityEnum.WARNING.ordinal()) { successful = false; } } myIsSuccessful = successful; }
private String toDescription() { StringBuilder b = new StringBuilder(100); if (myMessages.size() > 0) { if (myMessages.get(0).getSeverity() != null) { b.append(myMessages.get(0).getSeverity().name()); b.append(" - "); } b.append(myMessages.get(0).getMessage()); b.append(" - "); b.append(myMessages.get(0).getLocationString()); } else { b.append("No issues"); } return b.toString(); }
@Override public String lookup(String theKey) { if ("line".equals(theKey)) { return toString(myMessage.getLocationLine()); } if ("col".equals(theKey)) { return toString(myMessage.getLocationCol()); } if ("message".equals(theKey)) { return toString(myMessage.getMessage()); } if ("location".equals(theKey)) { return toString(myMessage.getLocationString()); } if ("severity".equals(theKey)) { return myMessage.getSeverity() != null ? myMessage.getSeverity().name() : null; } return ""; }
/** * Populate an operation outcome with the results of the validation */ public void populateOperationOutcome(IBaseOperationOutcome theOperationOutcome) { for (SingleValidationMessage next : myMessages) { String location; if (isNotBlank(next.getLocationString())) { location = next.getLocationString(); } else if (next.getLocationLine() != null || next.getLocationCol() != null) { location = "Line[" + next.getLocationLine() + "] Col[" + next.getLocationCol() + "]"; } else { location = null; } String severity = next.getSeverity() != null ? next.getSeverity().getCode() : null; OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, severity, next.getMessage(), location, Constants.OO_INFOSTATUS_PROCESSING); } if (myMessages.isEmpty()) { String message = myCtx.getLocalizer().getMessage(ValidationResult.class, "noIssuesDetected"); OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, "information", message, null, "informational"); } }
if (result.isSuccessful() == false) { for (SingleValidationMessage message : result.getMessages()) { System.out.println(message.getSeverity().toString() + ": " + message.getMessage());
if (result.isSuccessful() == false) { for (SingleValidationMessage message : result.getMessages()) { System.out.println(message.getSeverity().toString() + ": " + message.getMessage());
if (result.isSuccessful() == false) { for (SingleValidationMessage message : result.getMessages()) { System.out.println(message.getSeverity().toString() + ": " + message.getMessage());
boolean found = false; for (SingleValidationMessage next : validationResult.getMessages()) { if (next.getSeverity().ordinal() >= myAddResponseIssueHeaderOnSeverity) { addResponseIssueHeader(theRequestDetails, next); found = true; if (next.getSeverity().ordinal() >= myFailOnSeverity) { postProcessResultOnFailure(theRequestDetails, validationResult); fail(theRequestDetails, validationResult); IBaseOperationOutcome outcome = null; for (SingleValidationMessage next : validationResult.getMessages()) { if (next.getSeverity().ordinal() >= myAddResponseOutcomeHeaderOnSeverity) { outcome = validationResult.toOperationOutcome(); break;
/** * Runs validation on a given resource, logs the results, and returns the response. * @param theResource the resource to be validated * @return ValidationResult */ public ValidationResult validate(IBaseResource theResource) { ValidationResult result = validator.validateWithResult(theResource); // Do we have any errors or fatal errors? // Show the issues for (SingleValidationMessage next : result.getMessages()) { switch (next.getSeverity()) { case ERROR: logger.error(next.getLocationString() + " - " + next.getMessage()); break; case INFORMATION: logger.info(next.getLocationString() + " - " + next.getMessage()); break; case WARNING: logger.warn(next.getLocationString() + " - " + next.getMessage()); break; case FATAL: logger.error(next.getLocationString() + " - " + next.getMessage()); break; default: logger.debug(next.getLocationString() + " - " + next.getMessage()); } } return result; } }
if (message.getSeverity() == ResultSeverityEnum.ERROR) { if (!message.getMessage().contains( "Element 'ExplanationOfBenefit.id': minimum required = 1, but only found 0")) { System.out.println(message.getSeverity() + ": " + message.getMessage()); Assert.fail(message.getSeverity() + ": " + message.getMessage());