Interface RelationDao<S extends RelatableEntity,​T extends RelatableEntity>

    • 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 or null 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 by request 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 by request 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 by request 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 by request 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