213 |
213 |
}
|
214 |
214 |
return retList;
|
215 |
215 |
}
|
|
216 |
|
216 |
217 |
@Override
|
217 |
218 |
public List<RuleSet> getRuleSets() throws DaoException {
|
218 |
219 |
ResultSet rs = null;
|
... | ... | |
275 |
276 |
closeConnection(con);
|
276 |
277 |
}
|
277 |
278 |
return retList;
|
|
279 |
}
|
|
280 |
|
|
281 |
@Override
|
|
282 |
public List<RuleSet> getRuleSets(String guidelineAcronym) throws DaoException {
|
|
283 |
ResultSet rs = null;
|
|
284 |
Connection con = null;
|
|
285 |
PreparedStatement stmt = null;
|
|
286 |
List<RuleSet> retList = new ArrayList<RuleSet>();
|
|
287 |
logger.debug("Accessing DB to get all RuleSets");
|
|
288 |
|
|
289 |
try {
|
|
290 |
con = getConnection();
|
|
291 |
String query="SELECT name, description, guidelines_acronym, visibility, id, short_name FROM rulesets WHERE guidelines_acronym=? ORDER BY id";
|
|
292 |
stmt = con.prepareStatement(query);
|
|
293 |
stmt.setString(1,guidelineAcronym);
|
|
294 |
rs = stmt.executeQuery();
|
|
295 |
|
|
296 |
while (rs.next()) {
|
|
297 |
RuleSet retSet = new RuleSet();
|
|
298 |
|
|
299 |
retSet.setName(rs.getString(1));
|
|
300 |
retSet.setDescription(rs.getString(2));
|
|
301 |
retSet.setGuidelinesAcronym(rs.getString(3));
|
|
302 |
List<String> visibility = new ArrayList<String>();
|
|
303 |
Array tt = rs.getArray("visibility");
|
|
304 |
if (tt != null) {
|
|
305 |
String[] ent = (String[])tt.getArray();
|
|
306 |
visibility.addAll(Arrays.asList(ent));
|
|
307 |
}
|
|
308 |
retSet.setVisibility(visibility);
|
|
309 |
retSet.setId(rs.getInt(5));
|
|
310 |
retSet.setShortName(rs.getString(6));
|
|
311 |
List <Rule> rules = this.getRulesOfRuleset(retSet.getId());
|
|
312 |
List <Rule> contentRules = new ArrayList<Rule>();
|
|
313 |
List <Rule> usageRules = new ArrayList<Rule>();
|
|
314 |
Set <Integer> contentRulesIds = new HashSet<Integer>();
|
|
315 |
Set <Integer> usageRulesIds = new HashSet<Integer>();
|
|
316 |
for (Rule rule : rules) {
|
|
317 |
if (rule.getJob_type().equals("content")) {
|
|
318 |
contentRules.add(rule);
|
|
319 |
contentRulesIds.add(rule.getId());
|
|
320 |
} else if (rule.getJob_type().equals("usage")) {
|
|
321 |
usageRules.add(rule);
|
|
322 |
usageRulesIds.add(rule.getId());
|
|
323 |
}
|
|
324 |
}
|
|
325 |
retSet.setContentRules(contentRules);
|
|
326 |
retSet.setUsageRules(usageRules);
|
|
327 |
retSet.setContentRulesIds(contentRulesIds);
|
|
328 |
retSet.setUsageRulesIds(usageRulesIds);
|
|
329 |
retList.add(retSet);
|
|
330 |
}
|
|
331 |
} catch (Exception e) {
|
|
332 |
logger.error("Accessing DB to get all RuleSets.", e);
|
|
333 |
} finally {
|
|
334 |
if (stmt != null) {
|
|
335 |
try {
|
|
336 |
stmt.close();
|
|
337 |
} catch (SQLException e) {
|
|
338 |
logger.error("Accessing DB to get all RuleSets.", e);
|
|
339 |
}
|
|
340 |
}
|
|
341 |
closeConnection(con);
|
|
342 |
}
|
|
343 |
return retList;
|
278 |
344 |
}
|
279 |
345 |
|
280 |
346 |
public List<Rule> getRulesOfRuleset(int ruleSetId) throws DaoException {
|
Updating rule set to search by guidelines acronym