KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > eventhandler > ACReports


1 package de.webman.acl.eventhandler;
2
3 import java.util.*;
4 import com.teamkonzept.lib.*;
5 import de.webman.acl.*;
6
7 /**
8  * <b>ACReports</b> is a collection of functions for
9  * transforming lists of access control data into lists
10  * suitable for template processing.
11  *
12  * @author $Author: uli $
13  * @version $Revision: 1.4 $
14  */

15 public class ACReports
16 {
17
18     /**
19      * Returns a hashtable suitable for template processing.
20      *
21      * @param tasks a list of tasks.
22      * @return a hashtable suitable for template processing.
23      * @throws TKException if an error occurred during the
24      * conversion.
25      */

26     public static TKHashtable makeTaskReport (TKVector tasks)
27         throws TKException
28     {
29         if (tasks == null || tasks.size() == 0)
30         {
31             return null;
32         }
33
34         TKHashtable taskList = new TKHashtable();
35         Enumeration iterator = tasks.elements();
36
37         while (iterator.hasMoreElements())
38         {
39             Task task = (Task) iterator.nextElement();
40             Context context = task.getContext();
41
42             TKHashtable contextTable = (TKHashtable) taskList.get(context.getID());
43
44             if (contextTable == null)
45             {
46                 contextTable = new TKHashtable();
47                 contextTable.put("CONTEXT_NAME", context.getName());
48                 contextTable.put("CONTEXT_SHORTCUT", context.getShortcut());
49
50                 taskList.put(context.getID(), contextTable);
51             }
52
53             TKVector contextTasks = (TKVector) contextTable.get("CONTEXT_TASKS");
54
55             if (contextTasks == null)
56             {
57                 contextTasks = new TKVector();
58
59                 contextTable.put("CONTEXT_TASKS", contextTasks);
60             }
61
62             TKHashtable taskTable = new TKHashtable();
63             taskTable.put("TASK_ID", task.getID());
64             taskTable.put("TASK_NAME", task.getName());
65
66             TKVector roles = RoleFactory.getInstance().getRoles(task);
67             TKVector taskRoles = new TKVector(roles.size());
68
69             for (int index = 0; index < roles.size(); index++)
70             {
71                 Role role = (Role) roles.elementAt(index);
72
73                 TKHashtable roleTable = new TKHashtable();
74                 roleTable.put("ROLE_NAME", role.getName());
75
76                 taskRoles.addElement(roleTable);
77             }
78
79             taskTable.put("TASK_ROLES", taskRoles);
80
81             TKVector actions = task.getActions();
82             TKVector taskActions = new TKVector(actions.size());
83
84             for (int index = 0; index < actions.size(); index++)
85             {
86                 Action action = (Action) actions.elementAt(index);
87
88                 TKHashtable actionTable = new TKHashtable();
89                 actionTable.put("ACTION_NAME", action.getName());
90
91                 taskActions.addElement(actionTable);
92             }
93
94             taskTable.put("TASK_ACTIONS", taskActions);
95
96             contextTasks.addElement(taskTable);
97         }
98
99         return taskList;
100     }
101
102     /**
103      * Returns a hashtable suitable for template processing.
104      *
105      * @param groups a list of groups.
106      * @return a hashtable suitable for template processing.
107      * @throws TKException if an error occurred during the
108      * conversion.
109      */

110     public static TKHashtable makeGroupReport (TKVector groups)
111         throws TKException
112     {
113         if (groups == null || groups.size() == 0)
114         {
115             return null;
116         }
117
118         return new TKHashtable();
119     }
120
121     /**
122      * Returns a hashtable suitable for template processing.
123      *
124      * @param roles a list of roles.
125      * @return a hashtable suitable for template processing.
126      * @throws TKException if an error occurred during the
127      * conversion.
128      */

129     public static TKHashtable makeRoleReport (TKVector roles)
130         throws TKException
131     {
132         if (roles == null || roles.size() == 0)
133         {
134             return null;
135         }
136
137         return new TKHashtable();
138     }
139
140     /**
141      * Returns a hashtable suitable for template processing.
142      *
143      * @param users a list of users.
144      * @return a hashtable suitable for template processing.
145      * @throws TKException if an error occurred during the
146      * conversion.
147      */

148     public static TKHashtable makeUserReport (TKVector users)
149         throws TKException
150     {
151         if (users == null || users.size() == 0)
152         {
153             return null;
154         }
155
156         return new TKHashtable();
157     }
158
159 }
160
Popular Tags