@Test public void testGenerateCriteria_MultipleOr() throws Exception { Map<String, String> mapCriteria = new HashMap<String, String>(); mapCriteria.put("prop1", "a|b"); mapCriteria.put("prop2", "c"); mapCriteria.put("prop3", "d"); QueryByCriteria.Builder qbcBuilder = generator.generateCriteria(TestClass.class, mapCriteria, false); assertNotNull("build should not have been null", qbcBuilder); QueryByCriteria qbc = qbcBuilder.build(); Predicate and = qbc.getPredicate(); assertTrue("top level predicate type incorrect. Was: " + and, and instanceof AndPredicate); Set<Predicate> predicates = ((AndPredicate) and).getPredicates(); assertEquals("Wrong number of top-level predicates", 3, predicates.size()); boolean foundProp1 = false; boolean foundProp2 = false; boolean foundProp3 = false; for (Predicate predicate : predicates) { if (predicate instanceof LikePredicate) { LikePredicate like = (LikePredicate)predicate; if (like.getPropertyPath().equals("prop2")) { assertEquals("prop2 had wrong value", "c", like.getValue().getValue()); foundProp2 = true; } else { fail("Invalid like predicate encountered: " + predicate); } } else if (predicate instanceof LikeIgnoreCasePredicate) { LikeIgnoreCasePredicate like = (LikeIgnoreCasePredicate)predicate; if (like.getPropertyPath().equals("prop3")) { assertEquals("prop3 had wrong value", "d", like.getValue().getValue()); foundProp3 = true; } else { fail("Invalid likeIgnoreCase predicate encountered: " + predicate); } } else if (predicate instanceof OrPredicate) { foundProp1 = true; OrPredicate orPredicate = (OrPredicate)predicate; assertEquals("wrong number of predicates in the internal OR predicate",2, orPredicate.getPredicates().size()); for (Predicate orSubPredicate : orPredicate.getPredicates()) { if (orSubPredicate instanceof LikeIgnoreCasePredicate) { LikeIgnoreCasePredicate likeInternal = (LikeIgnoreCasePredicate)orSubPredicate; if (likeInternal.getPropertyPath().equals("prop1")) { assertTrue("prop1 had wrong value", "a".equals(likeInternal.getValue().getValue()) || "b".equals(likeInternal.getValue().getValue())); } else { fail("Invalid predicate, does not have a propertypath of prop1:" + predicate); } } else { fail("Unexpected predicate: " + orSubPredicate); } } } else { fail("Unexpected predicate: " + predicate); } } assertTrue("prop1 predicate missing", foundProp1); assertTrue("prop2 predicate missing", foundProp2); assertTrue("prop3 predicate missing", foundProp3); }
@Override @Deprecated public QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly) { if (usePrimaryKeysOnly) { return getCollectionCriteriaFromMapUsingPrimaryKeysOnly(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } else { return getCollectionCriteriaFromMap(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } }
LookupCriteriaGeneratorImpl implements LookupCriteriaGenerator { @Override @Deprecated public QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly) { if (usePrimaryKeysOnly) { return getCollectionCriteriaFromMapUsingPrimaryKeysOnly(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } else { return getCollectionCriteriaFromMap(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } } }
LookupCriteriaGeneratorImpl implements LookupCriteriaGenerator { @Override @Deprecated public QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly) { if (usePrimaryKeysOnly) { return getCollectionCriteriaFromMapUsingPrimaryKeysOnly(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } else { return getCollectionCriteriaFromMap(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } }  }
LookupCriteriaGeneratorImpl implements LookupCriteriaGenerator { @Override @Deprecated public QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly) { if (usePrimaryKeysOnly) { return getCollectionCriteriaFromMapUsingPrimaryKeysOnly(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } else { return getCollectionCriteriaFromMap(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } }  DateTimeService getDateTimeService(); void setDateTimeService(DateTimeService dateTimeService); DataDictionaryService getDataDictionaryService(); void setDataDictionaryService(DataDictionaryService dataDictionaryService); DatabasePlatform getDbPlatform(); void setDbPlatform(DatabasePlatform dbPlatform); DataObjectService getDataObjectService(); void setDataObjectService(DataObjectService dataObjectService); @Override @Deprecated QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly); @Override QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps,
            List<String> wildcardAsLiteralPropertyNames, boolean usePrimaryKeysOnly); @Override QueryByCriteria.Builder createObjectCriteriaFromMap(Object example, Map<String, String> formProps); boolean createCriteria(Object example, String searchValue, String propertyName, boolean caseInsensitive, boolean treatWildcardsAndOperatorsAsLiteral, Predicates criteria); }
LookupCriteriaGeneratorImpl implements LookupCriteriaGenerator { @Override @Deprecated public QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly) { if (usePrimaryKeysOnly) { return getCollectionCriteriaFromMapUsingPrimaryKeysOnly(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } else { return getCollectionCriteriaFromMap(type, instantiateLookupDataObject(type), formProps).toQueryBuilder(); } }  DateTimeService getDateTimeService(); void setDateTimeService(DateTimeService dateTimeService); DataDictionaryService getDataDictionaryService(); void setDataDictionaryService(DataDictionaryService dataDictionaryService); DatabasePlatform getDbPlatform(); void setDbPlatform(DatabasePlatform dbPlatform); DataObjectService getDataObjectService(); void setDataObjectService(DataObjectService dataObjectService); @Override @Deprecated QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps, boolean usePrimaryKeysOnly); @Override QueryByCriteria.Builder generateCriteria(Class<?> type, Map<String, String> formProps,
            List<String> wildcardAsLiteralPropertyNames, boolean usePrimaryKeysOnly); @Override QueryByCriteria.Builder createObjectCriteriaFromMap(Object example, Map<String, String> formProps); boolean createCriteria(Object example, String searchValue, String propertyName, boolean caseInsensitive, boolean treatWildcardsAndOperatorsAsLiteral, Predicates criteria);  }