KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > library > topic > TopicDO


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: TopicDO.java,v $
31  * Revision 1.4 2005/04/29 02:48:16 colinmacleod
32  * Data bugfixes.
33  * Changed primary key back to Integer.
34  *
35  * Revision 1.3 2005/04/10 20:31:57 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:46 colinmacleod
42  * Changed copyright text to GPL v2 explicitly.
43  *
44  * Revision 1.1.1.1 2005/03/10 17:52:06 colinmacleod
45  * Restructured ivata op around Hibernate/PicoContainer.
46  * Renamed ivata groupware.
47  *
48  * Revision 1.3 2004/07/13 19:47:29 colinmacleod
49  * Moved project to POJOs from EJBs.
50  * Applied PicoContainer to services layer (replacing session EJBs).
51  * Applied Hibernate to persistence layer (replacing entity EJBs).
52  *
53  * Revision 1.2 2004/03/21 21:16:29 colinmacleod
54  * Shortened name to ivata op.
55  *
56  * Revision 1.1.1.1 2004/01/27 20:58:43 colinmacleod
57  * Moved ivata openportal to SourceForge..
58  *
59  * Revision 1.2 2003/10/15 14:16:53 colin
60  * fixing for XDoclet
61  *
62  * Revision 1.2 2003/06/04 09:28:36 colin
63  * made comparable
64  *
65  * Revision 1.1 2003/02/24 19:09:24 colin
66  * moved to business
67  *
68  * Revision 1.4 2003/02/04 17:43:50 colin
69  * copyright notice
70  *
71  * Revision 1.3 2003/01/08 10:40:14 jano
72  * we changed interface of libraryBeans, we are using libraryRightBean for amending rights and for finding out
73  * and we are not storing rights in TopicDO
74  *
75  * Revision 1.2 2002/12/03 09:44:54 jano
76  * I added rights for TOPIC
77  *
78  * Revision 1.1 2002/11/28 14:12:15 jano
79  * we need because it's better pass one object as many Strings
80  *
81  * Revision 1.2 2002/11/26 14:56:31 jano
82  * -----------------------------------------------------------------------------
83  */

84 package com.ivata.groupware.business.library.topic;
85
86 import com.ivata.groupware.container.persistence.BaseDO;
87
88
89 /**
90  * <p>Represents a topic which can be used for a library item. Each library item
91  * in ivata groupware must have a topic associated with it, and this is important
92  * as access to each item is granted or denied on the basis of the topic
93  * associated with it.</p>
94  *
95  * @since 2002-11-26
96  * @author jano
97  * @version $Revision: 1.4 $
98  *
99  * @hibernate.class
100  * table="library_topic"
101  */

102 public class TopicDO extends BaseDO implements Comparable JavaDoc {
103
104     /**
105      * <p>Briefly describes the topic in one line.</p>
106      */

107     private String JavaDoc caption;
108
109     /**
110      * <p>Name of image file.</p>
111      */

112     private String JavaDoc image;
113     /**
114      * <p>Comparison method. See if the object supplied is a topic dependent
115      * object and, if so, whether or not its contents are greater than, the same
116      * or less than this one.</p>
117      *
118      * <p>This method sorts by the caption first then the id.</p>
119      *
120      * @param compare the object to compare with this one.
121      * @return a positive number if the object supplied in <code>compare</code>
122      * is greater than this one, <code>0</code> if they are the same,
123      * otherwise a negative number.
124      */

125     public int compareTo(final Object JavaDoc compare) {
126         // first check it is non-null and the class is right
127
if ((compare == null) || !(this.getClass().isInstance(compare))) {
128             return 1;
129         }
130
131         TopicDO topicDO = (TopicDO) compare;
132         Integer JavaDoc id = getId();
133         Integer JavaDoc topicId = topicDO.getId();
134
135         // see the ids are the same
136
if (((id == null) ? (topicId == null) : id.equals(topicId))) {
137             return 0;
138         }
139
140         // see if the captions are equal - if so, use the id
141
if (((caption == null) ? (topicDO.caption == null)
142                                    : caption.equals(topicDO.caption))) {
143             // if the id is null and the other id is not null, return +ve
144
if (id == null) {
145                 return 1;
146             }
147
148             return 0;
149         }
150
151         // if the name is null and the other name is not null, return +ve
152
if (caption == null) {
153             return 1;
154         }
155
156         // otherwise, compare the names
157
return caption.compareTo(topicDO.caption);
158     }
159
160     /**
161      * <p>Briefly describes the topic in one line.</p>
162      *
163      * @return current value of caption.
164      * @hibernate.property
165      */

166     public final String JavaDoc getCaption() {
167         return caption;
168     }
169     /**
170      * <p>Name of image file.</p>
171      *
172      * @return image file name.
173      * @hibernate.property
174      */

175     public String JavaDoc getImage() {
176         return image;
177     }
178
179     /**
180      * <p>Briefly describes the topic in one line.</p>
181      *
182      * @param caption new value of caption.
183      */

184     public final void setCaption(final String JavaDoc caption) {
185         this.caption = caption;
186     }
187
188     /**
189      * <p>Name of image file.</p>
190      *
191      * @param image new image file name.
192      */

193     public final void setImage(final String JavaDoc image) {
194         this.image = image;
195     }
196 }
197
Popular Tags