org.olat.group.context
Class BGContextManagerImpl

java.lang.Object
  extended by org.olat.group.context.BGContextManagerImpl
All Implemented Interfaces:
BGContextManager

public class BGContextManagerImpl
extends java.lang.Object
implements BGContextManager

Description:
Implementation of the business group context manager.

Initial Date: Aug 19, 2004

Author:
gnaegi

Method Summary
 void addBGContextToResource(BGContext bgContext, OLATResource resource)
          Add a business group context to an OLATResource
 BGContext copyAndAddBGContextToResource(java.lang.String contextName, OLATResource resource, BGContext originalBgContext)
          Creates and persists a business group context as a copy of an existing business group context.
 int countBGOwnersOfBGContext(BGContext bgContext)
          Count the number of identities that are owner of any group in the given business group context
 int countBGParticipantsOfBGContext(BGContext bgContext)
          Count the number of identities that are participants of any group in the given business group context
 int countGroupsOfBGContext(BGContext bgContext)
          Count the number of groups within a business group context
 int countGroupsOfType(java.lang.String groupType)
          Count the number of groups of a certain group type
 BGContext createAndAddBGContextToResource(java.lang.String contextName, OLATResource resource, java.lang.String groupType, Identity initialOwner, boolean defaultContext)
          Creates a relation from a business group context to an OLATResource (e.g.
 BGContext createAndPersistBGContext(java.lang.String name, java.lang.String description, java.lang.String groupType, Identity owner, boolean defaultContext)
          Creates a busines group context object and persists the object in the database
 void deleteBGContext(BGContext bgContext)
          Deletes a business group context from the database
 java.util.List findBGContextsForIdentity(Identity identity, boolean defaultContexts, boolean nonDefaultContexts)
          Find all business group contexts for a specific user.
 java.util.List findBGContextsForResource(OLATResource resource, boolean defaultContexts, boolean nonDefaultContexts)
          Find all business group contexts for the given OLATResource defaultContexts and nonDefaultContexts can both be true or partly be true, but not be both false
 java.util.List findBGContextsForResource(OLATResource resource, java.lang.String groupType, boolean defaultContexts, boolean nonDefaultContexts)
          Find all business group contexts for the given OLATResource with the given group type defaultContexts and nonDefaultContexts can both be true or partly be true, but not be both false
 BusinessGroup findGroupAttendedBy(Identity identity, java.lang.String groupName, BGContext bgContext)
          Find a business group in the given business group context where the given user is in the group as participant
 BusinessGroup findGroupOfBGContext(java.lang.String groupName, BGContext bgContext)
          Find a business group in the given business group context
 java.util.List findOLATResourcesForBGContext(BGContext bgContext)
          Find all OLATResources that are associated with the given business group context
 java.util.List findRepositoryEntriesForBGContext(BGContext bgContext)
          Find all repository entries of the OLAT resources that have a relation to this group context.
 java.util.List getBGOwnersOfBGContext(BGContext bgContext)
          Find the identities that are owners of any group in the given business group context
 java.util.List getBGParticipantsOfBGContext(BGContext bgContext)
          Find the identities that are participants of any group in the given business group context
 java.util.List<BusinessGroup> getGroupsOfBGContext(BGContext bgContext)
          Find all groups from a business group context
static BGContextManager getInstance()
           
 boolean isIdentityInBGContext(Identity identity, BGContext bgContext, boolean asOwner, boolean asParticipant)
          Check if the given identity is in this business group context
 BGContext loadBGContext(BGContext bgContext)
          Refresh the given bgContext
 void removeBGContextFromResource(BGContext bgContext, OLATResource resource)
          Remove the given business group context from this OLATResource
 void updateBGContext(BGContext bgContext)
          Updates a business group context in the database
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static BGContextManager getInstance()
Returns:
singleton instance

createAndPersistBGContext

public BGContext createAndPersistBGContext(java.lang.String name,
                                           java.lang.String description,
                                           java.lang.String groupType,
                                           Identity owner,
                                           boolean defaultContext)
Description copied from interface: BGContextManager
Creates a busines group context object and persists the object in the database

Specified by:
createAndPersistBGContext in interface BGContextManager
Parameters:
name - Display name of the group context
groupType - Business group type that this business group context can contain
owner - The initial owner, the users who can manage the business group context using the group context management tool
defaultContext - true: create as a default context, false: create as a regular context
Returns:
The persisted business group context
See Also:
BGContextManager.createAndPersistBGContext(java.lang.String, java.lang.String, java.lang.String, org.olat.core.id.Identity, boolean)

copyAndAddBGContextToResource

public BGContext copyAndAddBGContextToResource(java.lang.String contextName,
                                               OLATResource resource,
                                               BGContext originalBgContext)
Description copied from interface: BGContextManager
Creates and persists a business group context as a copy of an existing business group context. The new created context will then be associated to the given OLATResource. The copy process will copy all business group areas and all business groups. The groups will be configured identically as the original groups but will not contain any users.

Specified by:
copyAndAddBGContextToResource in interface BGContextManager
Parameters:
contextName - The new context name
resource - The OALTResource that the new context should be associated with using the group context management tool
originalBgContext - The original business group context that is uses for the copy process
Returns:
The new copied business group context
See Also:
BGContextManager.copyAndAddBGContextToResource(java.lang.String, org.olat.resource.OLATResource, org.olat.group.context.BGContext)

updateBGContext

public void updateBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Updates a business group context in the database

Specified by:
updateBGContext in interface BGContextManager
See Also:
BGContextManager.updateBGContext(org.olat.group.context.BGContext)

deleteBGContext

public void deleteBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Deletes a business group context from the database

Specified by:
deleteBGContext in interface BGContextManager
See Also:
BGContextManager.deleteBGContext(org.olat.group.context.BGContext)

getGroupsOfBGContext

public java.util.List<BusinessGroup> getGroupsOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Find all groups from a business group context

Specified by:
getGroupsOfBGContext in interface BGContextManager
Parameters:
bgContext - the business group context or null to find groups that are not within a business group context (e.b. buddygroups)
Returns:
A list containing business group contexts
See Also:
BGContextManager.getGroupsOfBGContext(org.olat.group.context.BGContext)

countGroupsOfBGContext

public int countGroupsOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Count the number of groups within a business group context

Specified by:
countGroupsOfBGContext in interface BGContextManager
Returns:
The number of groups
See Also:
BGContextManager.countGroupsOfBGContext(org.olat.group.context.BGContext)

countGroupsOfType

public int countGroupsOfType(java.lang.String groupType)
Description copied from interface: BGContextManager
Count the number of groups of a certain group type

Specified by:
countGroupsOfType in interface BGContextManager
Returns:
See Also:
BGContextManager.countGroupsOfType(java.lang.String)

findGroupOfBGContext

public BusinessGroup findGroupOfBGContext(java.lang.String groupName,
                                          BGContext bgContext)
Description copied from interface: BGContextManager
Find a business group in the given business group context

Specified by:
findGroupOfBGContext in interface BGContextManager
Returns:
The business group or null if no group found
See Also:
BGContextManager.findGroupOfBGContext(java.lang.String, org.olat.group.context.BGContext)

findGroupAttendedBy

public BusinessGroup findGroupAttendedBy(Identity identity,
                                         java.lang.String groupName,
                                         BGContext bgContext)
Description copied from interface: BGContextManager
Find a business group in the given business group context where the given user is in the group as participant

Specified by:
findGroupAttendedBy in interface BGContextManager
Returns:
The business group or null if no group found
See Also:
BGContextManager.findGroupAttendedBy(org.olat.core.id.Identity, java.lang.String, org.olat.group.context.BGContext)

getBGOwnersOfBGContext

public java.util.List getBGOwnersOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Find the identities that are owners of any group in the given business group context

Specified by:
getBGOwnersOfBGContext in interface BGContextManager
Returns:
A list of identities
See Also:
BGContextManager.getBGOwnersOfBGContext(org.olat.group.context.BGContext)

countBGOwnersOfBGContext

public int countBGOwnersOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Count the number of identities that are owner of any group in the given business group context

Specified by:
countBGOwnersOfBGContext in interface BGContextManager
Returns:
The number of identities
See Also:
BGContextManager.countBGOwnersOfBGContext(org.olat.group.context.BGContext)

getBGParticipantsOfBGContext

public java.util.List getBGParticipantsOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Find the identities that are participants of any group in the given business group context

Specified by:
getBGParticipantsOfBGContext in interface BGContextManager
Returns:
A list of identities
See Also:
BGContextManager.getBGParticipantsOfBGContext(org.olat.group.context.BGContext)

countBGParticipantsOfBGContext

public int countBGParticipantsOfBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Count the number of identities that are participants of any group in the given business group context

Specified by:
countBGParticipantsOfBGContext in interface BGContextManager
Returns:
The number of identities
See Also:
BGContextManager.countBGParticipantsOfBGContext(org.olat.group.context.BGContext)

isIdentityInBGContext

public boolean isIdentityInBGContext(Identity identity,
                                     BGContext bgContext,
                                     boolean asOwner,
                                     boolean asParticipant)
Description copied from interface: BGContextManager
Check if the given identity is in this business group context

Specified by:
isIdentityInBGContext in interface BGContextManager
asOwner - Flag to check if the user is in any group as owner
asParticipant - Flag to check if the user is in any group as participant
Returns:
true if user is in any group with ghe given role, false otherwhise
See Also:
BGContextManager.isIdentityInBGContext(org.olat.core.id.Identity, org.olat.group.context.BGContext, boolean, boolean)

createAndAddBGContextToResource

public BGContext createAndAddBGContextToResource(java.lang.String contextName,
                                                 OLATResource resource,
                                                 java.lang.String groupType,
                                                 Identity initialOwner,
                                                 boolean defaultContext)
Description copied from interface: BGContextManager
Creates a relation from a business group context to an OLATResource (e.g. course)

Specified by:
createAndAddBGContextToResource in interface BGContextManager
Parameters:
contextName - The new context name
resource - The OALTResource that the new context should be associated with
groupType - The group type the context should be used for
initialOwner - The initial owner. the users who can manage the business group context using the group context management tool
defaultContext - true: create as a default context, false: create as a regular context
Returns:
The new created business group context
See Also:
BGContextManager.createAndAddBGContextToResource(java.lang.String, org.olat.resource.OLATResource, java.lang.String, org.olat.core.id.Identity, boolean)

addBGContextToResource

public void addBGContextToResource(BGContext bgContext,
                                   OLATResource resource)
Description copied from interface: BGContextManager
Add a business group context to an OLATResource

Specified by:
addBGContextToResource in interface BGContextManager
See Also:
BGContextManager.addBGContextToResource(org.olat.group.context.BGContext, org.olat.resource.OLATResource)

findBGContextsForResource

public java.util.List findBGContextsForResource(OLATResource resource,
                                                boolean defaultContexts,
                                                boolean nonDefaultContexts)
Description copied from interface: BGContextManager
Find all business group contexts for the given OLATResource defaultContexts and nonDefaultContexts can both be true or partly be true, but not be both false

Specified by:
findBGContextsForResource in interface BGContextManager
defaultContexts - true: find default contexts
nonDefaultContexts - true: find non-default contexts
Returns:
A list of business group contexts
See Also:
BGContextManager.findBGContextsForResource(org.olat.resource.OLATResource, boolean, boolean)

findBGContextsForResource

public java.util.List findBGContextsForResource(OLATResource resource,
                                                java.lang.String groupType,
                                                boolean defaultContexts,
                                                boolean nonDefaultContexts)
Description copied from interface: BGContextManager
Find all business group contexts for the given OLATResource with the given group type defaultContexts and nonDefaultContexts can both be true or partly be true, but not be both false

Specified by:
findBGContextsForResource in interface BGContextManager
defaultContexts - true: find default contexts
nonDefaultContexts - true: find non-default contexts
Returns:
A list of business group contexts
See Also:
BGContextManager.findBGContextsForResource(org.olat.resource.OLATResource, java.lang.String, boolean, boolean)

findBGContextsForIdentity

public java.util.List findBGContextsForIdentity(Identity identity,
                                                boolean defaultContexts,
                                                boolean nonDefaultContexts)
Description copied from interface: BGContextManager
Find all business group contexts for a specific user. This will find all contexts where the user is in the owner group and all context where the user is in the owner group of the olat resource that uses this context. defaultContexts and nonDefaultContexts can both be true or partly be true, but not be both false

Specified by:
findBGContextsForIdentity in interface BGContextManager
defaultContexts - true: find default contexts
nonDefaultContexts - true: find non-default contexts
Returns:
A list of business group contexts
See Also:
BGContextManager.findBGContextsForIdentity(org.olat.core.id.Identity, boolean, boolean)

findOLATResourcesForBGContext

public java.util.List findOLATResourcesForBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Find all OLATResources that are associated with the given business group context

Specified by:
findOLATResourcesForBGContext in interface BGContextManager
Returns:
A list of OLATResources
See Also:
BGContextManager.findOLATResourcesForBGContext(org.olat.group.context.BGContext)

findRepositoryEntriesForBGContext

public java.util.List findRepositoryEntriesForBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Find all repository entries of the OLAT resources that have a relation to this group context. (see findOlatResourcesForBGContext)

Specified by:
findRepositoryEntriesForBGContext in interface BGContextManager
Returns:
List of repository entries
See Also:
BGContextManager.findRepositoryEntriesForBGContext(org.olat.group.context.BGContext)

removeBGContextFromResource

public void removeBGContextFromResource(BGContext bgContext,
                                        OLATResource resource)
Description copied from interface: BGContextManager
Remove the given business group context from this OLATResource

Specified by:
removeBGContextFromResource in interface BGContextManager
See Also:
BGContextManager.removeBGContextFromResource(org.olat.group.context.BGContext, org.olat.resource.OLATResource)

loadBGContext

public BGContext loadBGContext(BGContext bgContext)
Description copied from interface: BGContextManager
Refresh the given bgContext

Specified by:
loadBGContext in interface BGContextManager
Returns:
BGContext the updated context
See Also:
BGContextManager.loadBGContext(org.olat.group.context.BGContext)