11package org .hl7 .fhir .igtools .publisher ;
22
33import java .util .ArrayList ;
4- import java .util .HashMap ;
54import java .util .List ;
6- import java .util .Map ;
75
86import org .apache .commons .lang3 .NotImplementedException ;
97import org .hl7 .fhir .exceptions .FHIRException ;
108import org .hl7 .fhir .exceptions .PathEngineException ;
119import org .hl7 .fhir .r5 .context .SimpleWorkerContext ;
10+ import org .hl7 .fhir .r5 .fhirpath .BaseHostServices ;
1211import org .hl7 .fhir .r5 .fhirpath .FHIRPathEngine ;
1312import org .hl7 .fhir .r5 .fhirpath .TypeDetails ;
1413import org .hl7 .fhir .r5 .liquid .GlobalObject ;
1514import org .hl7 .fhir .r5 .fhirpath .ExpressionNode .CollectionStatus ;
16- import org .hl7 .fhir .r5 .fhirpath .FHIRPathEngine .IEvaluationContext ;
17- import org .hl7 .fhir .r5 .fhirpath .FHIRPathUtilityClasses .FunctionDetails ;
1815import org .hl7 .fhir .r5 .model .Base ;
1916import org .hl7 .fhir .r5 .model .DateTimeType ;
2017import org .hl7 .fhir .r5 .model .Resource ;
2118import org .hl7 .fhir .r5 .model .StringType ;
2219import org .hl7 .fhir .r5 .model .ValueSet ;
2320import org .hl7 .fhir .r5 .utils .validation .IResourceValidator ;
2421import org .hl7 .fhir .utilities .Utilities ;
22+ import org .hl7 .fhir .utilities .fhirpath .FHIRPathConstantEvaluationMode ;
2523import org .hl7 .fhir .utilities .validation .ValidationMessage ;
2624
27- public class IGPublisherHostServices implements IEvaluationContext {
28-
29-
25+ public class IGPublisherHostServices extends BaseHostServices {
26+
3027 private IGKnowledgeProvider igpkp ;
3128 private List <FetchedFile > fileList = new ArrayList <FetchedFile >();
3229 private SimpleWorkerContext context ;
3330 private DateTimeType dt ;
3431 private StringType pathToSpec ;
35- private Map <String , FunctionDefinition > functions = new HashMap <>();
3632
3733 public IGPublisherHostServices (IGKnowledgeProvider igpkp , List <FetchedFile > fileList ,
3834 SimpleWorkerContext context , DateTimeType dt , StringType pathToSpec ) {
39- super ();
35+ super (context );
4036 this .igpkp = igpkp ;
4137 this .fileList = fileList ;
4238 this .context = context ;
4339 this .dt = dt ;
4440 this .pathToSpec = pathToSpec ;
4541 }
46-
47- public IGPublisherHostServices registerFunction (FunctionDefinition function ) {
48- functions .put (function .name (), function );
49- return this ;
50- }
5142
5243 @ Override
53- public List <Base > resolveConstant (FHIRPathEngine engine , Object appContext , String name , boolean beforeContext , boolean explicitConstant ) throws PathEngineException {
44+ public List <Base > resolveConstant (FHIRPathEngine engine , Object appContext , String name , FHIRPathConstantEvaluationMode mode ) throws PathEngineException {
5445 if ("Globals" .equals (name )) {
5546 List <Base > list = new ArrayList <Base >();
5647 list .add (new GlobalObject (dt , pathToSpec ));
@@ -61,7 +52,7 @@ public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, Stri
6152 }
6253
6354 @ Override
64- public TypeDetails resolveConstantType (FHIRPathEngine engine , Object appContext , String name , boolean explicitConstant ) throws PathEngineException {
55+ public TypeDetails resolveConstantType (FHIRPathEngine engine , Object appContext , String name , FHIRPathConstantEvaluationMode mode ) throws PathEngineException {
6556 if ("Globals" .equals (name )) {
6657 return new TypeDetails (CollectionStatus .SINGLETON , "GlobalObject" );
6758 } else {
@@ -79,24 +70,6 @@ public boolean log(String argument, List<Base> focus) {
7970 return false ;
8071 }
8172
82- @ Override
83- public FunctionDetails resolveFunction (FHIRPathEngine engine , String functionName ) {
84- FunctionDefinition fd = functions .get (functionName );
85- return fd == null ? null : fd .details ();
86- }
87-
88- @ Override
89- public TypeDetails checkFunction (FHIRPathEngine engine , Object appContext , String functionName , TypeDetails focus , List <TypeDetails > parameters ) throws PathEngineException {
90- FunctionDefinition fd = functions .get (functionName );
91- return fd == null ? null : fd .check (engine , appContext , focus , parameters );
92- }
93-
94- @ Override
95- public List <Base > executeFunction (FHIRPathEngine engine , Object appContext , List <Base > focus , String functionName , List <List <Base >> parameters ) {
96- FunctionDefinition fd = functions .get (functionName );
97- return fd == null ? null : fd .execute (engine , appContext , focus , parameters );
98- }
99-
10073 @ Override
10174 public Base resolveReference (FHIRPathEngine engine , Object appContext , String url , Base refContext ) {
10275 if (Utilities .isAbsoluteUrl (url )) {
0 commit comments