Package org.jboss.as.cmp.ejbql

Examples of org.jboss.as.cmp.ejbql.Node


     * @param selectFunction a node implements SelectFunction
     * @return ASTPath child or null if there was no child of type ASTPath
     */
    private ASTPath getPathFromChildren(Node selectFunction) {
        for (int childInd = 0; childInd < selectFunction.jjtGetNumChildren(); ++childInd) {
            Node child = selectFunction.jjtGetChild(childInd);
            if (child instanceof ASTPath) {
                return (ASTPath) child;
            } else if (child instanceof SelectFunction) {
                Node path = getPathFromChildren(child);
                if (path != null) {
                    return (ASTPath) path;
                }
            }
        }
View Full Code Here


                    selected = true;
                    break;
                }
            }
        } else if (selectObject instanceof SelectFunction) {
            Node funcNode = (Node) selectObject;
            ASTPath fieldPath = getPathFromChildren(funcNode);
            if (fieldPath.getCMPField() == cmpField) {
                selected = true;
            }
        }
View Full Code Here

    public Object visit(SimpleNode node, Object data) {
        throw CmpMessages.MESSAGES.unknownNodeType(node);
    }

    public Object visit(ASTEJBQL node, Object data) {
        Node selectNode = node.jjtGetChild(0);
        Node fromNode = node.jjtGetChild(1);

        // compile selectNode
        StringBuffer selectClause = new StringBuffer(50);
        selectNode.jjtAccept(this, selectClause);

        StringBuffer whereClause = null;
        StringBuffer orderByClause = null;
        for (int i = 2; i < node.jjtGetNumChildren(); ++i) {
            Node childNode = node.jjtGetChild(i);
            if (childNode instanceof ASTWhere) {
                whereClause = new StringBuffer(20);
                childNode.jjtAccept(this, whereClause);
            } else if (childNode instanceof ASTOrderBy) {
                orderByClause = new StringBuffer();
                childNode.jjtAccept(this, orderByClause);
            } else if (childNode instanceof ASTLimitOffset) {
                childNode.jjtAccept(this, null);
            }
        }

        // compile fromNode
        StringBuffer fromClause = new StringBuffer(30);
View Full Code Here

    }

    public Object visit(ASTLimitOffset node, Object data) {
        int child = 0;
        if (node.hasOffset) {
            Node offsetNode = node.jjtGetChild(child++);
            if (offsetNode instanceof ASTParameter) {
                ASTParameter param = (ASTParameter) offsetNode;
                Class parameterType = getParameterType(param.number);
                if (int.class != parameterType && Integer.class != parameterType) {
                    throw CmpMessages.MESSAGES.offsetParameterMustBeInt();
                }
                offsetParam = param.number;
            } else {
                ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode;
                offsetValue = (int) param.value;
            }
        }

        if (node.hasLimit) {
            Node limitNode = node.jjtGetChild(child);
            if (limitNode instanceof ASTParameter) {
                ASTParameter param = (ASTParameter) limitNode;
                Class parameterType = getParameterType(param.number);
                if (int.class != parameterType && Integer.class != parameterType) {
                    throw CmpMessages.MESSAGES.limitParameterMustBeInt();
View Full Code Here

    }

    public Object visit(ASTSelect select, Object data) {
        StringBuffer sql = (StringBuffer) data;

        final Node child0 = select.jjtGetChild(0);
        final ASTPath path;
        if (child0 instanceof ASTPath) {
            path = (ASTPath) child0;

            if (path.isCMPField()) {
                // set the select object
                JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField();
                selectManager = selectField.getManager();
                selectObject = selectField;
                setTypeFactory(selectManager.getJDBCTypeFactory());

                // todo inner or left?
                //addLeftJoinPath(path);
                addInnerJoinPath(path);

                String alias = aliasManager.getAlias(path.getPath(path.size() - 2));
                SQLUtil.getColumnNamesClause(selectField, alias, sql);
            } else {
                JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge) path.getEntity();
                selectManager = selectEntity.getManager();
                selectObject = selectEntity;
                setTypeFactory(selectEntity.getManager().getJDBCTypeFactory());

                final String alias = aliasManager.getAlias(path.getPath());
                if (select.distinct) {
                    SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql);
                } else {
                    SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql);
                }

                /*
                if(readAhead.isOnFind())
                {
                   String eagerLoadGroupName = readAhead.getEagerLoadGroup();
                   boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName);
                   SQLUtil.appendColumnNamesClause(
                      selectEntity.getTableFields(),
                      loadGroupMask,
                      alias,
                      sql
                   );
                }
                */

                addLeftJoinPath(path);
            }
        } else {
            // the function should take a path expresion as a parameter
            path = getPathFromChildren(child0);

            if (path == null) {
                throw CmpMessages.MESSAGES.noPathExpressionInSelect();
            }

            if (path.isCMPField()) {
                JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField();
                selectManager = selectField.getManager();
                setTypeFactory(selectManager.getJDBCTypeFactory());
                if (selectField.getJDBCType().hasMapper())
                    this.functionJDBCType = selectField.getJDBCType();
            } else if (path.isCMRField()) {
                JDBCFieldBridge cmrField = (JDBCFieldBridge) path.getCMRField();
                selectManager = cmrField.getManager();
                setTypeFactory(selectManager.getJDBCTypeFactory());
                addLeftJoinPath(path);
            } else {
                final JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) path.getEntity();
                selectManager = entity.getManager();
                setTypeFactory(selectManager.getJDBCTypeFactory());
                addLeftJoinPath(path);
            }

            selectObject = child0;
            child0.jjtAccept(this, data);
        }

        return data;
    }
View Full Code Here

    }

    public Object visit(ASTNullComparison node, Object data) {
        StringBuffer sql = (StringBuffer) data;

        final Node child0 = node.jjtGetChild(0);
        if (child0 instanceof ASTPath) {
            ASTPath path = (ASTPath) child0;
            addLeftJoinPath(path);

            JDBCFieldBridge field = (JDBCFieldBridge) path.getField();
View Full Code Here

        return data;
    }

    public Object visit(ASTMemberOf node, Object data) {
        Node member = node.jjtGetChild(0);
        ASTPath colPath = (ASTPath) node.jjtGetChild(1);
        JDBCAbstractEntityBridge colEntity = (JDBCAbstractEntityBridge) colPath.getEntity();

        StringBuffer sql = (StringBuffer) data;
View Full Code Here

        ASTPath fromPath = (ASTPath) node.jjtGetChild(0);
        addInnerJoinPath(fromPath);
        String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2));
        CMPFieldBridge fromCMPField = (CMPFieldBridge) fromPath.getCMPField();

        Node toNode = node.jjtGetChild(1);
        if (toNode instanceof ASTParameter) {
            ASTParameter toParam = (ASTParameter) toNode;

            // can only compare like kind entities
            Class parameterType = getParameterType(toParam.number);
View Full Code Here

        return (not ? buf.append(')') : buf).append(')');
    }

    public Object visit(ASTEntityComparison node, Object data) {
        StringBuffer buf = (StringBuffer) data;
        Node arg0 = node.jjtGetChild(0);
        Node arg1 = node.jjtGetChild(1);
        if (node.opp.equals(SQLUtil.NOT_EQUAL)) {
            compareEntity(true, arg0, arg1, buf);
        } else {
            compareEntity(false, arg0, arg1, buf);
        }
View Full Code Here

     * @param selectFunction a node implements SelectFunction
     * @return ASTPath child or null if there was no child of type ASTPath
     */
    private ASTPath getPathFromChildren(Node selectFunction) {
        for (int childInd = 0; childInd < selectFunction.jjtGetNumChildren(); ++childInd) {
            Node child = selectFunction.jjtGetChild(childInd);
            if (child instanceof ASTPath) {
                return (ASTPath) child;
            } else if (child instanceof SelectFunction) {
                Node path = getPathFromChildren(child);
                if (path != null) {
                    return (ASTPath) path;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.ejbql.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.