Search in sources :

Example 1 with QueryLetRef

use of org.hl7.elm.r1.QueryLetRef 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());
        }
    }
}
Also used : Property(org.hl7.elm.r1.Property) Logger(org.slf4j.Logger) VersionedIdentifier(org.hl7.elm.r1.VersionedIdentifier) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) UsingDef(org.hl7.elm.r1.UsingDef) HashMap(java.util.HashMap) Deque(java.util.Deque) HashSet(java.util.HashSet) AliasRef(org.hl7.elm.r1.AliasRef) Retrieve(org.hl7.elm.r1.Retrieve) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) QueryLetRef(org.hl7.elm.r1.QueryLetRef) QName(javax.xml.namespace.QName) ArrayDeque(java.util.ArrayDeque) ByColumn(org.hl7.elm.r1.ByColumn) ExpressionDef(org.hl7.elm.r1.ExpressionDef) AliasRef(org.hl7.elm.r1.AliasRef) QName(javax.xml.namespace.QName) QueryLetRef(org.hl7.elm.r1.QueryLetRef) HashSet(java.util.HashSet)

Aggregations

ArrayDeque (java.util.ArrayDeque)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 QName (javax.xml.namespace.QName)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 AliasRef (org.hl7.elm.r1.AliasRef)1 ByColumn (org.hl7.elm.r1.ByColumn)1 ExpressionDef (org.hl7.elm.r1.ExpressionDef)1 Property (org.hl7.elm.r1.Property)1 QueryLetRef (org.hl7.elm.r1.QueryLetRef)1 Retrieve (org.hl7.elm.r1.Retrieve)1 UsingDef (org.hl7.elm.r1.UsingDef)1 VersionedIdentifier (org.hl7.elm.r1.VersionedIdentifier)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1