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