Project

General

Profile

« Previous | Next » 

Revision 36841

Added by Nikon Gasparis about 9 years ago

imported updated from trunk rev 36836

View differences:

RulesDAOimpl.java
11 11

  
12 12
import eu.dnetlib.domain.functionality.validator.Rule;
13 13
import eu.dnetlib.validator.commons.dao.AbstractDAO;
14
import eu.dnetlib.validator.commons.dao.DaoException;
14 15

  
15
public class RulesDAOimpl extends AbstractDAO<Rule> implements RulesDAO{
16
public class RulesDAOimpl extends AbstractDAO<Rule> implements RulesDAO {
16 17

  
17 18
	@Override
18
	public Integer save(Rule t) {
19
	public Integer save(Rule t) throws DaoException {
19 20
		Connection con = null;
20 21
		PreparedStatement stmt = null;
21 22
		Integer retId = -1;
......
81 82
		    stmt.executeBatch();
82 83
		    logger.debug("Rule + Properties inserted/updated");
83 84
		    
84
		} catch (SQLException e) {
85
		} catch (Exception e) {
85 86
			logger.error("Error accessing DB to get save/update Rule.", e);
87
			throw new DaoException(e);
86 88
		} finally {
87 89
			if (stmt != null) {
88 90
				try {
89 91
					stmt.close();
90 92
				} catch (SQLException e) {
91 93
					logger.error("Error accessing DB to get save/update Rule.", e);
94
					throw new DaoException(e);
92 95
				}
93 96
			}
94 97
		}
......
96 99
	}
97 100

  
98 101
	@Override
99
	public String delete(int id) {
102
	public String delete(int id) throws DaoException {
100 103
		Connection con = null;
101 104
		PreparedStatement stmt = null;
102 105
		logger.debug("Accessing DB to delete Rule");
......
115 118
				stmt.close();
116 119
			}			
117 120
			
118
		} catch (SQLException e) {
121
		} catch (Exception e) {
119 122
			logger.error("Error accessing DB to delete Rule.", e);
123
			throw new DaoException(e);
120 124
		} finally {
121 125
			if (stmt != null) {
122 126
				try {
123 127
					stmt.close();
124 128
				} catch (SQLException e) {
125 129
					logger.error("Error accessing DB to delete Rule.", e);
130
					throw new DaoException(e);
126 131
				}
127 132
			}
128 133
		}
......
140 145
	}
141 146

  
142 147
	@Override
143
	public List<Rule> getAllRulesByJobType(String jobType) {
148
	public List<Rule> getAllRulesByJobType(String jobType) throws DaoException {
144 149
		ResultSet rs = null;
145 150
		Connection con = null;
146 151
		PreparedStatement stmt = null;
......
173 178
			}
174 179

  
175 180

  
176
		} catch (SQLException e) {
181
		} catch (Exception e) {
177 182
			logger.error("Error accessing DB to get All Rules by jobType.", e);
183
			throw new DaoException(e);
178 184
		} finally {
179 185
			if (stmt != null) {
180 186
				try {
181 187
					stmt.close();
182 188
				} catch (SQLException e) {
183 189
					logger.error("Error accessing DB to get All Rules by jobType.", e);
190
					throw new DaoException(e);
184 191
				}
185 192
			}
186 193
		}
......
189 196
	}
190 197

  
191 198
	@Override
192
	public List<Rule> getAllRulesByJobTypeEntityType(String jobType, String entityType) {
199
	public List<Rule> getAllRulesByJobTypeEntityType(String jobType, String entityType) throws DaoException {
193 200
		ResultSet rs = null;
194 201
		Connection con = null;
195 202
		PreparedStatement stmt = null;
......
223 230
			}
224 231

  
225 232

  
226
		} catch (SQLException e) {
233
		} catch (Exception e) {
227 234
			logger.error("Error accessing DB to get All Rules by jobType.", e);
235
			throw new DaoException(e);
228 236
		} finally {
229 237
			if (stmt != null) {
230 238
				try {
231 239
					stmt.close();
232 240
				} catch (SQLException e) {
233 241
					logger.error("Error accessing DB to get All Rules by jobType.", e);
242
					throw new DaoException(e);
234 243
				}
235 244
			}
236 245
		}
......
239 248
	}
240 249

  
241 250
	@Override
242
	public List<Rule> getAllRules() {
251
	public List<Rule> getAllRules() throws DaoException {
243 252
		ResultSet rs = null;
244 253
		Connection con = null;
245 254
		PreparedStatement stmt = null;
......
270 279
			}
271 280

  
272 281
			logger.debug("rules: " + retList.size());
273
		} catch (SQLException e) {
282
		} catch (Exception e) {
274 283
			logger.error("Error accessing DB to get All Rule-pairs.", e);
284
			throw new DaoException(e);
275 285
		} finally {
276 286
			if (stmt != null) {
277 287
				try {
278 288
					stmt.close();
279 289
				} catch (SQLException e) {
280 290
					logger.error("Error accessing DB to get All Rule-pairs.", e);
291
					throw new DaoException(e);
281 292
				}
282 293
			}
283 294
		}
......
285 296

  
286 297
	}
287 298

  
288
	public Properties getProperties(int ruleId) {
299
	public Properties getProperties(int ruleId) throws DaoException {
289 300
		ResultSet rs = null;
290 301
		Connection con = null;
291 302
		PreparedStatement stmt = null;
......
304 315
				}				
305 316
			}
306 317

  
307
		} catch (SQLException e) {
318
		} catch (Exception e) {
308 319
			logger.error("Accessing DB to get Rule Properties.", e);
320
			throw new DaoException(e);
309 321
		} finally {
310 322
			if (stmt != null) {
311 323
				try {
312 324
					stmt.close();
313 325
				} catch (SQLException e) {
314 326
					logger.error("Accessing DB to get Rule Properties.", e);
327
					throw new DaoException(e);
315 328
				}
316 329
			}
317 330
		}
......
319 332
	}
320 333

  
321 334
	@Override
322
	public Rule get(int id) {
335
	public Rule get(int id) throws DaoException {
323 336
		ResultSet rs = null;
324 337
		Connection con = null;
325 338
		PreparedStatement stmt = null;
......
350 363
			}
351 364

  
352 365

  
353
		} catch (SQLException e) {
366
		} catch (Exception e) {
354 367
			logger.error("Accessing DB to get Rule.", e);
368
			throw new DaoException(e);
355 369
		} finally {
356 370
			if (stmt != null) {
357 371
				try {
358 372
					stmt.close();
359 373
				} catch (SQLException e) {
360 374
					logger.error("Accessing DB to get Rule.", e);
375
					throw new DaoException(e);
361 376
				}
362 377
			}
363 378
		}
......
366 381
	}
367 382

  
368 383
	@Override
369
	protected int getLastId() throws SQLException {
384
	protected int getLastId() throws DaoException {
370 385
		ResultSet rs = null;
371 386
		Connection con = null;
372 387
		PreparedStatement stmt = null;
......
386 401
			}
387 402

  
388 403

  
389
		} catch (SQLException e) {
404
		} catch (Exception e) {
390 405
			logger.error("Error while accessing DB to get Rule's next available id.", e);
406
			throw new DaoException(e);
391 407
		} finally {
392 408
			if (stmt != null) {
393 409
				try {
394 410
					stmt.close();
395 411
				} catch (SQLException e) {
396 412
					logger.error("Error while accessing DB to get Rule's next available id.", e);
413
					throw new DaoException(e);
397 414
				}
398 415
			}
399 416
		}

Also available in: Unified diff