KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > addressbook > struts > GroupRightForm


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: GroupRightForm.java,v $
31  * Revision 1.4 2005/04/29 02:48:14 colinmacleod
32  * Data bugfixes.
33  * Changed primary key back to Integer.
34  *
35  * Revision 1.3 2005/04/10 20:32:02 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:08 colinmacleod
42  * Changed copyright text to GPL v2 explicitly.
43  *
44  * Revision 1.1.1.1 2005/03/10 17:50:25 colinmacleod
45  * Restructured ivata op around Hibernate/PicoContainer.
46  * Renamed ivata groupware.
47  *
48  * Revision 1.6 2004/12/23 21:01:25 colinmacleod
49  * Updated Struts to v1.2.4.
50  * Changed base classes to use ivata masks.
51  *
52  * Revision 1.5 2004/11/12 18:19:14 colinmacleod
53  * Change action and form classes to extend MaskAction, MaskForm respectively.
54  *
55  * Revision 1.4 2004/07/13 19:41:14 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:08 colinmacleod
61  * Shortened name to ivata op.
62  *
63  * Revision 1.2 2004/02/01 22:00:33 colinmacleod
64  * Added full names to author tags
65  *
66  * Revision 1.1.1.1 2004/01/27 20:57:53 colinmacleod
67  * Moved ivata openportal to SourceForge..
68  *
69  * Revision 1.5 2003/11/18 09:55:46 jano
70  * commiting all forgoten staff
71  *
72  * Revision 1.4 2003/11/13 16:03:16 jano
73  * commitng everything to CVS
74  * can deploy and application is ruuning, can login into
75  *
76  * Revision 1.3 2003/10/17 12:36:12 jano
77  * fixing problems with building
78  * converting intranet -> portal
79  * Eclipse building
80  *
81  * Revision 1.2 2003/10/15 13:18:02 colin
82  * fixing for XDoclet
83  *
84  * Revision 1.4 2003/08/14 15:54:42 jano
85  * fixing bugs
86  *
87  * Revision 1.3 2003/08/13 13:32:43 jano
88  * addressBook exttension: next level
89  *
90  * Revision 1.2 2003/08/05 14:57:35 jano
91  * addressBook extension
92  *
93  * Revision 1.1 2003/06/02 22:17:48 colin
94  * changes for new user rights interface
95  * -----------------------------------------------------------------------------
96  */

97 package com.ivata.groupware.business.addressbook.struts;
98
99 import java.io.Serializable JavaDoc;
100 import java.util.Vector JavaDoc;
101
102 import javax.servlet.http.HttpServletRequest JavaDoc;
103 import javax.servlet.http.HttpSession JavaDoc;
104
105 import org.apache.struts.action.ActionMapping;
106
107 import com.ivata.groupware.business.addressbook.AddressBook;
108 import com.ivata.groupware.business.addressbook.person.group.GroupDO;
109 import com.ivata.mask.Mask;
110 import com.ivata.mask.validation.ValidationErrors;
111 import com.ivata.mask.web.struts.DialogForm;
112
113
114 /**
115  * <p>Contains details of AddressBook or UserGroup and rights being changed for that kindof group. Field type is saying what we are maintaining : addressBook = 1, userGroup = 2.</p>
116  *
117  * @since 2003-05-10
118  * @author Colin MacLeod
119  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
120  * @version $Revision: 1.4 $
121  */

