/** * Creates and returns a new Expression instance using this expression as a * prototype. All ExpressionParam operands are substituted with the values * in the <code>params</code> map. * <p> * <i>Null values in the <code>params</code> map should be explicitly * created in the map for the corresponding key. </i> * </p> * * @param parameters * a map of parameters, with each key being a string name of an * expression parameter, and value being the value that should be * used in the final expression. * @param pruneMissing * If <code>true</code>, subexpressions that rely on missing * parameters will be pruned from the resulting tree. If * <code>false</code> , any missing values will generate an * exception. * @return Expression resulting from the substitution of parameters with * real values, or null if the whole expression was pruned, due to * the missing parameters. * * @deprecated since 4.0 use {@link #params(Map, boolean)} instead. */ @Deprecated public Expression expWithParameters(Map<String, ?> parameters, boolean pruneMissing) { return params(parameters, pruneMissing); }
/** * Returns a collection of queries for this entity. * * @since 1.1 */ public Collection getEOQueries() { if (filteredQueries == null) { Collection queries = getDataMap().getQueryDescriptors(); if (queries.isEmpty()) { filteredQueries = Collections.EMPTY_LIST; } else { Map params = Collections.singletonMap("root", EOObjEntity.this); Expression filter = ExpressionFactory.exp("root = $root").params(params); filteredQueries = filter.filter(queries, new ArrayList()); } } return filteredQueries; }
/** * @since 2.13 */ private Expression exp(CayenneExp cayenneExp) { if (cayenneExp == null) { return null; } final String exp = cayenneExp.getExp(); if (exp == null || exp.isEmpty()) { return null; } final List<Object> inPositionParams = cayenneExp.getInPositionParams(); if (inPositionParams != null && !inPositionParams.isEmpty()) { return ExpressionFactory.exp(exp, inPositionParams.toArray()); } Expression expression = ExpressionFactory.exp(exp); final Map<String, Object> params = cayenneExp.getParams(); if (params != null && !params.isEmpty()) { expression = expression.params(params); } return expression; } }
/** * Returns a query built using this query as a prototype, using a set of * parameters to build the qualifier. * * @see org.apache.cayenne.exp.Expression#expWithParameters(java.util.Map, * boolean) parameter substitution. */ public SelectQuery<T> queryWithParameters(Map<String, ?> parameters, boolean pruneMissing) { // create a query replica SelectQuery<T> query = new SelectQuery<T>(); query.setDistinct(distinct); query.metaData.copyFromInfo(this.metaData); query.setRoot(root); if (orderings != null) { query.addOrderings(orderings); } // substitute qualifier parameters if (qualifier != null) { query.setQualifier(qualifier.params(parameters, pruneMissing)); } return query; }