KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > model > core > MenuItem


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.model.core;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Comparator JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24
25
26 /**
27  * <p>Menu item -- an element of menu.</p>
28  * <p>
29  * Menu item points to some page, linkable object, content resource or external
30  * source. Resulting URL is computed from <b>action</b>, <b>forward</b> and
31  * <b>location</b>.
32  * </p>
33  * <p>
34  * There are several layers on which menu items may be defined. Base layer
35  * consists of all items that are defined in configurational files. Such items
36  * cannot be edited. Next layer if formed with menu items that belong to
37  * {@link Layout}. Final layer exists only for {@link ContentPage}s and consists
38  * of menu items that were defined for some content page.
39  * </p>
40  * <p>
41  * Each menu item may have child menu items. For each menu item visibility is
42  * defined. This can be visible, invisible, heritable. Heritable visibility
43  * means that this menu item will have the same visibility as on previous layer.
44  * </p>
45  * <p>
46  * Menu item may actually be a redefinition. Redefinition is created when
47  * user 'edits' some menu item on layer different from that on which it was
48  * defined. Redefinition, in turn, may be redefined. Redefinition just changes
49  * some properties (currently visibility and position) of original menu item.
50  * </p>
51  * <p>
52  * Position specifies place in which menu item will be displayed in menu. If
53  * position is not specified (is <code>null</code>), than such menu item will
54  * be placed in the end of menu.
55  * </p>
56  * <p><a HREF="MenuItem.java.htm"><i>View Source</i></a>
57  * </p>
58  * <p/>
59  *
60  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
61  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
62  * @version $Revision: 1.47 $ $Date: 2006/03/15 11:22:06 $
63  * @struts.form include-all="false" extends="BaseForm"
64  * @hibernate.class table="`al_core_menu_item`" lazy="false"
65  */

