001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * This file creating date: Feb 23, 2003 / 12:25:04 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.entities;
044:
045: import java.io.Serializable;
046: import java.util.List;
047:
048: import net.jforum.repository.ForumRepository;
049:
050: /**
051: * Represents a specific forum.
052: *
053: * @author Rafael Steil
054: * @version $Id: Forum.java,v 1.13 2007/07/28 14:17:09 rafaelsteil Exp $
055: */
056: public class Forum implements Serializable {
057: private int id;
058: private int idCategories;
059: private String name;
060: private String description;
061: private int order;
062: private int totalTopics;
063: private int totalPosts;
064: private int lastPostId;
065: private boolean moderated;
066: private boolean unread;
067: private LastPostInfo lpi;
068:
069: public Forum() {
070: }
071:
072: public Forum(int forumId) {
073: this .id = forumId;
074: }
075:
076: public Forum(Forum f) {
077: this .description = f.getDescription();
078: this .id = f.getId();
079: this .idCategories = f.getCategoryId();
080: this .lastPostId = f.getLastPostId();
081: this .moderated = f.isModerated();
082: this .name = f.getName();
083: this .order = f.getOrder();
084: this .totalPosts = f.getTotalPosts();
085: this .totalTopics = f.getTotalTopics();
086: this .unread = f.getUnread();
087: this .lpi = f.getLastPostInfo();
088: }
089:
090: public void setLastPostInfo(LastPostInfo lpi) {
091: this .lpi = lpi;
092: }
093:
094: public LastPostInfo getLastPostInfo() {
095: return this .lpi;
096: }
097:
098: public List getModeratorList() {
099: return ForumRepository.getModeratorList(this .id);
100: }
101:
102: /**
103: * Gets the forum's description
104: *
105: * @return String with the description
106: */
107: public String getDescription() {
108: return this .description;
109: }
110:
111: /**
112: * Gets the forum's ID
113: *
114: * @return int value representing the ID
115: */
116: public int getId() {
117: return this .id;
118: }
119:
120: /**
121: * Gets the category which the forum belongs to
122: *
123: * @return int value representing the ID of the category
124: */
125: public int getCategoryId() {
126: return this .idCategories;
127: }
128:
129: /**
130: * Gets the ID of the last post
131: *
132: * @return int value representing the ID of the post
133: */
134: public int getLastPostId() {
135: return this .lastPostId;
136: }
137:
138: /**
139: * Checks if is a moderated forum
140: *
141: * @return boolean value. <code>true</code> if the forum is moderated, <code>false</code> if not.
142: */
143: public boolean isModerated() {
144: return this .moderated;
145: }
146:
147: /**
148: * Gets the name of the forum
149: *
150: * @return String with the name
151: */
152: public String getName() {
153: return this .name;
154: }
155:
156: /**
157: * Gets the order
158: *
159: * @return int value representing the order of the forum
160: */
161: public int getOrder() {
162: return this .order;
163: }
164:
165: /**
166: * Gets the total number of topics posted in the forum
167: *
168: * @return int value with the total number of the topics
169: */
170: public int getTotalTopics() {
171: return this .totalTopics;
172: }
173:
174: public boolean getUnread() {
175: return this .unread;
176: }
177:
178: /**
179: * Sets the description.
180: *
181: * @param description The description to set
182: */
183: public void setDescription(String description) {
184: this .description = description;
185: }
186:
187: /**
188: * Sets the id.
189: *
190: * @param id The id to set
191: */
192: public void setId(int id) {
193: this .id = id;
194: }
195:
196: /**
197: * Sets the category id
198: *
199: * @param idCategories The ID of the category to set to the forum
200: */
201: public void setIdCategories(int idCategories) {
202: this .idCategories = idCategories;
203: }
204:
205: /**
206: * Sets the ID of the last post
207: *
208: * @param lastPostId The post id
209: */
210: public void setLastPostId(int lastPostId) {
211: this .lastPostId = lastPostId;
212: }
213:
214: /**
215: * Sets the moderated flag to the forum
216: *
217: * @param moderated <code>true</code> or <code>false</code>
218: */
219: public void setModerated(boolean moderated) {
220: this .moderated = moderated;
221: }
222:
223: /**
224: * Sets the name of the forum
225: *
226: * @param name The name to set
227: */
228: public void setName(String name) {
229: this .name = name;
230: }
231:
232: /**
233: * Sets the order.
234: *
235: * @param order The order to set
236: */
237: public void setOrder(int order) {
238: this .order = order;
239: }
240:
241: public void setUnread(boolean status) {
242: this .unread = status;
243: }
244:
245: /**
246: * Sets the total number of topics
247: *
248: * @param totalTopics int value with the total number of topics
249: */
250: public void setTotalTopics(int totalTopics) {
251: this .totalTopics = totalTopics;
252: }
253:
254: public int getTotalPosts() {
255: return this .totalPosts;
256: }
257:
258: public void setTotalPosts(int totalPosts) {
259: this .totalPosts = totalPosts;
260: }
261:
262: /**
263: * @see java.lang.Object#equals(java.lang.Object)
264: */
265: public boolean equals(Object o) {
266: return ((o instanceof Forum) && (((Forum) o).getId() == this .id));
267: }
268:
269: /**
270: * @see java.lang.Object#hashCode()
271: */
272: public int hashCode() {
273: return this .id;
274: }
275:
276: /**
277: * @see java.lang.Object#toString()
278: */
279: public String toString() {
280: return "[" + this .name + ", id=" + this .id + ", order="
281: + this .order + "]";
282: }
283: }
|