KickJava   Java API By Example, From Geeks To Geeks.

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


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.HashMap JavaDoc;
27 import java.util.List JavaDoc;
28
29 import com.geinuke.vo.ForumVO;
30
31 public class ForumDAO extends GeiDAO{
32
33     
34     public ForumDAO() throws Exception JavaDoc {
35         super();
36         
37     }
38     
39     public List JavaDoc getVisibleForums()throws Exception JavaDoc{
40         List JavaDoc list=null;
41         try{
42             Integer JavaDoc v=new Integer JavaDoc(ForumVO.STATE_VISIBLE);
43             this.sqlMap().startTransaction();
44             list=this.sqlMap().queryForList("getForumsByState",v);
45             this.sqlMap().commitTransaction();
46         }finally{
47             this.sqlMap().endTransaction();
48         }
49         return list;
50         
51     }
52     
53     public ForumVO getForumByFId(int fid)throws Exception JavaDoc{
54         ForumVO res=null;
55         try{
56             
57             this.sqlMap().startTransaction();
58             res=(ForumVO)this.sqlMap().queryForObject("getForumByFId",new Integer JavaDoc(fid));
59             this.sqlMap().commitTransaction();
60         }finally{
61             this.sqlMap().endTransaction();
62         }
63         return res;
64         
65     }
66     
67     public void delForumByFId(int fid)throws Exception JavaDoc{
68         
69         try{
70             
71             this.sqlMap().startTransaction();
72             this.sqlMap().delete("delForumByFId",new Integer JavaDoc(fid));
73             this.sqlMap().commitTransaction();
74         }finally{
75             this.sqlMap().endTransaction();
76         }
77         
78         
79     }
80     
81     public void insForum(ForumVO mod)throws Exception JavaDoc{
82         try{
83             this.sqlMap().startTransaction();
84             this.sqlMap().insert("insForum",mod);
85             this.sqlMap().commitTransaction();
86         }finally{
87             this.sqlMap().endTransaction();
88         }
89     
90     }
91     
92     public void updateForum(ForumVO mod)throws Exception JavaDoc{
93         try{
94             this.sqlMap().startTransaction();
95             this.sqlMap().update("updateForum",mod);
96             this.sqlMap().commitTransaction();
97         }finally{
98             this.sqlMap().endTransaction();
99         }
100     
101     }
102     
103     public void insForumModerator(int fid,int uid)throws Exception JavaDoc{
104         try{
105             HashMap JavaDoc map=new HashMap JavaDoc();
106             map.put("euid",new Integer JavaDoc(uid));
107             map.put("efid",new Integer JavaDoc(fid));
108             this.sqlMap().startTransaction();
109             this.sqlMap().insert("insForumModerator",map);
110             this.sqlMap().commitTransaction();
111         }finally{
112             this.sqlMap().endTransaction();
113         }
114     
115     }
116     
117     public void insCategoryForum(int fid,int catid)throws Exception JavaDoc{
118         try{
119             HashMap JavaDoc map=new HashMap JavaDoc();
120             map.put("eecatid",new Integer JavaDoc(catid));
121             map.put("eefid",new Integer JavaDoc(fid));
122             this.sqlMap().startTransaction();
123             this.sqlMap().insert("insCategoryForum",map);
124             this.sqlMap().commitTransaction();
125         }finally{
126             this.sqlMap().endTransaction();
127         }
128     
129     }
130     
131     
132     public ForumVO getForumByTId(int tid)throws Exception JavaDoc{
133         ForumVO res=null;
134         try{
135             
136             this.sqlMap().startTransaction();
137             res=(ForumVO)this.sqlMap().queryForObject("getForumByTId",new Integer JavaDoc(tid));
138             this.sqlMap().commitTransaction();
139         }finally{
140             this.sqlMap().endTransaction();
141         }
142         return res;
143         
144     }
145
146 }
147
Popular Tags