private ISchematronResource getSchematron(IValidationContext<IBaseResource> theCtx) { Class<? extends IBaseResource> resource = theCtx.getResource().getClass(); Class<? extends IBaseResource> baseResourceClass = theCtx.getFhirContext().getResourceDefinition(resource).getBaseDefinition().getImplementingClass(); return getSchematronAndCache(theCtx, baseResourceClass); }
private ISchematronResource getSchematronAndCache(IValidationContext<IBaseResource> theCtx, Class<? extends IBaseResource> theClass) { synchronized (myClassToSchematron) { ISchematronResource retVal = myClassToSchematron.get(theClass); if (retVal != null) { return retVal; } String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase() + ".sch"; try (InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase)) { if (baseIs == null) { throw new InternalErrorException("Failed to load schematron for resource '" + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName() + "'. " + SchemaBaseValidator.RESOURCES_JAR_NOTE); } } catch (IOException e) { ourLog.error("Failed to close stream", e); } retVal = SchematronResourceSCH.fromClassPath(pathToBase); myClassToSchematron.put(theClass, retVal); return retVal; } } }
IErrorList errors = SchematronHelper.convertToErrorList(results, theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName());
private ISchematronResource getSchematron(IValidationContext<IBaseResource> theCtx) { Class<? extends IBaseResource> resource = theCtx.getResource().getClass(); Class<? extends IBaseResource> baseResourceClass = theCtx.getFhirContext().getResourceDefinition(resource).getBaseDefinition().getImplementingClass(); return getSchematronAndCache(theCtx, baseResourceClass); }
private ISchematronResource getSchematronAndCache(IValidationContext<IBaseResource> theCtx, Class<? extends IBaseResource> theClass) { synchronized (myClassToSchematron) { ISchematronResource retVal = myClassToSchematron.get(theClass); if (retVal != null) { return retVal; } String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase() + ".sch"; try (InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase)) { if (baseIs == null) { throw new InternalErrorException("Failed to load schematron for resource '" + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName() + "'. " + SchemaBaseValidator.RESOURCES_JAR_NOTE); } } catch (IOException e) { ourLog.error("Failed to close stream", e); } retVal = SchematronResourceSCH.fromClassPath(pathToBase); myClassToSchematron.put(theClass, retVal); return retVal; } } }
IErrorList errors = SchematronHelper.convertToErrorList(results, theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName());