Search in sources :

Example 1 with CompoundExpression

use of org.eclipse.persistence.internal.expressions.CompoundExpression in project eclipselink by eclipse-ee4j.

the class DescriptorQueryManager method updatePropertyParameterExpression.

/**
 * INTERNAL:
 * This method will walk the given expression and mark any parameter
 * expressions as property expressions. This is done when additional
 * criteria has been specified and parameter values must be resolved
 * through session properties.
 *
 * @see #postInitialize
 */
protected void updatePropertyParameterExpression(Expression exp) {
    if (exp.isCompoundExpression()) {
        updatePropertyParameterExpression(((CompoundExpression) exp).getFirstChild());
        updatePropertyParameterExpression(((CompoundExpression) exp).getSecondChild());
    } else if (exp.isFunctionExpression()) {
        for (Expression e : ((FunctionExpression) exp).getChildren()) {
            updatePropertyParameterExpression(e);
        }
    } else if (exp.isSubSelectExpression()) {
        ReportQuery subSelectQuery = ((SubSelectExpression) exp).getSubQuery();
        for (ReportItem item : subSelectQuery.getItems()) {
            updatePropertyParameterExpression(item.getAttributeExpression());
        }
    }
    if (exp.isParameterExpression()) {
        ((ParameterExpression) exp).setIsProperty(true);
    }
}
Also used : SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) ParameterExpression(org.eclipse.persistence.internal.expressions.ParameterExpression) CompoundExpression(org.eclipse.persistence.internal.expressions.CompoundExpression) FunctionExpression(org.eclipse.persistence.internal.expressions.FunctionExpression) Expression(org.eclipse.persistence.expressions.Expression) ReportQuery(org.eclipse.persistence.queries.ReportQuery) ParameterExpression(org.eclipse.persistence.internal.expressions.ParameterExpression) ReportItem(org.eclipse.persistence.internal.queries.ReportItem)

Example 2 with CompoundExpression

use of org.eclipse.persistence.internal.expressions.CompoundExpression in project eclipselink by eclipse-ee4j.

the class InImpl method value.

/**
 *  Add to list of values to be tested against.
 *  @param value expression
 *  @return in predicate
 */
@Override
public In<T> value(Expression<? extends T> value) {
    if (!(((InternalExpression) value).isLiteral() || ((InternalExpression) value).isParameter())) {
        RelationExpression baseIn = (RelationExpression) this.currentNode;
        this.currentNode = baseIn.getFirstChild().in(((SubQueryImpl) value).subQuery);
        if (this.parentNode != null) {
            if (this.parentNode.isCompoundExpression()) {
                CompoundExpression logExp = (LogicalExpression) this.parentNode;
                if (logExp.getFirstChild() == baseIn) {
                    logExp.create(this.currentNode, logExp.getSecondChild(), logExp.getOperator());
                } else {
                    logExp.create(logExp.getFirstChild(), this.currentNode, logExp.getOperator());
                }
            } else {
                FunctionExpression funcExp = (FunctionExpression) this.parentNode;
                funcExp.getChildren().set(funcExp.getChildren().indexOf(baseIn), this.currentNode);
            }
        }
    } else {
        if (this.currentNode.isRelationExpression()) {
            RelationExpression baseIn = (RelationExpression) this.currentNode;
            org.eclipse.persistence.expressions.Expression resultExp = ((InternalSelection) value).getCurrentNode();
            resultExp = org.eclipse.persistence.expressions.Expression.from(resultExp, baseIn.getFirstChild());
            ((Collection) ((CollectionExpression) baseIn.getSecondChild()).getValue()).add(resultExp);
            // Add to the expression list for #findRootAndParameters()
            this.expressions.add(value);
        } else {
            throw new IllegalStateException(ExceptionLocalization.buildMessage("CANNOT_ADD_CONSTANTS_TO_SUBQUERY_IN"));
        }
    }
    return this;
}
Also used : LogicalExpression(org.eclipse.persistence.internal.expressions.LogicalExpression) FunctionExpression(org.eclipse.persistence.internal.expressions.FunctionExpression) RelationExpression(org.eclipse.persistence.internal.expressions.RelationExpression) CompoundExpression(org.eclipse.persistence.internal.expressions.CompoundExpression) Collection(java.util.Collection)

Aggregations

CompoundExpression (org.eclipse.persistence.internal.expressions.CompoundExpression)2 FunctionExpression (org.eclipse.persistence.internal.expressions.FunctionExpression)2 Collection (java.util.Collection)1 Expression (org.eclipse.persistence.expressions.Expression)1 LogicalExpression (org.eclipse.persistence.internal.expressions.LogicalExpression)1 ParameterExpression (org.eclipse.persistence.internal.expressions.ParameterExpression)1 RelationExpression (org.eclipse.persistence.internal.expressions.RelationExpression)1 SubSelectExpression (org.eclipse.persistence.internal.expressions.SubSelectExpression)1 ReportItem (org.eclipse.persistence.internal.queries.ReportItem)1 ReportQuery (org.eclipse.persistence.queries.ReportQuery)1