Remove the alias/aliasAs custom functions from R4/r4b (use standard defineVariable now)
This commit is contained in:
parent
59bd0d012c
commit
0664e5601d
|
@ -60,7 +60,7 @@ public class ExpressionNode {
|
|||
Encode, Decode, Escape, Unescape, Trim, Split, Join, LowBoundary, HighBoundary, Precision,
|
||||
|
||||
// Local extensions to FHIRPath
|
||||
HtmlChecks1, HtmlChecks2, AliasAs, Alias, Comparable;
|
||||
HtmlChecks1, HtmlChecks2, Comparable;
|
||||
|
||||
public static Function fromCode(String name) {
|
||||
if (name.equals("empty"))
|
||||
|
@ -171,10 +171,6 @@ public class ExpressionNode {
|
|||
return Function.AnyTrue;
|
||||
if (name.equals("hasValue"))
|
||||
return Function.HasValue;
|
||||
if (name.equals("alias"))
|
||||
return Function.Alias;
|
||||
if (name.equals("aliasAs"))
|
||||
return Function.AliasAs;
|
||||
if (name.equals("htmlChecks"))
|
||||
return Function.HtmlChecks1;
|
||||
if (name.equals("htmlchecks"))
|
||||
|
@ -373,10 +369,6 @@ public class ExpressionNode {
|
|||
return "anyTrue";
|
||||
case HasValue:
|
||||
return "hasValue";
|
||||
case Alias:
|
||||
return "alias";
|
||||
case AliasAs:
|
||||
return "aliasAs";
|
||||
case Encode:
|
||||
return "encode";
|
||||
case Decode:
|
||||
|
|
|
@ -604,7 +604,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(null, base != null && base.isResource() ? base : null,
|
||||
base != null && base.isResource() ? base : null, base, null, base), list, ExpressionNode, true);
|
||||
base != null && base.isResource() ? base : null, base, base), list, ExpressionNode, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -623,7 +623,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
log = new StringBuilder();
|
||||
return execute(
|
||||
new ExecutionContext(null, base.isResource() ? base : null, base.isResource() ? base : null, base, null, base),
|
||||
new ExecutionContext(null, base.isResource() ? base : null, base.isResource() ? base : null, base, base),
|
||||
list, exp, true);
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list,
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list,
|
||||
ExpressionNode, true);
|
||||
}
|
||||
|
||||
|
@ -661,7 +661,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list,
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list,
|
||||
expressionNode, true);
|
||||
}
|
||||
|
||||
|
@ -681,7 +681,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list, exp, true);
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list, exp, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -848,16 +848,13 @@ public class FHIRPathEngine {
|
|||
private Base context;
|
||||
private Base thisItem;
|
||||
private List<Base> total;
|
||||
private Map<String, Base> aliases;
|
||||
private int index;
|
||||
|
||||
public ExecutionContext(Object appInfo, Base resource, Base rootResource, Base context, Map<String, Base> aliases,
|
||||
Base thisItem) {
|
||||
public ExecutionContext(Object appInfo, Base resource, Base rootResource, Base context, Base thisItem) {
|
||||
this.appInfo = appInfo;
|
||||
this.context = context;
|
||||
this.focusResource = resource;
|
||||
this.rootResource = rootResource;
|
||||
this.aliases = aliases;
|
||||
this.thisItem = thisItem;
|
||||
this.index = 0;
|
||||
}
|
||||
|
@ -886,22 +883,6 @@ public class FHIRPathEngine {
|
|||
return new IntegerType(index);
|
||||
}
|
||||
|
||||
public void addAlias(String name, List<Base> focus) throws FHIRException {
|
||||
if (aliases == null) {
|
||||
aliases = new HashMap<String, Base>();
|
||||
} else {
|
||||
aliases = new HashMap<String, Base>(aliases); // clone it, since it's going to change
|
||||
}
|
||||
if (focus.size() > 1) {
|
||||
throw makeException(null, I18nConstants.FHIRPATH_ALIAS_COLLECTION);
|
||||
}
|
||||
aliases.put(name, focus.size() == 0 ? null : focus.get(0));
|
||||
}
|
||||
|
||||
public Base getAlias(String name) {
|
||||
return aliases == null ? null : aliases.get(name);
|
||||
}
|
||||
|
||||
public ExecutionContext setIndex(int i) {
|
||||
index = i;
|
||||
return this;
|
||||
|
@ -1353,10 +1334,6 @@ public class FHIRPathEngine {
|
|||
return checkParamCount(lexer, location, exp, 0);
|
||||
case HasValue:
|
||||
return checkParamCount(lexer, location, exp, 0);
|
||||
case Alias:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case AliasAs:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case Encode:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case Decode:
|
||||
|
@ -3466,14 +3443,6 @@ public class FHIRPathEngine {
|
|||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Comparable:
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Alias:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return anything(CollectionStatus.SINGLETON);
|
||||
case AliasAs:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
case Encode:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
|
@ -3851,8 +3820,6 @@ public class FHIRPathEngine {
|
|||
return funcAllTrue(context, focus, exp);
|
||||
case HasValue:
|
||||
return funcHasValue(context, focus, exp);
|
||||
case AliasAs:
|
||||
return funcAliasAs(context, focus, exp);
|
||||
case Encode:
|
||||
return funcEncode(context, focus, exp);
|
||||
case Decode:
|
||||
|
@ -3867,8 +3834,6 @@ public class FHIRPathEngine {
|
|||
return funcSplit(context, focus, exp);
|
||||
case Join:
|
||||
return funcJoin(context, focus, exp);
|
||||
case Alias:
|
||||
return funcAlias(context, focus, exp);
|
||||
case HtmlChecks1:
|
||||
return funcHtmlChecks1(context, focus, exp);
|
||||
case HtmlChecks2:
|
||||
|
@ -4417,24 +4382,6 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<Base> funcAliasAs(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
||||
String name = nl.get(0).primitiveValue();
|
||||
context.addAlias(name, focus);
|
||||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcAlias(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
||||
String name = nl.get(0).primitiveValue();
|
||||
List<Base> res = new ArrayList<Base>();
|
||||
Base b = context.getAlias(name);
|
||||
if (b != null) {
|
||||
res.add(b);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<Base> funcHtmlChecks1(ExecutionContext context, List<Base> focus, ExpressionNode exp)
|
||||
throws FHIRException {
|
||||
// todo: actually check the HTML
|
||||
|
@ -4585,8 +4532,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
private ExecutionContext changeThis(ExecutionContext context, Base newThis) {
|
||||
return new ExecutionContext(context.appInfo, context.focusResource, context.rootResource, context.context,
|
||||
context.aliases, newThis);
|
||||
return new ExecutionContext(context.appInfo, context.focusResource, context.rootResource, context.context, newThis);
|
||||
}
|
||||
|
||||
private ExecutionTypeContext changeThis(ExecutionTypeContext context, TypeDetails newThis) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ExpressionNode {
|
|||
Encode, Decode, Escape, Unescape, Trim, Split, Join, LowBoundary, HighBoundary, Precision,
|
||||
|
||||
// Local extensions to FHIRPath
|
||||
HtmlChecks1, HtmlChecks2, AliasAs, Alias, Comparable;
|
||||
HtmlChecks1, HtmlChecks2, Comparable;
|
||||
|
||||
public static Function fromCode(String name) {
|
||||
if (name.equals("empty"))
|
||||
|
@ -171,10 +171,6 @@ public class ExpressionNode {
|
|||
return Function.AnyTrue;
|
||||
if (name.equals("hasValue"))
|
||||
return Function.HasValue;
|
||||
if (name.equals("alias"))
|
||||
return Function.Alias;
|
||||
if (name.equals("aliasAs"))
|
||||
return Function.AliasAs;
|
||||
if (name.equals("htmlChecks"))
|
||||
return Function.HtmlChecks1;
|
||||
if (name.equals("htmlchecks"))
|
||||
|
@ -373,10 +369,6 @@ public class ExpressionNode {
|
|||
return "anyTrue";
|
||||
case HasValue:
|
||||
return "hasValue";
|
||||
case Alias:
|
||||
return "alias";
|
||||
case AliasAs:
|
||||
return "aliasAs";
|
||||
case Encode:
|
||||
return "encode";
|
||||
case Decode:
|
||||
|
|
|
@ -605,7 +605,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(null, base != null && base.isResource() ? base : null,
|
||||
base != null && base.isResource() ? base : null, base, null, base), list, ExpressionNode, true);
|
||||
base != null && base.isResource() ? base : null, base, base), list, ExpressionNode, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -624,7 +624,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
log = new StringBuilder();
|
||||
return execute(
|
||||
new ExecutionContext(null, base.isResource() ? base : null, base.isResource() ? base : null, base, null, base),
|
||||
new ExecutionContext(null, base.isResource() ? base : null, base.isResource() ? base : null, base, base),
|
||||
list, exp, true);
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list,
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list,
|
||||
ExpressionNode, true);
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list,
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list,
|
||||
expressionNode, true);
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ public class FHIRPathEngine {
|
|||
list.add(base);
|
||||
}
|
||||
log = new StringBuilder();
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list, exp, true);
|
||||
return execute(new ExecutionContext(appContext, focusResource, rootResource, base, base), list, exp, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -849,16 +849,13 @@ public class FHIRPathEngine {
|
|||
private Base context;
|
||||
private Base thisItem;
|
||||
private List<Base> total;
|
||||
private Map<String, Base> aliases;
|
||||
private int index;
|
||||
|
||||
public ExecutionContext(Object appInfo, Base resource, Base rootResource, Base context, Map<String, Base> aliases,
|
||||
Base thisItem) {
|
||||
public ExecutionContext(Object appInfo, Base resource, Base rootResource, Base context, Base thisItem) {
|
||||
this.appInfo = appInfo;
|
||||
this.context = context;
|
||||
this.focusResource = resource;
|
||||
this.rootResource = rootResource;
|
||||
this.aliases = aliases;
|
||||
this.thisItem = thisItem;
|
||||
this.index = 0;
|
||||
}
|
||||
|
@ -887,22 +884,6 @@ public class FHIRPathEngine {
|
|||
return new IntegerType(index);
|
||||
}
|
||||
|
||||
public void addAlias(String name, List<Base> focus) throws FHIRException {
|
||||
if (aliases == null) {
|
||||
aliases = new HashMap<String, Base>();
|
||||
} else {
|
||||
aliases = new HashMap<String, Base>(aliases); // clone it, since it's going to change
|
||||
}
|
||||
if (focus.size() > 1) {
|
||||
throw makeException(null, I18nConstants.FHIRPATH_ALIAS_COLLECTION);
|
||||
}
|
||||
aliases.put(name, focus.size() == 0 ? null : focus.get(0));
|
||||
}
|
||||
|
||||
public Base getAlias(String name) {
|
||||
return aliases == null ? null : aliases.get(name);
|
||||
}
|
||||
|
||||
public ExecutionContext setIndex(int i) {
|
||||
index = i;
|
||||
return this;
|
||||
|
@ -1353,10 +1334,6 @@ public class FHIRPathEngine {
|
|||
return checkParamCount(lexer, location, exp, 0);
|
||||
case HasValue:
|
||||
return checkParamCount(lexer, location, exp, 0);
|
||||
case Alias:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case AliasAs:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case Encode:
|
||||
return checkParamCount(lexer, location, exp, 1);
|
||||
case Decode:
|
||||
|
@ -3468,14 +3445,6 @@ public class FHIRPathEngine {
|
|||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Comparable:
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Alias:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return anything(CollectionStatus.SINGLETON);
|
||||
case AliasAs:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
case Encode:
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes,
|
||||
new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
|
@ -3853,8 +3822,6 @@ public class FHIRPathEngine {
|
|||
return funcAllTrue(context, focus, exp);
|
||||
case HasValue:
|
||||
return funcHasValue(context, focus, exp);
|
||||
case AliasAs:
|
||||
return funcAliasAs(context, focus, exp);
|
||||
case Encode:
|
||||
return funcEncode(context, focus, exp);
|
||||
case Decode:
|
||||
|
@ -3869,8 +3836,6 @@ public class FHIRPathEngine {
|
|||
return funcSplit(context, focus, exp);
|
||||
case Join:
|
||||
return funcJoin(context, focus, exp);
|
||||
case Alias:
|
||||
return funcAlias(context, focus, exp);
|
||||
case HtmlChecks1:
|
||||
return funcHtmlChecks1(context, focus, exp);
|
||||
case HtmlChecks2:
|
||||
|
@ -4427,24 +4392,6 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<Base> funcAliasAs(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
||||
String name = nl.get(0).primitiveValue();
|
||||
context.addAlias(name, focus);
|
||||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcAlias(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
||||
String name = nl.get(0).primitiveValue();
|
||||
List<Base> res = new ArrayList<Base>();
|
||||
Base b = context.getAlias(name);
|
||||
if (b != null) {
|
||||
res.add(b);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<Base> funcHtmlChecks1(ExecutionContext context, List<Base> focus, ExpressionNode exp)
|
||||
throws FHIRException {
|
||||
// todo: actually check the HTML
|
||||
|
@ -4587,8 +4534,9 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
private ExecutionContext changeThis(ExecutionContext context, Base newThis) {
|
||||
return new ExecutionContext(context.appInfo, context.focusResource, context.rootResource, context.context,
|
||||
context.aliases, newThis);
|
||||
ExecutionContext newContext = new ExecutionContext(context.appInfo, context.focusResource, context.rootResource, context.context,
|
||||
newThis);
|
||||
return newContext;
|
||||
}
|
||||
|
||||
private ExecutionTypeContext changeThis(ExecutionTypeContext context, TypeDetails newThis) {
|
||||
|
|
Loading…
Reference in New Issue