private void log(String name, List<Base> contents) { if (hostServices == null || !hostServices.log(name, contents)) { if (log.length() > 0) log.append("; "); log.append(name); log.append(": "); boolean first = true; for (Base b : contents) { if (first) first = false; else log.append(","); log.append(convertToString(b)); } } }
private Base resolveConstant(ExecutionContext context, String s, boolean beforeContext) throws PathEngineException { if (s.equals("%sct")) return new StringType("http://snomed.info/sct").noExtensions(); else if (s.equals("%loinc")) return new StringType("http://loinc.org").noExtensions(); else if (s.equals("%ucum")) return new StringType("http://unitsofmeasure.org").noExtensions(); else if (s.equals("%resource")) { if (context.resource == null) throw new PathEngineException("Cannot use %resource in this context"); return context.resource; } else if (s.equals("%context")) { return context.context; } else if (s.equals("%us-zip")) return new StringType("[0-9]{5}(-[0-9]{4}){0,1}").noExtensions(); else if (s.startsWith("%\"vs-")) return new StringType("http://hl7.org/fhir/ValueSet/"+s.substring(5, s.length()-1)+"").noExtensions(); else if (s.startsWith("%\"cs-")) return new StringType("http://hl7.org/fhir/"+s.substring(5, s.length()-1)+"").noExtensions(); else if (s.startsWith("%\"ext-")) return new StringType("http://hl7.org/fhir/StructureDefinition/"+s.substring(6, s.length()-1)).noExtensions(); else if (hostServices == null) throw new PathEngineException("Unknown fixed constant '"+s+"'"); else return hostServices.resolveConstant(context.appInfo, s.substring(1), beforeContext); }
throw new PathEngineException("Unknown fixed constant type for '"+s+"'"); else return hostServices.resolveConstantType(context.appInfo, s);
return hostServices.checkFunction(context.appInfo, exp.getName(), paramTypes);
if (f == null) { if (hostServices != null) details = hostServices.resolveFunction(result.getName()); if (details == null) throw lexer.error("The name "+result.getName()+" is not a valid function name");
for (ExpressionNode p : exp.getParameters()) params.add(execute(context, focus, p, true)); return hostServices.executeFunction(context.appInfo, exp.getName(), params);
res = hostServices.resolveReference(context.appInfo, s);
private List<Base> execute(ExecutionContext context, Base item, ExpressionNode exp, boolean atEntry) throws FHIRException { List<Base> result = new ArrayList<Base>(); if (atEntry && context.appInfo != null && hostServices != null) { // we'll see if the name matches a constant known by the context. Base temp = hostServices.resolveConstant(context.appInfo, exp.getName(), true); if (temp != null) { result.add(temp); return result; } } if (atEntry && Character.isUpperCase(exp.getName().charAt(0))) {// special case for start up if (item.isResource() && item.fhirType().equals(exp.getName())) result.add(item); } else getChildrenByName(item, exp.getName(), result); if (atEntry && context.appInfo != null && hostServices != null && result.isEmpty()) { // well, we didn't get a match on the name - we'll see if the name matches a constant known by the context. // (if the name does match, and the user wants to get the constant value, they'll have to try harder... Base temp = hostServices.resolveConstant(context.appInfo, exp.getName(), false); if (temp != null) { result.add(temp); } } return result; }
throw new PathEngineException("Unknown fixed constant type for '"+s+"'"); else return hostServices.resolveConstantType(context.appInfo, s);
private Base resolveConstant(ExecutionContext context, String s, boolean beforeContext) throws PathEngineException { if (s.equals("%sct")) return new StringType("http://snomed.info/sct").noExtensions(); else if (s.equals("%loinc")) return new StringType("http://loinc.org").noExtensions(); else if (s.equals("%ucum")) return new StringType("http://unitsofmeasure.org").noExtensions(); else if (s.equals("%resource")) { if (context.resource == null) throw new PathEngineException("Cannot use %resource in this context"); return context.resource; } else if (s.equals("%context")) { return context.context; } else if (s.equals("%us-zip")) return new StringType("[0-9]{5}(-[0-9]{4}){0,1}").noExtensions(); else if (s.startsWith("%\"vs-")) return new StringType("http://hl7.org/fhir/ValueSet/"+s.substring(5, s.length()-1)+"").noExtensions(); else if (s.startsWith("%\"cs-")) return new StringType("http://hl7.org/fhir/"+s.substring(5, s.length()-1)+"").noExtensions(); else if (s.startsWith("%\"ext-")) return new StringType("http://hl7.org/fhir/StructureDefinition/"+s.substring(6, s.length()-1)).noExtensions(); else if (hostServices == null) throw new PathEngineException("Unknown fixed constant '"+s+"'"); else return hostServices.resolveConstant(context.appInfo, s.substring(1), beforeContext); }
private void log(String name, List<Base> contents) { if (hostServices == null || !hostServices.log(name, contents)) { if (log.length() > 0) log.append("; "); log.append(name); log.append(": "); boolean first = true; for (Base b : contents) { if (first) first = false; else log.append(","); log.append(convertToString(b)); } } }
@Override public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { ValidatorHostContext c = (ValidatorHostContext) appContext; if (externalHostServices != null) return externalHostServices.resolveConstantType(c.appContext, name); else return null; }
@Override public boolean log(String argument, List<Base> focus) { if (externalHostServices == null) return false; return externalHostServices.log(argument, focus); }
@Override public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) { if (externalHostServices == null) return null; LiquidEngineContext ctxt = (LiquidEngineContext) appContext; return externalHostServices.executeFunction(ctxt.externalContext, functionName, parameters); }
@Override public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException { if (externalHostServices == null) return null; LiquidEngineContext ctxt = (LiquidEngineContext) appContext; return externalHostServices.checkFunction(ctxt.externalContext, functionName, parameters); }
private List<Base> funcConformsTo(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException { if (hostServices == null) throw new FHIRException("Unable to check conformsTo - no hostservices provided"); List<Base> result = new ArrayList<Base>(); if (focus.size() != 1) result.add(new BooleanType(false).noExtensions()); else { String url = convertToString(execute(context, focus, exp.getParameters().get(0), true)); result.add(new BooleanType(hostServices.conformsToProfile(context.appInfo, focus.get(0), url)).noExtensions()); } return result; }
@Override public Base resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException { LiquidEngineContext ctxt = (LiquidEngineContext) appContext; if (ctxt.vars.containsKey(name)) return ctxt.vars.get(name); if (externalHostServices == null) return null; return externalHostServices.resolveConstant(ctxt.externalContext, name, beforeContext); }
@Override public Base resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException { ValidatorHostContext c = (ValidatorHostContext) appContext; if (externalHostServices != null) return externalHostServices.resolveConstant(c.appContext, name, beforeContext); else return null; }
@Override public FunctionDetails resolveFunction(String functionName) { if (externalHostServices == null) return null; return externalHostServices.resolveFunction(functionName); }
private TypeDetails executeContextType(ExecutionTypeContext context, String name) throws PathEngineException, DefinitionException { if (hostServices == null) throw new PathEngineException("Unable to resolve context reference since no host services are provided"); return hostServices.resolveConstantType(context.appInfo, name); }