resolveEntity()

in ui-modules/blueprint-composer/app/components/util/model/dsl.model.js [603:643]


    resolveEntity(entity, entityResolver) {
        let dsl = this;
        let curr = entity;
        while (dsl.kind === KIND.TARGET) {
            switch (dsl.name) {
                case TARGET.SELF:
                    break;
                case TARGET.PARENT:
                    if (!curr.parent) {
                        this.issues.push('The entity with ID <code>' + curr.id + '</code> does not have a parent');
                    }
                    curr = curr.parent;
                    break;
                case TARGET.CHILD:
                case TARGET.SIBLING:
                case TARGET.DESCENDANT:
                case TARGET.ANCESTOR:
                case TARGET.ENTITY:
                case TARGET.COMPONENT: // component can have 1 or 2 params
                    let name = dsl.params[dsl.params.length - 1].name;
                    let resolvedEntity = entityResolver(name);
                    if (resolvedEntity === null) {
                        this.issues.push('The reference ID <code>' + name + '</code> does not exist');
                    }
                    curr = resolvedEntity;
                    break;
                case TARGET.ROOT:
                case TARGET.SCOPEROOT:
                    curr = this.resolveRoot(curr);
                    break;
            }
            if (dsl.hasNext()) {
                // follow the call chain
                dsl = dsl.next;
            }
            else {
                break;
            }
        }
        return curr;
    }