001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-hbm/src/java/org/sakaiproject/component/app/messageforums/dao/hibernate/AreaImpl.java $
003: * $Id: AreaImpl.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006, 2007 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.component.app.messageforums.dao.hibernate;
021:
022: import java.util.HashSet;
023: import java.util.List;
024: import java.util.Set;
025: import java.util.TreeSet;
026:
027: import org.apache.commons.logging.Log;
028: import org.apache.commons.logging.LogFactory;
029: import org.sakaiproject.api.app.messageforums.Area;
030: import org.sakaiproject.api.app.messageforums.BaseForum;
031: import org.sakaiproject.api.app.messageforums.DBMembershipItem;
032:
033: public class AreaImpl extends MutableEntityImpl implements Area {
034:
035: private static final Log LOG = LogFactory.getLog(AreaImpl.class);
036:
037: private String contextId;
038:
039: private String name;
040:
041: private Boolean hidden;
042:
043: private Boolean locked;
044:
045: private Boolean moderated;
046:
047: private Boolean enabled;
048:
049: private String typeUuid;
050:
051: //private List openForums = new UniqueArrayList();
052: //private List privateForums = new UniqueArrayList();
053: //private List discussionForums = new UniqueArrayList();
054:
055: private Set openForumsSet;// = new HashSet();
056: private Set privateForumsSet;// = new HashSet();
057: private Set discussionForumsSet;// = new HashSet();
058: private Set membershipItemSet;
059:
060: public void setVersion(Integer version) {
061: this .version = version;
062: }
063:
064: public String getContextId() {
065: return contextId;
066: }
067:
068: public void setContextId(String contextId) {
069: this .contextId = contextId;
070: }
071:
072: public Boolean getHidden() {
073: return hidden;
074: }
075:
076: public void setHidden(Boolean hidden) {
077: this .hidden = hidden;
078: }
079:
080: public String getName() {
081: return name;
082: }
083:
084: public void setName(String name) {
085: this .name = name;
086: }
087:
088: public String getTypeUuid() {
089: return typeUuid;
090: }
091:
092: public void setTypeUuid(String typeUuid) {
093: this .typeUuid = typeUuid;
094: }
095:
096: public Boolean getEnabled() {
097: return enabled;
098: }
099:
100: public void setEnabled(Boolean enabled) {
101: this .enabled = enabled;
102: }
103:
104: public List getOpenForums() {
105: return Util.setToList(openForumsSet);
106: }
107:
108: public void setOpenForums(List openForums) {
109: this .openForumsSet = Util.listToSet(openForums);
110: }
111:
112: public List getPrivateForums() {
113: return Util.setToList(privateForumsSet);
114: }
115:
116: public void setPrivateForums(List privateForums) {
117: this .privateForumsSet = Util.listToSet(privateForums);
118: }
119:
120: public List getDiscussionForums() {
121: return Util.setToList(discussionForumsSet);
122: }
123:
124: public void setDiscussionForums(List discussionForums) {
125: this .discussionForumsSet = Util.listToSet(discussionForums);
126: }
127:
128: public String toString() {
129: //return "Area.id:" + id;
130: return "Area/" + id;
131: }
132:
133: public Boolean getLocked() {
134: return locked;
135: }
136:
137: public void setLocked(Boolean locked) {
138: this .locked = locked;
139: }
140:
141: public Boolean getModerated() {
142: return moderated;
143: }
144:
145: public void setModerated(Boolean moderated) {
146: this .moderated = moderated;
147: }
148:
149: public Set getDiscussionForumsSet() {
150: return discussionForumsSet;
151: }
152:
153: public void setDiscussionForumsSet(Set discussionForumsSet) {
154: this .discussionForumsSet = discussionForumsSet;
155: }
156:
157: public Set getOpenForumsSet() {
158: return openForumsSet;
159: }
160:
161: public void setOpenForumsSet(Set openForumsSet) {
162: this .openForumsSet = openForumsSet;
163: }
164:
165: public Set getPrivateForumsSet() {
166: return privateForumsSet;
167: }
168:
169: public void setPrivateForumsSet(Set privateForumsSet) {
170: this .privateForumsSet = privateForumsSet;
171: }
172:
173: public Set getMembershipItemSet() {
174: return membershipItemSet;
175: }
176:
177: public void setMembershipItemSet(Set membershipItemSet) {
178: this .membershipItemSet = membershipItemSet;
179: }
180:
181: ////////////////////////////////////////////////////////////////////////
182: // helper methods for collections
183: ////////////////////////////////////////////////////////////////////////
184:
185: public void addPrivateForum(BaseForum forum) {
186: if (LOG.isDebugEnabled()) {
187: LOG.debug("addPrivateForum(forum " + forum + ")");
188: }
189:
190: if (forum == null) {
191: throw new IllegalArgumentException("forum == null");
192: }
193:
194: if (privateForumsSet == null) {
195: privateForumsSet = new TreeSet();
196: }
197: forum.setArea(this );
198: privateForumsSet.add(forum);
199: }
200:
201: public void removePrivateForum(BaseForum forum) {
202: if (LOG.isDebugEnabled()) {
203: LOG.debug("removePrivateForum(forum " + forum + ")");
204: }
205:
206: if (forum == null) {
207: throw new IllegalArgumentException(
208: "Illegal topic argument passed!");
209: }
210:
211: forum.setArea(null);
212: privateForumsSet.remove(forum);
213: }
214:
215: public void addDiscussionForum(BaseForum forum) {
216: if (LOG.isDebugEnabled()) {
217: LOG.debug("addForum(forum " + forum + ")");
218: }
219:
220: if (forum == null) {
221: throw new IllegalArgumentException("forum == null");
222: }
223:
224: if (discussionForumsSet == null) {
225: discussionForumsSet = new TreeSet();
226: }
227: forum.setArea(this );
228: discussionForumsSet.add(forum);
229: }
230:
231: public void removeDiscussionForum(BaseForum forum) {
232: if (LOG.isDebugEnabled()) {
233: LOG.debug("removeDiscussionForum(forum " + forum + ")");
234: }
235:
236: if (forum == null) {
237: throw new IllegalArgumentException(
238: "Illegal topic argument passed!");
239: }
240:
241: forum.setArea(null);
242: discussionForumsSet.remove(forum);
243: openForumsSet.remove(forum);
244: }
245:
246: public void addOpenForum(BaseForum forum) {
247: if (LOG.isDebugEnabled()) {
248: LOG.debug("addOpenForum(forum " + forum + ")");
249: }
250:
251: if (forum == null) {
252: throw new IllegalArgumentException("forum == null");
253: }
254:
255: if (openForumsSet == null) {
256: openForumsSet = new TreeSet();
257: }
258: forum.setArea(this );
259: openForumsSet.add(forum);
260: }
261:
262: public void removeOpenForum(BaseForum forum) {
263: if (LOG.isDebugEnabled()) {
264: LOG.debug("removeOpenForum(forum " + forum + ")");
265: }
266:
267: if (forum == null) {
268: throw new IllegalArgumentException(
269: "Illegal topic argument passed!");
270: }
271:
272: forum.setArea(null);
273: openForumsSet.remove(forum);
274: }
275:
276: public void addMembershipItem(DBMembershipItem item) {
277: if (LOG.isDebugEnabled()) {
278: LOG.debug("addMembershipItem(item " + item + ")");
279: }
280:
281: if (item == null) {
282: throw new IllegalArgumentException("item == null");
283: }
284:
285: if (membershipItemSet == null) {
286: membershipItemSet = new HashSet();
287: }
288: membershipItemSet.add(item);
289: }
290:
291: public void removeMembershipItem(DBMembershipItem item) {
292: if (LOG.isDebugEnabled()) {
293: LOG.debug("removeMembershipItem(item " + item + ")");
294: }
295:
296: if (item == null) {
297: throw new IllegalArgumentException(
298: "Illegal level argument passed!");
299: }
300:
301: membershipItemSet.remove(item);
302: }
303:
304: }
|