com.arsdigita.kernel
Class Group

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.kernel.Party
                  extended bycom.arsdigita.kernel.Group

public class Group
extends Party

Represents a group.

Version:
1.0

Field Summary
static String BASE_DATA_OBJECT_TYPE
          Every instance of group must encapsulate a data object whose object type is either this base type or a subtype of this base type.
static String versionId
           
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE
 
Constructor Summary
Group()
          Default constructor.
Group(BigDecimal id)
          Constructor in which the contained DataObject is retrieved from the persistent storage mechanism with an OID specified by id and Group.BASE_DATA_OBJECT_TYPE.
Group(DataObject groupData)
           
Group(ObjectType type)
          Constructor in which the contained DataObject is initialized with a new DataObject with an ObjectType specified by type.
Group(OID oid)
          Constructor in which the contained DataObject is retrieved from the persistent storage mechanism with an OID specified by oid.
Group(String typeName)
          Constructor in which the contained DataObject is initialized with a new DataObject with an ObjectType specified by the string typeName.
 
Method Summary
 void addMember(User user)
          Adds a user to this group.
 void addMemberOrSubgroup(Party party)
          Adds a member/subgroup to this group.
 void addSubgroup(Group subgroup)
          Adds a subgroup to this group.
 void addSupergroup(Group supergroup)
          Adds a supergroup to this group (that is, adds this group as a subgroup of the specified group).
protected  void beforeSave()
           
 void clearMembers()
          Removes all direct members from this group.
 void clearSubgroups()
          Removes all direct subgroups from this group.
 void clearSupergroups()
          Removes this group from all groups of which this is a direct subgroup.
 long countAllMembers()
          Returns a count of this group's members (direct plus indirect).
 long countAllSubgroups()
          Returns a count of this group's subgroups (direct plus indirect).
 long countMembers()
          Returns a count of this group's direct members.
 long countSubgroups()
          Returns a count of this group's direct subgroups.
 Role createRole(String roleName)
          Creates a new role with the specified name in this group.
 void delete()
          Deletes this group.
 PartyCollection getAllContainedParties()
          Returns a collection of parties that are directly or indirectly members or subgroups of this group.
 PartyCollection getAllMembers()
          Returns a collection of users that are either directly or indirectly members of this group.
 UserCollection getAllMemberUsers()
          Returns a collection of users that are either directly or indirectly members of this group.
 GroupCollection getAllSubgroups()
          Returns a collection of groups that are subgroups of this group directly or indirectly.
 GroupCollection getAllSupergroups()
          Returns a collection of groups that are directly or indirectly supergroups of this group.
protected  String getBaseDataObjectType()
          Returns the base data object type for this domain object class.
 PartyCollection getContainedParties()
          Returns a collection of parties that are directly members or subgroups of this group.
 PartyCollection getMembers()
          Returns a collection of parties that are direct members of this group.
 UserCollection getMemberUsers()
          Returns a collection of users that are direct members of this group.
 String getName()
          Gets the name of this group.
 RoleCollection getOrderedRoles()
          Returns a collection of roles in this group ordered by name.
 Role getRole(String name)
          Returns the role with the specified name, or null if no such role exists for this group.
 RoleCollection getRoles()
          Returns a collection of roles in this group.
 GroupCollection getSubgroups()
          Returns a collection of groups that are direct subgroups of this group.
 GroupCollection getSupergroups()
          Returns a collection of groups that are direct supergroups of this group (that is, groups of which this is a subgroup).
 boolean hasDirectMember(Party party)
          Checks whether a user is a direct member of this group.
 boolean hasDirectMemberOrSubgroup(Party party)
          Checks whether a party is a member of this group (if the party is a User), or a subgroup of this group (if the party is a Group).
 boolean hasDirectSubgroup(Group subgroup)
          Checks whether a group is a direct subgroup of this group.
 boolean hasMember(Party party)
          Checks whether a user is directly or indirectly a member of this group.
 boolean hasSubgroup(Group subgroup)
          Checks whether a group is a subgroup of this group (either directly or indirectly).
 boolean isEmpty()
          Checks whether this group has any members or subgroups.
 void removeMember(User user)
          Removes a user from this group.
 void removeMemberOrSubgroup(Party party)
          Removes a member/subgroup from this group.
 void removeSubgroup(Group subgroup)
          Removes a subgroup from this group.
 void removeSupergroup(Group supergroup)
          Removes a supergroup from this group (that is, removes this group as a subgroup of the specified group).
