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:
org.springframework.data.repository.CrudRepository<RelationshipRest,Integer>,org.springframework.data.repository.PagingAndSortingRepository<RelationshipRest,Integer>,org.springframework.data.repository.Repository<RelationshipRest,Integer>
@Component("core.relationship") 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 Constructor Description RelationshipRestRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RelationshipRestcreateAndReturn(org.dspace.core.Context context, List<String> stringList)Method to implement to support the creation of a new instance.protected voiddelete(org.dspace.core.Context context, Integer id)Method to implement to support delete of a single object instanceorg.springframework.data.domain.Page<RelationshipRest>findAll(org.dspace.core.Context context, org.springframework.data.domain.Pageable pageable)Method to implement to support scroll of entity instances from the collection resource endpointorg.springframework.data.domain.Page<RelationshipRest>findByLabel(String label, UUID dsoId, 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.RelationshipRestfindOne(org.dspace.core.Context context, Integer integer)Method to implement to support retrieval of a specific REST object instanceClass<RelationshipRest>getDomainClass()The REST model supported by the repositoryRelationshipRestput(org.dspace.core.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-rightprotected RelationshipRestput(org.dspace.core.Context context, javax.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)-
Methods inherited from class org.dspace.app.rest.repository.DSpaceRestRepository
action, action, count, createAndReturn, createAndReturn, createAndReturn, createAndReturn, createAndReturn, delete, deleteAll, deleteAll, deleteById, existsById, findAll, findAll, findAll, findAllById, findById, patch, patch, put, put, put, save, save, saveAll, upload, upload, upload
-
Methods inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
getRequestService, obtainContext
-
-
-
-
Method Detail
-
findOne
@PreAuthorize("permitAll()") public RelationshipRest findOne(org.dspace.core.Context context, Integer integer)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(org.dspace.core.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
public Class<RelationshipRest> getDomainClass()
Description copied from class:DSpaceRestRepositoryThe REST model supported by the repository- Specified by:
getDomainClassin classDSpaceRestRepository<RelationshipRest,Integer>
-
createAndReturn
protected RelationshipRest createAndReturn(org.dspace.core.Context context, List<String> stringList) throws org.dspace.authorize.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:
org.dspace.authorize.AuthorizeExceptionSQLExceptionRepositoryMethodNotImplementedException- returned by the default implementation when the operation is not supported for the entity
-
put
public RelationshipRest put(org.dspace.core.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(org.dspace.core.Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, Integer id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, org.dspace.authorize.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:
RepositoryMethodNotImplementedExceptionSQLExceptionorg.dspace.authorize.AuthorizeException
-
delete
protected void delete(org.dspace.core.Context context, Integer id) throws org.dspace.authorize.AuthorizeExceptionDescription 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:
org.dspace.authorize.AuthorizeException
-
findByLabel
public org.springframework.data.domain.Page<RelationshipRest> findByLabel(String label, UUID dsoId, 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 presentpageable- The page object- Returns:
- A page with all the RelationshipRest objects that correspond to the constraints
- Throws:
SQLException- If something goes wrong
-
-