org.dspace.eperson
Class Group

java.lang.Object
  extended by org.dspace.content.DSpaceObject
      extended by org.dspace.eperson.Group

public class Group
extends DSpaceObject

Class representing a group of e-people.

Version:
$Revision: 4903 $
Author:
David Stuve

Field Summary
static int ID
           
static int NAME
           
 
Method Summary
 void addMember(EPerson e)
          add an eperson member
 void addMember(Group g)
          add group to this group
static Set<Integer> allMemberGroupIDs(Context c, EPerson e)
          get Set of Integers all of the group memberships for an eperson
static Group[] allMemberGroups(Context c, EPerson e)
          Get all of the groups that an eperson is a member of
static Set<Integer> allMemberIDs(Context c, Group g)
          Get Set of all Integers all of the epeople members for a group
static EPerson[] allMembers(Context c, Group g)
          Get all of the epeople who are a member of the specified group, or a member of a sub-group of the specified group, etc.
static Group create(Context context)
          Create a new group
 void delete()
          Delete a group
 boolean equals(Object other)
          Return true if other is the same Group as this object, false otherwise
static Group find(Context context, int id)
          find the group by its ID
static Group[] findAll(Context context, int sortField)
          Finds all groups in the site
static Group findByName(Context context, String name)
          Find the group by its name - assumes name is unique
 String getHandle()
          Get the Handle of the object.
 int getID()
          get the ID of the group object
 Group[] getMemberGroups()
          Return Group members of a Group
 EPerson[] getMembers()
          Return EPerson members of a Group
 String getName()
          get name of group
 DSpaceObject getParentObject()
          Return the dspace object that "own" the current object in the hierarchy.
 int getType()
          Get the type of this object, found in Constants
 boolean isEmpty()
          Return true if group has no direct or indirect members
static boolean isMember(Context c, int groupid)
          fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method
 boolean isMember(EPerson e)
          check to see if an eperson is a direct member.
 boolean isMember(Group g)
          check to see if g is a direct group member.
 void loadData()
          Populate Group with eperson and group objects
 void removeMember(EPerson e)
          remove an eperson from a group
 void removeMember(Group g)
          remove group from this group
static Group[] search(Context context, String query)
          Find the groups that match the search query across eperson_group_id or name
static Group[] search(Context context, String query, int offset, int limit)
          Find the groups that match the search query across eperson_group_id or name
static int searchResultCount(Context context, String query)
          Returns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.
 void setName(String name)
          set name of group
 void update()
          Update the group - writing out group object and EPerson list if necessary
 
Methods inherited from class org.dspace.content.DSpaceObject
addDetails, clearDetails, find, getAdminObject, getDetails
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final int ID
See Also:
Constant Field Values

NAME

public static final int NAME
See Also:
Constant Field Values
Method Detail

loadData

public void loadData()
Populate Group with eperson and group objects

Throws:
SQLException

create

public static Group create(Context context)
                    throws SQLException,
                           AuthorizeException
Create a new group

Parameters:
context - DSpace context object
Throws:
SQLException
AuthorizeException

getID

public int getID()
get the ID of the group object

Specified by:
getID in class DSpaceObject
Returns:
id

getName

public String getName()
get name of group

Specified by:
getName in class DSpaceObject
Returns:
name

setName

public void setName(String name)
set name of group

Parameters:
name - new group name

addMember

public void addMember(EPerson e)
add an eperson member

Parameters:
e - eperson

addMember

public void addMember(Group g)
add group to this group

Parameters:
g -

removeMember

public void removeMember(EPerson e)
remove an eperson from a group

Parameters:
e - eperson

removeMember

public void removeMember(Group g)
remove group from this group

Parameters:
g -

isMember

public boolean isMember(EPerson e)
check to see if an eperson is a direct member. If the eperson is a member via a subgroup will be returned false

Parameters:
e - eperson to check membership

isMember

public boolean isMember(Group g)
check to see if g is a direct group member. If g is a subgroup via another group will be returned false

Parameters:
g - group to check
Returns:

isMember

