package de.webman.acl.eventhandler;
import java.util.*;
import com.teamkonzept.lib.*;
import de.webman.acl.*;
/**
* <b>ACReports</b> is a collection of functions for
* transforming lists of access control data into lists
* suitable for template processing.
*
* @author $Author: uli $
* @version $Revision: 1.4 $
*/
public class ACReports
{
/**
* Returns a hashtable suitable for template processing.
*
* @param tasks a list of tasks.
* @return a hashtable suitable for template processing.
* @throws TKException if an error occurred during the
* conversion.
*/
public static TKHashtable makeTaskReport (TKVector tasks)
throws TKException
{
if (tasks == null || tasks.size() == 0)
{
return null;
}
TKHashtable taskList = new TKHashtable();
Enumeration iterator = tasks.elements();
while (iterator.hasMoreElements())
{
Task task = (Task) iterator.nextElement();
Context context = task.getContext();
TKHashtable contextTable = (TKHashtable) taskList.get(context.getID());
if (contextTable == null)
{
contextTable = new TKHashtable();
contextTable.put("CONTEXT_NAME", context.getName());
contextTable.put("CONTEXT_SHORTCUT", context.getShortcut());
taskList.put(context.getID(), contextTable);
}
TKVector contextTasks = (TKVector) contextTable.get("CONTEXT_TASKS");
if (contextTasks == null)
{
contextTasks = new TKVector();
contextTable.put("CONTEXT_TASKS", contextTasks);
}
TKHashtable taskTable = new TKHashtable();
taskTable.put("TASK_ID", task.getID());
taskTable.put("TASK_NAME", task.getName());
TKVector roles = RoleFactory.getInstance().getRoles(task);
TKVector taskRoles = new TKVector(roles.size());
for (int index = 0; index < roles.size(); index++)
{
Role role = (Role) roles.elementAt(index);
TKHashtable roleTable = new TKHashtable();
roleTable.put("ROLE_NAME", role.getName());
taskRoles.addElement(roleTable);
}
taskTable.put("TASK_ROLES", taskRoles);
TKVector actions = task.getActions();
TKVector taskActions = new TKVector(actions.size());
for (int index = 0; index < actions.size(); index++)
{
Action action = (Action) actions.elementAt(index);
TKHashtable actionTable = new TKHashtable();
actionTable.put("ACTION_NAME", action.getName());
taskActions.addElement(actionTable);
}
taskTable.put("TASK_ACTIONS", taskActions);
contextTasks.addElement(taskTable);
}
return taskList;
}
/**
* Returns a hashtable suitable for template processing.
*
* @param groups a list of groups.
* @return a hashtable suitable for template processing.
* @throws TKException if an error occurred during the
* conversion.
*/
public static TKHashtable makeGroupReport (TKVector groups)
throws TKException
{
if (groups == null || groups.size() == 0)
{
return null;
}
return new TKHashtable();
}
/**
* Returns a hashtable suitable for template processing.
*
* @param roles a list of roles.
* @return a hashtable suitable for template processing.
* @throws TKException if an error occurred during the
* conversion.
*/
public static TKHashtable makeRoleReport (TKVector roles)
throws TKException
{
if (roles == null || roles.size() == 0)
{
return null;
}
return new TKHashtable();
}
/**
* Returns a hashtable suitable for template processing.
*
* @param users a list of users.
* @return a hashtable suitable for template processing.
* @throws TKException if an error occurred during the
* conversion.
*/
public static TKHashtable makeUserReport (TKVector users)
throws TKException
{
if (users == null || users.size() == 0)
{
return null;
}
return new TKHashtable();
}
}
|