122 public class GroupRightForm extends DialogForm implements Serializable JavaDoc {
123     /**
124      * <p>Button for add group to the right list.</p>
125      */

126     private String JavaDoc add = null;
127     /**
128      *<p> if user did click "add" this will contain id of group which is *going to be add.</p>
129      */

130     private Integer JavaDoc addGroup = null;
131     private AddressBook addressBook;
132     /**
133      * <p> if user has right to remove the userGroup/addressBook is this true.</p>
134      */

135     private boolean canRemove = false;
136     /**
137      * <p>If list of rights is empty write this message out.</p>
138      */

139     private String JavaDoc emptyListMessage = null;
140     /**
141      * <p>Instance of group data object, containing all values
142      * of group being submitted.</p>
143      */

144     private GroupDO group = new GroupDO();
145     /**
146      * <p><code>Vector</code> containing <code>Integer</code> instances,
147      * representing ids of all the groups users the current group.</p>
148      */

149     private Vector JavaDoc groupIds = new Vector JavaDoc ();
150     /**
151      * <p><code>Vector</code> containing <code>String</code> instances,
152      * representing names of all the groups users the current group.</p>
153      */

154     private Vector JavaDoc groupNames = new Vector JavaDoc ();
155     /**
156      * <p><code>String</code> array of numbers representing the id's of the
157      * contact groups which users in the current group can add to.</p>
158      */

159     private String JavaDoc[] groupRightsAdd;
160     /**
161      * <p><code>String</code> array of numbers representing the id's of the
162      * contact groups which users in the current group can amend in.</p>
163      */

164     private String JavaDoc[] groupRightsAmend;
165     /**
166      * <p><code>String</code> array of numbers representing the id's of the
167      * contact groups which users in the current group can delete from.</p>
168      */

169     private String JavaDoc[] groupRightsRemove;
170     /**
171      * <p><code>String</code> array of numbers representing the id's of the
172      * contact groups which users in the current group can view.</p>
173      */

174     private String JavaDoc[] groupRightsView;
175
176     /**
177      * <p>The number of the active tab being displayed, starting with 0.</p>
178      */

179     private Integer JavaDoc groupRightTab_activeTab = null;
180     /**
181      * <p>The URI of the page which will be included to represent the currently
182      * chosen tab.</p>
183      */

184     private String JavaDoc includePage = "/addressBook/groupRightGeneral.jsp";
185     /**
186      * <p> if user has not right to chage addressBook / useGroup it's true.</p>
187      */

188     private boolean readOnly = false;
189     private String JavaDoc remove;
190     /**
191      * <p>Indicates the names of 'rows' of the list. This will either be
192      * <code>groupNames</code> or <code>topicCaptions</code>, depending on the
193      * list currently being displayed.</p>
194      */

195     private Vector JavaDoc rowNames;
196     /**
197      * <p>Indicates the 'rows' of the list. This will either be <code>groupIds</code>
198      * or <code>topicIds</code>, depending on the list currently being displayed.</p>
199      */

200     private Vector JavaDoc rows;
201     /**
202      * <p><code>String</code> array of numbers representing the id's of the
203      * topics or groups which have been selected for deletion.</p>
204      */

205     private String JavaDoc[] selected;
206     /**
207      * <p> We can maintain AddressBook or UserGroup.</p>
208      */

209     private String JavaDoc type = null;
210     /**
211      * <p>
212      * Defines the base class of all objects in the value object list.
213      * </p>
214      */

215     private Class JavaDoc baseClass;
216     /**
217      * <p>
218      * Mask containing all the field definitions for this list.
219      * </p>
220      */

221     private Mask mask;
222
223     /**
224      * <p>
225      * Construct a group right form.
226      * </p>
227      *
228      * @param addressBook address book implementation to use.
229      * @param maskParam Refer to {@link DialogForm#DialogForm}.
230      * @param baseClassParam Refer to {@link DialogForm#DialogForm}.
231      */

232     GroupRightForm(final AddressBook addressBook,
233             final Mask maskParam,
234             final Class JavaDoc baseClassParam) {
235         this.addressBook = addressBook;
236     }
237
238     /**
239      * <p>
240      * Return all form state to initial values.
241      * </p>
242      *
243      * @see com.ivata.mask.web.struts.MaskForm#clear()
244      */

245     protected void clear() {
246         add = null;
247         addGroup = null;
248         canRemove = false;
249         emptyListMessage = null;
250         group = new GroupDO();
251         groupIds = new Vector JavaDoc ();
252         groupNames = new Vector JavaDoc ();
253         groupRightTab_activeTab = null;
254         setHelpKey("addressbook.groupRightUser");
255         includePage = "/addressBook/groupRightGeneral.jsp";
256         readOnly = false;
257         remove = null;
258         rowNames = null;
259         rows = null;
260         selected = null;
261         type = null;
262     }
263
264     /**
265      * <p>Get whether or not the add button was pressed.</p>
266      *
267      * <p>If the add button was pressed, this attribute is set to a non-null
268      * string.</p>
269      *
270      * @return non-<code>null</code> if the add key was pressed, otherwise
271      * <code>null</code>.
272      */

273     public final String JavaDoc getAdd() {
274         return add;
275     }
276
277     /**
278      *<p> if user did click "add" this will contain id of group which is
279      * *going to be added.</p>
280      *
281      * @return the current value of addGroup.
282      */

283     public final Integer JavaDoc getAddGroup() {
284         return this.addGroup;
285     }
286
287     /**
288      * <p> if user has right to remove the userGroup/addressBook is this true.</p>
289      *
290      * @return the current value of canRemove.
291      */

292     public final boolean getCanRemove() {
293         return this.canRemove;
294     }
295
296     /**
297      * <p>Description of group.</p>
298      *
299      * @return the current value of group.description
300      */

301     public final String JavaDoc getDescription() {
302         return this.group.getDescription();
303     }
304
305     /**
306      * <p>If list of rights is empty write this message out.</p>
307      *
308      * @return the current value of emptyListMessage.
309      */

310     public final String JavaDoc getEmptyListMessage() {
311         return this.emptyListMessage;
312     }
313
314     /**
315      * <p>Instance of group data object, containing all values
316      * of group being submitted.</p>
317      *
318      * @return the current value of group.
319      */

320     public final GroupDO getGroup() {
321         return this.group;
322     }
323
324     /**
325      * <p>Get a <code>Vector</code> containing <code>Integer</code> instances,
326      * representing ids of all the groups users the current group.</p>
327      *
328      * @return current value of groupIds.
329      */

330     public final Vector JavaDoc getGroupIds() {
331         return groupIds;
332     }
333
334     /**
335      * <p>Get a <code>Vector</code> containing <code>Integer</code> instances,
336      * representing ids of all the groups users the current group.</p>
337      *
338      * @return current value of groupNames.
339      */

340     public final Vector JavaDoc getGroupNames() {
341         return groupNames;
342     }
343
344     /**
345      * <p><code>String</code> array of numbers representing the id's of the
346      * contact groups which users in the current group can add to.</p>
347      *
348      * @return the current value of groupRightsAdd[].
349      */

350     public final String JavaDoc[] getGroupRightsAdd() {
351         return this.groupRightsAdd;
352     }
353
354     /**
355      * <p><code>String</code> array of numbers representing the id's of the
356      * contact groups which users in the current group can amend in.</p>
357      *
358      * @return the current value of groupRightsAmend[].
359      */

360     public final String JavaDoc[] getGroupRightsAmend() {
361         return this.groupRightsAmend;
362     }
363
364     /**
365      * <p><code>String</code> array of numbers representing the id's of the
366      * contact groups which users in the current group can delete from.</p>
367      *
368      * @return the current value of groupRightsRemove[].
369      */

370     public final String JavaDoc[] getGroupRightsRemove() {
371         return this.groupRightsRemove;
372     }
373
374     /**
375      * <p><code>String</code> array of numbers representing the id's of the
376      * contact groups which users in the current group can view.</p>
377      *
378      * @return the current value of groupRightsView[].
379      */

380     public final String JavaDoc[] getGroupRightsView() {
381         return this.groupRightsView;
382     }
383
384     /**
385      * <p>Get the number of the active tab being displayed, starting with 0.</p>
386      *
387      * @return current value of groupTab_activeTab.
388      */

389     public final Integer JavaDoc getGroupRightTab_activeTab() {
390         return groupRightTab_activeTab;
391     }
392
393     /**
394      * <p>Get the URI of the page which will be included to represent the currently
395      * chosen tab.</p>
396      *
397      * @return the current value of includePage.
398      */

399     public final String JavaDoc getIncludePage() {
400         return includePage;
401     }
402
403     /**
404      * <p>Name of group.</p>
405      *
406      * @return the current value of group.name
407      */

408     public String JavaDoc getName() {
409         return this.group.getName();
410     }
411
412     /**
413      * <p> if user has not right to chage addressBook / useGroup it's true.</p>
414      *
415      * @return the current value of readOnly.
416      */

417     public final boolean getReadOnly() {
418         return this.readOnly;
419     }
420
421     /**
422      * <p>Get whether or not the remove button was pressed.</p>
423      *
424      * <p>If the remove button was pressed, this attribute is set to a non-null
425      * string.</p>
426      *
427      * @return non-<code>null</code> if the remove key was pressed, otherwise
428      * <code>null</code>.
429      */

430     public final String JavaDoc getRemove() {
431         return remove;
432     }
433
434     /**
435      * <p>Get the names of 'rows' of the list.</p>
436      *
437      * @return <code>groupNames</code> or <code>topicCaptions</code>, depending
438      * on the list currently being displayed.</p>
439      */

440     public final Vector JavaDoc getRowNames() {
441         return this.rowNames;
442     }
443
444     /**
445      * <p>Get the 'rows' of the list.</p>
446      *
447      * @return <code>groupIds</code> or <code>topicIds</code>, depending on the
448      * list currently being displayed.</p>
449      */

450     public final Vector JavaDoc getRows() {
451         return this.rows;
452     }
453
454     /**
455      * <p>Get a <code>String</code> array of numbers representing the id's of the
456      * topics or groups which have been selected for deletion.</p>
457      *
458      * @return current value of selected
459      */

460     public final String JavaDoc[] getSelected() {
461         return selected;
462     }
463
464     /**
465      * <p> We can maintain AddressBook or UserGroup.</p>
466      *
467      * @return the current value of type.
468      */

469     public final String JavaDoc getType() {
470         return this.type;
471     }
472
473     /**
474      * <p>Reset all bean properties to their default state. This method
475      * is called before the properties are repopulated by the controller
476      * servlet.</p>
477      *
478      * @param mapping The mapping used to select this instance
479      * @param request The servlet request we are processing
480      */

481     public void reset(final ActionMapping mapping,
482             final HttpServletRequest JavaDoc request) {
483         super.reset(mapping, request);
484         setGroupRightTab_activeTab(new Integer JavaDoc(0));
485         selected = new String JavaDoc[0];
486
487         if (includePage.equals("/addressBook/groupRightDetail.jsp")) {
488             groupRightsView = new String JavaDoc [0];
489             groupRightsAdd = new String JavaDoc [0];
490             groupRightsAmend = new String JavaDoc [0];
491             groupRightsRemove = new String JavaDoc [0];
492         }
493     }
494
495     /**
496      * <p>Set whether or not the add button was pressed.</p>
497      *
498      * <p>If the add button was pressed, this attribute is set to a non-null
499      * string.</p>
500      *
501      * @param add set to non-<code>null</code> if the add key was pressed, otherwise
502      * <code>null</code>.
503      */

504     public final void setAdd(final String JavaDoc add) {
505         this.add = add;
506     }
507
508     /**
509      *<p> if user did click "add" this will contain id of group which is *going to be add.</p>
510      *
511      * @param addGroup the new value of addGroup.
512      */

513     public final void setAddGroup(final Integer JavaDoc addGroup) {
514         this.addGroup = addGroup;
515     }
516
517     /**
518      * <p> if user has right to remove the userGroup/addressBook is this true.</p>
519      *
520      * @param canRemove the new value of canRemove.
521      */

522     public final void setCanRemove(final boolean canRemove) {
523         this.canRemove = canRemove;
524     }
525
526     /**
527      * <p>Description of group.</p>
528      *
529      * @param description the new value of group.description
530      */

531     public final void setDescription(final String JavaDoc description) {
532         this.group.setDescription(description);
533     }
534
535     /**
536      * <p>If list of rights is empty write this message out.</p>
537      *
538      * @param emptyListMessage the new value of emptyListMessage.
539      */

540     public final void setEmptyListMessage(final String JavaDoc emptyListMessage) {
541         this.emptyListMessage = emptyListMessage;
542     }
543
544     /**
545      * <p>Instance of group data object, containing all values
546      * of group being submitted.</p>
547      *
548      * @param group the new value of group.
549      */

550     public final void setGroup(final GroupDO group) {
551         this.group = group;
552     }
553
554     /**
555      * <p>Set a <code>Vector</code> containing <code>Integer</code> instances,
556      * representing ids of all the groups users the current group.</p>
557      *
558      * @param groupIds new value of groupIds.
559      */

560     public final void setGroupIds(final Vector JavaDoc groupIds) {
561         this.groupIds = groupIds;
562     }
563
564     /**
565      * <p>Set a <code>Vector</code> containing <code>Integer</code> instances,
566      * representing ids of all the groups users the current group.</p>
567      *
568      * @param groupNames new value of groupNames.
569      */

570     public final void setGroupNames(final Vector JavaDoc groupNames) {
571         this.groupNames = groupNames;
572     }
573
574     /**
575      * <p><code>String</code> array of numbers representing the id's of the
576      * contact groups which users in the current group can add to.</p>
577      *
578      * @param groupRightsAdd[] the new value of groupRightsAdd[].
579      */

580     public final void setGroupRightsAdd(final String JavaDoc groupRightsAdd[]) {
581         this.groupRightsAdd = groupRightsAdd;
582     }
583
584     /**
585      * <p><code>String</code> array of numbers representing the id's of the
586      * contact groups which users in the current group can amend in.</p>
587      *
588      * @param groupRightsAmend[] the new value of groupRightsAmend[].
589      */

590     public final void setGroupRightsAmend(final String JavaDoc groupRightsAmend[]) {
591         this.groupRightsAmend = groupRightsAmend;
592     }
593
594     /**
595      * <p><code>String</code> array of numbers representing the id's of the
596      * contact groups which users in the current group can delete from.</p>
597      *
598      * @param groupRightsRemove[] the new value of groupRightsRemove[].
599      */

600     public final void setGroupRightsRemove(final String JavaDoc groupRightsRemove[]) {
601         this.groupRightsRemove = groupRightsRemove;
602     }
603
604     /**
605      * <p><code>String</code> array of numbers representing the id's of the
606      * contact groups which users in the current group can view.</p>
607      *
608      * @param groupRightsView[] the new value of groupRightsView[].
609      */

610     public final void setGroupRightsView(final String JavaDoc groupRightsView[]) {
611         this.groupRightsView = groupRightsView;
612     }
613
614     /**
615      * <p>Set the number of the active tab being displayed, starting with 0.</p>
616      *
617      * @param groupRightTab_activeTab the new value of groupTab_activeTab.
618      */

619     public final void setGroupRightTab_activeTab(final Integer JavaDoc groupRightTab_activeTab) {
620         this.groupRightTab_activeTab = groupRightTab_activeTab;
621     }
622
623     /**
624      * <p>Set the URI of the page which will be included to represent the currently
625      * chosen tab.</p>
626      *
627      * @param includePage new value of includePage.
628      */

629     public final void setIncludePage(final String JavaDoc includePage) {
630         this.includePage = includePage;
631     }
632
633     /**
634      * <p>Name of group.</p>
635      *
636      * @param name the new value of group.name
637      */

638     public final void setName(final String JavaDoc name) {
639         this.group.setName(name);
640     }
641
642     /**
643      * <p> if user has not right to chage addressBook / useGroup it's true.</p>
644      *
645      * @param readOnly the new value of readOnly.
646      */

647     public final void setReadOnly(final boolean readOnly) {
648         this.readOnly = readOnly;
649     }
650
651     /**
652      * <p>Set whether or not the remove button was pressed.</p>
653      *
654      * <p>If the remove button was pressed, this attribute is set to a non-null
655      * string.</p>
656      *
657      * @param remove set to non-<code>null</code> if the remove key was pressed,
658      * otherwise <code>null</code>.
659      */

660     public final void setRemove(final String JavaDoc remove) {
661         this.remove = remove;
662     }
663
664     /**
665      * <p>Set the names of 'rows' of the list.</p>
666      *
667      * @param rowNames <code>groupNames</code> or <code>topicCaptions</code>, depending
668      * on the list currently being displayed.</p>
669      */

670     public final void setRowNames(final Vector JavaDoc rowNames) {
671         this.rowNames = rowNames;
672     }
673
674     /**
675      * <p>Set the 'rows' of the list.</p>
676      *
677      * @param rows <code>groupIds</code> or <code>topicIds</code>, depending on the
678      * list currently being displayed.</p>
679      */

680     public final void setRows(final Vector JavaDoc rows) {
681         this.rows = rows;
682     }
683
684     /**
685      * <p>Set a <code>String</code> array of numbers representing the id's of the
686      * topics which have been selected for deletion.</p>
687      *
688      * @param new value of libraryRightsAdd.
689      */

690     public final void setSelected(final String JavaDoc[] selected) {
691         this.selected = selected;
692     }
693
694     /**
695      * <p> We can maintain AddressBook or UserGroup.</p>
696      *
697      * @param type the new value of type.
698      */

699     public final void setType(final String JavaDoc type) {
700         this.type = type;
701     }
702
703     /**
704      * <p>Validates the form contents.</p>
705      *
706      * @param addressBook valid <code>AddressBookRemote</code> instance.
707      * @param locale locale used to show error messages.
708      * @param session current session to set/get attributes from.
709      * @return <code>null</code> or an <code>ActionMessages</code> object
710      * with recorded error messages.
711      */

712     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
713             final HttpSession JavaDoc session) {
714         ValidationErrors validationErrors = new ValidationErrors();
715
716         return validationErrors;
717     }
718
719     /**
720      * <p>
721      * Defines the base class of all objects in the value object list.
722      * </p>
723      *
724      * @return base class of all objects in the value object list.
725      */

726     public final Class JavaDoc getBaseClass() {
727         return baseClass;
728     }
729
730     /**
731      * <p>
732      * Mask containing all the field definitions for this list.
733      * </p>
734      *
735      * @return mask containing all the field definitions for this list.
736      */

737     public final Mask getMask() {
738         return mask;
739     }
740 }
741
Popular Tags