public static boolean isMember(Context c,
                               int groupid)
                        throws SQLException
fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method

Parameters:
c - context
groupid - group ID to check
Throws:
SQLException

allMemberGroups

public static Group[] allMemberGroups(Context c,
                                      EPerson e)
                               throws SQLException
Get all of the groups that an eperson is a member of

Parameters:
c -
e -
Returns:
Throws:
SQLException

allMemberGroupIDs

public static Set<Integer> allMemberGroupIDs(Context c,
                                             EPerson e)
                                      throws SQLException
get Set of Integers all of the group memberships for an eperson

Parameters:
c -
e -
Returns:
Set of Integer groupIDs
Throws:
SQLException

allMembers

public static EPerson[] allMembers(Context c,
                                   Group g)
                            throws SQLException
Get all of the epeople who are a member of the specified group, or a member of a sub-group of the specified group, etc.

Parameters:
c - DSpace context
g - Group object
Returns:
Array of EPerson objects
Throws:
SQLException

allMemberIDs

public static Set<Integer> allMemberIDs(Context c,
                                        Group g)
                                 throws SQLException
Get Set of all Integers all of the epeople members for a group

Parameters:
c - DSpace context
g - Group object
Returns:
Set of Integer epersonIDs
Throws:
SQLException

find

public static Group find(Context context,
                         int id)
                  throws SQLException
find the group by its ID

Parameters:
context -
id -
Throws:
SQLException

findByName

public static Group findByName(Context context,
                               String name)
                        throws SQLException
Find the group by its name - assumes name is unique

Parameters:
context -
name -
Returns:
Group
Throws:
SQLException

findAll

public static Group[] findAll(Context context,
                              int sortField)
                       throws SQLException
Finds all groups in the site

Parameters:
context - DSpace context
sortField - field to sort by -- Group.ID or Group.NAME
Returns:
array of all groups in the site
Throws:
SQLException

search

public static Group[] search(Context context,
                             String query)
                      throws SQLException
Find the groups that match the search query across eperson_group_id or name

Parameters:
context - DSpace context
query - The search string
Returns:
array of Group objects
Throws:
SQLException

search

public static Group[] search(Context context,
                             String query,
                             int offset,
                             int limit)
                      throws SQLException
Find the groups that match the search query across eperson_group_id or name

Parameters:
context - DSpace context
query - The search string
offset - Inclusive offset
limit - Maximum number of matches returned
Returns:
array of Group objects
Throws:
SQLException

searchResultCount

public static int searchResultCount(Context context,
                                    String query)
                             throws SQLException
Returns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.

Parameters:
context - DSpace context
query - The search string
Returns:
the number of groups mathching the query
Throws:
SQLException

delete

public void delete()
            throws SQLException
Delete a group

Throws:
SQLException

getMembers

public EPerson[] getMembers()
Return EPerson members of a Group


getMemberGroups

public Group[] getMemberGroups()
Return Group members of a Group

Returns:

isEmpty

public boolean isEmpty()
Return true if group has no direct or indirect members


update

public void update()
            throws SQLException,
                   AuthorizeException
Update the group - writing out group object and EPerson list if necessary

Throws:
SQLException
AuthorizeException

equals

public boolean equals(Object other)
Return true if other is the same Group as this object, false otherwise

Overrides:
equals in class Object
Parameters:
other - object to compare to
Returns:
true if object passed in represents the same group as this object

getType

public int getType()
Description copied from class: DSpaceObject
Get the type of this object, found in Constants

Specified by:
getType in class DSpaceObject
Returns:
type of the object

getHandle

public String getHandle()
Description copied from class: DSpaceObject
Get the Handle of the object. This may return null

Specified by:
getHandle in class DSpaceObject
Returns:
Handle of the object, or null if it doesn't have one

getParentObject

public DSpaceObject getParentObject()
                             throws SQLException
Description copied from class: DSpaceObject
Return the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.

Overrides:
getParentObject in class DSpaceObject
Returns:
the dspace object that "own" the current object in the hierarchy
Throws:
SQLException


Copyright © 2010 DuraSpace. All Rights Reserved.