use of org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateFunctionPathExpression.
/**
* Validates the left and right expressions of the given compound expression. The test to perform is:
* <ul>
* <li>If the left or the right expression is a path expression, validation makes sure it is a
* basic mapping, an association field is not allowed.</li>
* </ul>
*
* @param expression The {@link CompoundExpression} to validate by validating its left and right
* expressions
* @param pathType The type of field that is allowed
* @return A number indicating the validation result. {@link #isValid(int, int)} can be used to
* determine the validation status of an expression based on its position
*/
protected int validateFunctionPathExpression(CompoundExpression expression, PathType pathType) {
int result = 0;
// Left expression
if (expression.hasLeftExpression()) {
Expression leftExpression = expression.getLeftExpression();
StateFieldPathExpression pathExpression = getStateFieldPathExpression(leftExpression);
if (pathExpression != null) {
boolean valid = validateStateFieldPathExpression(pathExpression, pathType);
updateStatus(result, 0, valid);
} else {
leftExpression.accept(this);
}
}
// Right expression
if (expression.hasRightExpression()) {
Expression rightExpression = expression.getRightExpression();
StateFieldPathExpression pathExpression = getStateFieldPathExpression(rightExpression);
if (pathExpression != null) {
boolean valid = validateStateFieldPathExpression(pathExpression, pathType);
updateStatus(result, 1, valid);
} else {
rightExpression.accept(this);
}
}
return result;
}
use of org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateInExpression.
/**
* Validates the given {@link InExpression}. The test to perform is:
* <ul>
* <li>If the expression is a path expression, validation makes sure it is an association mapping,
* a basic field is not allowed.</li>
* </ul>
*
* @param expression The {@link InExpression} to validate
*/
protected void validateInExpression(InExpression expression) {
// Validate the left expression
if (expression.hasExpression()) {
Expression stringExpression = expression.getExpression();
// Special case for state field path expression
StateFieldPathExpression pathExpression = getStateFieldPathExpression(stringExpression);
if (pathExpression != null) {
validateStateFieldPathExpression(pathExpression, validPathExpressionTypeForInExpression());
} else {
stringExpression.accept(this);
}
}
// Validate the items
expression.getInItems().accept(getInItemsVisitor());
}
use of org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateArithmeticExpression.
/**
* Validates the arithmetic factor expression. The test to perform is:
* <ul>
* <li>If the arithmetic factor is a path expression, validation makes sure it is a basic
* mapping, an association field is not allowed.</li>
* </ul>
*
* @param expression The {@link ArithmeticFactor} to validate
* @return <code>false</code> if the arithmetic factor expression was validated and is invalid;
* <code>true</code> otherwise
*/
protected boolean validateArithmeticExpression(ArithmeticFactor expression) {
boolean valid = true;
if (expression.hasExpression()) {
Expression factor = expression.getExpression();
// Special case for state field path expression, association field is not allowed
StateFieldPathExpression pathExpression = getStateFieldPathExpression(factor);
if (pathExpression != null) {
valid = validateStateFieldPathExpression(pathExpression, PathType.BASIC_FIELD_ONLY);
} else {
factor.accept(this);
}
}
return valid;
}
use of org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateCountFunction.
/**
* Validates the given {@link CountFunction}. The default behavior does not require to
* semantically validate it.
*
* @param expression The {@link CountFunction} to validate
*/
protected void validateCountFunction(CountFunction expression) {
if (expression.hasExpression()) {
Expression leftExpression = expression.getExpression();
StateFieldPathExpression pathExpression = getStateFieldPathExpression(leftExpression);
if (pathExpression != null) {
validateStateFieldPathExpression(pathExpression, validPathExpressionTypeForCountFunction());
} else {
leftExpression.accept(this);
}
}
}
use of org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateTypeExpression.
/**
* Validates the given {@link TypeExpression}. The test to perform is:
* <ul>
* <li>If the encapsulated expression is a path expression, validation makes sure it is an
* association field, a basic field is not allowed.</li>
* </ul>
*
* @param expression The {@link TypeExpression} to validate
* @return <code>false</code> if the encapsulated expression was validated and is invalid;
* <code>true</code> otherwise
*/
protected boolean validateTypeExpression(TypeExpression expression) {
// Validate the expression
if (expression.hasEncapsulatedExpression()) {
Expression encapsulatedExpression = expression.getExpression();
// Special case for state field path expression, only association field is allowed
StateFieldPathExpression pathExpression = getStateFieldPathExpression(encapsulatedExpression);
if (pathExpression != null) {
return validateStateFieldPathExpression(pathExpression, PathType.ASSOCIATION_FIELD_ONLY);
} else {
encapsulatedExpression.accept(this);
}
}
return true;
}
Aggregations