001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: TopicDO.java,v $
031: * Revision 1.4 2005/04/29 02:48:16 colinmacleod
032: * Data bugfixes.
033: * Changed primary key back to Integer.
034: *
035: * Revision 1.3 2005/04/10 20:31:57 colinmacleod
036: * Added new themes.
037: * Changed id type to String.
038: * Changed i tag to em and b tag to strong.
039: * Improved PicoContainerFactory with NanoContainer scripts.
040: *
041: * Revision 1.2 2005/04/09 17:19:46 colinmacleod
042: * Changed copyright text to GPL v2 explicitly.
043: *
044: * Revision 1.1.1.1 2005/03/10 17:52:06 colinmacleod
045: * Restructured ivata op around Hibernate/PicoContainer.
046: * Renamed ivata groupware.
047: *
048: * Revision 1.3 2004/07/13 19:47:29 colinmacleod
049: * Moved project to POJOs from EJBs.
050: * Applied PicoContainer to services layer (replacing session EJBs).
051: * Applied Hibernate to persistence layer (replacing entity EJBs).
052: *
053: * Revision 1.2 2004/03/21 21:16:29 colinmacleod
054: * Shortened name to ivata op.
055: *
056: * Revision 1.1.1.1 2004/01/27 20:58:43 colinmacleod
057: * Moved ivata openportal to SourceForge..
058: *
059: * Revision 1.2 2003/10/15 14:16:53 colin
060: * fixing for XDoclet
061: *
062: * Revision 1.2 2003/06/04 09:28:36 colin
063: * made comparable
064: *
065: * Revision 1.1 2003/02/24 19:09:24 colin
066: * moved to business
067: *
068: * Revision 1.4 2003/02/04 17:43:50 colin
069: * copyright notice
070: *
071: * Revision 1.3 2003/01/08 10:40:14 jano
072: * we changed interface of libraryBeans, we are using libraryRightBean for amending rights and for finding out
073: * and we are not storing rights in TopicDO
074: *
075: * Revision 1.2 2002/12/03 09:44:54 jano
076: * I added rights for TOPIC
077: *
078: * Revision 1.1 2002/11/28 14:12:15 jano
079: * we need because it's better pass one object as many Strings
080: *
081: * Revision 1.2 2002/11/26 14:56:31 jano
082: * -----------------------------------------------------------------------------
083: */
084: package com.ivata.groupware.business.library.topic;
085:
086: import com.ivata.groupware.container.persistence.BaseDO;
087:
088: /**
089: * <p>Represents a topic which can be used for a library item. Each library item
090: * in ivata groupware must have a topic associated with it, and this is important
091: * as access to each item is granted or denied on the basis of the topic
092: * associated with it.</p>
093: *
094: * @since 2002-11-26
095: * @author jano
096: * @version $Revision: 1.4 $
097: *
098: * @hibernate.class
099: * table="library_topic"
100: */
101: public class TopicDO extends BaseDO implements Comparable {
102:
103: /**
104: * <p>Briefly describes the topic in one line.</p>
105: */
106: private String caption;
107:
108: /**
109: * <p>Name of image file.</p>
110: */
111: private String image;
112:
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 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 id = getId();
133: Integer 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) : caption
142: .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 getCaption() {
167: return caption;
168: }
169:
170: /**
171: * <p>Name of image file.</p>
172: *
173: * @return image file name.
174: * @hibernate.property
175: */
176: public String getImage() {
177: return image;
178: }
179:
180: /**
181: * <p>Briefly describes the topic in one line.</p>
182: *
183: * @param caption new value of caption.
184: */
185: public final void setCaption(final String caption) {
186: this .caption = caption;
187: }
188:
189: /**
190: * <p>Name of image file.</p>
191: *
192: * @param image new image file name.
193: */
194: public final void setImage(final String image) {
195: this.image = image;
196: }
197: }
|