Package org.dspace.app.rest.repository
Class RelationshipRestRepository
java.lang.Object
org.dspace.app.rest.repository.AbstractDSpaceRestRepository
org.dspace.app.rest.repository.DSpaceRestRepository<RelationshipRest,Integer>
org.dspace.app.rest.repository.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
-
Field Summary
Fields inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
converter, utils -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RelationshipRestcreateAndReturn(Context context, List<String> stringList) Method to implement to support the creation of a new instance.protected voidMethod to implement to support delete of a single object instanceorg.springframework.data.domain.Page<RelationshipRest>Method to implement to support scroll of entity instances from the collection resource endpointorg.springframework.data.domain.Page<RelationshipRest>findByItemsAndType(Integer typeId, String label, UUID focusUUID, Set<UUID> items, org.springframework.data.domain.Pageable pageable) 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.org.springframework.data.domain.Page<RelationshipRest>findByLabel(String label, UUID dsoId, String relatedEntityType, org.springframework.data.domain.Pageable pageable) 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.Method to implement to support retrieval of a specific REST object instanceThe REST model supported by the repositoryprotected RelationshipRestput(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, Integer id, com.fasterxml.jackson.databind.JsonNode jsonNode) Method to replace the metadata of a relationship (the left/right places and the leftward/rightward labels)put(Context context, String contextPath, Integer id, List<String> stringList, Boolean itemToReplaceIsRight) 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-rightMethods inherited from class org.dspace.app.rest.repository.DSpaceRestRepository
action, action, count, createAndReturn, createAndReturn, createAndReturn, createAndReturn, createAndReturn, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAll, findAll, findAllById, findById, patch, patch, put, put, put, save, save, saveAll, setBeanName, upload, upload, uploadMethods inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
getRequestService, obtainContext
-
Constructor Details
-
RelationshipRestRepository
public RelationshipRestRepository()
-
-
Method Details
-
findOne
Description copied from class:DSpaceRestRepositoryMethod to implement to support retrieval of a specific REST object instance- Specified by:
findOnein classDSpaceRestRepository<RelationshipRest,Integer> - Parameters:
context- the dspace contextinteger- 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:DSpaceRestRepositoryMethod to implement to support scroll of entity instances from the collection resource endpoint- Specified by:
findAllin classDSpaceRestRepository<RelationshipRest,Integer> - Parameters:
context- the dspace contextpageable- object embedding the requested pagination info- Returns:
-
getDomainClass
Description copied from class:DSpaceRestRepositoryThe REST model supported by the repository- Specified by:
getDomainClassin classDSpaceRestRepository<RelationshipRest,Integer>
-
createAndReturn
protected RelationshipRest createAndReturn(Context context, List<String> stringList) throws AuthorizeException, SQLException, RepositoryMethodNotImplementedException Description copied from class:DSpaceRestRepositoryMethod to implement to support the creation of a new instance. Usually require to retrieve the http request from the thread bound attribute- Overrides:
createAndReturnin classDSpaceRestRepository<RelationshipRest,Integer> - Parameters:
context- the dspace contextstringList- 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:
AuthorizeExceptionSQLExceptionRepositoryMethodNotImplementedException- 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 hereid- ID of the relationship we wish to modifystringList- Item to replace either right or left item of relationship withitemToReplaceIsRight- 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:
putin classDSpaceRestRepository<RelationshipRest,Integer> - Parameters:
context- the dspace contextrequest-apiCategory- the API category e.g. "api"model- the DSpace model e.g. "metadatafield"id- the ID of the target REST objectjsonNode- the part of the request body representing the updated rest object- Returns:
- Throws:
RepositoryMethodNotImplementedExceptionSQLExceptionAuthorizeException
-
delete
Description copied from class:DSpaceRestRepositoryMethod to implement to support delete of a single object instance- Overrides:
deletein classDSpaceRestRepository<RelationshipRest,Integer> - Parameters:
context- the dspace contextid- 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 returneddsoId- The dsoId of the object that has to be a leftItem or rightItem if this parameter is presentrelatedEntityType- The entity type that the items who have a relationship with the given dso should havepageable- 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 relationshipslabel- 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 relationshipspageable- The page information- Returns:
- Throws:
SQLException- If database error
-