static GroupCollection retrieveAll()
          Retrieves all groups.
 void setName(String name)
          Sets the name of this group.
 
Methods inherited from class com.arsdigita.kernel.Party
addEmailAddress, getAlternateEmails, getDisplayName, getEmailAddresses, getPrimaryEmail, getURI, removeEmailAddress, retrieveAllParties, setPrimaryEmail, setURI
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, initialize, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
Every instance of group must encapsulate a data object whose object type is either this base type or a subtype of this base type.

See Also:
Constant Field Values
Constructor Detail

Group

public Group(DataObject groupData)

Group

public Group()
Default constructor. The contained DataObject is initialized with a new DataObject with an ObjectType of "Group".

See Also:
Party.Party(String), DataObject, ObjectType

Group

public Group(String typeName)
Constructor in which the contained DataObject is initialized with a new DataObject with an ObjectType specified by the string typeName.

Parameters:
typeName - the name of the ObjectType of the contained DataObject
See Also:
Party.Party(ObjectType), DataObject, ObjectType

Group

public Group(ObjectType type)
Constructor in which the contained DataObject is initialized with a new DataObject with an ObjectType specified by type.

Parameters:
type - the ObjectType of the created object
See Also:
Party.Party(ObjectType), DataObject, ObjectType

Group

public Group(OID oid)
      throws DataObjectNotFoundException
Constructor in which the contained DataObject is retrieved from the persistent storage mechanism with an OID specified by oid.

Parameters:
oid - the OID for the retrieved DataObject
See Also:
Party.Party(OID), DataObject, OID

Group

public Group(BigDecimal id)
      throws DataObjectNotFoundException
Constructor in which the contained DataObject is retrieved from the persistent storage mechanism with an OID specified by id and Group.BASE_DATA_OBJECT_TYPE.

Parameters:
id - the id for the retrieved DataObject
See Also:
Party.Party(OID), BASE_DATA_OBJECT_TYPE, DataObject, OID
Method Detail

getBaseDataObjectType

protected String getBaseDataObjectType()
Description copied from class: DomainObject
Returns the base data object type for this domain object class. Intended to be overrided by subclasses whenever the subclass will only work if their primary data object is of a certain base type.

Overrides:
getBaseDataObjectType in class Party

getName

public String getName()
Gets the name of this group.

Specified by:
getName in class Party
Returns:
the name of this group.

setName

public void setName(String name)
Sets the name of this group.

Parameters:
name - this group's name

getMembers

public PartyCollection getMembers()
Returns a collection of parties that are direct members of this group. Currently, this is the same as getMemberUsers(). However, in the future we may allow other types of parties to be members of groups (specifically, we may allow groups to be members of groups).

NOTE: Any prior calls to addMember() or removeMember() will not affect the resulting collection unless save() has been called after adding or removing the member(s).

Returns:
a collection of parties that are direct members of this group.

getMemberUsers

public UserCollection getMemberUsers()
Returns a collection of users that are direct members of this group.

NOTE: Any prior calls to addMember() or removeMember() will not affect the resulting collection unless save() has been called after adding or removing the member(s).

Returns:
a collection of users that are direct members of this group.

addMember

public void addMember(User user)
Adds a user to this group.

Parameters:
user - the user to add to this group

removeMember

public void removeMember(User user)
Removes a user from this group.

Parameters:
user - the user to remove from this group

hasDirectMember

public boolean hasDirectMember(Party party)
Checks whether a user is a direct member of this group.

Returns:
true if the user is a direct member of group; false otherwise.

countMembers

public long countMembers()
Returns a count of this group's direct members.

Returns:
a count of this group's direct members.

hasDirectSubgroup

public boolean hasDirectSubgroup(Group subgroup)
Checks whether a group is a direct subgroup of this group.

