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

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

Nouveau projet

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