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 RelationEntityaddRelation(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.intgetSourcesCount(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.intgetTargetsCount(RelationQuery request)Get total number of related targets for the entity.booleanisRelated(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)Checks if given entities are related.voidmoveRelationsToContent(RelatableEntity fromRelatableEntity, RelatableEntity toRelatableEntity, RelationDescriptor descriptor)Moves all the relations of the specified type from one entity to another.intremoveAllRelations(RelatableEntity relatableEntity)This method removes all relations (across all names and types), where given entity participates.intremoveAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)This method removes all relations (across all names and types), where given entity participates.intremoveAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> readableEntities)This method removes all relations (across all names and types), where given entity participates.intremoveAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor, RelatableEntity relatableEntity)This method remove all relations of the given type where the given entity participatesvoidremoveRelation(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:RelationManagerChecks if given entities are related. Name of relation is specified byRelationargument.- Specified by:
isRelatedin interfaceRelationManager- Returns:
trueif entities are related,falseotherwise.
-
addRelation
public RelationEntity addRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Description copied from interface:RelationManagerCreate a new relation between 2 entities. This method does nothing if relation already exists. Name of relation is specified byRelationargument- Specified by:
addRelationin interfaceRelationManager- Returns:
- created (or existent) relation
-
removeRelation
public void removeRelation(RelatableEntity source, RelatableEntity target, RelationDescriptor relationDescriptor)
Description copied from interface:RelationManagerDelete relation. This method does nothing if relation already exists. Name of relation is specified byRelationargument- Specified by:
removeRelationin interfaceRelationManager
-
removeAllRelations
public int removeAllRelations(RelatableEntity relatableEntity)
Description copied from interface:RelationManagerThis method removes all relations (across all names and types), where given entity participates.- Specified by:
removeAllRelationsin interfaceRelationManager- Returns:
- number of relations which were removed.
-
removeAllRelationsFromEntityWithType
public int removeAllRelationsFromEntityWithType(RelationDescriptor relationDescriptor, RelatableEntity relatableEntity)
Description copied from interface:RelationManagerThis method remove all relations of the given type where the given entity participates- Specified by:
removeAllRelationsFromEntityWithTypein interfaceRelationManager- Returns:
- number of relations which were removed
-
removeAllRelationsFromCurrentAndHistoricalEntities
public int removeAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)
Description copied from interface:RelationManagerThis 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:
removeAllRelationsFromCurrentAndHistoricalEntitiesin interfaceRelationManager- Returns:
- number of relations which were removed.
-
removeAllRelationsFromCurrentAndHistoricalEntities
public int removeAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> readableEntities)
Description copied from interface:RelationManagerThis 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:
removeAllRelationsFromCurrentAndHistoricalEntitiesin interfaceRelationManager- Returns:
- number of relations which were removed.
-
getSources
public @NonNull PageResponse<RelatableEntity> getSources(RelationQuery request, LimitedRequest pageRequest)
Description copied from interface:RelationManagerFetch all related sources for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequestargument- Specified by:
getSourcesin interfaceRelationManager- Returns:
PageResponse- See Also:
RelationQuery,LimitedRequest
-
getTargets
public @NonNull PageResponse<RelatableEntity> getTargets(RelationQuery request, LimitedRequest pageRequest)
Description copied from interface:RelationManagerFetch all related targets for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequestargument- Specified by:
getTargetsin interfaceRelationManager- Returns:
PageResponse- See Also:
RelationQuery,LimitedRequest
-
getSourcesCount
public int getSourcesCount(RelationQuery request)
Description copied from interface:RelationManagerGet total number of related sources for the entity. Querying parameters (relation name, filtering etc.) is provided byrequestargument- Specified by:
getSourcesCountin interfaceRelationManager- Returns:
- total number of related sources for the entity
- See Also:
RelationQuery
-
getTargetsCount
public int getTargetsCount(RelationQuery request)
Description copied from interface:RelationManagerGet total number of related targets for the entity. Querying parameters (relation name, filtering etc.) is provided byrequestargument- Specified by:
getTargetsCountin 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:RelationManagerMoves 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:
moveRelationsToContentin 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
-
-