//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.usermodel;

import java.util.Iterator;

import org.huihoo.workflow.WorkflowComplexComponent;

/**
 * This interface represents the abstract notion of a user, which
 * can be used to represent any entity, such as an individual, a
 * corporation, and a login id.
 *
 */
public abstract class WorkflowParticipant extends WorkflowComplexComponent
{
	public final static String SUPER_ADMINISTRATOR_PACKAGE = "ALL_PACKAGES";

	/** 
	 * Construct a new WorkflowComponenet.
	 */
	protected WorkflowParticipant()
	{
		this(null,null);
	}
	
	/** 
	 * Construct a new WorkflowComponenet.
	 *
	 * @param uuid_ The element ID
	 * @param name The element name
	 */
	protected WorkflowParticipant(String uuid, String name)
	{
		this(uuid, name, null);
	}

	/** 
	 * Construct a new WorkflowComponenet.
	 *
	 * @param uuid_       The element ID
	 * @param name        The element name
	 * @param description The element description
	 */
	protected WorkflowParticipant(String uuid_, String name, String description)
	{
		super(uuid_, name, description);
	}
	
	// ------------------------------------------------------------- Properties
	/**
	 * Return the rank of this user.
	 */
	public abstract WorkflowRank getRank();

	/**
	 * Set the rank of this user.
	 *
	 * @param userRank The new rank
	 */
	public abstract void setRank(WorkflowRank userRank);

	/**
	 * Return the full name of this user.
	 */
	public abstract String getFullName();

	/**
	 * Set the full name of this user.
	 *
	 * @param fullName The new full name
	 */
	public abstract void setFullName(String fullName);

	/**
	 * Return the logon password of this user, optionally prefixed with the
	 * identifier of an encoding scheme surrounded by curly braces, such as
	 * <code>{md5}xxxxx</code>.
	 */
	public abstract String getPassword();

	/**
	 * jSet the logon password of this user, optionally prefixed with the
	 * identifier of an encoding scheme surrounded by curly braces, such as
	 * <code>{md5}xxxxx</code>.
	 *
	 * @param password The new logon password
	 */
	public abstract void setPassword(String password);

	/**
	 * Return the set of {@link Group}s to which this user belongs.
	 */
	public abstract Iterator getGroups();

	/**
	 * Return the set of {@link WorkflowRole}s to which this user belongs.
	 */
	public abstract Iterator getRoles();

	/**
	 * Return the set of {@link Department}s to which this user belongs.
	 */
	public abstract Iterator getDepartments();

	// --------------------------------------------------------- Public Methods
	/**
	 * Is this user in the specified Administrator group of WorkflowPackage?
	 *
	 * @param packageID The packageID to check
	 */
	public abstract boolean isAdministrator(String packageID);

	/**
	 * Add a new {@link Group} to those this user belongs to.
	 *
	 * @param group The new group
	 */
	public abstract void addGroup(WorkflowGroup group);

	/**
	 * Is this user in the specified {@link Group}?
	 *
	 * @param group The group to check
	 */
	public abstract boolean isInGroup(WorkflowGroup group);

	/**
	 * Remove a {@link Group} from those this user belongs to.
	 *
	 * @param group The old group
	 */
	public abstract void removeGroup(WorkflowGroup group);

	/**
	 * Remove all {@link Group}s from those this user belongs to.
	 */
	public abstract void removeGroups();

	/**
	 * Add a new {@link WorkflowRole} to those this user belongs to.
	 *
	 * @param role The new role
	 */
	public abstract void addRole(WorkflowRole role);

	/**
	 * Is this user in the specified {@link WorkflowRole}?
	 *
	 * @param role The role to check
	 */
	public abstract boolean isInRole(WorkflowRole role);

	/**
	 * Remove a {@link WorkflowRole} from those this user belongs to.
	 *
	 * @param role The old role
	 */
	public abstract void removeRole(WorkflowRole role);

	/**
	 * Remove all {@link WorkflowRole}s from those this user belongs to.
	 */
	public abstract void removeRoles();

	/**
	 * Add a new {@link Department} to those this user belongs to.
	 *
	 * @param department The new department
	 */
	public abstract void addDepartment(WorkflowDepartment department);

	/**
	 * Is this user in the specified {@link Department}?
	 *
	 * @param department The department to check
	 */
	public abstract boolean isInDepartment(WorkflowDepartment department);

	/**
	 * Remove a {@link Department} from those this user belongs to.
	 *
	 * @param department The old department
	 */
	public abstract void removeDepartment(WorkflowDepartment department);

	/**
	 * Remove all {@link Department}s from those this user belongs to.
	 */
	public abstract void removeDepartments();

}