66 public class MenuItem extends BaseObject {
67
68     /**
69      * The visibility of menu item is inherited from the parent
70      */

71     public static final byte VISIBILITY_HERITABLE = 0;
72     /**
73      * Menu item is visible
74      */

75     public static final byte VISIBILITY_VISIBLE = 1;
76     /**
77      * Menu item is onvisible
78      */

79     public static final byte VISIBILITY_INVISIBLE = 2;
80
81     /**
82      * Constants for alignment of menu item. These are the same as those that
83      * defined for HTML 'align' attribute
84      */

85     public static final String JavaDoc ALIGN_LEFT = "left";
86     public static final String JavaDoc ALIGN_RIGHT = "right";
87     public static final String JavaDoc ALIGN_ABS_BOTTOM = "absBottom";
88     public static final String JavaDoc ALIGN_ABS_MIDDLE = "absMiddle";
89     public static final String JavaDoc ALIGN_BASELINE = "baseline";
90     public static final String JavaDoc ALIGN_BOTTOM = "bottom";
91     public static final String JavaDoc ALIGN_MIDDLE = "middle";
92     public static final String JavaDoc ALIGN_TEXT_TOP = "textTop";
93     public static final String JavaDoc ALIGN_TOP = "top";
94
95     /**
96      * Comparator that compares menu items by their positions
97      */

98     public static final Comparator JavaDoc POSITION_COMPARATOR = new Comparator JavaDoc() {
99         public int compare(Object JavaDoc o1, Object JavaDoc o2) {
100             if ( !(o1 instanceof MenuItem) || !(o2 instanceof MenuItem) ) {
101                 throw new ClassCastException JavaDoc("Cannot compare instance of " + o1.getClass().getName() + " to the instance of " + o2.getClass().getName());
102             }
103             MenuItem item1 = (MenuItem) o1;
104             MenuItem item2 = (MenuItem) o2;
105             return item1.getPosition().compareTo(item2.getPosition());
106         }
107     };
108
109     //~ Instance variables
110

111     /**
112      * ID of this menu item
113      */

114     protected Long JavaDoc id;
115
116     /**
117      * Parent item
118      */

119     protected MenuItem parentItem;
120
121     /**
122      * List of child items
123      */

124     protected List JavaDoc childItems = new ArrayList JavaDoc();
125
126     /**
127      * Identifier of this menu item (corresponds to 'name' in MenuComponent)
128      * Must be <code>null</code> for redefinitions
129      */

130     protected String JavaDoc identifier;
131
132     /**
133      * Align menu 'left','right','top','bottom' ...and other alignment of particular menu system
134      */

135     protected String JavaDoc align;
136
137     /**
138      * Style to apply to element that renders this item on the View layer (primarily, CSS-style, but there is no restriction)
139      */

140     protected String JavaDoc style;
141
142     /**
143      * Style class to apply to element that renders this item on the View layer (primarily, CSS-class, but there is no restriction)
144      */

145     protected String JavaDoc styleClass;
146
147     /**
148      * ID of element that renderes this item on the View layer (e.g. value of HTML "id" element)
149      */

150     protected String JavaDoc styleId;
151
152     /**
153      * Image for this menu item
154      */

155     protected String JavaDoc image;
156
157     /**
158      * Alternate image for this menu item
159      */

160     protected String JavaDoc altImage;
161
162     /**
163      * Holds value of property action, that is, Struts Logical Action Name.
164      */

165     protected String JavaDoc action;
166
167     /**
168      * Holds value of property action, that is, Struts Global Action Forward Name.
169      */

170     protected String JavaDoc forward;
171
172     /**
173      * Holds value of property location.
174      */

175     protected String JavaDoc location;
176
177     /**
178      * Whether or not location is external
179      */

180     protected Boolean JavaDoc externalLocation = Boolean.FALSE;
181
182     /**
183      * Holds value of property page.
184      */

185     protected String JavaDoc anchor;
186
187     /**
188      * Target window to open menu link in
189      */

190     protected String JavaDoc target;
191
192     /**
193      * Visibility on current layer. Menu item can be visible or invisible on curernt layer, or its behaviour
194      * can be the same as its equivalent on parent layer
195      */

196     protected Byte JavaDoc visibility;
197
198     /**
199      * Position of menu item in list. Can be null, it means that menu item will be at the end of the list
200      */

201     protected Integer JavaDoc position;
202
203     /**
204      * 'onlick' JavaScript event handler for this menu item
205      */

206     protected String JavaDoc onclick;
207
208     /**
209      * 'onmouseover' JavaScript event handler for this menu item
210      */

211     protected String JavaDoc onmouseover;
212
213     /**
214      * 'onmouseout JavaScript event handler for this menu item
215      */

216     protected String JavaDoc onmouseout;
217
218     /**
219      * List of allowed user roles
220      */

221     protected List JavaDoc roles = new ArrayList JavaDoc();
222
223     /**
224      * Link to menu item, for which this item is redefinition
225      */

226     protected MenuItem origItem;
227
228     /**
229      * List of redefinition items
230      */

231     protected List JavaDoc redefinitionItems = new ArrayList JavaDoc();
232
233     /**
234      * Owner of this menu item. Owner acts as a layer
235      */

236     protected Localizable owner;
237
238     // localizable fields
239

240     /**
241      * Map of titles for different locales
242      */

243     protected Map JavaDoc title = new HashMap JavaDoc();
244
245     /**
246      * Map of tooltips for different locales
247      */

248     protected Map JavaDoc toolTip = new HashMap JavaDoc();
249
250     /**
251      * Version of this menu item
252      */

253     protected Long JavaDoc version;
254
255     /**
256      * List of pages linked with this item
257      */

258     protected List JavaDoc linkedPages = new ArrayList JavaDoc();
259
260     /**
261      * List of resources linked with this item
262      */

263     protected List JavaDoc linkedResources = new ArrayList JavaDoc();
264
265
266     //~ Methods
267

268     /**
269      * Returns the id of the menu item
270      *
271      * @return id
272      * @struts.form-field
273      * @hibernate.id column="`id`"
274      * generator-class="increment" unsaved-value="null"
275      */

276     public Long JavaDoc getId() {
277         return id;
278     }
279
280     /**
281      * Sets id of the menu item
282      *
283      * @param id the id to be set
284      */

285     public void setId(Long JavaDoc id) {
286         this.id = id;
287     }
288
289     /**
290      * Returns the parent menu item
291      *
292      * @return parent folder
293      * @hibernate.many-to-one column="`parent_id`" not-null="false" outer-join="false" lazy="false"
294      */

295     public MenuItem getParentItem() {
296         return parentItem;
297     }
298
299     /**
300      * Sets the parent menu item
301      *
302      * @param parentItem parent menu item
303      */

304     public void setParentItem(MenuItem parentItem) {
305         this.parentItem = parentItem;
306     }
307
308     /**
309      * Returns list of child items of this menu item
310      *
311      * @return list of child items
312      * @hibernate.bag name="childItems" inverse="true" lazy="true" cascade="delete" order-by="`pos`" outer-join="false"
313      * @hibernate.collection-key column="`parent_id`"
314      * @hibernate.collection-one-to-many class="com.blandware.atleap.model.core.MenuItem"
315      */

316     public List JavaDoc getChildItems() {
317         return childItems;
318     }
319
320     /**
321      * Sets list of child items of this menu item
322      *
323      * @param childItems list of child items
324      */

325     public void setChildItems(List JavaDoc childItems) {
326         this.childItems = childItems;
327     }
328
329     /**
330      * Returns the identifier of the menu item
331      *
332      * @return identifier
333      * @hibernate.property
334      * @hibernate.column name="`identifier`" not-null="false" unique="false" length="252"
335      */

336     public String JavaDoc getIdentifier() {
337         return identifier;
338     }
339
340     /**
341      * Sets the identifier of the menu item
342      *
343      * @param identifier the identifier to set
344      */

345     public void setIdentifier(String JavaDoc identifier) {
346         this.identifier = identifier;
347     }
348
349     /**
350      * Returns the align 'left','right','top','bottom' ...and other alignment of particular menu system.
351      *
352      * @return align
353      * @struts.form-field
354      * @hibernate.property
355      * @hibernate.column name="`align`" not-null="false" unique="false" length="252"
356      */

357     public String JavaDoc getAlign() {
358         return align;
359     }
360
361     /**
362      * Sets the align of this menu item
363      *
364      * @param align the align to set
365      */

366     public void setAlign(String JavaDoc align) {
367         this.align = align;
368     }
369
370
371     /**
372      * Returns the CSS-style of this menu item
373      *
374      * @return CSS-style
375      * @struts.form-field
376      * @hibernate.property
377      * @hibernate.column name="`style`" not-null="false" unique="false" length="252"
378      */

379     public String JavaDoc getStyle() {
380         return style;
381     }
382
383     /**
384      * Sets the CSS-style of this menu item
385      *
386      * @param style CSS-style
387      */

388     public void setStyle(String JavaDoc style) {
389         this.style = style;
390     }
391
392     /**
393      * Returns the style class of this menu item
394      *
395      * @return style class
396      * @struts.form-field
397      * @hibernate.property
398      * @hibernate.column name="`style_class`" not-null="false" unique="false" length="252"
399      */

400     public String JavaDoc getStyleClass() {
401         return styleClass;
402     }
403
404     /**
405      * Sets the style class of this menu item
406      *
407      * @param styleClass the style class to set
408      */

409     public void setStyleClass(String JavaDoc styleClass) {
410         this.styleClass = styleClass;
411     }
412
413     /**
414      * Returns the style ID of this menu item
415      *
416      * @return style ID
417      * @struts.form-field
418      * @hibernate.property
419      * @hibernate.column name="`style_id`" not-null="false" unique="false" length="252"
420      */

421     public String JavaDoc getStyleId() {
422         return styleId;
423     }
424
425     /**
426      * Sets the style ID of this menu item
427      *
428      * @param styleId the style ID to set
429      */

430     public void setStyleId(String JavaDoc styleId) {
431         this.styleId = styleId;
432     }
433
434     /**
435      * Returns the URL of image that corresponds to this menu item
436      *
437      * @return URL of image
438      * @struts.form-field
439      * @hibernate.property
440      * @hibernate.column name="`image`" not-null="false" unique="false" length="252"
441      */

442     public String JavaDoc getImage() {
443         return image;
444     }
445
446     /**
447      * Sets the URL of image
448      *
449      * @param image URL of image
450      */

451     public void setImage(String JavaDoc image) {
452         this.image = image;
453     }
454
455     /**
456      * Returns the URL of alternative image that corresponds to this menu item
457      *
458      * @return URL of alternative image
459      * @struts.form-field
460      * @hibernate.property
461      * @hibernate.column name="`alt_image`" not-null="false" unique="false" length="252"
462      */

463     public String JavaDoc getAltImage() {
464         return altImage;
465     }
466
467     /**
468      * Sets the URL of alternative image
469      *
470      * @param altImage URL of alternative image
471      */

472     public void setAltImage(String JavaDoc altImage) {
473         this.altImage = altImage;
474     }
475
476
477     /**
478      * Gets name of Struts Action that is triggered when user activates this menu item
479      *
480      * @return name of Struts Action
481      * @hibernate.property
482      * @hibernate.column name="`action`" not-null="false" unique="false" length="252"
483      */

484     public String JavaDoc getAction() {
485         return action;
486     }
487
488     /**
489      * Sets name of Struts Action that is triggered when user activates this menu item
490      *
491      * @param action name of Struts Action
492      */

493     public void setAction(String JavaDoc action) {
494         this.action = action;
495     }
496
497     /**
498      * Gets name of Struts Global Action Forward that is used when user activates this menu item
499      *
500      * @return String name of Struts Global Action Forward
501      * @hibernate.property
502      * @hibernate.column name="`forward`" not-null="false" unique="false" length="252"
503      */

504     public String JavaDoc getForward() {
505         return forward;
506     }
507
508     /**
509      * Sets name of Struts Global Action Forward that is used when user activates this menu item
510      *
511      * @param forward name of Struts Global Action Forward
512      */

513     public void setForward(String JavaDoc forward) {
514         this.forward = forward;
515     }
516
517     /**
518      * Gets concrete location
519      *
520      * @return location
521      * @struts.form-field
522      * @hibernate.property
523      * @hibernate.column name="`location`" not-null="false" unique="false" length="252"
524      */

525     public String JavaDoc getLocation() {
526         return location;
527     }
528
529     /**
530      * Sets concrete location
531      *
532      * @param location the location to set
533      */

534     public void setLocation(String JavaDoc location) {
535         this.location = location;
536     }
537
538     /**
539      * Gets whether the location is external
540      *
541      * @return whether the location is external
542      * @hibernate.property column="`external_location`" not-null="true" type="true_false"
543      */

544     public Boolean JavaDoc getExternalLocation() {
545         return externalLocation;
546     }
547
548     /**
549      * Sets whether the location is external
550      *
551      * @param externalLocation whether the location is external
552      */

553     public void setExternalLocation(Boolean JavaDoc externalLocation) {
554         this.externalLocation = externalLocation;
555     }
556
557     /**
558      * Gets name of link on page where this item is displayed
559      *
560      * @return name of anchor
561      * @hibernate.property
562      * @hibernate.column name="`anchor`" not-null="false" unique="false" length="252"
563      */

564     public String JavaDoc getAnchor() {
565         return anchor;
566     }
567
568     /**
569      * Sets name of link on page where this item is displayed
570      *
571      * @param anchor the name of anchor
572      */

573     public void setAnchor(String JavaDoc anchor) {
574         this.anchor = anchor;
575     }
576
577
578     /**
579      * Returns the target of the link
580      *
581      * @return target of the link
582      * @struts.form-field
583      * @hibernate.property
584      * @hibernate.column name="`target`" not-null="false" unique="false" length="252"
585      */

586     public String JavaDoc getTarget() {
587         return target;
588     }
589
590     /**
591      * Sets target of the link
592      *
593      * @param target target of the link
594      */

595     public void setTarget(String JavaDoc target) {
596         this.target = target;
597     }
598
599
600     /**
601      * Returns visibility of this menu item
602      *
603      * @return visibility
604      * @struts.form-field
605      * @hibernate.property
606      * @hibernate.column name="`visibility`" not-null="true" unique="false"
607      */

608     public Byte JavaDoc getVisibility() {
609         return visibility;
610     }
611
612     /**
613      * Sets visibility of this menu item
614      *
615      * @param visibility the visibility to set
616      */

617     public void setVisibility(Byte JavaDoc visibility) {
618         this.visibility = visibility;
619     }
620
621     /**
622      * Returns <code>true</code> if this menu item is visible on current layer
623      *
624      * @return boolean whether this menu item is visible on current layer
625      */

626     public boolean isVisible() {
627         return visibility.byteValue() == VISIBILITY_VISIBLE;
628     }
629
630     /**
631      * Returns <code>true</code>, if this menu item is inivisible on current layer
632      *
633      * @return boolean whether this menu item is invisible on current layer
634      */

635     public boolean isInvisible() {
636         return visibility.byteValue() == VISIBILITY_INVISIBLE;
637     }
638
639     /**
640      * Returns <code>true</code> if this menu item should behave like its equivavelent on parent layer
641      *
642      * @return boolean whether this menu item should behave like its equivavelent on parent layer
643      */

644     public boolean isVisibilityHeritable() {
645         return visibility.byteValue() == VISIBILITY_HERITABLE;
646     }
647
648
649     /**
650      * Returns position of menu item. It can be <code>null</code> -- this means,
651      * that this element will be positioned last.
652      *
653      * @return position
654      * @hibernate.property
655      * @hibernate.column name="`pos`" not-null="false" unique="false"
656      */

657     public Integer JavaDoc getPosition() {
658         return position;
659     }
660
661     /**
662      * Sets position of menu item. It can be <code>null</code> -- this means,
663      * that this element will be positioned last.
664      *
665      * @param position the position to set
666      */

667     public void setPosition(Integer JavaDoc position) {
668         this.position = position;
669     }
670
671     /**
672      * Returns 'onclick' JavaScript event handler for this menu item
673      *
674      * @return 'onclick' event handler
675      * @hibernate.property
676      * @hibernate.column name="`js_onclick`" not-null="false" unique="false" length="252"
677      */

678     public String JavaDoc getOnclick() {
679         return onclick;
680     }
681
682     /**
683      * Sets 'onclick' JavaScript event handler for this menu item
684      *
685      * @param onclick 'onclick' event handler
686      */

687     public void setOnclick(String JavaDoc onclick) {
688         this.onclick = onclick;
689     }
690
691     /**
692      * Returns 'onmouseover' JavaScript event handler for this menu item
693      *
694      * @return String 'onmouseover' event handler
695      * @hibernate.property
696      * @hibernate.column name="`js_onmouseover`" not-null="false" unique="false" length="252"
697      */

698     public String JavaDoc getOnmouseover() {
699         return onmouseover;
700     }
701
702     /**
703      * Sets 'onmouseover' JavaScript event handler for this menu item
704      *
705      * @param onmouseover 'onmouseover' event handler
706      */

707     public void setOnmouseover(String JavaDoc onmouseover) {
708         this.onmouseover = onmouseover;
709     }
710
711     /**
712      * Returns 'onmouseout' JavaScript event handler for this menu item
713      *
714      * @return 'onmouseout' event handler
715      * @hibernate.property
716      * @hibernate.column name="`js_onmouseout`" not-null="false" unique="false" length="252"
717      */

718     public String JavaDoc getOnmouseout() {
719         return onmouseout;
720     }
721
722     /**
723      * Sets 'onmouseout' JavaScript event handler for this menu item
724      *
725      * @param onmouseout 'onmouseout' event handler
726      */

727     public void setOnmouseout(String JavaDoc onmouseout) {
728         this.onmouseout = onmouseout;
729     }
730
731     /**
732      * Returns roles. Those are the roles that are allowed to use this menu item.
733      *
734      * @return list of roles
735      * @hibernate.bag table="`al_core_menu_item_role`" cascade="none" lazy="true" inverse="false" outer-join="false"
736      * @hibernate.collection-key column="`menu_item_id`"
737      * @hibernate.collection-many-to-many class="com.blandware.atleap.model.core.Role"
738      * column="`rolename`" outer-join="false"
739      * @hibernate.cache usage="read-write"
740      */

741     public List JavaDoc getRoles() {
742         return roles;
743     }
744
745     /**
746      * Gets all roles, represented as string (roles are separated with commas)
747      *
748      * @return roles, separated with commas
749      */

750     public String JavaDoc getRolesAsString() {
751         StringBuffer JavaDoc roles = new StringBuffer JavaDoc();
752         if ( this.roles != null && this.roles.size() > 0 ) {
753             for ( Iterator JavaDoc i = this.roles.iterator(); i.hasNext(); ) {
754                 Role role = (Role) i.next();
755                 roles.append(role.getTitle());
756                 if ( i.hasNext() ) {
757                     roles.append(", ");
758                 }
759             }
760         }
761         return roles.toString();
762     }
763
764     /**
765      * Sets roles. Those are the roles that are allowed to use this menu item.
766      *
767      * @param roles list of roles
768      */

769     public void setRoles(List JavaDoc roles) {
770         this.roles = roles;
771     }
772
773     /**
774      * Adds a connection between this menu item and a given role
775      *
776      * @param role the role to be connected with
777      */

778     public void addRole(Role role) {
779         if ( !role.getMenuItems().contains(this) ) {
780             role.getMenuItems().add(this);
781         }
782         if ( !getRoles().contains(role) ) {
783             getRoles().add(role);
784         }
785     }
786
787     /**
788      * Removes a connection between this menu item and a given role
789      *
790      * @param role the role
791      */

792     public void removeRole(Role role) {
793         role.getMenuItems().remove(this);
794         getRoles().remove(role);
795     }
796
797     /**
798      * Returns menu item, for which this one is redefinition
799      *
800      * @return original item
801      * @hibernate.many-to-one column="`orig_id`" not-null="false" outer-join="false" lazy="false"
802      */

803     public MenuItem getOrigItem() {
804         return origItem;
805     }
806
807     /**
808      * Sets menu item, for which this one is redefinition
809      *
810      * @param origItem original item
811      */

812     public void setOrigItem(MenuItem origItem) {
813         this.origItem = origItem;
814     }
815
816     /**
817      * Returns a list of redefinitions of this menu item
818      *
819      * @return list of redefinitions
820      * @hibernate.bag name="redefinitionItems" inverse="true" lazy="true" cascade="delete" outer-join="false"
821      * @hibernate.collection-key column="`orig_id`"
822      * @hibernate.collection-one-to-many class="com.blandware.atleap.model.core.MenuItem"
823      */

824     protected List JavaDoc getRedefinitionItems() {
825         return redefinitionItems;
826     }
827
828     /**
829      * Sets list of redefinitions of this menu item
830      *
831      * @param redefinitionItems list of redefinitions
832      */

833     protected void setRedefinitionItems(List JavaDoc redefinitionItems) {
834         this.redefinitionItems = redefinitionItems;
835     }
836
837     /**
838      * Returns <code>true</code> if this menu item is redefinition of another
839      *
840      * @return whether this is redefinition
841      */

842     public boolean isRedefinition() {
843         return this.origItem != null;
844     }
845
846
847     /**
848      * Returns the owner: Layout or Page
849      *
850      * @return the owner
851      * @struts.form-field
852      * @hibernate.many-to-one column="`owner_id`" not-null="false" outer-join="false" lazy="false"
853      */

854     public Localizable getOwner() {
855         return owner;
856     }
857
858     /**
859      * Sets the owner of this menu item
860      *
861      * @param owner new owner
862      */

863     public void setOwner(Localizable owner) {
864         this.owner = owner;
865     }
866
867     /**
868      * Returns <code>true</code> if this menu item is dynamic. Dynamic menu item
869      * is item that was created by user, not defined in xml-file.
870      *
871      * @return whether this menu item is dynamic
872      */

873     public boolean isDynamic() {
874         return this.owner != null;
875     }
876
877
878     /**
879      * Gets list of pages this menu item is linked with
880      *
881      * @return list of linked pages
882      * @hibernate.bag table="`al_core_menu_item_page`" cascade="none" lazy="true" inverse="false" outer-join="false"
883      * @hibernate.collection-key column="`menu_item_id`"
884      * @hibernate.collection-many-to-many class="com.blandware.atleap.model.core.Page" column="`page_id`" outer-join="false"
885      */

886     public List JavaDoc getLinkedPages() {
887         return linkedPages;
888     }
889
890     /**
891      * Sets list of pages this menu item is linked with
892      *
893      * @param linkedPages list of linked pages
894      */

895     public void setLinkedPages(List JavaDoc linkedPages) {
896         this.linkedPages = linkedPages;
897     }
898
899     /**
900      * Adds a connection between this menu item and a given page
901      *
902      * @param page the page to be connected with
903      */

904     public void addLinkedPage(Page page) {
905         if ( !page.getLinkedMenuItems().contains(this) ) {
906             page.getLinkedMenuItems().add(this);
907         }
908         if ( !getLinkedPages().contains(page) ) {
909             getLinkedPages().add(page);
910         }
911     }
912
913     /**
914      * Removes a connection between this menu item and a given page
915      *
916      * @param page the page
917      */

918     public void removeLinkedPage(Page page) {
919         page.getLinkedMenuItems().remove(this);
920         getLinkedPages().remove(page);
921     }
922
923
924     /**
925      * Gets list of content resources this menu item is linked with
926      *
927      * @return list of content resources
928      * @hibernate.bag table="`al_core_menu_item_resource`" cascade="none" lazy="true" inverse="false" outer-join="false"
929      * @hibernate.collection-key column="`menu_item_id`"
930      * @hibernate.collection-many-to-many class="com.blandware.atleap.model.core.ContentResource" column="`resource_id`" outer-join="false"
931      */

932     public List JavaDoc getLinkedResources() {
933         return linkedResources;
934     }
935
936     /**
937      * Sets list of content resources this menu item is linked with
938      *
939      * @param linkedContentResources list of content resources
940      */

941     public void setLinkedResources(List JavaDoc linkedContentResources) {
942         this.linkedResources = linkedContentResources;
943     }
944
945     /**
946      * Adds a connection between this menu item and a given content resource
947      *
948      * @param resource the content resource to be connected with
949      */

950     public void addLinkedResource(ContentResource resource) {
951         if ( !resource.getLinkedMenuItems().contains(this) ) {
952             resource.getLinkedMenuItems().add(this);
953         }
954         if ( !getLinkedPages().contains(resource) ) {
955             getLinkedPages().add(resource);
956         }
957     }
958
959     /**
960      * Removes a connection between this menu item and a given content resource
961      *
962      * @param resource the content resource
963      */

964     public void removeLinkedResource(ContentResource resource) {
965         resource.getLinkedMenuItems().remove(this);
966         getLinkedResources().remove(resource);
967     }
968
969
970     /**
971      * Gets mapping from locale identifiers to titles of this menu item
972      *
973      * @return mapping from locale identifiers to titles
974      * @struts.form-field
975      * @hibernate.map table="`al_core_menu_item_title`" lazy="true" cascade="all" outer-join="false"
976      * @hibernate.collection-key column="`id`"
977      * @hibernate.collection-index column="`title_identifier`" type="string" length="10"
978      * @hibernate.collection-element type="string" column="`title`" not-null="false" length="252"
979      */

980     public Map JavaDoc getTitle() {
981         return title;
982     }
983
984     /**
985      * Sets mapping from locale identifiers to titles of this menu item
986      *
987      * @param title mapping from locale identifiers to titles
988      */

989     public void setTitle(Map JavaDoc title) {
990         this.title = title;
991     }
992
993     /**
994      * Gets mapping from locale identifiers to tool tips of this menu item
995      *
996      * @return mapping from locale identifiers to tool tips
997      * @struts.form-field
998      * @hibernate.map table="`al_core_menu_item_tooltip`" lazy="true" cascade="all" outer-join="false"
999      * @hibernate.collection-key column="`id`"
1000     * @hibernate.collection-index column="`tooltip_identifier`" type="string" length="10"
1001     * @hibernate.collection-element type="string" column="`tooltip`" not-null="false" length="252"
1002     */

1003    public Map JavaDoc getToolTip() {
1004        return toolTip;
1005    }
1006
1007    /**
1008     * Sets mapping from locale identifiers to tool tips of this menu item
1009     *
1010     * @param toolTip mapping from locale identifiers to tool tips
1011     */

1012    public void setToolTip(Map JavaDoc toolTip) {
1013        this.toolTip = toolTip;
1014    }
1015
1016    /**
1017     * Returns version of this menu item
1018     *
1019     * @return version
1020     * @struts.form-field
1021     * @hibernate.version column="`version`" type="long" unsaved-value="null"
1022     */

1023    public Long JavaDoc getVersion() {
1024        return version;
1025    }
1026
1027    /**
1028     * Sets version of this menu item
1029     *
1030     * @param version new version
1031     */

1032    public void setVersion(Long JavaDoc version) {
1033        this.version = version;
1034    }
1035
1036    public boolean equals(Object JavaDoc o) {
1037        if ( this == o ) {
1038            return true;
1039        }
1040        if ( !(o instanceof MenuItem) ) {
1041            return false;
1042        }
1043
1044        final MenuItem menuItem = (MenuItem) o;
1045
1046        if ( identifier != null ? !identifier.equals(menuItem.identifier) : menuItem.identifier != null ) {
1047            return false;
1048        }
1049        if ( owner != null ? !owner.equals(menuItem.owner) : menuItem.owner != null ) {
1050            return false;
1051        }
1052        if ( parentItem != null ? !parentItem.equals(menuItem.parentItem) : menuItem.parentItem != null ) {
1053            return false;
1054        }
1055
1056        return true;
1057    }
1058
1059    public int hashCode() {
1060        int result;
1061        result = (parentItem != null ? parentItem.hashCode() : 0);
1062        result = 29 * result + (identifier != null ? identifier.hashCode() : 0);
1063        result = 29 * result + (owner != null ? owner.hashCode() : 0);
1064        return result;
1065    }
1066
1067
1068}
1069
Popular Tags