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 public final class FeatureGroupDAO implements IFeatureGroupDAO
45 {
46
47 private static final String SQL_SELECT = " SELECT id_feature_group, feature_group_description, feature_group_label, feature_group_order, feature_group_icon";
48 private static final String SQL_QUERY_SELECT = SQL_SELECT + " FROM core_feature_group " + " WHERE id_feature_group = ? ";
49 private static final String SQL_QUERY_INSERT = " INSERT INTO core_feature_group ( id_feature_group , feature_group_description, feature_group_label, feature_group_order, feature_group_icon ) "
50 + " VALUES ( ?, ?, ?, ?, ? )";
51 private static final String SQL_QUERY_DELETE = " DELETE FROM core_feature_group WHERE id_feature_group = ? ";
52 private static final String SQL_QUERY_UPDATE = " UPDATE core_feature_group SET feature_group_description = ?, "
53 + " feature_group_label = ? , feature_group_order = ?, feature_group_icon = ? " + " WHERE id_feature_group = ?";
54 private static final String SQL_QUERY_SELECTALL = SQL_SELECT + " FROM core_feature_group ORDER BY feature_group_order ASC";
55 private static final String SQL_QUERY_COUNT_FEATUREGROUP = " SELECT COUNT(id_feature_group)FROM core_feature_group";
56
57
58
59
60
61
62
63
64
65
66 public void insert( FeatureGroup featureGroup )
67 {
68 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT ) )
69 {
70
71 daoUtil.setString( 1, featureGroup.getId( ) );
72 daoUtil.setString( 2, featureGroup.getDescriptionKey( ) );
73 daoUtil.setString( 3, featureGroup.getLabelKey( ) );
74 daoUtil.setInt( 4, featureGroup.getOrder( ) );
75 daoUtil.setString( 5, featureGroup.getIcon( ) );
76
77 daoUtil.executeUpdate( );
78 }
79 }
80
81
82
83
84
85
86
87
88 public FeatureGroup load( String strIdFeatureGroup )
89 {
90 FeatureGroup featureGroup = null;
91 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT ) )
92 {
93 daoUtil.setString( 1, strIdFeatureGroup );
94
95 daoUtil.executeQuery( );
96
97 if ( daoUtil.next( ) )
98 {
99 featureGroup = new FeatureGroup( );
100 featureGroup.setId( daoUtil.getString( 1 ) );
101 featureGroup.setDescriptionKey( daoUtil.getString( 2 ) );
102 featureGroup.setLabelKey( daoUtil.getString( 3 ) );
103 featureGroup.setOrder( daoUtil.getInt( 4 ) );
104 featureGroup.setIcon( daoUtil.getString( 5 ) );
105 }
106
107 }
108
109 return featureGroup;
110 }
111
112
113
114
115
116
117
118 public void delete( String strIdFeatureGroup )
119 {
120 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE ) )
121 {
122 daoUtil.setString( 1, strIdFeatureGroup );
123 daoUtil.executeUpdate( );
124 }
125 }
126
127
128
129
130
131
132
133 public void store( FeatureGroup featureGroup )
134 {
135 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE ) )
136 {
137
138 daoUtil.setString( 1, featureGroup.getDescriptionKey( ) );
139 daoUtil.setString( 2, featureGroup.getLabelKey( ) );
140 daoUtil.setInt( 3, featureGroup.getOrder( ) );
141 daoUtil.setString( 4, featureGroup.getIcon( ) );
142 daoUtil.setString( 5, featureGroup.getId( ) );
143
144 daoUtil.executeUpdate( );
145 }
146 }
147
148
149
150
151
152
153 public List<FeatureGroup> selectFeatureGroupsList( )
154 {
155 List<FeatureGroup> featureGroupList = new ArrayList<>( );
156 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECTALL ) )
157 {
158 daoUtil.executeQuery( );
159
160 while ( daoUtil.next( ) )
161 {
162 FeatureGroupght/FeatureGroup.html#FeatureGroup">FeatureGroup featureGroup = new FeatureGroup( );
163
164 featureGroup.setId( daoUtil.getString( 1 ) );
165 featureGroup.setDescriptionKey( daoUtil.getString( 2 ) );
166 featureGroup.setLabelKey( daoUtil.getString( 3 ) );
167 featureGroup.setOrder( daoUtil.getInt( 4 ) );
168 featureGroup.setIcon( daoUtil.getString( 5 ) );
169
170 featureGroupList.add( featureGroup );
171 }
172
173 }
174
175 return featureGroupList;
176 }
177
178
179
180
181
182
183 public int selectFeatureGroupsCount( )
184 {
185 int nCount = 0;
186 try ( DAOUtil/DAOUtil.html#DAOUtil">DAOUtil daoUtil = new DAOUtil( SQL_QUERY_COUNT_FEATUREGROUP ) )
187 {
188
189 daoUtil.executeQuery( );
190 while ( daoUtil.next( ) )
191 {
192 nCount = daoUtil.getInt( 1 );
193 }
194
195 }
196
197 return nCount;
198 }
199 }