From: <gca...@us...> - 2012-07-04 13:22:51
|
Revision: 4090 http://openutils.svn.sourceforge.net/openutils/?rev=4090&view=rev Author: gcatania Date: 2012-07-04 13:22:42 +0000 (Wed, 04 Jul 2012) Log Message: ----------- Merged revisions 4089 via svnmerge from https://openutils.svn.sourceforge.net/svnroot/openutils/trunk/openutils-bshd5 ........ r4089 | gcatania | 2012-07-04 15:19:09 +0200 (Wed, 04 Jul 2012) | 1 line BSHD-2 added support for default filtering on example tree ........ Revision Links: -------------- http://openutils.svn.sourceforge.net/openutils/?rev=4089&view=rev Modified Paths: -------------- branches/openutils-bshd5-backport/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java Property Changed: ---------------- branches/openutils-bshd5-backport/ branches/openutils-bshd5-backport/pom.xml branches/openutils-bshd5-backport/src/ Property changes on: branches/openutils-bshd5-backport ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/openutils-bshd5:1-4040,4042-4056,4058-4087 + /trunk/openutils-bshd5:1-4040,4042-4056,4058-4089 Modified: svn:mergeinfo - /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087* + /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087*,4089* Property changes on: branches/openutils-bshd5-backport/pom.xml ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/openutils-bshd5/pom.xml:4045-4047,4059,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087 + /trunk/openutils-bshd5/pom.xml:4045-4047,4059,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089 Property changes on: branches/openutils-bshd5-backport/src ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087 + /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089 Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java =================================================================== --- branches/openutils-bshd5-backport/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2012-07-04 13:19:09 UTC (rev 4089) +++ branches/openutils-bshd5-backport/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2012-07-04 13:22:42 UTC (rev 4090) @@ -191,7 +191,7 @@ */ public List<T> findFiltered(T filter) { - return getThis().findFiltered(new ExampleTree(filter), Integer.MAX_VALUE, 0, getDefaultOrder()); + return getThis().findFiltered(defaultExample(filter), Integer.MAX_VALUE, 0, getDefaultOrder()); } /** @@ -207,7 +207,7 @@ */ public List<T> findFiltered(T filter, Order... orders) { - return getThis().findFiltered(new ExampleTree(filter), Integer.MAX_VALUE, 0, orders); + return getThis().findFiltered(defaultExample(filter), Integer.MAX_VALUE, 0, orders); } /** @@ -223,7 +223,7 @@ */ public List<T> findFiltered(T filter, int maxResults, int page) { - return getThis().findFiltered(new ExampleTree(filter), maxResults, page, getDefaultOrder()); + return getThis().findFiltered(defaultExample(filter), maxResults, page, getDefaultOrder()); } /** @@ -303,7 +303,7 @@ */ public T findFilteredFirst(T filter, List<Criterion> criteria) { - ExampleTree exampleTree = new ExampleTree(filter); + ExampleTree exampleTree = defaultExample(filter); appendToRoot(exampleTree, criteria); return getFirstInCollection(getThis().findFiltered(exampleTree, Integer.MAX_VALUE, 0, getDefaultOrder())); } @@ -436,7 +436,7 @@ public List<Object> findFilteredProperties(T filter, int maxResults, int page, List<String> properties, Order... orders) { - return getThis().findFilteredProperties(new ExampleTree(filter), maxResults, page, properties, orders); + return getThis().findFilteredProperties(defaultExample(filter), maxResults, page, properties, orders); } /** @@ -488,7 +488,7 @@ HibernateCallback callback; if (MapUtils.isEmpty(metadata) && CollectionUtils.isEmpty(criteria)) { - callback = new ExampleTreeCallback(new ExampleTree(filter), maxResults, page, orders); + callback = new ExampleTreeCallback(defaultExample(filter), maxResults, page, orders); } else { @@ -519,7 +519,7 @@ HibernateCallback callback; if (MapUtils.isEmpty(metadata) && CollectionUtils.isEmpty(criteria)) { - callback = new ExampleTreePropertiesCallback(new ExampleTree(filter), maxResults, page, properties, orders); + callback = new ExampleTreePropertiesCallback(defaultExample(filter), maxResults, page, properties, orders); } else { @@ -675,11 +675,22 @@ } /** + * Returns the default example tree that will be applied to a filtered search by entity. The default implementation + * just returns an {@link ExampleTree}, subclasses may override. + * @param entity the example (filter) entity + * @return an example for the entity + */ + protected ExampleTree defaultExample(T entity) + { + return new ExampleTree(entity); + } + + /** * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't * set any default filter, subclasses may override this. * @return map of property name - filter metadata - * @deprecated {@link FilterMetadata} has been deprecated in favor of {@link ExampleTree#add(String, Criterion)} and - * {@link ExampleTree#overridePropertyFilter(String, String, Criterion)} + * @deprecated this method uses the deprecated class {@link FilterMetadata}, use {@link #defaultExample(Object)} + * instead */ @Deprecated protected Map<String, FilterMetadata> getDefaultFilterMetadata() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |