Skip to content

Commit

Permalink
Merge pull request #409 from hapifhir/gg-v5.2.13
Browse files Browse the repository at this point in the history
Gg v5.2.13
  • Loading branch information
grahamegrieve committed Dec 24, 2020
2 parents 401b73c + 8e62a16 commit 3bc2633
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 17 deletions.
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Validator:
* More rules around URL validation, instead of just marking them as errors
* Don't report errors for extensible bindings when profiles apply required bindings

Other code changes:
* fix rendering issue with profile references
* only use c:\temp for logs if it's writeable
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,7 @@ private Cell genTypes(HierarchicalTableGenerator gen, Row r, ElementDefinition e
c.getPieces().add(gen.new Piece("#"+ed.getElement().getPath(), tail(ed.getElement().getPath()), ed.getElement().getPath()));
} else {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null));
c.getPieces().add(gen.new Piece(ed.getSource().getUserString("path")+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath()));
c.getPieces().add(gen.new Piece(corePath+ed.getSource().getUserString("path")+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath()));
}
}
return c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ private static boolean hasCTempDir() {
return false;
}
File tmp = new File("c:\\temp");
return tmp.exists() && tmp.isDirectory();
return tmp.exists() && tmp.isDirectory() && tmp.canWrite();
}

public static String pathURL(String... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ public class I18nConstants {
public static final String TYPE_SPECIFIC_CHECKS_DT_URI_UUID = "Type_Specific_Checks_DT_URI_UUID";
public static final String TYPE_SPECIFIC_CHECKS_DT_URI_WS = "Type_Specific_Checks_DT_URI_WS";
public static final String TYPE_SPECIFIC_CHECKS_DT_URL_RESOLVE = "Type_Specific_Checks_DT_URL_Resolve";
public static final String TYPE_SPECIFIC_CHECKS_DT_CANONICAL_TYPE = "TYPE_SPECIFIC_CHECKS_DT_CANONICAL_TYPE";
public static final String TYPE_SPECIFIC_CHECKS_DT_CANONICAL_RESOLVE = "TYPE_SPECIFIC_CHECKS_DT_CANONICAL_RESOLVE";
public static final String TYPE_SPECIFIC_CHECKS_DT_UUID_STRAT = "Type_Specific_Checks_DT_UUID_Strat";
public static final String TYPE_SPECIFIC_CHECKS_DT_UUID_VAID = "Type_Specific_Checks_DT_UUID_Vaid";
public static final String UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER = "Unable_to_connect_to_terminology_server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Terminology_TX_NoValid_13 = The Coding provided ({2}) is not in the value set {0
Terminology_TX_NoValid_14 = The Coding provided ({2}) is not in the value set {0}, and a code is recommended to come from this value set. {1}
Terminology_TX_NoValid_15 = The value provided (''{0}'') could not be validated in the absence of a terminology server
Terminology_TX_NoValid_16 = The value provided (''{0}'') is not in the value set {1} ({2}), and a code is required from this value set){3}
Terminology_TX_NoValid_17 = The value provided (''{0}'') is not in the value set {1} ({2}), and a code should come from this value set unless it has no suitable code and the validator cannot judge what is suitable){3}
Terminology_TX_NoValid_17 = The value provided (''{0}'') is not in the value set {1} ({2}), and a code should come from this value set unless it has no suitable code and the validator cannot judge what is suitable) {3}
Terminology_TX_NoValid_18 = The value provided (''{0}'') is not in the value set {1} ({2}), and a code is recommended to come from this value set){3}
Terminology_TX_NoValid_2 = None of the codes provided are in the value set {0} ({1}), and a code should come from this value set unless it has no suitable code and the validator cannot judge what is suitable) (codes = {2})
Terminology_TX_NoValid_3 = None of the codes provided are in the value set {0} ({1}), and a code is recommended to come from this value set) (codes = {2})
Expand Down Expand Up @@ -634,3 +634,5 @@ SD_ED_BIND_NOT_VS = The valueSet reference {1} on element {0} points to somethin
SD_ED_BIND_NO_BINDABLE = The element {0} has a binding, but no bindable types are present {1}
DISCRIMINATOR_BAD_PATH = Error processing path expression for disciminator: {0} (src = ''{1}'')
SLICING_CANNOT_BE_EVALUATED = Slicing cannot be evaluated: {0}
TYPE_SPECIFIC_CHECKS_DT_CANONICAL_RESOLVE = Canonical URL ''{0}'' does not resolve
TYPE_SPECIFIC_CHECKS_DT_CANONICAL_TYPE = Canonical URL ''{0}'' refers to a resource that has the wrong type. Found {1} expecting one of {2}
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,28 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
import org.hl7.fhir.validation.BaseValidator.TrackedLocationRelatedMessage;
import org.hl7.fhir.validation.instance.utils.IndexedElement;

