@Override public final void encodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theWriter, "theWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } doEncodeResourceToWriter(theResource, theWriter); }
@Override public void encodeResourceToJsonLikeWriter(IBaseResource theResource, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } doEncodeResourceToJsonLikeWriter(theResource, theJsonLikeWriter); }
public static IIdType fullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, IBaseResource theResource, String theServerBase, IIdType theResourceId) { IIdType retVal = null; if (theResourceId.hasIdPart() && isNotBlank(theServerBase)) { String resName = theResourceId.getResourceType(); if (theResource != null && isBlank(resName)) { FhirContext context = theServer.getFhirContext(); context = getContextForVersion(context, theResource.getStructureFhirVersionEnum()); resName = context.getResourceDefinition(theResource).getName(); } if (isNotBlank(resName)) { retVal = theResourceId.withServerBase(theServerBase, resName); } } return retVal; }
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IBaseResource> theClass, ResourceDef theResourceAnnotation, boolean theStandardType, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { super(theResourceName, theClass, theStandardType, theContext, theClassToElementDefinitions); myContext = theContext; myResourceProfile = theResourceAnnotation.profile(); myId = theResourceAnnotation.id(); IBaseResource instance; try { instance = theClass.newInstance(); } catch (Exception e) { throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e); } myStructureVersion = instance.getStructureFhirVersionEnum(); if (myStructureVersion != theContext.getVersion().getVersion()) { throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "typeWrongVersion", theContext.getVersion().getVersion(), theClass.getName(), myStructureVersion)); } }
Map<String, String[]> parameters = theRequestDetails.getParameters(); if (parameters.containsKey(Constants.PARAM_FORMAT)) { FhirVersionEnum forVersion = theResource.getStructureFhirVersionEnum(); p = RestfulServerUtils.getNewParser(theRequestDetails.getServer().getFhirContext(), forVersion, theRequestDetails); } else {
FhirVersionEnum haveVersion = responseResource.getStructureFhirVersionEnum();
private String extractExtension(IBaseResource theSubscription, String theUrl) { try { switch (theSubscription.getStructureFhirVersionEnum()) { case DSTU2: { ca.uhn.fhir.model.dstu2.resource.Subscription subscription = (ca.uhn.fhir.model.dstu2.resource.Subscription) theSubscription;
FhirVersionEnum forVersion = theResource.getStructureFhirVersionEnum(); IParser parser = getNewParser(theServer.getFhirContext(), forVersion, theRequestDetails); parser.encodeResourceToWriter(theResource, writer);
protected void encodeResourceToWriter(IBaseResource theResource, Writer theWriter, EncodeContext theEncodeContext) throws IOException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theWriter, "theWriter can not be null"); Validate.notNull(theEncodeContext, "theEncodeContext can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } String resourceName = myContext.getResourceDefinition(theResource).getName(); theEncodeContext.pushPath(resourceName, true); doEncodeResourceToWriter(theResource, theWriter, theEncodeContext); theEncodeContext.popPath(); }
@Override public void encodeResourceToJsonLikeWriter(IBaseResource theResource, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } EncodeContext encodeContext = new EncodeContext(); String resourceName = myContext.getResourceDefinition(theResource).getName(); encodeContext.pushPath(resourceName, true); doEncodeResourceToJsonLikeWriter(theResource, theJsonLikeWriter, encodeContext); }
public static IIdType fullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, IBaseResource theResource, String theServerBase, IIdType theResourceId) { IIdType retVal = null; if (theResourceId.hasIdPart() && isNotBlank(theServerBase)) { String resName = theResourceId.getResourceType(); if (theResource != null && isBlank(resName)) { FhirContext context = theServer.getFhirContext(); context = getContextForVersion(context, theResource.getStructureFhirVersionEnum()); resName = context.getResourceDefinition(theResource).getName(); } if (isNotBlank(resName)) { retVal = theResourceId.withServerBase(theServerBase, resName); } } return retVal; }
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IBaseResource> theClass, ResourceDef theResourceAnnotation, boolean theStandardType, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { super(theResourceName, theClass, theStandardType, theContext, theClassToElementDefinitions); myContext = theContext; myResourceProfile = theResourceAnnotation.profile(); myId = theResourceAnnotation.id(); IBaseResource instance; try { instance = theClass.newInstance(); } catch (Exception e) { throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e); } myStructureVersion = instance.getStructureFhirVersionEnum(); if (myStructureVersion != theContext.getVersion().getVersion()) { throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "typeWrongVersion", theContext.getVersion().getVersion(), theClass.getName(), myStructureVersion)); } }
Map<String, String[]> parameters = theRequestDetails.getParameters(); if (parameters.containsKey(Constants.PARAM_FORMAT)) { FhirVersionEnum forVersion = theResource.getStructureFhirVersionEnum(); p = RestfulServerUtils.getNewParser(theRequestDetails.getServer().getFhirContext(), forVersion, theRequestDetails); } else {
FhirVersionEnum haveVersion = responseResource.getStructureFhirVersionEnum();
FhirVersionEnum forVersion = theResource.getStructureFhirVersionEnum(); IParser parser = getNewParser(theServer.getFhirContext(), forVersion, theRequestDetails); parser.encodeResourceToWriter(theResource, writer);