Parameters:
subgroup - the subgroup to check
Returns:
true if the specified group is a direct subgroup of this group; false otherwise.

countSubgroups

public long countSubgroups()
Returns a count of this group's direct subgroups.

Returns:
a count of this group's direct subgroups.

isEmpty

public boolean isEmpty()
Checks whether this group has any members or subgroups.

Returns:
false if this group has any members or subgroups; true otherwise.

clearMembers

public void clearMembers()
Removes all direct members from this group.

Throws:
PersistenceException - if members could not be cleared because of a database or persistence exception.

clearSubgroups

public void clearSubgroups()
                    throws PersistenceException
Removes all direct subgroups from this group.

Throws:
PersistenceException - if subgroups could not be cleared because of a database or persistence exception.

clearSupergroups

public void clearSupergroups()
                      throws PersistenceException
Removes this group from all groups of which this is a direct subgroup.

Throws:
PersistenceException - if supergroups could not be cleared because of a database or persistence exception.
See Also:
delete()

getSubgroups

public GroupCollection getSubgroups()
Returns a collection of groups that are direct subgroups of this group.

NOTE: Any prior calls to addSubgroup() or removeSubgroup() will not affect the resulting collection unless save() has been called after adding or removing the subgroup(s).

Returns:
a collection of groups that are direct subgroups of this group.

addSubgroup

public void addSubgroup(Group subgroup)
Adds a subgroup to this group.

Parameters:
subgroup - the subgroup to add to this group

removeSubgroup

public void removeSubgroup(Group subgroup)
Removes a subgroup from this group.

Parameters:
subgroup - the subgroup to remove from this group

getSupergroups

public GroupCollection getSupergroups()
Returns a collection of groups that are direct supergroups of this group (that is, groups of which this is a subgroup).

NOTE: Any prior calls to addSupergroup() or removeSupergroup() will not affect the resulting collection unless save() has been called after adding or removing the supergroup(s).

Returns:
a collection of groups that are direct supergroups of this group.

addSupergroup

public void addSupergroup(Group supergroup)
Adds a supergroup to this group (that is, adds this group as a subgroup of the specified group).

This has the same effect as calling supergroup.addSubgroup(this), except in that case the change persists when the supergroup is saved. For example:

 groupA.addSubgroup(groupB);
 groupA.save();
 
is equivalent to
 groupB.addSupergroup(groupA);
 groupB.save();
 

Parameters:
supergroup - the supergroup to add to this group

removeSupergroup

public void removeSupergroup(Group supergroup)
Removes a supergroup from this group (that is, removes this group as a subgroup of the specified group).

This has the same effect as calling supergroup.removeSubgroup(this), except in that case, the change persists when the supergroup is saved. For example:

 groupA.removeSubgroup(groupB);
 groupA.save();
 
is equivalent to
 groupB.removeSupergroup(groupA);
 groupB.save();
 

Parameters:
supergroup - the supergroup to remove from this group

getContainedParties

public PartyCollection getContainedParties()
Returns a collection of parties that are directly members or subgroups of this group.

NOTE: Any prior calls to membership or subgroup methods will not affect the resulting collection until save() has been called.

Returns:
a collection of parties that are directly contained in this group

getAllSubgroups

public GroupCollection getAllSubgroups()
Returns a collection of groups that are subgroups of this group directly or indirectly.

NOTE: any prior calls to addSubgroup() or removeSubgroup() will not affect the resulting collection unless save() has been called after adding or removing the subgroup(s).

Returns:
A collection of groups that are subgroups of this group.

getAllSupergroups

public GroupCollection getAllSupergroups()
Returns a collection of groups that are directly or indirectly supergroups of this group.

NOTE: Any prior calls to addSupergroup() or removeSupergroup() will not affect the resulting collection unless save() has been called after adding or removing the supergroup(s).

Returns:
a collection of groups that are supergroups of this group.

getAllContainedParties

public PartyCollection getAllContainedParties()
Returns a collection of parties that are directly or indirectly members or subgroups of this group.

NOTE: Any prior calls to membership or subgroup methods will not affect the resulting collection until save() has been called.

Returns:
a collection of parties that are contained in this group

