Package org.dspace.content.dao.impl
Class RelationshipDAOImpl
- All Implemented Interfaces:
RelationshipDAO,GenericDAO<Relationship>
public class RelationshipDAOImpl
extends AbstractHibernateDAO<Relationship>
implements RelationshipDAO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcountByItem(Context context, Item item, boolean excludeTilted, boolean excludeNonLatest) This method returns a count of Relationship objects that have the given Item object as a leftItem or a rightItemintcountByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft, boolean excludeNonLatest) Count total number of relationships (rows in relationship table) by an item and a relationship type and a boolean indicating whether the item should be the leftItem or the rightItemintcountByItemAndRelationshipTypeAndList(Context context, UUID focusUUID, RelationshipType relationshipType, List<UUID> items, boolean isLeft) Count total number of relationships that match focusItem on the one hand and matches list of related items elsewhere.intcountByRelationshipType(Context context, RelationshipType relationshipType) Count total number of relationships (rows in relationship table) by a relationship typeintcountByTypeName(Context context, String typeName) Count total number of relationships (rows in relationship table) given a typeNameintCount total number of relationships (rows in relationship table)findByItem(Context context, Item item, boolean excludeTilted, boolean excludeNonLatest) This method returns a list of Relationship objects that have the given Item object as a leftItem or a rightItemfindByItem(Context context, Item item, Integer limit, Integer offset, boolean excludeTilted, boolean excludeNonLatest) This method returns a list of Relationship objects that have the given Item object as a leftItem or a rightItemfindByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft, Integer limit, Integer offset, boolean excludeNonLatest) This method returns a list of Relationship objects for the given RelationshipType object.findByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, Integer limit, Integer offset, boolean excludeNonLatest) This method returns a list of Relationship objects for the given RelationshipType object.findByItemAndRelationshipTypeAndList(Context context, UUID focusUUID, RelationshipType relationshipType, List<UUID> items, boolean isLeft, int offset, int limit) This method is used to retrieve relationships that match focusItem on the one hand and matches list of related items elsewhere.findByLatestItemAndRelationshipType(Context context, Item latestItem, RelationshipType relationshipType, boolean isLeft) This method returns the UUIDs of all items that have a relationship with the given item, from the perspective of the other item.findByRelationshipType(Context context, RelationshipType relationshipType) This method returns a list of Relationship objects for the given RelationshipType object.findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit, Integer offset) This method returns a list of Relationship objects for the given RelationshipType object.findByTypeName(Context context, String typeName) This method returns a list of Relationship objects for the given typeNamefindByTypeName(Context context, String typeName, Integer limit, Integer offset) This method returns a list of Relationship objects for the given typeNameprotected jakarta.persistence.criteria.PredicategetLeftItemPredicate(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.Root<Relationship> relationshipRoot, Item item, boolean excludeTilted, boolean excludeNonLatest) Get the predicate for a criteria query that selects relationships by their left item.protected jakarta.persistence.criteria.PredicategetRightItemPredicate(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.Root<Relationship> relationshipRoot, Item item, boolean excludeTilted, boolean excludeNonLatest) Get the predicate for a criteria query that selects relationships by their right item.Methods inherited from class org.dspace.core.AbstractHibernateDAO
count, count, countLong, create, createQuery, createQuery, delete, executeCriteriaQuery, findAll, findAll, findByID, findByID, findByID, findByX, findMany, findMany, findUnique, getCriteriaBuilder, getCriteriaQuery, getHibernateSession, iterate, list, list, list, list, save, singleResult, singleResult, uniqueResult, uniqueResult
-
Constructor Details
-
RelationshipDAOImpl
public RelationshipDAOImpl()
-
-
Method Details
-
findByItem
public List<Relationship> findByItem(Context context, Item item, boolean excludeTilted, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects that have the given Item object as a leftItem or a rightItem- Specified by:
findByItemin interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextitem- The item that should be either a leftItem or a rightItem of all the Relationship objects in the returned listexcludeTilted- If true, excludes tilted relationshipsexcludeNonLatest- If true, excludes all relationships for which the other item has a more recent version that is relevant for this relationship- Returns:
- The list of Relationship objects that contain either a left or a right item that is equal to the given item
- Throws:
SQLException- If something goes wrong
-
findByItem
public List<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset, boolean excludeTilted, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects that have the given Item object as a leftItem or a rightItem- Specified by:
findByItemin interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextitem- The item that should be either a leftItem or a rightItem of all the Relationship objects in the returned listlimit- paging limitoffset- paging offsetexcludeTilted- If true, excludes tilted relationshipsexcludeNonLatest- If true, excludes all relationships for which the other item has a more recent version that is relevant for this relationship- Returns:
- The list of Relationship objects that contain either a left or a right item that is equal to the given item
- Throws:
SQLException- If something goes wrong
-
getLeftItemPredicate
protected jakarta.persistence.criteria.Predicate getLeftItemPredicate(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.Root<Relationship> relationshipRoot, Item item, boolean excludeTilted, boolean excludeNonLatest) Get the predicate for a criteria query that selects relationships by their left item.- Parameters:
criteriaBuilder- the criteria builder.relationshipRoot- the relationship root.item- the item that is being searched for.excludeTilted- if true, exclude tilted relationships.excludeNonLatest- if true, exclude relationships for which the opposite item is not the latest version that is relevant.- Returns:
- a predicate that satisfies the given restrictions.
-
getRightItemPredicate
protected jakarta.persistence.criteria.Predicate getRightItemPredicate(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.Root<Relationship> relationshipRoot, Item item, boolean excludeTilted, boolean excludeNonLatest) Get the predicate for a criteria query that selects relationships by their right item.- Parameters:
criteriaBuilder- the criteria builder.relationshipRoot- the relationship root.item- the item that is being searched for.excludeTilted- if true, exclude tilted relationships.excludeNonLatest- if true, exclude relationships for which the opposite item is not the latest version that is relevant.- Returns:
- a predicate that satisfies the given restrictions.
-
countByItem
public int countByItem(Context context, Item item, boolean excludeTilted, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOThis method returns a count of Relationship objects that have the given Item object as a leftItem or a rightItem- Specified by:
countByItemin interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextitem- The item that should be either a leftItem or a rightItem of all the Relationship objects in the returned listexcludeTilted- if true, excludes tilted relationshipsexcludeNonLatest- if true, exclude relationships for which the opposite item is not the latest version that is relevant- Returns:
- The list of Relationship objects that contain either a left or a right item that is equal to the given item
- Throws:
SQLException- If something goes wrong
-
findByRelationshipType
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given RelationshipType object. It will construct a list of all Relationship objects that have the given RelationshipType object as the relationshipType property- Specified by:
findByRelationshipTypein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextrelationshipType- The RelationshipType object to be checked on- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
findByRelationshipType
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit, Integer offset) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given RelationshipType object. It will construct a list of all Relationship objects that have the given RelationshipType object as the relationshipType property- Specified by:
findByRelationshipTypein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextrelationshipType- The RelationshipType object to be checked onlimit- paging limitoffset- paging offset- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
findByItemAndRelationshipType
public List<Relationship> findByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, Integer limit, Integer offset, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given RelationshipType object. It will construct a list of all Relationship objects that have the given RelationshipType object as the relationshipType property- Specified by:
findByItemAndRelationshipTypein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextitem- item to filter byrelationshipType- The RelationshipType object to be checked onlimit- paging limitoffset- paging offsetexcludeNonLatest- If true, excludes all relationships for which the other item has a more recent version that is relevant for this relationship- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
findByItemAndRelationshipType
public List<Relationship> findByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft, Integer limit, Integer offset, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given RelationshipType object. It will construct a list of all Relationship objects that have the given RelationshipType object as the relationshipType property- Specified by:
findByItemAndRelationshipTypein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contextitem- item to filter byrelationshipType- The RelationshipType object to be checked onisLeft- Is item left or rightlimit- paging limitoffset- paging offsetexcludeNonLatest- If true, excludes all relationships for which the other item has a more recent version that is relevant for this relationship- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
findByLatestItemAndRelationshipType
public List<ItemUuidAndRelationshipId> findByLatestItemAndRelationshipType(Context context, Item latestItem, RelationshipType relationshipType, boolean isLeft) throws SQLException Description copied from interface:RelationshipDAOThis method returns the UUIDs of all items that have a relationship with the given item, from the perspective of the other item. In other words, given a relationship with the given item, the given item should have "latest status" in order for the other item uuid to be returned. This method differs from the "excludeNonLatest" property in other methods, because in this method the current item should have "latest status" to return the other item, whereas with "excludeNonLatest" the other item should have "latest status" to be returned. This method is used to index items in solr; when searching for related items of one of the returned uuids, the given item should appear as a search result. NOTE: This method does not returnRelationships for performance, because doing so would eagerly fetch the items on both sides, which is unnecessary. NOTE: tilted relationships are NEVER excluded when fetching one relationship type.- Specified by:
findByLatestItemAndRelationshipTypein interfaceRelationshipDAO- Parameters:
context- the DSpace context.latestItem- the target item; only relationships where this item has "latest status" should be considered.relationshipType- the relationship type for which relationships should be selected.isLeft- whether the entity type of the item occurs on the left or right side of the relationship type. This is redundant in most cases, but necessary because relationship types my have the same entity type on both sides.- Returns:
- a list containing pairs of relationship ids and item uuids.
- Throws:
SQLException- if something goes wrong.
-
findByTypeName
Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given typeName- Specified by:
findByTypeNamein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contexttypeName- The leftward or rightward typeName of the relationship type- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
findByTypeName
public List<Relationship> findByTypeName(Context context, String typeName, Integer limit, Integer offset) throws SQLException Description copied from interface:RelationshipDAOThis method returns a list of Relationship objects for the given typeName- Specified by:
findByTypeNamein interfaceRelationshipDAO- Parameters:
context- The relevant DSpace contexttypeName- The leftward or rightward typeName of the relationship typelimit- paging limitoffset- paging offset- Returns:
- A list of Relationship objects that have the given RelationshipType object as the relationshipType property
- Throws:
SQLException- If something goes wrong
-
countByRelationshipType
public int countByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException Description copied from interface:RelationshipDAOCount total number of relationships (rows in relationship table) by a relationship type- Specified by:
countByRelationshipTypein interfaceRelationshipDAO- Parameters:
context- contextrelationshipType- relationship type to filter by- Returns:
- total count
- Throws:
SQLException- if database error
-
countRows
Description copied from interface:RelationshipDAOCount total number of relationships (rows in relationship table)- Specified by:
countRowsin interfaceRelationshipDAO- Parameters:
context- context- Returns:
- total count
- Throws:
SQLException- if database error
-
countByItemAndRelationshipType
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft, boolean excludeNonLatest) throws SQLException Description copied from interface:RelationshipDAOCount total number of relationships (rows in relationship table) by an item and a relationship type and a boolean indicating whether the item should be the leftItem or the rightItem- Specified by:
countByItemAndRelationshipTypein interfaceRelationshipDAO- Parameters:
context- contextitem- item to filter byrelationshipType- relationship type to filter byisLeft- indicating whether the counted Relationships should have the given Item on the left sideexcludeNonLatest- if true, exclude relationships for which the opposite item is not the latest version that is relevant- Returns:
- total count
- Throws:
SQLException- if database error
-
countByTypeName
Description copied from interface:RelationshipDAOCount total number of relationships (rows in relationship table) given a typeName- Specified by:
countByTypeNamein interfaceRelationshipDAO- Parameters:
context- contexttypeName- the relationship typeName to filter by- Returns:
- total count
- Throws:
SQLException- if database error
-
findByItemAndRelationshipTypeAndList
public List<Relationship> findByItemAndRelationshipTypeAndList(Context context, UUID focusUUID, RelationshipType relationshipType, List<UUID> items, boolean isLeft, int offset, int limit) throws SQLException Description copied from interface:RelationshipDAOThis method is used to retrieve relationships that match focusItem on the one hand and matches list of related items elsewhere.- Specified by:
findByItemAndRelationshipTypeAndListin interfaceRelationshipDAO- Parameters:
context- DSpace context objectfocusUUID- UUID of Item that will match left side if the param isLeft is true otherwise right siderelationshipType- Relationship type to filter byitems- List of UUID that will use to filter other side respect the focusUUIDisLeft- Indicating whether the counted Relationships should have the given Item on the left side or notoffset- paging offsetlimit- paging limit- Returns:
- Throws:
SQLException- If database error
-
countByItemAndRelationshipTypeAndList
public int countByItemAndRelationshipTypeAndList(Context context, UUID focusUUID, RelationshipType relationshipType, List<UUID> items, boolean isLeft) throws SQLException Description copied from interface:RelationshipDAOCount total number of relationships that match focusItem on the one hand and matches list of related items elsewhere.- Specified by:
countByItemAndRelationshipTypeAndListin interfaceRelationshipDAO- Parameters:
context- DSpace context objectfocusUUID- UUID of Item that will match left side if the param isLeft is true otherwise right siderelationshipType- Relationship type to filter byitems- List of UUID that will use to filter other side respect the focusUUIDisLeft- Indicating whether the counted Relationships should have the given Item on the left side or not- Returns:
- Throws:
SQLException- If database error
-