1 package org.apache.fulcrum.security.torque.basic;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import java.sql.Connection;
21 import java.util.List;
22
23 import org.apache.fulcrum.security.entity.Group;
24 import org.apache.fulcrum.security.torque.TorqueAbstractGroupManager;
25 import org.apache.fulcrum.security.torque.om.TorqueBasicGroupPeer;
26 import org.apache.torque.NoRowsException;
27 import org.apache.torque.TooManyRowsException;
28 import org.apache.torque.TorqueException;
29 import org.apache.torque.criteria.Criteria;
30
31
32
33
34
35
36
37 public class TorqueBasicGroupManagerImpl extends TorqueAbstractGroupManager
38 {
39
40
41
42 @SuppressWarnings("unchecked")
43 protected <T extends Group> List<T> doSelectAllGroups(Connection con)
44 throws TorqueException
45 {
46 Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
47
48 return (List<T>)TorqueBasicGroupPeer.doSelect(criteria, con);
49 }
50
51
52
53
54 @SuppressWarnings("unchecked")
55 protected <T extends Group> T doSelectById(Integer id, Connection con)
56 throws NoRowsException, TooManyRowsException, TorqueException
57 {
58 return (T)TorqueBasicGroupPeer.retrieveByPK(id, con);
59 }
60
61
62
63
64 @SuppressWarnings("unchecked")
65 protected <T extends Group> T doSelectByName(String name, Connection con)
66 throws NoRowsException, TooManyRowsException, TorqueException
67 {
68 Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
69 criteria.where(TorqueBasicGroupPeer.GROUP_NAME, name);
70 criteria.setIgnoreCase(true);
71 criteria.setSingleRecord(true);
72
73 T t = (T)TorqueBasicGroupPeer.doSelectSingleRecord(criteria, con);
74 if (t == null)
75 {
76 throw new NoRowsException(name);
77 }
78
79 return t;
80 }
81 }