use of org.hl7.elm.r1.AliasRef in project quality-measure-and-cohort-service by Alvearie.
the class PathCaptureContext method reportProperty.
public void reportProperty(Property elm) {
// Log guarding to prevent some of the parameter resolution logic from getting called unnecessarily
if (LOG.isTraceEnabled()) {
LOG.trace("Property {} source {}", elm.getPath(), elm.getSource() != null ? elm.getSource().getClass().getSimpleName() : null);
}
Set<QName> modelTypeNames = null;
if (elm.getScope() != null || elm.getSource() instanceof AliasRef) {
String aliasName = (elm.getScope() != null) ? elm.getScope() : ((AliasRef) elm.getSource()).getName();
QueryAliasContext aliasContext = getCurrentQueryContext().resolveAlias(aliasName);
if (aliasContext == null) {
aliasContext = getCurrentExpressionContext().resolveAlias(aliasName);
}
modelTypeNames = ElmUtils.getModelTypeNames(aliasContext.getAliasedQuerySource().getExpression());
} else if (elm.getSource() instanceof QueryLetRef) {
String letName = ((QueryLetRef) elm.getSource()).getName();
QueryLetContext letContext = getCurrentQueryContext().resolveLet(letName);
if (letContext == null) {
letContext = getCurrentExpressionContext().resolveLet(letName);
}
modelTypeNames = ElmUtils.getModelTypeNames(letContext.getLetClause().getExpression());
} else {
// There are times when the scope is null. I've noticed this particularly when referencing properties
// of another expression result
modelTypeNames = ElmUtils.getModelTypeNames(elm.getSource());
}
LOG.trace("ModelTypeNames {}", modelTypeNames);
if (modelTypeNames != null) {
for (QName qname : modelTypeNames) {
pathsByQName.computeIfAbsent(qname, key -> new HashSet<>()).add(elm.getPath());
}
}
}
Aggregations