Perf tuning FML: re-use FHIRPathEngine in new Property
hapifhir/org.hl7.fhir.core#1703 FML transform create heavyweight FHIRPathEngine objects for every new Property. Re-use existing ProfileUtilities/FHIRPathEngine objects from StructureMapUtilities.
This commit is contained in:
parent
18b4fc1714
commit
b75e401090
|
@ -39,8 +39,9 @@ import java.util.List;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.ContextUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
||||
|
@ -144,7 +145,11 @@ public class Manager {
|
|||
}
|
||||
|
||||
public static Element build(IWorkerContext context, StructureDefinition sd) {
|
||||
Property p = new Property(context, sd.getSnapshot().getElementFirstRep(), sd);
|
||||
return build(context, sd, new ProfileUtilities(context, null, null));
|
||||
}
|
||||
|
||||
public static Element build(IWorkerContext context, StructureDefinition sd, ProfileUtilities profileUtilities) {
|
||||
Property p = new Property(context, sd.getSnapshot().getElementFirstRep(), sd, profileUtilities, new ContextUtilities(context));
|
||||
Element e = new Element(p.getName(), p);
|
||||
e.setPath(sd.getType());
|
||||
return e;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.r5.utils.structuremap;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
|
||||
|
@ -10,7 +11,7 @@ public interface ITransformerServices {
|
|||
// public boolean validateByValueSet(Coding code, String valuesetId);
|
||||
public void log(String message); // log internal progress
|
||||
|
||||
public Base createType(Object appInfo, String name) throws FHIRException;
|
||||
public Base createType(Object appInfo, String name, ProfileUtilities profileUtilities) throws FHIRException;
|
||||
|
||||
public Base createResource(Object appInfo, Base res, boolean atRootofTransform); // an already created resource is provided; this is to identify/store it
|
||||
|
||||
|
|
|
@ -1787,7 +1787,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
}
|
||||
}
|
||||
Base res = services != null ? services.createType(context.getAppInfo(), tn) : typeFactory(tn);
|
||||
Base res = services != null ? services.createType(context.getAppInfo(), tn, profileUtilities) : typeFactory(tn);
|
||||
if (res.isResource() && !res.fhirType().equals("Parameters")) {
|
||||
// res.setIdBase(tgt.getParameter().size() > 1 ? getParamString(vars, tgt.getParameter().get(0)) : UUID.randomUUID().toString().toLowerCase());
|
||||
if (services != null)
|
||||
|
@ -1928,7 +1928,7 @@ public class StructureMapUtilities {
|
|||
if (sd == null) {
|
||||
throw new FHIRException("Unable to create type "+tn);
|
||||
} else {
|
||||
return Manager.build(worker, sd);
|
||||
return Manager.build(worker, sd, profileUtilities);
|
||||
}
|
||||
} else {
|
||||
return ResourceFactory.createResourceOrType(tn);
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
|
@ -140,7 +141,7 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base createType(Object appInfo, String name) throws FHIRException {
|
||||
public Base createType(Object appInfo, String name, ProfileUtilities profileUtilities) throws FHIRException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.PrintWriter;
|
|||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
|
@ -34,9 +35,9 @@ public class TransformSupportServices implements ITransformerServices {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base createType(Object appInfo, String name) throws FHIRException {
|
||||
public Base createType(Object appInfo, String name, ProfileUtilities profileUtilities) throws FHIRException {
|
||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, name);
|
||||
return Manager.build(context, sd);
|
||||
return Manager.build(context, sd, profileUtilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue