KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > dao > UserDAO


1
2
3  /*
4  -- GeiNuke --
5 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
6  http://www.hostingjava.it/-geinuke/
7
8 This file is part of GeiNuke.
9
10     GeiNuke is free software; you can redistribute it and/or modify
11     it under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14
15     GeiNuke is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     GNU General Public License for more details.
19
20     You should have received a copy of the GNU General Public License
21     along with GeiNuke; if not, write to the Free Software
22     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */

24 package com.geinuke.dao;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import com.geinuke.vo.BlogAuthorVO;
30 import com.geinuke.vo.RoleVO;
31 import com.geinuke.vo.UserVO;
32
33 public class UserDAO extends GeiDAO{
34
35     
36     public UserDAO() throws Exception JavaDoc {
37         super();
38         
39     }
40     
41     public List JavaDoc getUsersByForumID(int fid)throws Exception JavaDoc{
42         List JavaDoc list=null;
43         try{
44             this.sqlMap().startTransaction();
45             list=this.sqlMap().queryForList("getUsersByForumID",new Integer JavaDoc(fid));
46             this.sqlMap().commitTransaction();
47         }finally{
48             this.sqlMap().endTransaction();
49         }
50         return list;
51         
52     }
53     
54     public UserVO getUserByID(UserVO u) throws Exception JavaDoc{
55         UserVO user=null;
56         try{
57             this.sqlMap().startTransaction();
58             user=(UserVO)this.sqlMap().queryForObject("getUserByID",u);
59             this.sqlMap().commitTransaction();
60         }finally{
61             this.sqlMap().endTransaction();
62         }
63         return user;
64     }
65     
66     public UserVO getUserFromByPID(int pid) throws Exception JavaDoc{
67         UserVO user=null;
68         try{
69             this.sqlMap().startTransaction();
70             user=(UserVO)this.sqlMap().queryForObject("getUserFromByPID",
71                     new Integer JavaDoc(pid));
72             this.sqlMap().commitTransaction();
73         }finally{
74             this.sqlMap().endTransaction();
75         }
76         return user;
77     }
78     
79     public UserVO getUserToByPID(int pid) throws Exception JavaDoc{
80         UserVO user=null;
81         try{
82             this.sqlMap().startTransaction();
83             user=(UserVO)this.sqlMap().queryForObject("getUserToByPID",
84                     new Integer JavaDoc(pid));
85             this.sqlMap().commitTransaction();
86         }finally{
87             this.sqlMap().endTransaction();
88         }
89         return user;
90     }
91     
92     public UserVO getUserByID(int id) throws Exception JavaDoc{
93         UserVO user=null;
94         user=new UserVO();
95         user.setId(id);
96         
97         return getUserByID(user);
98     }
99     
100     public BlogAuthorVO getBlogAuthorByBID(int bid) throws Exception JavaDoc{
101         BlogAuthorVO user=null;
102         try{
103             this.sqlMap().startTransaction();
104             user=(BlogAuthorVO)this.sqlMap().queryForObject("getBlogAuthorByBID",new Integer JavaDoc(bid));
105             this.sqlMap().commitTransaction();
106         }finally{
107             this.sqlMap().endTransaction();
108         }
109         return user;
110     }
111     
112     
113     public ArrayList JavaDoc getAllRoles()throws Exception JavaDoc{
114         ArrayList JavaDoc list=null;
115         List JavaDoc llist=null;
116         try{
117             sqlMap().startTransaction();
118             llist=sqlMap().queryForList("getAllRoles",new String JavaDoc(""));
119             this.sqlMap().commitTransaction();
120         }finally{
121             sqlMap().endTransaction();
122         }
123         list=new ArrayList JavaDoc(llist);
124         
125         return list;
126     }
127     
128     public ArrayList JavaDoc getBlogAuthors()throws Exception JavaDoc{
129         ArrayList JavaDoc list=null;
130         List JavaDoc llist=null;
131         try{
132             sqlMap().startTransaction();
133             llist=sqlMap().queryForList("getBlogAuthors",new String JavaDoc(""));
134             this.sqlMap().commitTransaction();
135         }finally{
136             sqlMap().endTransaction();
137         }
138         list=new ArrayList JavaDoc(llist);
139         
140         return list;
141     }
142     
143     public ArrayList JavaDoc getAllUsers()throws Exception JavaDoc{
144         ArrayList JavaDoc list=null;
145         List JavaDoc llist=null;
146         try{
147             sqlMap().startTransaction();
148             llist=sqlMap().queryForList("getAllUsers",new String JavaDoc(""));
149             this.sqlMap().commitTransaction();
150         }finally{
151             sqlMap().endTransaction();
152         }
153         list=new ArrayList JavaDoc(llist);
154         
155         return list;
156     }
157     
158     public void insertUser(UserVO u) throws Exception JavaDoc{
159         
160         try{
161             this.sqlMap().startTransaction();
162             this.sqlMap().insert("insUser",u);
163             this.sqlMap().commitTransaction();
164         }finally{
165             this.sqlMap().endTransaction();
166         }
167         
168     }
169     
170     public void insertRole(RoleVO u) throws Exception JavaDoc{
171         
172         try{
173             this.sqlMap().startTransaction();
174             this.sqlMap().insert("insRole",u);
175             this.sqlMap().commitTransaction();
176         }finally{
177             this.sqlMap().endTransaction();
178         }
179         
180     }
181     
182     public void updateUser(UserVO u) throws Exception JavaDoc{
183         
184         try{
185             this.sqlMap().startTransaction();
186             this.sqlMap().update("updateUser",u);
187             this.sqlMap().commitTransaction();
188         }finally{
189             this.sqlMap().endTransaction();
190         }
191         //this.updateRole((UserVO)u.getRole());
192

193     }
194     
195     public void updateAllDefStyle(String JavaDoc style) throws Exception JavaDoc{
196         
197         try{
198             this.sqlMap().startTransaction();
199             this.sqlMap().update("updateAllDefStyle",style);
200             this.sqlMap().commitTransaction();
201         }finally{
202             this.sqlMap().endTransaction();
203         }
204         //this.updateRole((UserVO)u.getRole());
205

206     }
207     
208     public void updateUserRole(UserVO u) throws Exception JavaDoc{
209         
210         try{
211             this.sqlMap().startTransaction();
212             this.sqlMap().update("updateUserRole",u);
213             this.sqlMap().commitTransaction();
214         }finally{
215             this.sqlMap().endTransaction();
216         }
217         
218     }
219     
220     public UserVO getUserByAuth(UserVO u) throws Exception JavaDoc{
221         UserVO user=null;
222         try{
223             this.sqlMap().startTransaction();
224             user=(UserVO)this.sqlMap().queryForObject("getUserByAuth",u);
225             this.sqlMap().commitTransaction();
226         }finally{
227             this.sqlMap().endTransaction();
228         }
229         return user;
230     }
231     
232     public UserVO getUserByUName(UserVO u) throws Exception JavaDoc{
233         UserVO user=null;
234         try{
235             this.sqlMap().startTransaction();
236             user=(UserVO)this.sqlMap().queryForObject("getUserByUName",u);
237             this.sqlMap().commitTransaction();
238         }finally{
239             this.sqlMap().endTransaction();
240         }
241         return user;
242     }
243     
244     
245 }
246
Popular Tags