KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > addressbook > person > group > GroupDO


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: GroupDO.java,v $
31  * Revision 1.4 2005/04/28 18:47:10 colinmacleod
32  * Fixed XHMTL, styles and resin compatibility.
33  * Added support for URL rewriting.
34  *
35  * Revision 1.3 2005/04/10 20:09:36 colinmacleod
36  * Added new themes.
37  * Changed id type to String.
38  * Changed i tag to em and b tag to strong.
39  * Improved PicoContainerFactory with NanoContainer scripts.
40  *
41  * Revision 1.2 2005/04/09 17:19:07 colinmacleod
42  * Changed copyright text to GPL v2 explicitly.
43  *
44  * Revision 1.1.1.1 2005/03/10 17:50:31 colinmacleod
45  * Restructured ivata op around Hibernate/PicoContainer.
46  * Renamed ivata groupware.
47  *
48  * Revision 1.6 2004/12/31 18:22:13 colinmacleod
49  * Added override for displayValue.
50  *
51  * Revision 1.5 2004/11/12 15:57:05 colinmacleod
52  * Removed dependencies on SSLEXT.
53  * Moved Persistence classes to ivata masks.
54  *
55  * Revision 1.4 2004/07/13 19:41:13 colinmacleod
56  * Moved project to POJOs from EJBs.
57  * Applied PicoContainer to services layer (replacing session EJBs).
58  * Applied Hibernate to persistence layer (replacing entity EJBs).
59  *
60  * Revision 1.3 2004/03/21 21:16:06 colinmacleod
61  * Shortened name to ivata op.
62  *
63  * Revision 1.2 2004/02/01 22:00:32 colinmacleod
64  * Added full names to author tags
65  *
66  * Revision 1.1.1.1 2004/01/27 20:57:51 colinmacleod
67  * Moved ivata openportal to SourceForge..
68  *
69  * Revision 1.3 2003/10/17 12:36:12 jano
70  * fixing problems with building
71  * converting intranet -> portal
72  * Eclipse building
73  *
74  * Revision 1.2 2003/10/15 13:18:02 colin
75  * fixing for XDoclet
76  *
77  * Revision 1.3 2003/07/29 15:45:55 jano
78  * we have new field in groupDO
79  *
80  * Revision 1.2 2003/06/02 22:04:53 colin
81  * added comparison method
82  *
83  * Revision 1.1 2003/02/24 19:09:21 colin
84  * moved to business
85  *
86  * Revision 1.7 2003/02/04 17:43:45 colin
87  * copyright notice
88  *
89  * Revision 1.6 2003/01/10 10:29:23 jano
90  * we need information about user who created group
91  *
92  * Revision 1.5 2003/01/09 10:01:52 jano
93  * we are not storing group's rights in geoupDO now
94  * we are using methods in addressBookRightsBean
95  *
96  * Revision 1.4 2002/12/12 15:05:55 jano
97  * rights for groups
98  *
99  * Revision 1.3 2002/06/21 12:48:58 colin
100  * restructured com.ivata.groupware.web
101  *
102  * Revision 1.2 2002/06/17 07:28:54 colin
103  * improved and extended javadoc documentation
104  *
105  * Revision 1.1 2002/06/13 11:21:24 colin
106  * first version with rose model integration.
107  * -----------------------------------------------------------------------------
108  */

109 package com.ivata.groupware.business.addressbook.person.group;
110
111 import java.util.HashSet JavaDoc;
112 import java.util.Set JavaDoc;
113
114 import org.apache.log4j.Logger;
115
116 import com.ivata.groupware.business.addressbook.person.PersonDO;
117 import com.ivata.groupware.container.persistence.NamedDO;
118 import com.ivata.groupware.web.tree.TreeNode;
119
120 /**
121  * <p>Represents a group of people. This can be a company, a department or
122  * a team within the addressbook. On the basis of these groupings, access
123  * rights are assigned throughout the system.</p>
124  *
125  * @since 2002-05-15
126  * @author Colin MacLeod
127  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
128  * @version $Revision: 1.4 $
129  *
130  * @hibernate.class
131  * table="person_group"
132  * @hibernate.cache
133  * usage="read-write"
134  */

