Revision 36841
Added by Nikon Gasparis about 9 years ago
RulesetsDAOimpl.java | ||
---|---|---|
14 | 14 |
import eu.dnetlib.domain.functionality.validator.Rule; |
15 | 15 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
16 | 16 |
import eu.dnetlib.validator.commons.dao.AbstractDAO; |
17 |
import eu.dnetlib.validator.commons.dao.DaoException; |
|
17 | 18 |
import eu.dnetlib.validator.commons.dao.Utilities; |
18 | 19 |
|
19 | 20 |
public class RulesetsDAOimpl extends AbstractDAO<RuleSet> implements RulesetsDAO{ |
20 | 21 |
|
21 | 22 |
@Override |
22 |
public Integer save(RuleSet t) { |
|
23 |
public Integer save(RuleSet t) throws DaoException {
|
|
23 | 24 |
Connection con = null; |
24 | 25 |
PreparedStatement stmt = null; |
25 | 26 |
Integer retId = -1; |
... | ... | |
79 | 80 |
stmt.executeBatch(); |
80 | 81 |
logger.debug("Ruleset_has_rules values inserted/updated"); |
81 | 82 |
|
82 |
} catch (SQLException e) {
|
|
83 |
} catch (Exception e) { |
|
83 | 84 |
logger.error("Error accessing DB to save ruleset.", e); |
85 |
throw new DaoException(e); |
|
84 | 86 |
} finally { |
85 | 87 |
if (stmt != null) { |
86 | 88 |
try { |
87 | 89 |
stmt.close(); |
88 | 90 |
} catch (SQLException e) { |
89 | 91 |
logger.error("Error accessing DB to save ruleset.", e); |
92 |
throw new DaoException(e); |
|
90 | 93 |
} |
91 | 94 |
} |
92 | 95 |
} |
... | ... | |
94 | 97 |
} |
95 | 98 |
|
96 | 99 |
@Override |
97 |
public RuleSet get(int id) { |
|
100 |
public RuleSet get(int id) throws DaoException {
|
|
98 | 101 |
ResultSet rs = null; |
99 | 102 |
Connection con = null; |
100 | 103 |
PreparedStatement stmt = null; |
... | ... | |
141 | 144 |
retSet.setUsageRulesIds(usageRulesIds); |
142 | 145 |
} |
143 | 146 |
} |
144 |
} catch (SQLException e) {
|
|
147 |
} catch (Exception e) { |
|
145 | 148 |
logger.error("Accessing DB to get RuleSet.", e); |
146 | 149 |
} finally { |
147 | 150 |
if (stmt != null) { |
... | ... | |
155 | 158 |
return retSet; |
156 | 159 |
} |
157 | 160 |
|
158 |
public List<RuleSet> updateRuleSetHasRules() { |
|
161 |
public List<RuleSet> updateRuleSetHasRules() throws DaoException {
|
|
159 | 162 |
ResultSet rs = null; |
160 | 163 |
Connection con = null; |
161 | 164 |
PreparedStatement stmt = null, stmt1 = null;; |
... | ... | |
194 | 197 |
} |
195 | 198 |
} |
196 | 199 |
|
197 |
} catch (SQLException e) {
|
|
200 |
} catch (Exception e) { |
|
198 | 201 |
logger.error("Accessing DB to get all RuleSets.", e); |
199 | 202 |
} finally { |
200 | 203 |
if (stmt != null) { |
... | ... | |
208 | 211 |
return retList; |
209 | 212 |
} |
210 | 213 |
@Override |
211 |
public List<RuleSet> getRuleSets() { |
|
214 |
public List<RuleSet> getRuleSets() throws DaoException {
|
|
212 | 215 |
ResultSet rs = null; |
213 | 216 |
Connection con = null; |
214 | 217 |
PreparedStatement stmt = null; |
... | ... | |
258 | 261 |
} |
259 | 262 |
} |
260 | 263 |
|
261 |
} catch (SQLException e) {
|
|
264 |
} catch (Exception e) { |
|
262 | 265 |
logger.error("Accessing DB to get all RuleSets.", e); |
263 | 266 |
} finally { |
264 | 267 |
if (stmt != null) { |
... | ... | |
272 | 275 |
return retList; |
273 | 276 |
} |
274 | 277 |
|
275 |
public List<Rule> getRulesOfRuleset(int ruleSetId) { |
|
278 |
public List<Rule> getRulesOfRuleset(int ruleSetId) throws DaoException {
|
|
276 | 279 |
ResultSet rs = null; |
277 | 280 |
Connection con = null; |
278 | 281 |
PreparedStatement stmt = null; |
... | ... | |
305 | 308 |
} |
306 | 309 |
logger.debug("rules: " + retList.size()); |
307 | 310 |
|
308 |
} catch (SQLException e) {
|
|
311 |
} catch (Exception e) { |
|
309 | 312 |
logger.error("Error accessing DB to get All Rules by jobType.", e); |
313 |
throw new DaoException(e); |
|
310 | 314 |
} finally { |
311 | 315 |
if (stmt != null) { |
312 | 316 |
try { |
313 | 317 |
stmt.close(); |
314 | 318 |
} catch (SQLException e) { |
315 | 319 |
logger.error("Error accessing DB to get All Rules by jobType.", e); |
320 |
throw new DaoException(e); |
|
316 | 321 |
} |
317 | 322 |
} |
318 | 323 |
} |
... | ... | |
330 | 335 |
} |
331 | 336 |
|
332 | 337 |
@Override |
333 |
protected int getLastId() throws SQLException {
|
|
338 |
protected int getLastId() throws DaoException {
|
|
334 | 339 |
ResultSet rs = null; |
335 | 340 |
Connection con = null; |
336 | 341 |
PreparedStatement stmt = null; |
... | ... | |
348 | 353 |
rs.next(); |
349 | 354 |
retId=rs.getInt(1); |
350 | 355 |
} |
351 |
|
|
352 |
|
|
353 |
} catch (SQLException e) { |
|
356 |
} catch (Exception e) { |
|
354 | 357 |
logger.error("Error while accessing DB to get RuleSet's next available id.", e); |
358 |
throw new DaoException(e); |
|
355 | 359 |
} finally { |
356 | 360 |
if (stmt != null) { |
357 | 361 |
try { |
358 | 362 |
stmt.close(); |
359 | 363 |
} catch (SQLException e) { |
360 | 364 |
logger.error("Error while accessing DB to get RuleSet's next available id.", e); |
365 |
throw new DaoException(e); |
|
361 | 366 |
} |
362 | 367 |
} |
363 | 368 |
} |
Also available in: Unified diff
imported updated from trunk rev 36836