KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > Task


1 package de.webman.acl;
2
3 import com.teamkonzept.lib.TKException;
4 import com.teamkonzept.lib.TKVector;
5 import de.webman.acl.db.TaskDBData;
6
7 /**
8  * A task groups one ore more actions into a logical unit. Additionally, it is
9  * qualified by a context.
10  *
11  * @version 1.0
12  * @since 1.0
13  * @author © 2001 Webman AG
14  */

15 public class Task
16     extends WMObject
17 {
18
19     // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/Task.java,v 1.1 2001/08/20 08:25:07 mischa Exp $
20

21     // Attributes
22

23     /**
24      * The name of the task.
25      */

26     private String JavaDoc name = null;
27
28     /**
29      * The context of the task.
30      */

31     private Integer JavaDoc context = null;
32
33
34     // Constructors
35

36     /**
37      * Provide instantion only to package classes or subclasses.
38      *
39      * @param data the initial task data.
40      */

41     protected Task (TaskDBData data)
42     {
43         super(data);
44
45         this.name = data.getName();
46         this.context = data.getContext();
47     }
48
49
50     // Methods
51

52     /**
53      * Returns the factory of the object.
54      *
55      * @return the factory of the object.
56      * @exception com.teamkonzept.lib.TKException if an error occured during factory retrieval.
57      */

58     public final ObjectFactory getFactory ()
59         throws TKException
60     {
61         return TaskFactory.getInstance();
62     }
63
64     /**
65      * Returns the name of the task.
66      *
67      * @return the name of the task.
68      */

69     public final String JavaDoc getName ()
70     {
71         return name;
72     }
73
74     /**
75      * Assigns the name of the task.
76      *
77      * @param name the name of the task.
78      */

79     public final void setName (String JavaDoc name)
80     {
81         super.modifyAttribute(this.name, name);
82         this.name = name;
83     }
84
85     /**
86      * Returns the ID of the context of the task.
87      *
88      * @return the ID of the context of the task.
89      */

90     public final Integer JavaDoc getContextID ()
91     {
92         return context;
93     }
94
95     /**
96      * Returns the context of the task.
97      *
98      * @return the context of the task.
99      * @exception com.teamkonzept.lib.TKException if an error occured during context retrieval.
100      */

101     public final Context getContext ()
102         throws TKException
103     {
104         return context != null
105                        ? (Context) ContextFactory.getInstance().getObject(context)
106                        : null;
107     }
108
109     /**
110      * Assigns the context of the task.
111      *
112      * @param context the context of the task.
113      */

114     public final void setContext (Context context)
115     {
116         Integer JavaDoc id = context != null
117                              ? context.getID()
118                              : null;
119
120         super.modifyAttribute(this.context, id);
121         this.context = id;
122     }
123
124     /**
125      * Returns all associated actions.
126      *
127      * @return all associated actions.
128      * @exception com.teamkonzept.lib.TKException if an error occured during action retrieval.
129      */

130     public final TKVector getActions ()
131         throws TKException
132     {
133         return ActionFactory.getInstance().getObjects(super.getAssociations());
134     }
135
136     /**
137      * Adds an association with the given action.
138      *
139      * @param action the action.
140      * @exception com.teamkonzept.lib.TKException if an error occured during action retrieval.
141      */

142     public final void addAction (Action action)
143         throws TKException
144     {
145         super.addAssociation(action);
146     }
147
148     /**
149      * Removes the association with the given action.
150      *
151      * @param action the action.
152      * @exception com.teamkonzept.lib.TKException if an error occured during action retrieval.
153      */

154     public final void removeAction (Action action)
155         throws TKException
156     {
157         super.removeAssociation(action);
158     }
159
160     /**
161      * Removes the associations with all actions.
162      *
163      * @exception com.teamkonzept.lib.TKException if an error occured during action retrieval.
164      */

165     public final void removeActions ()
166         throws TKException
167     {
168         super.removeAssociations();
169     }
170
171     /**
172      * Checks wether there is an association with the given action.
173      *
174      * @param action the action.
175      * @return <CODE>true</CODE> if there is an association with the
176      * given action, otherwise <CODE>false</CODE>.
177      * @exception com.teamkonzept.lib.TKException if an error occured during action retrieval.
178      */

179     public final boolean hasAction (Action action)
180         throws TKException
181     {
182         return super.containsAssociation(action);
183     }
184
185     /**
186      * Returns all roles referencing the task.
187      *
188      * @return all roles referencing the task.
189      * @exception com.teamkonzept.lib.TKException if an error occured during role retrieval.
190      */

191     public final TKVector getRoles ()
192         throws TKException
193     {
194         return RoleFactory.getInstance().getRoles(this);
195     }
196
197 }
198
Popular Tags