Class DefaultRelationManager
- java.lang.Object
-
- com.atlassian.confluence.internal.relations.DefaultRelationManager
-
- All Implemented Interfaces:
RelationManager
public class DefaultRelationManager extends Object implements RelationManager
- Since:
- 5.9
-
-
Constructor Summary
Constructors Constructor Description DefaultRelationManager(@NonNull Content2ContentHibernateRelationDao content2ContentHibernateRelationDao, @NonNull User2ContentHibernateRelationDao user2ContentHibernateRelationDao, @NonNull User2UserHibernateRelationDao user2UserHibernateRelationDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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(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
removeAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor, RelatableEntity relatableEntity)
This method remove all relations of the given type where the given entity participatesvoid
removeRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Delete relation.
-
-
-
Constructor Detail
-
DefaultRelationManager
public DefaultRelationManager(@NonNull Content2ContentHibernateRelationDao content2ContentHibernateRelationDao, @NonNull User2ContentHibernateRelationDao user2ContentHibernateRelationDao, @NonNull User2UserHibernateRelationDao user2UserHibernateRelationDao)
-
-
Method Detail
-
isRelated
public boolean isRelated(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Description copied from interface:RelationManager
Checks if given entities are related. Name of relation is specified byRelation
argument.- Specified by:
isRelated
in interfaceRelationManager
- Returns:
true
if entities are related,false
otherwise.
-
addRelation
public RelationEntity addRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Description copied from interface:RelationManager
Create a new relation between 2 entities. This method does nothing if relation already exists. Name of relation is specified byRelation
argument- Specified by:
addRelation
in interfaceRelationManager
- Returns:
- created (or existent) relation
-
removeRelation
public void removeRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Description copied from interface:RelationManager
Delete relation. This method does nothing if relation already exists. Name of relation is specified byRelation
argument- Specified by:
removeRelation
in interfaceRelationManager
-
removeAllRelations
public int removeAllRelations(RelatableEntity relatableEntity)
Description copied from interface:RelationManager
This method removes all relations (across all names and types), where given entity participates.- Specified by:
removeAllRelations
in interfaceRelationManager
- Returns:
- number of relations which were removed.
-
removeAllRelationsFromEntityWithType
public int removeAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor, RelatableEntity relatableEntity)
Description copied from interface:RelationManager
This method remove all relations of the given type where the given entity participates- Specified by:
removeAllRelationsFromEntityWithType
in interfaceRelationManager
- Returns:
- number of relations which were removed
-
removeAllRelationsFromCurrentAndHistoricalEntities
public int removeAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)
Description copied from interface:RelationManager
This method removes all relations (across all names and types), where given entity participates. It also removes all relations from the historical versions of the given entity if the entity is the most current version of content- Specified by:
removeAllRelationsFromCurrentAndHistoricalEntities
in interfaceRelationManager
- Returns:
- number of relations which were removed.
-
removeAllRelationsFromCurrentAndHistoricalEntities
public int removeAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> readableEntities)
Description copied from interface:RelationManager
This method removes all relations (across all names and types), where given entity participates. It also removes all relations from the historical versions of the given entity if the entity is the most current version of content. This will try to use batch delete as much as possible- Specified by:
removeAllRelationsFromCurrentAndHistoricalEntities
in interfaceRelationManager
- Returns:
- number of relations which were removed.
-
getSources
public @NonNull PageResponse<RelatableEntity> getSources(RelationQuery request, LimitedRequest pageRequest)
Description copied from interface:RelationManager
Fetch all related sources for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Specified by:
getSources
in interfaceRelationManager
- Returns:
PageResponse
- See Also:
RelationQuery
,LimitedRequest
-
getTargets
public @NonNull PageResponse<RelatableEntity> getTargets(RelationQuery request, LimitedRequest pageRequest)
Description copied from interface:RelationManager
Fetch all related targets for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Specified by:
getTargets
in interfaceRelationManager
- Returns:
PageResponse
- See Also:
RelationQuery
,LimitedRequest
-
getSourcesCount
public int getSourcesCount(RelationQuery request)
Description copied from interface:RelationManager
Get total number of related sources for the entity. Querying parameters (relation name, filtering etc.) is provided byrequest
argument- Specified by:
getSourcesCount
in interfaceRelationManager
- Returns:
- total number of related sources for the entity
- See Also:
RelationQuery
-
getTargetsCount
public int getTargetsCount(RelationQuery request)
Description copied from interface:RelationManager
Get total number of related targets for the entity. Querying parameters (relation name, filtering etc.) is provided byrequest
argument- Specified by:
getTargetsCount
in interfaceRelationManager
- Returns:
- total number of related targets for the entity
- See Also:
RelationQuery
-
moveRelationsToContent
public void moveRelationsToContent(RelatableEntity fromRelatableEntity, RelatableEntity toRelatableEntity, RelationDescriptor descriptor)
Description copied from interface:RelationManager
Moves all the relations of the specified type from one entity to another. The source entity will have all relations of the specified type removed- Specified by:
moveRelationsToContent
in interfaceRelationManager
- Parameters:
fromRelatableEntity
- the entity from which to remove the relationstoRelatableEntity
- the entity to which the relations will be addeddescriptor
- the type of relation to move
-
-