135 public class GroupDO extends NamedDO implements TreeNode {
136     /**
137      * Refer to {@link Logger}.
138      */

139     private static Logger logger = Logger.getLogger(GroupDO.class);
140     /**
141      * <p>Store a clear-text description of the function and purpose of this
142      * group.</p>
143      */

144     private String JavaDoc description;
145
146     /**
147      * <p>Store the the person who is head of this group. In the case
148      * where the group represents a company department, this should be the
149      * manager of that department.</p>
150      */

151     private PersonDO head;
152
153     /**
154      * <p>Store the name of the group. This name should uniquely identify the
155      * group in clear text.</p>
156      */

157     private String JavaDoc name;
158     /**
159      * <p>Parent group - group which contains this group.</p>
160      */

161     private GroupDO parent;
162
163     /**
164      * <p>All the people in this group.</p>
165      */

166     private Set JavaDoc people = new HashSet JavaDoc();
167
168     /**
169      * <p>All the users in this group.</p>
170      */

171     private Set JavaDoc users = new HashSet JavaDoc();
172
173     /**
174      * <p>
175      * Address book group - used to reference the address book this group is in.
176      * </p>
177      *
178      * @return Address book group - used to reference the address book this
179      * group is in.
180      */

181     public final GroupDO getAddressBook() {
182         // check this is not an address book itself
183
assert (parent != null);
184         if (GroupConstants.equals(getId(), GroupConstants.ADDRESS_BOOK)
185                 || GroupConstants.equals(GroupConstants.ADDRESS_BOOK,
186                         parent.getId())) {
187             return this;
188         }
189         GroupDO addressBook = this;
190         assert (addressBook.parent.parent != null);
191         
192         // go thro' all parents till we find the address book.
193
while (!GroupConstants.equals(
194                         addressBook.parent.parent.getId(),
195                         GroupConstants.ADDRESS_BOOK)) {
196             addressBook = addressBook.parent;
197             // if you get this, it is because the group tree has become unstable
198
// : this group has no parent which is an address book anywhere up
199
// the tree.
200
if (addressBook.parent.parent == null) {
201                 throw new NullPointerException JavaDoc("ERROR in GroupDO: the group "
202                         + "hierarchy is invalid: group '"
203                         + name
204                         + "' ("
205                         + getId()
206                         + ") has no address book as a parent.");
207             }
208         }
209         return addressBook;
210     }
211
212     /**
213      * <p>Get a clear-text description of the function and purpose of this
214      * group.</p>
215      *
216      * @return a clear-text description of the function and purpose of this
217      * group.
218      * @hibernate.property
219      */

220     public final String JavaDoc getDescription() {
221         return description;
222     }
223
224     /**
225      * <p>
226      * For a group, the value displayed in a choice box is just the name,
227      * </p>
228      *
229      * @see com.ivata.mask.valueobject.ValueObject#getDisplayValue()
230      */

231     public final String JavaDoc getDisplayValue() {
232         return name;
233     }
234
235     /**
236      * <p>Get the the person who is head of this group. In the case where
237      * the group represents a company department, this should be the manager of
238      * that department.</p>
239      *
240      * @return the the person who is head of this group.
241      * @hibernate.many-to-one
242      */

243     public PersonDO getHead() {
244         return head;
245     }
246     /**
247      * <p>Get the name of the group. This name should uniquely identify the
248      * group within its place in the heirarchy in clear text.</p>
249      *
250      * @return the name of this group, a clear-text string which identifies the
251      * group uniquely within its place in the group heirarchy.
252      * @hibernate.property
253      * column="name"
254      */

255     public final String JavaDoc getName() {
256         return name;
257     }
258
259     /**
260      * <p>
261      * Get the parent group of this group - the group which contains this one.
262      * </p>
263      *
264      * @return the parent group of this group.
265      * @hibernate.many-to-one
266      * column="parent"
267      */

268     public final GroupDO getParent () {
269         return parent;
270     }
271
272     /**
273      * <p>All the people in this group.</p>
274      *
275      * @return the people in this group.
276      *
277      * @hibernate.set
278      * @hibernate.collection-key
279      * column="person_group"
280      * @hibernate.collection-one-to-many
281      * cascade="all"
282      * class="com.ivata.groupware.business.addressbook.person.PersonDO"
283      */

284     public final Set JavaDoc getPeople() {
285         return people;
286     }
287
288     /**
289      * <p>All the users in this group.</p>
290      *
291      * @return the users in this group.
292      *
293      * @hibernate.set
294      * role="person_user"
295      * table="person_group_member"
296      * @hibernate.collection-key
297      * column="person_group"
298      * @hibernate.collection-many-to-many
299      * class="com.ivata.groupware.admin.security.user.UserDO"
300      * column="person_user"
301      */

302     public final Set JavaDoc getUsers() {
303         return users;
304     }
305
306     /**
307      * <p>Set a clear-text description of the function and purpose of this
308      * group.</p>
309      *
310      * @param description a clear-text description of the function and purpose
311      * of this group.
312      */

313     public final void setDescription(final String JavaDoc description) {
314         this.description = description;
315     }
316     /**
317      * <p>Set the person who is head of this group. In the case where
318      * the group represents a company department, this should be the manager of
319      * that department.</p>
320      *
321      * @param headParam the person who is head of this group.
322      */

323     public void setHead(PersonDO headParam) {
324         if (logger.isDebugEnabled()) {
325             logger.debug("setHead before: '" + head + "', after: '"
326                     + headParam + "'");
327         }
328
329         head = headParam;
330     }
331     /**
332      * <p>Set the name of the group. This name should uniquely identify the
333      * group in clear text.</p>
334      *
335      * @param nameParam the new name to set for this group.
336      */

337     public void setName(String JavaDoc nameParam) {
338         if (logger.isDebugEnabled()) {
339             logger.debug("setName before: '" + name + "', after: '"
340                     + nameParam + "'");
341         }
342
343         name = nameParam;
344     }
345     /**
346      * <p>Set the parent of this group.</p>
347      *
348      * @param parentParam the parent of this group.
349      */

350     public void setParent(GroupDO parentParam) {
351         if (logger.isDebugEnabled()) {
352             logger.debug("setParent before: '" + parent
353                     + "', after: '" + parentParam + "'");
354         }
355
356         parent = parentParam;
357     }
358     /**
359      * <p>All the people in this group.</p>
360      *
361      * @param peopleParam the people in this group.
362      */

363     public void setPeople(Set JavaDoc peopleParam) {
364         if (logger.isDebugEnabled()) {
365             logger.debug("setPeople before: '" + people
366                     + "', after: '" + peopleParam + "'");
367         }
368
369         people = peopleParam;
370     }
371     /**
372      * <p>All the users in this group.</p>
373      *
374      * @param usersParam the users in this group.
375      */

376     public void setUsers(Set JavaDoc usersParam) {
377         if (logger.isDebugEnabled()) {
378             logger.debug("setUsers before: '" + users
379                     + "', after: '" + usersParam+ "'");
380         }
381
382         users = usersParam;
383     }
384 }
385
Popular Tags