Search in sources :

Example 6 with IResourceValidator

use of org.hl7.fhir.r4.utils.validation.IResourceValidator in project org.hl7.fhir.core by hapifhir.

the class ValidationTests method conformsToProfile.

@Override
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
    IResourceValidator val = TestingUtilities.getSharedWorkerContext(version).newValidator();
    List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
    if (item instanceof Resource) {
        val.validate(appContext, valerrors, (Resource) item, url);
        boolean ok = true;
        for (ValidationMessage v : valerrors) ok = ok && v.getLevel().isError();
        return ok;
    }
    throw new NotImplementedException("Not done yet (IGPublisherHostServices.conformsToProfile), when item is element");
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) IResourceValidator(org.hl7.fhir.r5.utils.validation.IResourceValidator) NotImplementedException(org.apache.commons.lang3.NotImplementedException) ArrayList(java.util.ArrayList) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) Resource(org.hl7.fhir.r5.model.Resource)

Example 7 with IResourceValidator

use of org.hl7.fhir.r4.utils.validation.IResourceValidator in project org.hl7.fhir.core by hapifhir.

the class ValidationEngine method fetchRaw.

@Override
public byte[] fetchRaw(IResourceValidator validator, String source) throws IOException {
    SimpleHTTPClient http = new SimpleHTTPClient();
    HTTPResult res = http.get(source);
    res.checkThrowException();
    return res.getContent();
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult)

Example 8 with IResourceValidator

use of org.hl7.fhir.r4.utils.validation.IResourceValidator in project org.hl7.fhir.core by hapifhir.

the class StandAloneValidatorFetcher method fetchCanonicalResource.

@Override
public CanonicalResource fetchCanonicalResource(IResourceValidator validator, String url) throws URISyntaxException {
    String[] p = url.split("\\/");
    String root = getRoot(p, url);
    if (root != null) {
        TerminologyClient c;
        c = TerminologyClientFactory.makeClient(root, "fhir/validator", context.getVersion());
        return c.read(p[p.length - 2], p[p.length - 1]);
    } else {
        throw new FHIRException("The URL '" + url + "' is not known to the FHIR validator, and has not been provided as part of the setup / parameters");
    }
}
Also used : TerminologyClient(org.hl7.fhir.r5.terminologies.TerminologyClient) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 9 with IResourceValidator

use of org.hl7.fhir.r4.utils.validation.IResourceValidator in project org.hl7.fhir.core by hapifhir.

the class ValidationTests method fetchRaw.

@Override
public byte[] fetchRaw(IResourceValidator validator, String source) throws MalformedURLException, IOException {
    SimpleHTTPClient http = new SimpleHTTPClient();
    HTTPResult res = http.get(source);
    res.checkThrowException();
    return res.getContent();
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult)

Aggregations

ArrayList (java.util.ArrayList)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)4 IOException (java.io.IOException)3 FileNotFoundException (java.io.FileNotFoundException)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 Element (org.hl7.fhir.r5.elementmodel.Element)2 Resource (org.hl7.fhir.r5.model.Resource)2 IResourceValidator (org.hl7.fhir.r5.utils.validation.IResourceValidator)2 HTTPResult (org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult)2 SAXException (org.xml.sax.SAXException)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 ValidationException (org.everit.json.schema.ValidationException)1