public static IValidationContext<IBaseResource> subContext(final IValidationContext<IBaseResource> theCtx, final IBaseResource theResource) { return new ValidationContext<IBaseResource>(theCtx.getFhirContext(), theResource, new IEncoder() { @Override public String encode() { return theCtx.getFhirContext().newXmlParser().encodeResourceToString(theResource); } @Override public EncodingEnum getEncoding() { return EncodingEnum.XML; } }, theCtx.getMessages()); } }
@Override public String encode() { return theCtx.getFhirContext().newXmlParser().encodeResourceToString(theResource); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
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); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { Object resource = theCtx.getResource(); if (!(theCtx.getResource() instanceof IBaseResource)) { ourLog.debug("Not validating object of type {}", theCtx.getResource().getClass()); return Collections.emptyList(); } if (resource instanceof QuestionnaireResponse) { return doValidate(theCtx, (QuestionnaireResponse) resource); } RuntimeResourceDefinition def = theCtx.getFhirContext().getResourceDefinition((IBaseResource) resource); if ("QuestionnaireResponse".equals(def.getName()) == false) { return Collections.emptyList(); } /* * If we have a non-RI structure, convert it */ IParser p = theCtx.getFhirContext().newJsonParser(); String string = p.encodeResourceToString((IBaseResource) resource); QuestionnaireResponse qa = p.parseResource(QuestionnaireResponse.class, string); return doValidate(theCtx, qa); }
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; } } }
private boolean loadReferences(IBaseResource theResource, WorkerContext theWorkerCtx, IValidationContext<?> theValCtx, ArrayList<ValidationMessage> theMessages) { List<ResourceReferenceInfo> refs = theValCtx.getFhirContext().newTerser().getAllResourceReferences(theResource);
encodedResource = theContext.getResourceAsString(); } else { encodedResource = theContext.getFhirContext().newXmlParser().encodeResourceToString((IBaseResource) theContext.getResource());
resourceAsString = theCtx.getResourceAsString(); } else { resourceAsString = theCtx.getFhirContext().newXmlParser().encodeResourceToString(theCtx.getResource()); IErrorList errors = SchematronHelper.convertToErrorList(results, theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName());
public static IValidationContext<IBaseResource> subContext(final IValidationContext<IBaseResource> theCtx, final IBaseResource theResource) { return new ValidationContext<IBaseResource>(theCtx.getFhirContext(), theResource, new IEncoder() { @Override public String encode() { return theCtx.getFhirContext().newXmlParser().encodeResourceToString(theResource); } @Override public EncodingEnum getEncoding() { return EncodingEnum.XML; } }, theCtx.getMessages()); } }
@Override public String encode() { return theCtx.getFhirContext().newXmlParser().encodeResourceToString(theResource); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { return validate(theCtx.getFhirContext(), theCtx.getResourceAsString(), theCtx.getResourceAsStringEncoding()); }
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); }
@Override protected List<ValidationMessage> validate(IValidationContext<?> theCtx) { Object resource = theCtx.getResource(); if (!(theCtx.getResource() instanceof IBaseResource)) { ourLog.debug("Not validating object of type {}", theCtx.getResource().getClass()); return Collections.emptyList(); } if (resource instanceof QuestionnaireResponse) { return doValidate(theCtx, (QuestionnaireResponse) resource); } RuntimeResourceDefinition def = theCtx.getFhirContext().getResourceDefinition((IBaseResource) resource); if ("QuestionnaireResponse".equals(def.getName()) == false) { return Collections.emptyList(); } /* * If we have a non-RI structure, convert it */ IParser p = theCtx.getFhirContext().newJsonParser(); String string = p.encodeResourceToString((IBaseResource) resource); QuestionnaireResponse qa = p.parseResource(QuestionnaireResponse.class, string); return doValidate(theCtx, qa); }