Interface RemoteRelationService
- All Known Implementing Classes:
RemoteRelationServiceImpl
@ExperimentalApi
public interface RemoteRelationService
Relation service, which allows to manage relations between entities. "Relations" are used when it's needed to mark
related content. Good examples of relations are Watches (when user marks certain pages as watchable), Likes (user
marks content as "Liked") or Favourites (content is marked as favourite by user) (all are "user2content" type of
relations).
For example, to create a favourite relation between a user and the DEV Space :
relationService.create(RelationInstance.builder(user, new SpaceFavouriteRelation(), space).build));
assertTrue(relationService.isRelated(user, new SpaceFavouriteRelation(), space));
and to find the favourite spaces of a user :
relationService.findTargets(user, new SpaceFavouriteRelation()).fetchMany(new SimplePageRequest(0, 10));
- Since:
- 9.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<S extends Relatable,
T extends Relatable>
CompletionStage<Void>createCompletionStage
(RelationInstance<S, T> relationInstance) Creates a directed relation between two relatable entities.<S extends Relatable,
T extends Relatable>
CompletionStage<Void>deleteCompletionStage
(RelationInstance<S, T> relationInstance) Remove a relation if it exists between a source and a target relatable entity<S extends Relatable,
T extends Relatable>
CompletionStage<Boolean>isRelatedCompletionStage
(S source, RelationDescriptor<S, T> relationDescriptor, T target) Determine whether a given source and target are related by the given relation
-
Method Details
-
createCompletionStage
<S extends Relatable,T extends Relatable> CompletionStage<Void> createCompletionStage(RelationInstance<S, T> relationInstance) throws ServiceExceptionCreates 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))
;- 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- Since:
- 9.0
-
deleteCompletionStage
<S extends Relatable,T extends Relatable> CompletionStage<Void> deleteCompletionStage(RelationInstance<S, T> relationInstance) throws ServiceExceptionRemove a relation if it exists between a source and a target relatable entity- Type Parameters:
S
- type of the source entityT
- type of the target entity- Parameters:
relationInstance
- relation to be deleted- Throws:
ServiceException
- if validation fails- Since:
- 9.0
-
isRelatedCompletionStage
<S extends Relatable,T extends Relatable> CompletionStage<Boolean> isRelatedCompletionStage(S source, RelationDescriptor<S, T> relationDescriptor, T target) Determine whether a given source and target are related by the given relation- 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
- Since:
- 9.0
-