public QueryKeyExpression existingDerivedExpressionNamed(String attributeName) { if (this.derivedExpressions == null) { return null; } List<Expression> derivedExpressionsCopy; synchronized(this) { derivedExpressionsCopy = new ArrayList(this.derivedExpressions); } for (Expression derivedExpression : derivedExpressionsCopy) { QueryKeyExpression exp = (QueryKeyExpression)derivedExpression; if (exp.getName().equals(attributeName)) { return exp; } } return null; }
public QueryKeyExpression existingDerivedExpressionNamed(String attributeName) { if (this.derivedExpressions == null) { return null; } List<Expression> derivedExpressionsCopy; synchronized(this) { derivedExpressionsCopy = new ArrayList(this.derivedExpressions); } for (Expression derivedExpression : derivedExpressionsCopy) { QueryKeyExpression exp = (QueryKeyExpression)derivedExpression; if (exp.getName().equals(attributeName)) { return exp; } } return null; }
/** * INTERNAL: * Compute a consistent hash-code for the expression. * This is used to allow dynamic expression's SQL to be cached. */ @Override public int computeHashCode() { int hashCode = super.computeHashCode(); if (getName() != null) { hashCode = hashCode + getName().hashCode(); } return hashCode; }
/** * INTERNAL: * Compute a consistent hash-code for the expression. * This is used to allow dynamic expression's SQL to be cached. */ @Override public int computeHashCode() { int hashCode = super.computeHashCode(); if (getName() != null) { hashCode = hashCode + getName().hashCode(); } return hashCode; }
public QueryKeyExpression existingDerivedExpressionNamed(String attributeName) { if (derivedExpressions == null) { return null; } for (Enumeration e = derivedExpressions.elements(); e.hasMoreElements();) { QueryKeyExpression exp = (QueryKeyExpression)e.nextElement(); if (exp.getName().equals(attributeName)) { return exp; } } return null; }
/** * INTERNAL: * Used to print a debug form of the expression tree. */ @Override public void writeDescriptionOn(BufferedWriter writer) throws IOException { writer.write(getName()); if (castClass != null){ writer.write(" (" + castClass.getName() + ") "); } writer.write(tableAliasesDescription()); }
/** * INTERNAL: * Used to print a debug form of the expression tree. */ @Override public void writeDescriptionOn(BufferedWriter writer) throws IOException { writer.write(getName()); if (castClass != null){ writer.write(" (" + castClass.getName() + ") "); } writer.write(tableAliasesDescription()); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } QueryKeyExpression expression = (QueryKeyExpression) object; // Return false for anyOf expressions, as equality is unknown. if (shouldQueryToManyRelationship() || expression.shouldQueryToManyRelationship()) { return false; } return ((getName() == expression.getName()) || ((getName() != null) && getName().equals(expression.getName()))); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ @Override public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } QueryKeyExpression expression = (QueryKeyExpression) object; // Return false for anyOf expressions, as equality is unknown. if (shouldQueryToManyRelationship() || expression.shouldQueryToManyRelationship()) { return false; } return ((getName() == expression.getName()) || ((getName() != null) && getName().equals(expression.getName()))); }
/** * INTERNAL: * Used to print a debug form of the expression tree. */ public void writeDescriptionOn(BufferedWriter writer) throws IOException { writer.write(getName()); writer.write(tableAliasesDescription()); }
/** * Iterate through a list of expressions searching for the given attribute name. * Return true if it is found, false otherwise. */ protected boolean isAttributeNameInJoinedExpressionList(String attributeName, List joinedExpressionList) { for (Iterator joinEnum = joinedExpressionList.iterator(); joinEnum.hasNext();) { QueryKeyExpression expression = (QueryKeyExpression)joinEnum.next(); while (!expression.getBaseExpression().isExpressionBuilder()) { expression = (QueryKeyExpression)expression.getBaseExpression(); } if (expression.getName().equals(attributeName)) { return true; } } return false; }
@Override public void printCollection(Vector items, ExpressionSQLPrinter printer) { if (items.size() == 1 && items.get(0) instanceof QueryKeyExpression && "deleteTs".equals(((QueryKeyExpression) items.get(0)).getName())) { if (!CubaUtil.isSoftDeletion()) { try { printer.getWriter().write("(0=0)"); return; } catch (IOException e) { throw new RuntimeException(e); } } } super.printCollection(items, printer); } }
/** * Iterate through a list of expressions searching for the given attribute name. * Return true if it is found, false otherwise. */ protected boolean isAttributeNameInJoinedExpressionList(String attributeName, List joinedExpressionList) { for (Iterator joinEnum = joinedExpressionList.iterator(); joinEnum.hasNext();) { QueryKeyExpression expression = (QueryKeyExpression)joinEnum.next(); while (!expression.getBaseExpression().isExpressionBuilder()) { expression = (QueryKeyExpression)expression.getBaseExpression(); } if (expression.getName().equals(attributeName)) { return true; } } return false; }
/** * Iterate through a list of expressions searching for the given attribute name. * Return true if it is found, false otherwise. */ protected boolean isAttributeNameInJoinedExpressionList(String attributeName, List joinedExpressionList) { for (Iterator joinEnum = joinedExpressionList.iterator(); joinEnum.hasNext();) { QueryKeyExpression expression = (QueryKeyExpression)joinEnum.next(); while (!expression.getBaseExpression().isExpressionBuilder()) { expression = (QueryKeyExpression)expression.getBaseExpression(); } if (expression.getName().equals(attributeName)) { return true; } } return false; }
@Override public QueryKey getQueryKeyOrNull() { if (!hasQueryKey) { return null; } // Oct 19, 2000 JED // Added try/catch. This was throwing a NPE in the following case // expresssionBuilder.get("firstName").get("bob") //moved by Gordon Yorke to cover validate and normalize if (getContainingDescriptor() == null) { throw QueryException.invalidQueryKeyInExpression(getName()); } if (queryKey == null) { queryKey = getContainingDescriptor().getQueryKeyNamed(getName()); if (queryKey == null) { hasQueryKey = false; } } return queryKey; }
/** * INTERNAL: * Return if partial attribute. */ public boolean isPartialAttribute(String attributeName) { if (this.partialAttributeExpressions == null) { return false; } List<Expression> partialAttributeExpressions = getPartialAttributeExpressions(); int size = partialAttributeExpressions.size(); for (int index = 0; index < size; index++) { QueryKeyExpression expression = (QueryKeyExpression)partialAttributeExpressions.get(index); while (!expression.getBaseExpression().isExpressionBuilder()) { expression = (QueryKeyExpression)expression.getBaseExpression(); } if (expression.getName().equals(attributeName)) { return true; } } return false; }
/** * INTERNAL: */ public DatabaseField getField() { if (!isAttribute()) { return null; } return getContainingDescriptor().getObjectBuilder().getFieldForQueryKeyName(getName()); }
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ public Expression twistedForBaseAndContext(Expression newBase, Expression context) { Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context); QueryKeyExpression result = (QueryKeyExpression)twistedBase.get(getName()); if (shouldUseOuterJoin) { result.doUseOuterJoin(); } if (shouldQueryToManyRelationship) { result.doQueryToManyRelationship(); } return result; }
/** * INTERNAL: * Lookup the query key for this item. * If an aggregate of foreign mapping is found it is traversed. */ protected QueryKey getLeafQueryKeyFor(DatabaseQuery query, Expression expression, ClassDescriptor rootDescriptor, AbstractSession session) throws QueryException { // Check for database field expressions or place holder if ((expression == null) || (expression.isFieldExpression())) { return null; } if (!(expression.isQueryKeyExpression())) { return null; } QueryKeyExpression qkExpression = (QueryKeyExpression)expression; Expression baseExpression = qkExpression.getBaseExpression(); ClassDescriptor descriptor = baseExpression.getLeafDescriptor(query, rootDescriptor, session); return descriptor.getQueryKeyNamed(qkExpression.getName()); }