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.intgetRelationsCount(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.intgetSourcesCount(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.intgetTargetsCount(RelationQuery<S> request)Count of all related targets for the entity.intremoveAllRelations(RelatableEntity relatableEntity)This method removes all relations (across all names and types), where given entity participates.intremoveAllRelations(Iterable<? extends RelatableEntity> relatableEntities)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> relatableEntities)This method removes all relations (across all names and types), where given entity participates.intremoveAllRelationsFromEntityWithName(String relationName, RelatableEntity relatableEntity)This method remove all relations with the given name, where the given entity participatesvoidremoveRelationEntity(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:
RelationEntityornullif 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 byrequestargument- 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 byrequestargument- 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 byrequestargument- 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 byrequestargument- 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
-
-