getAllMembers

public PartyCollection getAllMembers()
Returns a collection of users that are either directly or indirectly members of this group. For example, if user x is a member of group A, and A is a subgroup of B, then B.getAllMembers() will contain user x.

Currently, this is the same as getAllMemberUsers(). However, in the future we may allow other types of parties to be members of groups (specifically, we may allow groups to be members of groups).

NOTE: Any prior calls to addMember() or removeMember() will not affect the resulting collection unless save() has been called after adding or removing the member(s).

Returns:
a collection of partiess that are members of this group.
See Also:
PartyCollection

getAllMemberUsers

public UserCollection getAllMemberUsers()
Returns a collection of users that are either directly or indirectly members of this group. For example, if user x is a member of group A, and A is a subgroup of B, then B.getAllMemberUsers() will contain user x.

NOTE: Any prior calls to addMember() or removeMember() will not affect the resulting collection unless save() has been called after adding or removing the member(s).

Returns:
a collection of users that are members of this group.
See Also:
UserCollection

hasMember

public boolean hasMember(Party party)
Checks whether a user is directly or indirectly a member of this group.

Returns:
true if the user is a direct or indirect member; false otherwise.

countAllMembers

public long countAllMembers()
Returns a count of this group's members (direct plus indirect).

Returns:
the total number of members of this group.

hasSubgroup

public boolean hasSubgroup(Group subgroup)
Checks whether a group is a subgroup of this group (either directly or indirectly).

Parameters:
subgroup - the subgroup to check
Returns:
true if the specified group is a direct or indirect subgroup of this group; false otherwise.

countAllSubgroups

public long countAllSubgroups()
Returns a count of this group's subgroups (direct plus indirect).

Returns:
the total number of subgroups of this group.

hasDirectMemberOrSubgroup

public boolean hasDirectMemberOrSubgroup(Party party)
Checks whether a party is a member of this group (if the party is a User), or a subgroup of this group (if the party is a Group).

Parameters:
party - the user/group to check
Returns:
true if the specified party is a user that is a direct member of this group, or if the specified party is a group that is a direct subgroup of this group; false otherwise.

addMemberOrSubgroup

public void addMemberOrSubgroup(Party party)
Adds a member/subgroup to this group. (If the party is a User, it's made a member. If it's a Group, it's made a subgroup.)

Parameters:
party - the party to add to this group

removeMemberOrSubgroup

public void removeMemberOrSubgroup(Party party)
Removes a member/subgroup from this group.

Parameters:
party - the party to remove from this group

createRole

public Role createRole(String roleName)
Creates a new role with the specified name in this group. The role is automatically saved whenever the group itself is saved. Note that roles can only be created after the group for which the role is being created is itself saved.

Parameters:
roleName - the name for the role to be added to this group
Returns:
the new role.
See Also:
Role

getRoles

public RoleCollection getRoles()
Returns a collection of roles in this group.

NOTE: Any prior calls to createRole() will not affect the resulting collection unless save() has been called after adding or removing the role(s).

Returns:
a collection of roles in this group.

getRole

public Role getRole(String name)
Returns the role with the specified name, or null if no such role exists for this group.

NOTE: any prior calls to createRole() will not affect the resulting collection unless save() has been called after adding or removing the role(s).

Parameters:
name - the name of the role to retrieve
Returns:
the specified role.

getOrderedRoles

public RoleCollection getOrderedRoles()
Returns a collection of roles in this group ordered by name.

NOTE: Any prior calls to createRole() will not affect the resulting collection unless save() has been called after adding or removing the role(s).

Returns:
a collection of roles in this group, ordered by name.

beforeSave

protected void beforeSave()
                   throws PersistenceException
Overrides:
beforeSave in class ACSObject
Throws:
PersistenceException

delete

public void delete()
            throws PersistenceException
Deletes this group. The group is removed from all supergroups (see clearSupergroups()).

Overrides:
delete in class DomainObject
Throws:
PersistenceException
See Also:
DataObject.delete()

retrieveAll

public static GroupCollection retrieveAll()
Retrieves all groups.

Returns:
a collection of all groups.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC