1 5 package org.exoplatform.services.communication.forum.hibernate; 6 7 import java.util.Collection ; 8 import java.util.Date ; 9 import java.util.HashMap ; 10 import java.util.Map ; 11 12 import org.apache.commons.lang.StringUtils; 13 import org.exoplatform.services.communication.forum.Forum; 14 15 24 public class ForumImpl implements Forum { 25 private String id ; 26 private String owner ; 27 private Date createdDate ; 28 private String modifiedBy ; 29 private Date modifiedDate ; 30 private String lastPostBy ; 31 private Date lastPostDate ; 32 private String name ; 33 private String description ; 34 private int postCount ; 35 private int topicCount ; 36 private String viewForumRole = "guest"; 37 private String createTopicRole ; 38 private String replyTopicRole ; 39 private String moderators ; 40 private String categoryId ; 41 private int forumOrder ; 42 43 private transient Map moderatorMap_ ; 44 45 public ForumImpl() { 46 } 47 48 51 public String getId() { return id ; } 52 public void setId( String s) { id = s ; } 53 54 57 public String getCategoryId() { return categoryId ; } 58 public void setCategoryId( String id) { categoryId = id ;} 59 60 63 public String getOwner() { return owner ; } 64 public void setOwner(String s) { owner = s ; } 65 66 69 public Date getCreatedDate() { return createdDate ; } 70 public void setCreatedDate(Date d) { createdDate = d ; } 71 72 75 public String getModifiedBy() { return modifiedBy ; } 76 public void setModifiedBy(String s) { modifiedBy = s ;} 77 78 81 public Date getModifiedDate() { return modifiedDate ; } 82 public void setModifiedDate(Date d) { modifiedDate = d ;} 83 84 87 public String getLastPostBy() { return lastPostBy ; } 88 public void setLastPostBy(String s) { lastPostBy = s ;} 89 92 public Date getLastPostDate() { return lastPostDate ; } 93 public void setLastPostDate(Date d) { lastPostDate = d ;} 94 95 98 public String getForumName() { return name ; } 99 public void setForumName(String s) { name = s ; } 100 101 104 public String getDescription() { return description ; } 105 public void setDescription(String s) { description = s; } 106 107 110 public int getPostCount() { return postCount ; } 111 public void setPostCount(int num) { postCount = num ; } 112 void addPostCount(int num) { postCount += num; } 113 114 117 public int getTopicCount() { return topicCount; } 118 public void setTopicCount(int num) { topicCount = num; } 119 void addTopicCount(int num) { topicCount += num; } 120 121 124 public String getViewForumRole() { return viewForumRole ; } 125 public void setViewForumRole(String s) { viewForumRole = s ; } 126 127 130 public String getCreateTopicRole() { return createTopicRole ; } 131 public void setCreateTopicRole(String s) {createTopicRole = s ;} 132 133 136 public String getReplyTopicRole() { return replyTopicRole ; } 137 public void setReplyTopicRole(String role) { replyTopicRole = role; } 138 139 142 public String getModerators() { return moderators ; } 143 public void setModerators(String s) { moderators = s ; } 144 145 148 public int getForumOrder() { return forumOrder ; } 149 public void setForumOrder(int num) { forumOrder = num ; } 150 151 public boolean isModerator(String 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 getAllModerators() { 159 if(moderatorMap_ == null) { 160 moderatorMap_ = new HashMap () ; 161 if (moderators != null) { 162 String [] users = StringUtils.split(moderators, ",") ; 163 for(int i = 0; i < users.length; i++) { 164 String user = users[i].trim() ; 165 moderatorMap_.put(user, user) ; 166 167 } 168 } 169 } 170 return moderatorMap_.values() ; 171 } 172 } | Popular Tags |