/** Finds Generic Entity records by all of the specified expressions (ie: combined using OR) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@return List of GenericValue instances that match the query */ public List findByOr(String entityName, List expressions) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.OR); return findByCondition(entityName, ecl, null, null); }
@SuppressWarnings("unchecked") // hamcrest's generics are broken :( private EntityConditionListMatcher(EntityConditionList conditions) { this.expectedOperator = conditions.getOperator(); final int size = conditions.getConditionListSize(); final List<Matcher<? super EntityCondition>> matchers = new ArrayList<Matcher<? super EntityCondition>>(size); for (int i=0; i<size; ++i) { matchers.add((Matcher<EntityCondition>)entityCondition(conditions.getCondition(i))); } this.conditions = new IsIterableContainingInAnyOrder<EntityCondition>(matchers); }
private Predicate<GenericValue> getPredicateForEntityConditionList(final EntityConditionList conditionList) { final List<Predicate<GenericValue>> conditions = newArrayListWithCapacity(conditionList.getConditionListSize()); final Iterator<? extends EntityCondition> iter = conditionList.getConditionIterator(); while (iter.hasNext()) { conditions.add(getPredicateFor(iter.next())); } if (conditionList.getOperator().equals(EntityOperator.AND)) { return Predicates.and(conditions); } if (conditionList.getOperator().equals(EntityOperator.OR)) { return Predicates.or(conditions); } throw new UnsupportedOperationException("Mock cannot yet handle EntityConditionList with operator " + conditionList.getOperator()); }
private static List<EntityCondition> toList(EntityConditionList conditions) { final List<EntityCondition> list = new ArrayList<EntityCondition>(conditions.getConditionListSize()); final Iterator<? extends EntityCondition> iter = conditions.getConditionIterator(); while (iter.hasNext()) { list.add(iter.next()); } return list; } }
final Iterator<? extends EntityCondition> conditionIterator = conditionList.getConditionIterator(); final List<EntityCondition> result = new ArrayList<EntityCondition>(conditionList.getConditionListSize()); while (conditionIterator.hasNext()) { result.add(transformCondition(conditionIterator.next(), function)); return new EntityConditionList(result, conditionList.getOperator()); } else if (input instanceof EntityExprList) { final EntityExprList exprList = (EntityExprList) input; result.add(transformCondition(exprIterator.next(), function)); return new EntityConditionList(result, exprList.getOperator()); } else { return input;
private boolean matches(final EntityConditionList other) { return expectedOperator.equals(other.getOperator()) && conditions.matches(toList(other)); }
private List<GenericValue> filterByAnd(List<GenericValue> values, final EntityConditionList conditions) { final Iterator<? extends EntityCondition> iter = conditions.getConditionIterator(); while (iter.hasNext()) { values = filterByEntityCondition(values, iter.next()); } return values; }
final Iterator<? extends EntityCondition> conditionIterator = ((EntityConditionList) input).getConditionIterator(); while (conditionIterator.hasNext()) { result &= predicateTrueForEachLeafExpression(conditionIterator.next(), predicate);
/** Finds Generic Entity records by all of the specified expressions (ie: combined using AND) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@return List of GenericValue instances that match the query */ public List findByAnd(String entityName, List expressions) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.AND); return findByCondition(entityName, ecl, null, null); }
List tempResult = new ArrayList(); for (int i = 0; i < entityConditionList.getConditionListSize(); i++) { EntityCondition subEntityCondition = entityConditionList.getCondition(i); if (EntityOperator.AND.equals(entityConditionList.getOperator())) { tempResult = findByConditionWorker(tempEntityCache, modelEntity, subEntityCondition, fieldsToSelect, orderBy); tempEntityCache.put(genericValue, genericValue); } else if (EntityOperator.OR.equals(entityConditionList.getOperator())) {
/** Finds Generic Entity records by all of the specified expressions (ie: combined using OR) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@return List of GenericValue instances that match the query */ public List findByOr(String entityName, List expressions) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.OR); return findByCondition(entityName, ecl, null, null); }
List tempResult = new ArrayList(); for (int i = 0; i < entityConditionList.getConditionListSize(); i++) { EntityCondition subEntityCondition = entityConditionList.getCondition(i); if (EntityOperator.AND.equals(entityConditionList.getOperator())) { tempResult = findByConditionWorker(tempEntityCache, modelEntity, subEntityCondition, fieldsToSelect, orderBy); tempEntityCache.put(genericValue, genericValue); } else if (EntityOperator.OR.equals(entityConditionList.getOperator())) {
/** Finds Generic Entity records by all of the specified expressions (ie: combined using OR) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByOr(String entityName, List expressions, List orderBy) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.OR); return findByCondition(entityName, ecl, null, orderBy); }
List<GenericValue> tempResult = new ArrayList<GenericValue>(); for (int i = 0; i < entityConditionList.getConditionListSize(); i++) { EntityCondition subEntityCondition = entityConditionList.getCondition(i); if (EntityOperator.AND.equals(entityConditionList.getOperator())) { tempResult = findByConditionWorker(tempEntityCache, modelEntity, subEntityCondition, fieldsToSelect, orderBy); tempEntityCache.put(genericValue, genericValue); } else if (EntityOperator.OR.equals(entityConditionList.getOperator())) {
@Override public List<GenericValue> findByOr(final String entityName, final List<? extends EntityCondition> expressions, final List<String> orderBy) throws DataAccessException { return findByCondition(entityName, new EntityConditionList(expressions, EntityOperator.OR), null, orderBy); }
/** Finds Generic Entity records by all of the specified expressions (ie: combined using AND) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@return List of GenericValue instances that match the query */ public List findByAnd(String entityName, List expressions) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.AND); return findByCondition(entityName, ecl, null, null); }
/** Finds Generic Entity records by all of the specified expressions (ie: combined using OR) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByOr(String entityName, List expressions, List orderBy) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.OR); return findByCondition(entityName, ecl, null, orderBy); }
/** Finds Generic Entity records by all of the specified expressions (ie: combined using AND) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByAnd(String entityName, List expressions, List orderBy) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.AND); return findByCondition(entityName, ecl, null, orderBy); }
/** Finds Generic Entity records by all of the specified expressions (ie: combined using AND) *@param entityName The Name of the Entity as defined in the entity XML file *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByAnd(String entityName, List expressions, List orderBy) throws GenericEntityException { EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.AND); return findByCondition(entityName, ecl, null, orderBy); }
@Override public List<GenericValue> findByLike(final String entityName, final Map<String, ?> map, final List<String> orderBy) throws DataAccessException { final List<EntityExpr> list = newArrayListWithCapacity(map.size()); for (final Map.Entry<String, ?> entry : map.entrySet()) { list.add(new EntityExpr(entry.getKey(), EntityOperator.LIKE, entry.getValue())); } final EntityCondition condition = new EntityConditionList(list, EntityOperator.AND); return findByCondition(entityName, condition, orderBy); }