Class RelationServiceImpl
- java.lang.Object
-
- com.atlassian.confluence.api.impl.service.relation.RelationServiceImpl
-
- All Implemented Interfaces:
RelationService
public class RelationServiceImpl extends Object implements RelationService
- Since:
- 5.9
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.api.service.relations.RelationService
RelationService.RelatableFinder<R extends Relatable>, RelationService.Validator
-
-
Constructor Summary
Constructors Constructor Description RelationServiceImpl(RelationManager relationManager, RelationInstanceFactory relationInstanceFactory, RelatableFactory relatableFactory, RelatableResolver relatableResolver, PaginationService paginationService, FavouriteManager favouriteManager, LikeManager likeManager, PermissionManager permissionManager, UserChecker userChecker, ValidatingRelationDescriptorRegistry relationDescriptorRegistry, AccessModeService accessModeService, LicenseService licenseService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S extends Relatable,T extends Relatable>
RelationInstance<S,T>create(RelationInstance<S,T> relationInstance)
Creates a directed relation between two relatable entities.<S extends Relatable,T extends Relatable>
voiddelete(RelationInstance<S,T> relationInstance)
Remove a relation if it exists between a source and a target relatable entity<S extends Relatable,T extends Relatable>
RelationService.RelatableFinder<S>findSources(T target, RelationDescriptor<S,T> relationDescriptor)
Create a finder to find sources of a relation.<S extends Relatable,T extends Relatable>
RelationService.RelatableFinder<T>findTargets(S source, RelationDescriptor<S,T> relationDescriptor)
Create a finder to find targets of a relation.<S extends Relatable,T extends Relatable>
booleanisRelated(S source, RelationDescriptor<S,T> relationDescriptor, T target)
Determine whether a given source and target are related by the given relation<S extends Relatable,T extends Relatable>
voidremoveAllRelationsFromEntityWithType(RelationDescriptor<S,T> relationDescriptor, Relatable relatable)
Remove all relations of the given type where the given entity participatesRelationService.Validator
validator()
-
-
-
Constructor Detail
-
RelationServiceImpl
public RelationServiceImpl(RelationManager relationManager, RelationInstanceFactory relationInstanceFactory, RelatableFactory relatableFactory, RelatableResolver relatableResolver, PaginationService paginationService, FavouriteManager favouriteManager, LikeManager likeManager, PermissionManager permissionManager, UserChecker userChecker, ValidatingRelationDescriptorRegistry relationDescriptorRegistry, AccessModeService accessModeService, LicenseService licenseService)
-
-
Method Detail
-
create
public <S extends Relatable,T extends Relatable> RelationInstance<S,T> create(RelationInstance<S,T> relationInstance) throws ServiceException
Description copied from interface:RelationService
Creates a directed relation between two relatable entities.For example, when a user favourites a space a SpaceFavouriteRelation is created from the user to the space:
relationService.create(RelationInstance.builder(user, new SpaceFavouriteRelation(), space).build))
;- Specified by:
create
in interfaceRelationService
- Type Parameters:
S
- type of the source entityT
- type of the target entity- Parameters:
relationInstance
- the relation to create- Returns:
- the newly created relationInstance
- Throws:
ServiceException
- if validation fails
-
delete
public <S extends Relatable,T extends Relatable> void delete(RelationInstance<S,T> relationInstance) throws ServiceException
Description copied from interface:RelationService
Remove a relation if it exists between a source and a target relatable entity- Specified by:
delete
in interfaceRelationService
- Type Parameters:
S
- type of the source entityT
- type of the target entity- Parameters:
relationInstance
- relation to be deleted- Throws:
ServiceException
- if validation fails
-
validator
public RelationService.Validator validator()
- Specified by:
validator
in interfaceRelationService
- Returns:
- a new validator to validate create and delete operations that can be performed using the RelationService
-
findTargets
public <S extends Relatable,T extends Relatable> RelationService.RelatableFinder<T> findTargets(S source, RelationDescriptor<S,T> relationDescriptor)
Description copied from interface:RelationService
Create a finder to find targets of a relation. This method is used to find all targets for given relation and given source. For example, it can be used in operations like "findAllFavouriteContentForGivenUser" (user2content relation) or "findAllUsersThisUserIsFollowingTo" (user2user relation)For example, to find spaces that a user has favourites :
relationService.findTargets(user, new SpaceFavouriteRelation()).fetchMany(new SimplePageRequest(0, 10));
- Specified by:
findTargets
in interfaceRelationService
- Type Parameters:
S
- the type of the source entityT
- the type of the target entity- Parameters:
source
- the source entity (LHS) of the relationrelationDescriptor
- the type of relation to find- Returns:
- a finder to find targets of a relation.
-
findSources
public <S extends Relatable,T extends Relatable> RelationService.RelatableFinder<S> findSources(T target, RelationDescriptor<S,T> relationDescriptor)
Description copied from interface:RelationService
Create a finder to find sources of a relation.This method is used to find all sources for given relation and given source. For example, it can be used in operations like "findAllUsersWhoFavouritedThisPage" (user2content relation) or "findAllFollowers" (user2user relation)
For example, to find users that favourite a particular space :
relationService.findSources(space, new SpaceFavouriteRelation()).fetchMany(new SimplePageRequest(0, 10));
- Specified by:
findSources
in interfaceRelationService
- Type Parameters:
S
- the type of the source entityT
- the type of the target entity- Parameters:
target
- the target entity (RHS) of the relationrelationDescriptor
- the type of relation to find- Returns:
- a finder to find targets of a relation.
-
isRelated
public <S extends Relatable,T extends Relatable> boolean isRelated(S source, RelationDescriptor<S,T> relationDescriptor, T target)
Description copied from interface:RelationService
Determine whether a given source and target are related by the given relation- Specified by:
isRelated
in interfaceRelationService
- Type Parameters:
S
- type of the source entityT
- type of the target entity- Returns:
- true if the relation exists between the given source and target
-
removeAllRelationsFromEntityWithType
public <S extends Relatable,T extends Relatable> void removeAllRelationsFromEntityWithType(RelationDescriptor<S,T> relationDescriptor, Relatable relatable)
Description copied from interface:RelationService
Remove all relations of the given type where the given entity participates- Specified by:
removeAllRelationsFromEntityWithType
in interfaceRelationService
- Type Parameters:
S
- the type of the source entity in the relation typeT
- the type of the target entity in the relation type- Parameters:
relationDescriptor
- relation descriptor representing the type of relation to removerelatable
- the entity participating in the relationships
-
-