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());
}
}
}
}
Aggregations