1 | package com.ether.dao; |
---|
2 | |
---|
3 | import com.ether.IsotopeG03; |
---|
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.Projection; |
---|
9 | import org.hibernate.criterion.Projections; |
---|
10 | import org.hibernate.criterion.Restrictions; |
---|
11 | import org.jetbrains.annotations.NotNull; |
---|
12 | |
---|
13 | import java.util.HashSet; |
---|
14 | import java.util.LinkedHashSet; |
---|
15 | import java.util.List; |
---|
16 | import java.util.Set; |
---|
17 | |
---|
18 | |
---|
19 | /** |
---|
20 | * @author npipsl |
---|
21 | * @date july 2012 |
---|
22 | */ |
---|
23 | public class IsotopeG03DAOImpl |
---|
24 | extends DomainAccessObjectImpl<IsotopeG03, Integer> |
---|
25 | implements IsotopeG03DAO |
---|
26 | { |
---|
27 | protected IsotopeG03DAOImpl() |
---|
28 | { |
---|
29 | super( IsotopeG03.class ); |
---|
30 | } |
---|
31 | |
---|
32 | @NotNull |
---|
33 | public List<IsotopeG03> getAllIsotopeG03() |
---|
34 | throws PersistenceException |
---|
35 | { |
---|
36 | final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeG03.class ); |
---|
37 | return selectAllByCriteria( IsotopeG03.class, criteria ); |
---|
38 | } |
---|
39 | |
---|
40 | @NotNull |
---|
41 | public List<IsotopeG03> getTransitionsByIsotopeG03Name( final List<String> isotopeNameArray, final Float spectralRangeLower, final Float spectralRangeUpper ) |
---|
42 | throws PersistenceException |
---|
43 | { |
---|
44 | final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeG03.class ); |
---|
45 | criteria.add( Restrictions.in( "chMoleIsot", isotopeNameArray ) ); |
---|
46 | criteria.add( Restrictions.ge( "wavenbMax", spectralRangeLower ) ); |
---|
47 | criteria.add( Restrictions.le( "wavenbMin", spectralRangeUpper ) ); |
---|
48 | return selectAllByCriteria( IsotopeG03.class, criteria ); |
---|
49 | } |
---|
50 | |
---|
51 | @NotNull |
---|
52 | public Set<String> getTransitionsUpperByTransitionLower( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper , final String transitionLower) |
---|
53 | throws PersistenceException |
---|
54 | { |
---|
55 | |
---|
56 | final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeG03.class ) |
---|
57 | .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) ) |
---|
58 | .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) ) |
---|
59 | .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) ) |
---|
60 | .add( Restrictions.eq( "codeQuantLower",transitionLower ) ); |
---|
61 | criteria.addOrder( Order.asc( "codeQuantUpper" ) ); |
---|
62 | criteria.setProjection( Projections.distinct( Projections.property( "codeQuantUpper" ) )); |
---|
63 | |
---|
64 | |
---|
65 | final List<String> transitions = selectAllByCriteria( String.class, criteria ); |
---|
66 | return new LinkedHashSet<String>( transitions ); |
---|
67 | } |
---|
68 | |
---|
69 | @NotNull |
---|
70 | public Set<String> getTransitionsUpperByTransitionUpper( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper , final String transitionUpper) |
---|
71 | throws PersistenceException |
---|
72 | { |
---|
73 | |
---|
74 | final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeG03.class ) |
---|
75 | .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) ) |
---|
76 | .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) ) |
---|
77 | .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) ) |
---|
78 | .add( Restrictions.eq( "codeQuantUpper",transitionUpper ) ); |
---|
79 | /*classer par ordre croissant*/ |
---|
80 | criteria.addOrder( Order.asc("codeQuantLower") ); |
---|
81 | /*enlever les doublons*/ |
---|
82 | criteria.setProjection( Projections.distinct( Projections.property( "codeQuantLower" ) )); |
---|
83 | |
---|
84 | |
---|
85 | final List<String> transitions = selectAllByCriteria( String.class, criteria ); |
---|
86 | return new LinkedHashSet<String>( transitions ); |
---|
87 | } |
---|
88 | |
---|
89 | @NotNull |
---|
90 | public Set<String> getTransitionsUpper( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper ) |
---|
91 | throws PersistenceException |
---|
92 | { |
---|
93 | return getTransitions(isotopesSelectedNameList, spectralRangeLower, spectralRangeUpper, true); |
---|
94 | } |
---|
95 | |
---|
96 | @NotNull |
---|
97 | public Set<String> getTransitionsLower( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper ) |
---|
98 | throws PersistenceException |
---|
99 | { |
---|
100 | return getTransitions(isotopesSelectedNameList, spectralRangeLower, spectralRangeUpper, false); |
---|
101 | } |
---|
102 | |
---|
103 | @NotNull |
---|
104 | private Set<String> getTransitions( final List<String> isotopesSelectedNameList, final Float spectralRangeLower, final Float spectralRangeUpper, final boolean isForUpper ) |
---|
105 | throws PersistenceException |
---|
106 | { |
---|
107 | final DetachedCriteria criteria = DetachedCriteria.forClass( IsotopeG03.class ) |
---|
108 | .add( Restrictions.in( "chMoleIsot", isotopesSelectedNameList ) ) |
---|
109 | .add( Restrictions.ge( "wavenbMax", spectralRangeLower ) ) |
---|
110 | .add( Restrictions.le( "wavenbMin", spectralRangeUpper ) ); |
---|
111 | |
---|
112 | if(isForUpper) |
---|
113 | criteria.addOrder( Order.asc( "codeQuantUpper" ) ) |
---|
114 | .setProjection( Projections.distinct( Projections.property( "codeQuantUpper" ) ) ); |
---|
115 | else |
---|
116 | criteria.addOrder( Order.asc("codeQuantLower") ) |
---|
117 | .setProjection( Projections.distinct( Projections.property( "codeQuantLower" ) ) ); |
---|
118 | |
---|
119 | final List<String> transitions = selectAllByCriteria( String.class, criteria ); |
---|
120 | return new LinkedHashSet<String> ( transitions ); |
---|
121 | } |
---|
122 | |
---|
123 | } |
---|