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