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: MenuDO.java,v $
031: * Revision 1.7 2005/10/02 14:08:58 colinmacleod
032: * Added/improved log4j logging.
033: *
034: * Revision 1.6 2005/09/29 13:22:47 colinmacleod
035: * Added read-only functionality to data object classes (with a check on each
036: * setter).
037: *
038: * Revision 1.5 2005/09/14 16:10:22 colinmacleod
039: * Removed unused local and class variables.
040: * Added serialVersionUID.
041: *
042: * Revision 1.4 2005/04/29 02:48:20 colinmacleod
043: * Data bugfixes.
044: * Changed primary key back to Integer.
045: *
046: * Revision 1.3 2005/04/10 20:10:05 colinmacleod
047: * Added new themes.
048: * Changed id type to String.
049: * Changed i tag to em and b tag to strong.
050: * Improved PicoContainerFactory with NanoContainer scripts.
051: *
052: * Revision 1.2 2005/04/09 17:19:58 colinmacleod
053: * Changed copyright text to GPL v2 explicitly.
054: *
055: * Revision 1.1.1.1 2005/03/10 17:51:32 colinmacleod
056: * Restructured ivata op around Hibernate/PicoContainer.
057: * Renamed ivata groupware.
058: *
059: * Revision 1.1 2004/09/30 15:16:04 colinmacleod
060: * Split off addressbook elements into security subproject.
061: *
062: * Revision 1.4 2004/07/13 19:41:16 colinmacleod
063: * Moved project to POJOs from EJBs.
064: * Applied PicoContainer to services layer (replacing session EJBs).
065: * Applied Hibernate to persistence layer (replacing entity EJBs).
066: *
067: * Revision 1.3 2004/03/21 21:16:19 colinmacleod
068: * Shortened name to ivata op.
069: *
070: * Revision 1.2 2004/02/01 22:00:34 colinmacleod
071: * Added full names to author tags
072: *
073: * Revision 1.1.1.1 2004/01/27 20:57:59 colinmacleod
074: * Moved ivata openportal to SourceForge..
075: *
076: * Revision 1.2 2003/10/15 13:49:57 colin
077: * fixing fo Xdoclet
078: *
079: * Revision 1.7 2003/02/24 19:27:17 colin
080: * restructured file paths
081: *
082: * Revision 1.6 2003/02/04 17:43:50 colin
083: * copyright notice
084: *
085: * Revision 1.5 2002/09/27 18:15:32 peter
086: * vector of menuItem ids added to menuDO and the appropriate changes to Menubean
087: *
088: * Revision 1.4 2002/09/11 15:00:05 colin
089: * improved documentation
090: *
091: * Revision 1.3 2002/08/19 13:48:58 colin
092: * added image to menu items
093: *
094: * Revision 1.2 2002/06/28 13:29:54 colin
095: * added comparison method.
096: *
097: * Revision 1.1 2002/06/13 11:21:57 colin
098: * first version with rose model integration.
099: * -----------------------------------------------------------------------------
100: */
101: package com.ivata.groupware.navigation.menu;
102:
103: import org.apache.log4j.Logger;
104:
105: import java.util.Set;
106:
107: import com.ivata.groupware.container.persistence.BaseDO;
108:
109: /**
110: * <p><code>EntityBean</code> to store the users menu system.</p>
111: *
112: * <p>This is a dependent value class, used to pass data back from the.</p>
113: * {@link MenuBean MenuBean} to a client application.</p>
114: *
115: * <p><strong>Note:</strong> This class provides data from {@link MenuBean MenuBean}.
116: * This is no local copy of the bean class, however, and changes here
117: * will not be automatically reflected in {@link MenuBean MenuBean}.</p>
118: *
119: * @since 2002-05-07
120: * @author Colin MacLeod
121: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
122: * @version $Revision: 1.7 $
123: * @see MenuBean
124: *
125: * @hibernate.class
126: * table="navigation_menu"
127: * @hibernate.cache
128: * usage="read-write"
129: */
130: public class MenuDO extends BaseDO {
131: /**
132: * Logger for this class.
133: */
134: private static final Logger logger = Logger.getLogger(MenuDO.class);
135:
136: /**
137: * Serialization version (for <code>Serializable</code> interface).
138: */
139: private static final long serialVersionUID = 1L;
140: /**
141: * <p>All the menu items under this menu.</p>
142: */
143: private Set items;
144: /**
145: * <p>Order in which this menu should appear, in relation to the other
146: * menus.<p>
147: */
148: private Integer priority;
149: /**
150: * <p>Text or caption which should appear on this menu.</p>
151: */
152: private String text;
153:
154: /**
155: * <p>Comparison method. See if the object supplied is a menu dependent
156: * object and, if so, whether or not its contents are the same as this one.
157: * Only the <code>id</code> fields are compared.</p>
158: *
159: * @param compare the object to compare with this one.
160: * @return <code>true</code> if the object supplied in <code>compare</code>
161: * is effectively the same as this one, otherwise false.
162: */
163: public boolean equals(final Object compare) {
164: if (logger.isDebugEnabled()) {
165: logger.debug("equals(Object compare = " + compare
166: + ") - start");
167: }
168:
169: // first check it is non-null and the class is right
170: if ((compare == null) || !(this .getClass().isInstance(compare))) {
171: if (logger.isDebugEnabled()) {
172: logger
173: .debug("equals(Object) - end - return value = " + false);
174: }
175: return false;
176: }
177: MenuDO menuDO = (MenuDO) compare;
178: Integer id = getId();
179: Integer menuDOId = menuDO.getId();
180:
181: // check that the ids are the same
182: boolean returnboolean = (((id == null) ? (menuDOId == null)
183: : id.equals(menuDOId)));
184: if (logger.isDebugEnabled()) {
185: logger.debug("equals(Object) - end - return value = "
186: + returnboolean);
187: }
188: return returnboolean;
189: }
190:
191: /**
192: * <p>Get all the menu items under this menu.</p>
193: *
194: * @return all items in this menu as a <code>Collection</code> of
195: * <code>MenuItemDO</code> instances.
196: *
197: * @hibernate.set
198: * sort="com.ivata.groupware.navigation.menu.item.MenuItemComparator"
199: * @hibernate.collection-key
200: * column="menu"
201: * @hibernate.collection-one-to-many
202: * class="com.ivata.groupware.navigation.menu.item.MenuItemDO"
203: */
204: public final Set getItems() {
205: if (logger.isDebugEnabled()) {
206: logger.debug("getItems() - start");
207: }
208:
209: if (logger.isDebugEnabled()) {
210: logger.debug("getItems() - end - return value = " + items);
211: }
212: return items;
213: }
214:
215: /**
216: * <p>Get the order in which this menu should appear, in relation to the other
217: * menus.<p>
218: *
219: * @return the order in which this menu should appear, in relation
220: * to the other menus. Lower values of this number will appear lower in the
221: * Set of menus (and are therefore more significant).
222: * @hibernate.property
223: */
224: public final Integer getPriority() {
225: if (logger.isDebugEnabled()) {
226: logger.debug("getPriority() - start");
227: }
228:
229: if (logger.isDebugEnabled()) {
230: logger.debug("getPriority() - end - return value = "
231: + priority);
232: }
233: return priority;
234: }
235:
236: /**
237: * <p>Get the text or caption which should appear on this menu.</p>
238: *
239: * @return the text or caption which should appear on this menu
240: * @hibernate.property
241: */
242: public final String getText() {
243: if (logger.isDebugEnabled()) {
244: logger.debug("getText() - start");
245: }
246:
247: if (logger.isDebugEnabled()) {
248: logger.debug("getText() - end - return value = " + text);
249: }
250: return text;
251: }
252:
253: /**
254: * <p>Set all the menu items under this menu.</p>
255: *
256: * @param items all items in this menu as a <code>Collection</code> of
257: * <code>MenuItemDO</code> instances.
258: */
259: public final void setItems(final Set items) {
260: if (logger.isDebugEnabled()) {
261: logger.debug("setItems(Set items = " + items + ") - start");
262: }
263:
264: checkSetter();
265: this .items = items;
266:
267: if (logger.isDebugEnabled()) {
268: logger.debug("setItems(Set) - end");
269: }
270: }
271:
272: /**
273: * <p>Set the order in which this menu should appear, in relation to the other
274: * menus.<p>
275: *
276: * @param priority the order in which this menu should appear, in relation
277: * to the other menus. Lower values of this number will appear lower in the
278: * list of menus (and are therefore more significant).
279: */
280: public final void setPriority(final Integer priority) {
281: if (logger.isDebugEnabled()) {
282: logger.debug("setPriority(Integer priority = " + priority
283: + ") - start");
284: }
285:
286: this .priority = priority;
287:
288: if (logger.isDebugEnabled()) {
289: logger.debug("setPriority(Integer) - end");
290: }
291: }
292:
293: /**
294: * <p>Set the text or caption which should appear on this menu.</p>
295: *
296: * @param text the text or caption which should appear on this menu
297: */
298: public final void setText(final String text) {
299: if (logger.isDebugEnabled()) {
300: logger.debug("setText(String text = " + text + ") - start");
301: }
302:
303: checkSetter();
304: this .text = text;
305:
306: if (logger.isDebugEnabled()) {
307: logger.debug("setText(String) - end");
308: }
309: }
310:
311: }
|