public class BaseValidator {

public class TrackedLocationRelatedMessage {
private Object location;
private ValidationMessage vmsg;
public TrackedLocationRelatedMessage(Object location, ValidationMessage vmsg) {
super();
this.location = location;
this.vmsg = vmsg;
}
public Object getLocation() {
return location;
}
public ValidationMessage getVmsg() {
return vmsg;
}

}

public class ValidationControl {
private boolean allowed;
private IssueSeverity level;
Expand Down Expand Up @@ -122,8 +140,10 @@ public IssueSeverity getLevel() {
protected IWorkerContext context;
protected TimeTracker timeTracker = new TimeTracker();
protected XVerExtensionManager xverManager;

public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager) {
protected List<TrackedLocationRelatedMessage> trackedMessages = new ArrayList<>();
protected List<ValidationMessage> messagesToRemove = new ArrayList<>();

public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super();
this.context = context;
this.xverManager = xverManager;
Expand Down Expand Up @@ -493,7 +513,38 @@ protected boolean txWarning(List<ValidationMessage> errors, String txLink, Issue
return thePass;

}

/**
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails. Also, keep track of it later in case we want to remove it if we find a required binding for this element later
*
* @param thePass
* Set this parameter to <code>false</code> if the validation does not pass
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/
protected boolean txWarningForLaterRemoval(Object location, List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) {
String nmsg = context.formatMessage(msg, theMessageArguments);
ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg);
if (checkMsgId(msg, vmsg)) {
errors.add(vmsg);
}
trackedMessages.add(new TrackedLocationRelatedMessage(location, vmsg));
}
return thePass;

}

protected void removeTrackedMessagesForLocation(List<ValidationMessage> errors, Object location, String path) {
List<TrackedLocationRelatedMessage> messages = new ArrayList<>();
for (TrackedLocationRelatedMessage m : trackedMessages) {
if (m.getLocation() == location) {
messages.add(m);
messagesToRemove.add(m.getVmsg());
}
}
trackedMessages.removeAll(messages);
}

protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass) {
String nmsg = context.formatMessage(msg, theMessageArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ public ReferenceValidationPolicy validationPolicy(Object appContext, String path
if (resource != null) {
return ReferenceValidationPolicy.CHECK_VALID;
}
if (!url.startsWith("http://hl7.org/fhir")) {
if (!(url.contains("hl7.org") || url.contains("fhir.org"))) {
return ReferenceValidationPolicy.IGNORE;
} else if (fetcher != null) {
return fetcher.validationPolicy(appContext, path, url);
Expand Down Expand Up @@ -1748,6 +1748,14 @@ public void setLocale(Locale locale) {

@Override
public CanonicalResource fetchCanonicalResource(String url) throws URISyntaxException {
Resource res = context.fetchResource(Resource.class, url);
if (res != null) {
if (res instanceof CanonicalResource) {
return (CanonicalResource) res;
} else {
return null;
}
}
return fetcher != null ? fetcher.fetchCanonicalResource(url) : null;
}

Expand Down
Loading

0 comments on commit 3bc2633

Please sign in to comment.