source: geisa/persistence/implementation/com/ether/dao/IsotopeIasiG03DAOImpl.java @ 553

Last change on this file since 553 was 553, checked in by npipsl, 12 years ago

transitions

File size: 4.3 KB
Line 
1package com.ether.dao;
2
3import com.ether.IsotopeG09;
4import com.ether.IsotopeIasiG03;
5
6import com.ether.PersistenceException;
7import org.hibernate.criterion.DetachedCriteria;
8import org.hibernate.criterion.Order;
9import org.hibernate.criterion.Projections;
10import org.hibernate.criterion.Restrictions;
11import org.jetbrains.annotations.NotNull;
12
13import java.util.HashSet;
14import java.util.LinkedHashSet;
15import java.util.List;
16import java.util.Set;
17/**
18 * @author npipsl
19 * @date july 2012
20 */
21
22
23public class IsotopeIasiG03DAOImpl
24        extends DomainAccessObjectImpl<IsotopeIasiG03, Integer>
25        implements IsotopeIasiG03DAO
26{
27    protected IsotopeIasiG03DAOImpl()
28    {
29        super( IsotopeIasiG03.class );
30    }
31
32     @NotNull
33    public Set<String> getTransitionsUpperByTransitionLower( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper , final String transitionLower)
34            throws PersistenceException
35    {
36
37          final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeIasiG03.class )
38                .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) )
39                .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) )
40                .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) )
41                .add( Restrictions.eq( "codeQuantLower",transitionLower ) );
42        criteria.addOrder( Order.asc( "codeQuantUpper" ) );
43        criteria.setProjection( Projections.distinct( Projections.property( "codeQuantUpper" ) ));
44
45        final List<String> transitions = selectAllByCriteria( String.class, criteria );
46        return new LinkedHashSet<String>( transitions );
47    }
48
49     @NotNull
50    public Set<String> getTransitionsUpperByTransitionUpper( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper , final String transitionUpper)
51            throws PersistenceException
52    {
53
54          final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeIasiG03.class )
55                .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) )
56                .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) )
57                .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) )
58                .add( Restrictions.eq( "codeQuantUpper",transitionUpper ) );
59        criteria.addOrder( Order.asc("codeQuantLower") );
60        criteria.setProjection( Projections.distinct( Projections.property( "codeQuantLower" ) ));
61
62        final List<String> transitions = selectAllByCriteria( String.class, criteria );
63        return new LinkedHashSet<String>( transitions );
64    }
65
66
67    @NotNull
68    public Set<String> getTransitionsUpper( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper )
69            throws PersistenceException
70    {
71        return getTransitions(isotopesSelectedNameList, spectralRangeLower, spectralRangeUpper, true);
72    }
73
74    @NotNull
75    public Set<String> getTransitionsLower( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper )
76            throws PersistenceException
77    {
78        return getTransitions(isotopesSelectedNameList, spectralRangeLower, spectralRangeUpper, false);
79    }
80
81    @NotNull
82    private Set<String> getTransitions( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper, final boolean isForUpper )
83            throws PersistenceException
84    {
85        final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeIasiG03.class )
86                .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) )
87                .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) )
88                .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) );
89
90        if(isForUpper)
91            criteria.addOrder( Order.asc( "codeQuantUpper" ) )
92                    .setProjection( Projections.distinct( Projections.property( "codeQuantUpper" ) ) );
93        else
94            criteria.addOrder( Order.asc("codeQuantLower") )
95                    .setProjection( Projections.distinct( Projections.property( "codeQuantLower" ) ) );
96
97        final List<String> transitions = selectAllByCriteria( String.class, criteria );
98        return new LinkedHashSet<String> ( transitions );
99    }
100
101}
Note: See TracBrowser for help on using the repository browser.