Line | |
---|
1 | package com.ether.dao.simulation; |
---|
2 | |
---|
3 | import com.ether.dao.SearchableAbstractHibernateMappingDAO; |
---|
4 | import com.ether.simulation.Attribute; |
---|
5 | import com.ether.simulation.SimulationFilter; |
---|
6 | import org.hibernate.criterion.DetachedCriteria; |
---|
7 | import org.hibernate.criterion.Order; |
---|
8 | import org.hibernate.criterion.Restrictions; |
---|
9 | import org.jetbrains.annotations.NotNull; |
---|
10 | import org.springframework.util.StringUtils; |
---|
11 | |
---|
12 | /** |
---|
13 | * @author vmipsl |
---|
14 | * @date 12 juillet 2012 |
---|
15 | */ |
---|
16 | public class AttributeDAOImpl |
---|
17 | extends SearchableAbstractHibernateMappingDAO<Attribute, Integer, SimulationFilter> |
---|
18 | implements AttributeDAO |
---|
19 | { |
---|
20 | protected AttributeDAOImpl() |
---|
21 | { |
---|
22 | super( Attribute.class, Integer.class ); |
---|
23 | } |
---|
24 | |
---|
25 | @Override |
---|
26 | protected DetachedCriteria searchCriteria( @NotNull final SimulationFilter filter, final boolean isForCount ) |
---|
27 | { |
---|
28 | final DetachedCriteria criteria = DetachedCriteria.forClass( Attribute.class ); |
---|
29 | |
---|
30 | if( StringUtils.hasText( filter.getSearchText() ) ) |
---|
31 | criteria.add( Restrictions.or( escapedLike( "name", filter.getSearchText() ), escapedLike( "value", filter.getSearchText() ) ) ); |
---|
32 | |
---|
33 | if( !isForCount ) |
---|
34 | criteria.addOrder( Order.asc( filter.getSort() ) ); |
---|
35 | return criteria; |
---|
36 | } |
---|
37 | |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.