Search in sources :

Example 1 with SimpleAttributePointer

use of com.haulmont.cuba.core.sys.jpql.pointer.SimpleAttributePointer in project cuba by cuba-platform.

the class IdentificationVariableNode method deductFields.

public void deductFields(QueryVariableContext queryVC, CommonTree node, DomainModel model) {
    List children = node.getChildren();
    CommonTree T_SELECTED_ITEMS_NODE = (CommonTree) children.get(0);
    for (Object o : T_SELECTED_ITEMS_NODE.getChildren()) {
        o = ((SelectedItemNode) o).getChild(0);
        if (!(o instanceof PathNode)) {
            throw new RuntimeException("Not a path node");
        }
        PathNode pathNode = (PathNode) o;
        Pointer pointer = pathNode.resolvePointer(model, queryVC);
        if (pointer instanceof NoPointer) {
            queryVC.setEntity(NoJpqlEntityModel.getInstance());
            return;
        }
        if (pointer instanceof SimpleAttributePointer) {
            SimpleAttributePointer saPointer = (SimpleAttributePointer) pointer;
            queryVC.getEntity().addAttributeCopy(saPointer.getAttribute());
        } else if (pointer instanceof EntityPointer) {
            if (T_SELECTED_ITEMS_NODE.getChildren().size() != 1) {
                // todo implement
                throw new UnsupportedOperationException("Unimplemented variant with returned array");
            } else {
                queryVC.setEntity(((EntityPointer) pointer).getEntity());
            }
        }
    }
}
Also used : SimpleAttributePointer(com.haulmont.cuba.core.sys.jpql.pointer.SimpleAttributePointer) EntityPointer(com.haulmont.cuba.core.sys.jpql.pointer.EntityPointer) CommonTree(org.antlr.runtime.tree.CommonTree) NoPointer(com.haulmont.cuba.core.sys.jpql.pointer.NoPointer) List(java.util.List) Pointer(com.haulmont.cuba.core.sys.jpql.pointer.Pointer) SimpleAttributePointer(com.haulmont.cuba.core.sys.jpql.pointer.SimpleAttributePointer) EntityPointer(com.haulmont.cuba.core.sys.jpql.pointer.EntityPointer) NoPointer(com.haulmont.cuba.core.sys.jpql.pointer.NoPointer)

Aggregations

EntityPointer (com.haulmont.cuba.core.sys.jpql.pointer.EntityPointer)1 NoPointer (com.haulmont.cuba.core.sys.jpql.pointer.NoPointer)1 Pointer (com.haulmont.cuba.core.sys.jpql.pointer.Pointer)1 SimpleAttributePointer (com.haulmont.cuba.core.sys.jpql.pointer.SimpleAttributePointer)1 List (java.util.List)1 CommonTree (org.antlr.runtime.tree.CommonTree)1