public interface RelationManager
It is very similar to the content properties, but the very important difference is that for given page we're not interested for all relations, but only if it is related with one particular entity (f.e. to show the page we don't need to know all the users who "favourited" this page, we just need to know if the current user did). At the same time we need to fetch all the contentproperties to render the page properly.
So it was decided to create generic relation service to feed and serve "relational" functionality efficiently.
Each relation contains a source (for example, in favourite relations, source is the user, which favourited some page),
target (for example, in favourite relations, target is the page, favourited by user) and some metadata like relation name etc.
Depends on type of entities, which participate in relation, relations may be one of the 3 types: user2user
(when both source and target are users - for example, following relation), user2content (example: favouriting, watching, Liking etc.)
and content2content (when both source and target are content object)
(pls. see RelationshipTypeEnum
for more details)
RelationEntity
,
RelatableEntity
,
RelationService
Modifier and Type | Method and Description |
---|---|
RelationEntity |
addRelation(RelatableEntity source,
RelatableEntity target,
RelationDescriptor relationDescriptor)
Create a new relation between 2 entities.
|
@NonNull PageResponse<RelatableEntity> |
getSources(RelationQuery request,
LimitedRequest pageRequest)
Fetch all related sources for the entity.
|
int |
getSourcesCount(RelationQuery request)
Get total number of related sources for the entity.
|
@NonNull PageResponse<RelatableEntity> |
getTargets(RelationQuery request,
LimitedRequest pageRequest)
Fetch all related targets for the entity.
|
int |
getTargetsCount(RelationQuery request)
Get total number of related targets for the entity.
|
boolean |
isRelated(RelatableEntity source,
RelatableEntity target,
RelationDescriptor relationDescriptor)
Checks if given entities are related.
|
void |
moveRelationsToContent(RelatableEntity fromRelatableEntity,
RelatableEntity toRelatableEntity,
RelationDescriptor descriptor)
Moves all the relations of the specified type from one entity to another.
|
int |
removeAllRelations(RelatableEntity relatableEntity)
This method removes all relations (across all names and types), where given entity participates.
|
int |
removeAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> readableEntities)
This method removes all relations (across all names and types), where given entity participates.
|
int |
removeAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)
This method removes all relations (across all names and types), where given entity participates.
|
int |
removeAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor,
RelatableEntity relatableEntity)
This method remove all relations of the given type where the given entity participates
|
void |
removeRelation(RelatableEntity source,
RelatableEntity target,
RelationDescriptor relationDescriptor)
Delete relation.
|
boolean isRelated(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Relation
argument.source
- target
- relationDescriptor
- true
if entities are related, false
otherwise.RelationEntity addRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Relation
argumentsource
- target
- relationDescriptor
- void removeRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Relation
argumentsource
- target
- relationDescriptor
- int removeAllRelations(RelatableEntity relatableEntity)
relatableEntity
- int removeAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor, RelatableEntity relatableEntity)
relationDescriptor
- relatableEntity
- int removeAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)
relatableEntity
- int removeAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> readableEntities)
readableEntities
- void moveRelationsToContent(RelatableEntity fromRelatableEntity, RelatableEntity toRelatableEntity, RelationDescriptor descriptor)
fromRelatableEntity
- the entity from which to remove the relationstoRelatableEntity
- the entity to which the relations will be addeddescriptor
- the type of relation to move@NonNull PageResponse<RelatableEntity> getSources(RelationQuery request, LimitedRequest pageRequest)
request
argumentrequest
- pageRequest
- PageResponse
RelationQuery
,
LimitedRequest
@NonNull PageResponse<RelatableEntity> getTargets(RelationQuery request, LimitedRequest pageRequest)
request
argumentrequest
- pageRequest
- PageResponse
RelationQuery
,
LimitedRequest
int getSourcesCount(RelationQuery request)
request
argumentrequest
- RelationQuery
int getTargetsCount(RelationQuery request)
request
argumentrequest
- RelationQuery
Copyright © 2003–2020 Atlassian. All rights reserved.