01: /*
02: * UserHandler.java
03: *
04: * Created on June 22, 2004, 5:44 PM
05: */
06:
07: package org.manentia.kasai.role;
08:
09: import java.util.Collection;
10: import java.util.List;
11:
12: import org.manentia.kasai.Role;
13: import org.manentia.kasai.exceptions.AlreadyExistsException;
14: import org.manentia.kasai.exceptions.DataAccessException;
15: import org.manentia.kasai.exceptions.DoesntExistsException;
16: import org.manentia.kasai.exceptions.InvalidAttributesException;
17:
18: /**
19: *
20: * @author rzuasti
21: */
22: public class RoleHandler {
23: private static RoleHandler instance;
24:
25: private RoleHandler() {
26: }
27:
28: public static synchronized RoleHandler getInstance() {
29: if (instance == null) {
30: instance = new RoleHandler();
31: }
32:
33: return instance;
34: }
35:
36: public void addOperativeToRole(final String idOperative,
37: final int role) throws DoesntExistsException,
38: DataAccessException {
39:
40: RoleDAOFactory.getInstance().createDAO().addOperativeToRole(
41: idOperative, role);
42: }
43:
44: public int create(String name, String description,
45: String[] operatives) throws InvalidAttributesException,
46: AlreadyExistsException, DoesntExistsException,
47: DataAccessException {
48: return RoleDAOFactory.getInstance().createDAO().create(name,
49: description, operatives);
50: }
51:
52: public void deleteOperativeFromRole(String idOperative, int role)
53: throws DataAccessException {
54: RoleDAOFactory.getInstance().createDAO()
55: .deleteOperativeFromRole(idOperative, role);
56: }
57:
58: public void delete(int id) throws DataAccessException {
59: RoleDAOFactory.getInstance().createDAO().delete(id);
60: }
61:
62: public Collection listOperativesFromRole(int role, String operative)
63: throws DataAccessException {
64: return RoleDAOFactory.getInstance().createDAO()
65: .listOperativesFromRole(role, operative);
66: }
67:
68: public Collection listOperativesNotInRole(int role)
69: throws DataAccessException {
70: return RoleDAOFactory.getInstance().createDAO()
71: .listOperativesNotInRole(role);
72: }
73:
74: public List list(String name, boolean exactly)
75: throws DataAccessException {
76: return RoleDAOFactory.getInstance().createDAO().list(name,
77: exactly);
78: }
79:
80: public Role read(int role) throws DataAccessException {
81: return RoleDAOFactory.getInstance().createDAO().read(role);
82: }
83:
84: public void update(int id, String name, String description)
85: throws InvalidAttributesException, DataAccessException {
86: RoleDAOFactory.getInstance().createDAO().update(id, name,
87: description);
88: }
89:
90: public void update(int id, String name, String description,
91: String[] operatives) throws InvalidAttributesException,
92: DataAccessException {
93: RoleDAOFactory.getInstance().createDAO().update(id, name,
94: description, operatives);
95: }
96: }
|