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.plugins.dbpage.business.section;
35
36 import fr.paris.lutece.plugins.dbpage.service.DbPageConnectionService;
37 import fr.paris.lutece.portal.service.database.PluginConnectionService;
38 import fr.paris.lutece.portal.service.util.AppLogService;
39 import fr.paris.lutece.util.string.StringUtil;
40
41 import java.util.List;
42
43
44
45
46
47 public abstract class DbPageSection implements IDbPageSection, Cloneable
48 {
49 private static final String EMPTY_STRING = "";
50
51
52
53 private long _lIdType;
54 private String _strDescType;
55 private String _strType;
56 private String _strTitle;
57 private String _strTemplatePath;
58 private List<String> _listColumnNames;
59 private String _strSQL;
60 private String _strDbPool;
61 private String _strRole;
62
63
64
65
66
67
68 public String getType( )
69 {
70 return _strType;
71 }
72
73
74
75
76
77
78 public void setType( String strType )
79 {
80 _strType = ( strType == null ) ? EMPTY_STRING : strType;
81 }
82
83
84
85
86
87
88 public String getTemplatePath( )
89 {
90 return _strTemplatePath;
91 }
92
93
94
95
96
97 public void setTemplatePath( String strTemplatePath )
98 {
99 _strTemplatePath = ( strTemplatePath == null ) ? EMPTY_STRING : strTemplatePath;
100 }
101
102
103
104
105
106
107 public List<String> getColumnNames( )
108 {
109 return _listColumnNames;
110 }
111
112
113
114
115
116
117 public void setColumnNames( List listColumnNames )
118 {
119 _listColumnNames = listColumnNames;
120 }
121
122
123
124
125
126
127 public String getTitle( )
128 {
129 return _strTitle;
130 }
131
132
133
134
135
136
137 public void setTitle( String strTitle )
138 {
139 _strTitle = ( strTitle == null ) ? EMPTY_STRING : strTitle;
140 }
141
142
143
144
145
146
147 public String getSql( )
148 {
149 return _strSQL;
150 }
151
152
153
154
155
156
157 public void setSql( String strSql )
158 {
159 _strSQL = ( strSql == null ) ? EMPTY_STRING : strSql;
160 }
161
162
163
164
165
166
167 public String getDbPool( )
168 {
169 return _strDbPool;
170 }
171
172
173
174
175
176
177 public void setDbPool( String strDbPool )
178 {
179 _strDbPool = ( strDbPool == null ) ? EMPTY_STRING : strDbPool;
180 }
181
182
183
184
185
186
187
188 public PluginConnectionService getConnectionService( String strPoolName )
189 {
190 return DbPageConnectionService.getConnectionService( strPoolName );
191 }
192
193
194
195
196
197
198 protected String getValuatedQuery( List listValues )
199 {
200 return substituteValues( getSql( ), listValues );
201 }
202
203
204
205
206
207
208
209 private String substituteValues( String strQuery, List listValues )
210 {
211 String strResult = strQuery;
212
213 for ( int i = 0; i < listValues.size( ); i++ )
214 {
215 String strValue = (String) listValues.get( i );
216 String strBookmark = "@value" + ( i + 1 ) + "@";
217 strResult = StringUtil.substitute( strResult, strValue, strBookmark );
218 }
219
220 return strResult;
221 }
222
223
224
225
226
227
228 public String getRole( )
229 {
230 return _strRole;
231 }
232
233
234
235
236
237
238 public void setRole( String strRole )
239 {
240 _strRole = ( strRole == null ) ? EMPTY_STRING : strRole;
241 }
242
243
244
245
246
247 public DbPageSection getDbSection( )
248 {
249 DbPageSection sect = null;
250
251 try
252 {
253 sect = (DbPageSection) this.clone( );
254 }
255 catch ( CloneNotSupportedException e )
256 {
257 AppLogService.error( e );
258 }
259
260 return sect;
261 }
262
263
264
265
266
267 public void setIdTypeSignature( long lIdType )
268 {
269 this._lIdType = lIdType;
270 }
271
272
273
274
275
276 public long getIdTypeSignature( )
277 {
278 return _lIdType;
279 }
280
281
282
283
284
285 public void setDescType( String strDescType )
286 {
287 this._strDescType = strDescType;
288 }
289
290
291
292
293
294 public String getDescType( )
295 {
296 return _strDescType;
297 }
298 }