Start removing dependency from FhirVersionEnum to FhirContext (#6512)
Deprecate path from FhirVersionEnum to FhirContext and replace usages.
This commit is contained in:
parent
77fa7f7819
commit
3b8569127e
|
@ -1293,7 +1293,15 @@ public class FhirContext {
|
||||||
* @since 5.1.0
|
* @since 5.1.0
|
||||||
*/
|
*/
|
||||||
public static FhirContext forCached(FhirVersionEnum theFhirVersionEnum) {
|
public static FhirContext forCached(FhirVersionEnum theFhirVersionEnum) {
|
||||||
return ourStaticContexts.computeIfAbsent(theFhirVersionEnum, v -> new FhirContext(v));
|
return ourStaticContexts.computeIfAbsent(theFhirVersionEnum, FhirContext::forVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An uncached version of forCached()
|
||||||
|
* @return a new FhirContext for theFhirVersionEnum
|
||||||
|
*/
|
||||||
|
public static FhirContext forVersion(FhirVersionEnum theFhirVersionEnum) {
|
||||||
|
return new FhirContext(theFhirVersionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<Class<? extends IBaseResource>> toCollection(
|
private static Collection<Class<? extends IBaseResource>> toCollection(
|
||||||
|
|
|
@ -135,15 +135,19 @@ public enum FhirVersionEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new FhirContext for this FHIR version
|
* Creates a new FhirContext for this FHIR version
|
||||||
|
* @deprecated since 7.7. Use {@link FhirContext#forVersion(FhirVersionEnum)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "7.7")
|
||||||
public FhirContext newContext() {
|
public FhirContext newContext() {
|
||||||
return new FhirContext(this);
|
return FhirContext.forVersion(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new FhirContext for this FHIR version, or returns a previously created one if one exists. This
|
* Creates a new FhirContext for this FHIR version, or returns a previously created one if one exists. This
|
||||||
* method uses {@link FhirContext#forCached(FhirVersionEnum)} to return a cached instance.
|
* method uses {@link FhirContext#forCached(FhirVersionEnum)} to return a cached instance.
|
||||||
|
* @deprecated since 7.7. Use {@link FhirContext#forCached(FhirVersionEnum)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "7.7")
|
||||||
public FhirContext newContextCached() {
|
public FhirContext newContextCached() {
|
||||||
return FhirContext.forCached(this);
|
return FhirContext.forCached(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package ca.uhn.fhir.narrative2;
|
package ca.uhn.fhir.narrative2;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.util.BundleUtil;
|
import ca.uhn.fhir.util.BundleUtil;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||||
|
@ -42,7 +43,8 @@ public class NarrativeGeneratorTemplateUtils {
|
||||||
* Given a Bundle as input, are any entries present with a given resource type
|
* Given a Bundle as input, are any entries present with a given resource type
|
||||||
*/
|
*/
|
||||||
public boolean bundleHasEntriesWithResourceType(IBaseBundle theBaseBundle, String theResourceType) {
|
public boolean bundleHasEntriesWithResourceType(IBaseBundle theBaseBundle, String theResourceType) {
|
||||||
FhirContext ctx = theBaseBundle.getStructureFhirVersionEnum().newContextCached();
|
FhirVersionEnum fhirVersionEnum = theBaseBundle.getStructureFhirVersionEnum();
|
||||||
|
FhirContext ctx = FhirContext.forCached(fhirVersionEnum);
|
||||||
List<Pair<String, IBaseResource>> entryResources =
|
List<Pair<String, IBaseResource>> entryResources =
|
||||||
BundleUtil.getBundleEntryUrlsAndResources(ctx, theBaseBundle);
|
BundleUtil.getBundleEntryUrlsAndResources(ctx, theBaseBundle);
|
||||||
return entryResources.stream()
|
return entryResources.stream()
|
||||||
|
|
|
@ -668,7 +668,7 @@ public abstract class BaseCommand implements Comparable<BaseCommand> {
|
||||||
|
|
||||||
protected void parseFhirContext(CommandLine theCommandLine) throws ParseException {
|
protected void parseFhirContext(CommandLine theCommandLine) throws ParseException {
|
||||||
FhirVersionEnum versionEnum = parseFhirVersion(theCommandLine);
|
FhirVersionEnum versionEnum = parseFhirVersion(theCommandLine);
|
||||||
myFhirCtx = versionEnum.newContext();
|
myFhirCtx = FhirContext.forVersion(versionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run(CommandLine theCommandLine) throws ParseException, ExecutionException;
|
public abstract void run(CommandLine theCommandLine) throws ParseException, ExecutionException;
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class VersionCanonicalizer {
|
||||||
private final FhirContext myContext;
|
private final FhirContext myContext;
|
||||||
|
|
||||||
public VersionCanonicalizer(FhirVersionEnum theTargetVersion) {
|
public VersionCanonicalizer(FhirVersionEnum theTargetVersion) {
|
||||||
this(theTargetVersion.newContextCached());
|
this(FhirContext.forCached(theTargetVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VersionCanonicalizer(FhirContext theTargetContext) {
|
public VersionCanonicalizer(FhirContext theTargetContext) {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
type: remove
|
||||||
|
issue: 6512
|
||||||
|
title: "The methods on FhirVersionEnum which produces a FhirContext (newContext() ,and newContextCached()) have been deprecated, and will be removed."
|
|
@ -686,7 +686,7 @@ public class RestfulServerUtils {
|
||||||
if (context.getVersion().getVersion() != theForVersion) {
|
if (context.getVersion().getVersion() != theForVersion) {
|
||||||
context = myFhirContextMap.get(theForVersion);
|
context = myFhirContextMap.get(theForVersion);
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = theForVersion.newContext();
|
context = FhirContext.forVersion(theForVersion);
|
||||||
myFhirContextMap.put(theForVersion, context);
|
myFhirContextMap.put(theForVersion, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ public class BaseController {
|
||||||
FhirVersionEnum version = theRequest.getFhirVersion(myConfig);
|
FhirVersionEnum version = theRequest.getFhirVersion(myConfig);
|
||||||
VersionCanonicalizer retVal = myCanonicalizers.get(version);
|
VersionCanonicalizer retVal = myCanonicalizers.get(version);
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
retVal = new VersionCanonicalizer(version.newContext());
|
retVal = new VersionCanonicalizer(FhirContext.forVersion(version));
|
||||||
myCanonicalizers.put(version, retVal);
|
myCanonicalizers.put(version, retVal);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
Loading…
Reference in New Issue