KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > forum > hibernate > ForumImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.communication.forum.hibernate;
6
7 import java.util.Collection JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.HashMap JavaDoc;
10 import java.util.Map JavaDoc;
11
12 import org.apache.commons.lang.StringUtils;
13 import org.exoplatform.services.communication.forum.Forum;
14
15 /**
16  * Created by The eXo Platform SARL .
17  * Author : Tuan Nguyen
18  * tuan08@users.sourceforge.net
19  * Date: Jun 14, 2003
20  * Time: 1:12:22 PM
21  *
22  * @hibernate.class table="FORUM"
23  */

24 public class ForumImpl implements Forum {
25   private String JavaDoc id ;
26   private String JavaDoc owner ;
27   private Date JavaDoc createdDate ;
28   private String JavaDoc modifiedBy ;
29   private Date JavaDoc modifiedDate ;
30   private String JavaDoc lastPostBy ;
31   private Date JavaDoc lastPostDate ;
32   private String JavaDoc name ;
33   private String JavaDoc description ;
34   private int postCount ;
35   private int topicCount ;
36   private String JavaDoc viewForumRole = "guest";
37   private String JavaDoc createTopicRole ;
38   private String JavaDoc replyTopicRole ;
39   private String JavaDoc moderators ;
40   private String JavaDoc categoryId ;
41   private int forumOrder ;
42   
43   private transient Map JavaDoc moderatorMap_ ;
44
45   public ForumImpl() {
46   }
47
48   /**
49    * @hibernate.id generator-class="assigned" unsaved-value="null"
50    ***/

51   public String JavaDoc getId() { return id ; }
52   public void setId( String JavaDoc s) { id = s ; }
53   
54   /**
55    * @hibernate.property
56    **/

57   public String JavaDoc getCategoryId() { return categoryId ; }
58   public void setCategoryId( String JavaDoc id) { categoryId = id ;}
59
60   /**
61    * @hibernate.property
62    **/

63   public String JavaDoc getOwner() { return owner ; }
64   public void setOwner(String JavaDoc s) { owner = s ; }
65
66   /**
67    * @hibernate.property
68    **/

69   public Date JavaDoc getCreatedDate() { return createdDate ; }
70   public void setCreatedDate(Date JavaDoc d) { createdDate = d ; }
71
72   /**
73    * @hibernate.property
74    **/

75   public String JavaDoc getModifiedBy() { return modifiedBy ; }
76   public void setModifiedBy(String JavaDoc s) { modifiedBy = s ;}
77
78   /**
79    * @hibernate.property
80    **/

81   public Date JavaDoc getModifiedDate() { return modifiedDate ; }
82   public void setModifiedDate(Date JavaDoc d) { modifiedDate = d ;}
83
84   /**
85    * @hibernate.property
86    **/

87   public String JavaDoc getLastPostBy() { return lastPostBy ; }
88   public void setLastPostBy(String JavaDoc s) { lastPostBy = s ;}
89   /**
90    * @hibernate.property
91    **/

92   public Date JavaDoc getLastPostDate() { return lastPostDate ; }
93   public void setLastPostDate(Date JavaDoc d) { lastPostDate = d ;}
94
95   /**
96    * @hibernate.property
97    **/

98   public String JavaDoc getForumName() { return name ; }
99   public void setForumName(String JavaDoc s) { name = s ; }
100
101   /**
102    * @hibernate.property length="65535" type="org.exoplatform.services.database.impl.TextClobType"
103    **/

104   public String JavaDoc getDescription() { return description ; }
105   public void setDescription(String JavaDoc s) { description = s; }
106
107   /**
108    * @hibernate.property
109    **/

110   public int getPostCount() { return postCount ; }
111   public void setPostCount(int num) { postCount = num ; }
112   void addPostCount(int num) { postCount += num; }
113
114   /**
115    * @hibernate.property
116    **/

117   public int getTopicCount() { return topicCount; }
118   public void setTopicCount(int num) { topicCount = num; }
119   void addTopicCount(int num) { topicCount += num; }
120   
121   /**
122    * @hibernate.property
123    **/

124   public String JavaDoc getViewForumRole() { return viewForumRole ; }
125   public void setViewForumRole(String JavaDoc s) { viewForumRole = s ; }
126
127   /**
128    * @hibernate.property
129    **/

130   public String JavaDoc getCreateTopicRole() { return createTopicRole ; }
131   public void setCreateTopicRole(String JavaDoc s) {createTopicRole = s ;}
132
133   /**
134    * @hibernate.property
135    **/

136   public String JavaDoc getReplyTopicRole() { return replyTopicRole ; }
137   public void setReplyTopicRole(String JavaDoc role) { replyTopicRole = role; }
138
139   /**
140    * @hibernate.property
141    **/

142   public String JavaDoc getModerators() { return moderators ; }
143   public void setModerators(String JavaDoc s) { moderators = s ; }
144     
145   /**
146    * @hibernate.property
147    **/

148   public int getForumOrder() { return forumOrder ; }
149   public void setForumOrder(int num) { forumOrder = num ; }
150   
151   public boolean isModerator(String JavaDoc user) {
152     if(owner.equals(user)) return true ;
153     if(moderatorMap_ == null) getAllModerators() ;
154     if(moderatorMap_.containsKey(user)) return true ;
155     return false ;
156   }
157   
158   public Collection JavaDoc getAllModerators() {
159     if(moderatorMap_ == null) {
160       moderatorMap_ = new HashMap JavaDoc() ;
161       if (moderators != null) {
162         String JavaDoc[] users = StringUtils.split(moderators, ",") ;
163         for(int i = 0; i < users.length; i++) {
164           String JavaDoc user = users[i].trim() ;
165           moderatorMap_.put(user, user) ;
166           
167         }
168       }
169     }
170     return moderatorMap_.values() ;
171   }
172 }
Popular Tags