1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.business.right;
35
36 import fr.paris.lutece.util.sql.DAOUtil;
37
38 import java.util.ArrayList;
39 import java.util.List;
40
41
42
43
44
45 public final class FeatureGroupDAO implements IFeatureGroupDAO
46 {
47
48 private static final String SQL_QUERY_SELECT = " SELECT id_feature_group, feature_group_description, feature_group_label, feature_group_order " +
49 " FROM core_feature_group " + " WHERE id_feature_group = ? ";
50 private static final String SQL_QUERY_INSERT = " INSERT INTO core_feature_group ( id_feature_group , feature_group_description, feature_group_label, feature_group_order ) " +
51 " VALUES ( ?, ?, ?, ? )";
52 private static final String SQL_QUERY_DELETE = " DELETE FROM core_feature_group WHERE id_feature_group = ? ";
53 private static final String SQL_QUERY_UPDATE = " UPDATE core_feature_group SET feature_group_description = ?, " +
54 " feature_group_label = ? , feature_group_order = ? " + " WHERE id_feature_group = ?";
55 private static final String SQL_QUERY_SELECTALL = " SELECT id_feature_group, feature_group_description, feature_group_label, feature_group_order " +
56 "" + " FROM core_feature_group ORDER BY feature_group_order ASC";
57 private static final String SQL_QUERY_COUNT_FEATUREGROUP = " SELECT COUNT(id_feature_group)FROM core_feature_group";
58
59
60
61
62
63
64
65
66 public void insert( FeatureGroup featureGroup )
67 {
68 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT );
69
70 daoUtil.setString( 1, featureGroup.getId( ) );
71 daoUtil.setString( 2, featureGroup.getDescriptionKey( ) );
72 daoUtil.setString( 3, featureGroup.getLabelKey( ) );
73 daoUtil.setInt( 4, featureGroup.getOrder( ) );
74
75 daoUtil.executeUpdate( );
76 daoUtil.free( );
77 }
78
79
80
81
82
83
84 public FeatureGroup load( String strIdFeatureGroup )
85 {
86 FeatureGroup featureGroup = null;
87 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT );
88 daoUtil.setString( 1, strIdFeatureGroup );
89
90 daoUtil.executeQuery( );
91
92 if ( daoUtil.next( ) )
93 {
94 featureGroup = new FeatureGroup( );
95 featureGroup.setId( daoUtil.getString( 1 ) );
96 featureGroup.setDescriptionKey( daoUtil.getString( 2 ) );
97 featureGroup.setLabelKey( daoUtil.getString( 3 ) );
98 featureGroup.setOrder( daoUtil.getInt( 4 ) );
99 }
100
101 daoUtil.free( );
102
103 return featureGroup;
104 }
105
106
107
108
109
110 public void delete( String strIdFeatureGroup )
111 {
112 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE );
113 daoUtil.setString( 1, strIdFeatureGroup );
114 daoUtil.executeUpdate( );
115 daoUtil.free( );
116 }
117
118
119
120
121
122 public void store( FeatureGroup featureGroup )
123 {
124 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE );
125
126 daoUtil.setString( 1, featureGroup.getDescriptionKey( ) );
127 daoUtil.setString( 2, featureGroup.getLabelKey( ) );
128 daoUtil.setInt( 3, featureGroup.getOrder( ) );
129 daoUtil.setString( 4, featureGroup.getId( ) );
130
131 daoUtil.executeUpdate( );
132 daoUtil.free( );
133 }
134
135
136
137
138
139 public List<FeatureGroup> selectFeatureGroupsList( )
140 {
141 List<FeatureGroup> featureGroupList = new ArrayList<FeatureGroup>( );
142 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECTALL );
143 daoUtil.executeQuery( );
144
145 while ( daoUtil.next( ) )
146 {
147 FeatureGroup featureGroup = new FeatureGroup( );
148
149 featureGroup.setId( daoUtil.getString( 1 ) );
150 featureGroup.setDescriptionKey( daoUtil.getString( 2 ) );
151 featureGroup.setLabelKey( daoUtil.getString( 3 ) );
152 featureGroup.setOrder( daoUtil.getInt( 4 ) );
153
154 featureGroupList.add( featureGroup );
155 }
156
157 daoUtil.free( );
158
159 return featureGroupList;
160 }
161
162
163
164
165
166 public int selectFeatureGroupsCount( )
167 {
168 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_COUNT_FEATUREGROUP );
169
170 int nCount = 0;
171 daoUtil.executeQuery( );
172
173 while ( daoUtil.next( ) )
174 {
175 nCount = daoUtil.getInt( 1 );
176 }
177
178 daoUtil.free( );
179
180 return nCount;
181 }
182 }