source: ether_statistics/persistence/implementation/com/ether/dao/simulation/AttributeDAOImpl.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 1.2 KB
Line 
1package com.ether.dao.simulation;
2
3import com.ether.dao.SearchableAbstractHibernateMappingDAO;
4import com.ether.simulation.Attribute;
5import com.ether.simulation.SimulationFilter;
6import org.hibernate.criterion.DetachedCriteria;
7import org.hibernate.criterion.Order;
8import org.hibernate.criterion.Restrictions;
9import org.jetbrains.annotations.NotNull;
10import org.springframework.util.StringUtils;
11
12/**
13 * @author vmipsl
14 * @date 12 juillet 2012
15 */
16public 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.