Interface RelationDao<S extends RelatableEntity,T extends RelatableEntity>
-
- All Known Implementing Classes:
Content2ContentHibernateRelationDao
,HibernateRelationDao
,User2ContentHibernateRelationDao
,User2UserHibernateRelationDao
public interface RelationDao<S extends RelatableEntity,T extends RelatableEntity>
Relation dao interface.- Since:
- 5.9
- See Also:
RelationManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RelationEntity<S,T>
createRelationEntity(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Create new relation.@Nullable RelationEntity<S,T>
getRelationEntity(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Get relation for given content, type and name.int
getRelationsCount(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Get total number of relations for given content, type and name.@NonNull List<S>
getSources(RelationQuery<T> request, int start, int limit)
Fetch all related sources for the entity.int
getSourcesCount(RelationQuery<T> request)
Count of all related sources for the entity.@NonNull List<T>
getTargets(RelationQuery<S> request, int start, int limit)
Fetch all related targets for the entity.int
getTargetsCount(RelationQuery<S> request)
Count of all related targets for the entity.int
removeAllRelations(RelatableEntity relatableEntity)
This method removes all relations (across all names and types), where given entity participates.int
removeAllRelations(Iterable<? extends RelatableEntity> relatableEntities)
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> relatableEntities)
This method removes all relations (across all names and types), where given entity participates.int
removeAllRelationsFromEntityWithName(String relationName, RelatableEntity relatableEntity)
This method remove all relations with the given name, where the given entity participatesvoid
removeRelationEntity(RelationEntity<S,T> relationEntity)
Remove relation
-
-
-
Method Detail
-
getRelationsCount
int getRelationsCount(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Get total number of relations for given content, type and name.- Parameters:
source
-target
-relationDescriptor
- specifies relation metadata, such as type and name- Returns:
- total number of relations for given entities, relation type and name.
- See Also:
RelationDescriptor
-
createRelationEntity
RelationEntity<S,T> createRelationEntity(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Create new relation. and saves it to the database- Parameters:
source
-target
-relationDescriptor
- specifies relation metadata, such as type and name- See Also:
RelationEntity
-
removeRelationEntity
void removeRelationEntity(RelationEntity<S,T> relationEntity)
Remove relation- Parameters:
relationEntity
-- See Also:
RelationEntity
-
getRelationEntity
@Nullable RelationEntity<S,T> getRelationEntity(S source, T target, RelationDescriptor<?,?> relationDescriptor)
Get relation for given content, type and name.- Parameters:
source
-target
-relationDescriptor
- specifies relation metadata, such as type and name- Returns:
RelationEntity
ornull
if no relations found
-
getSources
@NonNull List<S> getSources(RelationQuery<T> request, int start, int limit)
Fetch all related sources for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Parameters:
request
-start
-limit
-- Returns:
- list of
RelatableEntity
- See Also:
RelationQuery
-
getTargets
@NonNull List<T> getTargets(RelationQuery<S> request, int start, int limit)
Fetch all related targets for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Parameters:
request
-start
-limit
-- Returns:
- list of
RelatableEntity
- See Also:
RelationQuery
-
getSourcesCount
int getSourcesCount(RelationQuery<T> request)
Count of all related sources for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Parameters:
request
-- Returns:
- total number of all sources
-
getTargetsCount
int getTargetsCount(RelationQuery<S> request)
Count of all related targets for the entity. Fetching parameters (relation name, filtering etc.) is provided byrequest
argument- Parameters:
request
-- Returns:
- total number of all targets
-
removeAllRelations
int removeAllRelations(RelatableEntity relatableEntity)
This method removes all relations (across all names and types), where given entity participates.- Parameters:
relatableEntity
-- Returns:
- number of relations which were removed.
-
removeAllRelations
int removeAllRelations(Iterable<? extends RelatableEntity> relatableEntities)
This method removes all relations (across all names and types), where given entity participates.- Parameters:
relatableEntities
-- Returns:
- number of relations which were removed.
- Since:
- 6.12.0
-
removeAllRelationsFromEntityWithName
int removeAllRelationsFromEntityWithName(String relationName, RelatableEntity relatableEntity)
This method remove all relations with the given name, where the given entity participates- Parameters:
relationName
-relatableEntity
-- Returns:
- number of relations which were removed
-
removeAllRelationsFromCurrentAndHistoricalEntities
int removeAllRelationsFromCurrentAndHistoricalEntities(RelatableEntity relatableEntity)
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- Parameters:
relatableEntity
-- Returns:
- number of relations which were removed.
-
removeAllRelationsFromCurrentAndHistoricalEntities
int removeAllRelationsFromCurrentAndHistoricalEntities(Iterable<? extends RelatableEntity> relatableEntities)
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- Parameters:
relatableEntities
-- Returns:
- number of relations which were removed
- Since:
- 6.12.0
-
-