Class RelationshipRestRepository

All Implemented Interfaces:
Aware, BeanNameAware, org.springframework.data.repository.CrudRepository<RelationshipRest,Integer>, org.springframework.data.repository.PagingAndSortingRepository<RelationshipRest,Integer>, org.springframework.data.repository.Repository<RelationshipRest,Integer>

@Component("core.relationships") public class RelationshipRestRepository extends DSpaceRestRepository<RelationshipRest,Integer>
This is the repository that is responsible to manage Relationship Rest objects
  • Constructor Details

    • RelationshipRestRepository

      public RelationshipRestRepository()
  • Method Details

    • findOne

      @PreAuthorize("permitAll()") public RelationshipRest findOne(Context context, Integer integer)
      Description copied from class: DSpaceRestRepository
      Method to implement to support retrieval of a specific REST object instance
      Specified by:
      findOne in class DSpaceRestRepository<RelationshipRest,Integer>
      Parameters:
      context - the dspace context
      integer - the rest object id
      Returns:
      the REST object identified by its ID
    • findAll

      public org.springframework.data.domain.Page<RelationshipRest> findAll(Context context, org.springframework.data.domain.Pageable pageable)
      Description copied from class: DSpaceRestRepository
      Method to implement to support scroll of entity instances from the collection resource endpoint
      Specified by:
      findAll in class DSpaceRestRepository<RelationshipRest,Integer>
      Parameters:
      context - the dspace context
      pageable - object embedding the requested pagination info
      Returns:
    • getDomainClass

      public Class<RelationshipRest> getDomainClass()
      Description copied from class: DSpaceRestRepository
      The REST model supported by the repository
      Specified by:
      getDomainClass in class DSpaceRestRepository<RelationshipRest,Integer>
    • createAndReturn

      Description copied from class: DSpaceRestRepository
      Method to implement to support the creation of a new instance. Usually require to retrieve the http request from the thread bound attribute
      Overrides:
      createAndReturn in class DSpaceRestRepository<RelationshipRest,Integer>
      Parameters:
      context - the dspace context
      stringList - The list of Strings that will be used as data for the object that's to be created This list is retrieved from the uri-list body
      Returns:
      the created REST object
      Throws:
      AuthorizeException
      SQLException
      RepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entity
    • put

      public RelationshipRest put(Context context, String contextPath, Integer id, List<String> stringList, Boolean itemToReplaceIsRight) throws SQLException
      Method to replace either the right or left item of a relationship with a given new item Called by request mappings in RelationshipRestController - For replace right item (itemToReplaceIsRight = true) => Newly proposed changed relationship: left = old-left; right = new-item - For replace left item (itemToReplaceIsRight = false) => Newly proposed changed relationship: left = new-item; right = old-right
      Parameters:
      context -
      contextPath - What API call was made to get here
      id - ID of the relationship we wish to modify
      stringList - Item to replace either right or left item of relationship with
      itemToReplaceIsRight - Boolean to decide whether to replace right item (true) or left item (false)
      Returns:
      The (modified) relationship
      Throws:
      SQLException
    • put

      protected RelationshipRest put(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, Integer id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException
      Method to replace the metadata of a relationship (the left/right places and the leftward/rightward labels)
      Overrides:
      put in class DSpaceRestRepository<RelationshipRest,Integer>
      Parameters:
      context - the dspace context
      request -
      apiCategory - the API category e.g. "api"
      model - the DSpace model e.g. "metadatafield"
      id - the ID of the target REST object
      jsonNode - the part of the request body representing the updated rest object
      Returns:
      Throws:
      RepositoryMethodNotImplementedException
      SQLException
      AuthorizeException
    • delete

      protected void delete(Context context, Integer id) throws AuthorizeException
      Description copied from class: DSpaceRestRepository
      Method to implement to support delete of a single object instance
      Overrides:
      delete in class DSpaceRestRepository<RelationshipRest,Integer>
      Parameters:
      context - the dspace context
      id - the id of the rest object to delete
      Throws:
      AuthorizeException
    • findByLabel

      public org.springframework.data.domain.Page<RelationshipRest> findByLabel(String label, UUID dsoId, String relatedEntityType, org.springframework.data.domain.Pageable pageable) throws SQLException
      This method will find all the Relationship objects that a RelationshipType that corresponds to the given Label It's also possible to pass a DSO along to this method with a parameter which will only return Relationship objects that have this DSO as leftItem or rightItem. This endpoint is paginated
      Parameters:
      label - The label of a RelationshipType which the Relationships must have if they're to be returned
      dsoId - The dsoId of the object that has to be a leftItem or rightItem if this parameter is present
      relatedEntityType - The entity type that the items who have a relationship with the given dso should have
      pageable - The page object
      Returns:
      A page with all the RelationshipRest objects that correspond to the constraints
      Throws:
      SQLException - If something goes wrong
    • findByItemsAndType

      public org.springframework.data.domain.Page<RelationshipRest> findByItemsAndType(Integer typeId, String label, UUID focusUUID, Set<UUID> items, org.springframework.data.domain.Pageable pageable) throws SQLException
      This method is intended to be used when giving an item (focus) and a list of potentially related items we need to know which of these other items are already in a specific relationship with the focus item and, by exclusion which ones are not yet related.
      Parameters:
      typeId - The relationship type id to apply as a filter to the returned relationships
      label - The name of the relation as defined from the side of the 'focusItem'
      focusUUID - The uuid of the item to be checked on the side defined by 'relationshipLabel'
      items - The uuid of the items to be found on the other side of returned relationships
      pageable - The page information
      Returns:
      Throws:
      SQLException - If database error