mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Rename code matching '[mM]apping[a-zA-Z]*' to '[mM]apped[a-zA-Z]*'
Rename 'mappingCollection' and similar code to 'mappedCollection', in order to resolve Tim Donohue's feedback on the pull request.
This commit is contained in:
@@ -23,8 +23,8 @@ import org.dspace.app.rest.exception.MethodNotAllowedException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.link.HalLinkService;
|
||||
import org.dspace.app.rest.model.CollectionRest;
|
||||
import org.dspace.app.rest.model.MappingCollectionRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappingCollectionResourceWrapper;
|
||||
import org.dspace.app.rest.model.MappedCollectionRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappedCollectionResourceWrapper;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -42,16 +42,16 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* This RestController takes care of the retrieval, creation and deletion of MappingCollections
|
||||
* This RestController takes care of the retrieval, creation and deletion of MappedCollections
|
||||
* This class will typically receive a UUID that resolves to an Item and it'll perform logic on its collections
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/core/items/" +
|
||||
"{uuid:[0-9a-fxA-FX]{8}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{12}}" +
|
||||
"/mappedCollections")
|
||||
public class MappingCollectionRestController {
|
||||
public class MappedCollectionRestController {
|
||||
|
||||
private static final Logger log = Logger.getLogger(MappingCollectionRestController.class);
|
||||
private static final Logger log = Logger.getLogger(MappedCollectionRestController.class);
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@@ -71,7 +71,7 @@ public class MappingCollectionRestController {
|
||||
/**
|
||||
* This method will retrieve a List of Collections in which the item, that corresponds to the given UUID, resides
|
||||
* The owning collection is not included in this list. It will transform the list of Collections to a list of
|
||||
* CollectionRest objects and it'll then encapsulate these into a MappingCollectionResourceWrapper object
|
||||
* CollectionRest objects and it'll then encapsulate these into a MappedCollectionResourceWrapper object
|
||||
*
|
||||
* curl -X GET http://<dspace.restUrl>/api/core/item/{uuid}/mappedCollections
|
||||
*
|
||||
@@ -90,7 +90,7 @@ public class MappingCollectionRestController {
|
||||
* @throws SQLException If something goes wrong
|
||||
*/
|
||||
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})
|
||||
public MappingCollectionResourceWrapper retrieve(@PathVariable UUID uuid, HttpServletResponse response,
|
||||
public MappedCollectionResourceWrapper retrieve(@PathVariable UUID uuid, HttpServletResponse response,
|
||||
HttpServletRequest request, Pageable pageable)
|
||||
throws SQLException {
|
||||
Context context = ContextUtil.obtainContext(request);
|
||||
@@ -104,10 +104,10 @@ public class MappingCollectionRestController {
|
||||
}
|
||||
}
|
||||
|
||||
MappingCollectionRestWrapper mappingCollectionRestWrapper = new MappingCollectionRestWrapper();
|
||||
mappingCollectionRestWrapper.setMappingCollectionRestList(mappingCollectionRest);
|
||||
MappedCollectionRestWrapper mappingCollectionRestWrapper = new MappedCollectionRestWrapper();
|
||||
mappingCollectionRestWrapper.setMappedCollectionRestList(mappingCollectionRest);
|
||||
mappingCollectionRestWrapper.setItem(item);
|
||||
MappingCollectionResourceWrapper mappingCollectionResourceWrapper = new MappingCollectionResourceWrapper(
|
||||
MappedCollectionResourceWrapper mappingCollectionResourceWrapper = new MappedCollectionResourceWrapper(
|
||||
mappingCollectionRestWrapper, utils, pageable);
|
||||
|
||||
|
@@ -18,8 +18,8 @@ import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.converter.ItemConverter;
|
||||
import org.dspace.app.rest.link.HalLinkService;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.app.rest.model.MappingItemRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappingItemResourceWrapper;
|
||||
import org.dspace.app.rest.model.MappedItemRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappedItemResourceWrapper;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -42,9 +42,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/api/core/collections/" +
|
||||
"{uuid:[0-9a-fxA-FX]{8}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{12}}/mappedItems")
|
||||
public class MappingItemRestController {
|
||||
public class MappedItemRestController {
|
||||
|
||||
private static final Logger log = Logger.getLogger(MappingItemRestController.class);
|
||||
private static final Logger log = Logger.getLogger(MappedItemRestController.class);
|
||||
|
||||
@Autowired
|
||||
private CollectionService collectionService;
|
||||
@@ -65,14 +65,14 @@ public class MappingItemRestController {
|
||||
* This method will retrieve a List of Item objects that are mapped to the Collection given in the URL.
|
||||
* These Item objects will be filtered out of their owning collection is the given collection, resulting in
|
||||
* returning only items that belong to a different collection but are mapped to the given one.
|
||||
* These Items are then encapsulated in a MappingItemResourceWrapper and returned
|
||||
* These Items are then encapsulated in a MappedItemResourceWrapper and returned
|
||||
*
|
||||
* curl -X GET http://<dspace.restUrl>/api/core/collections/{uuid}/mappingItems
|
||||
* curl -X GET http://<dspace.restUrl>/api/core/collections/{uuid}/mappedItems
|
||||
*
|
||||
* Example:
|
||||
* <pre>
|
||||
* {@code
|
||||
* curl -X GET http://<dspace.restUrl>/api/core/collections/8b632938-77c2-487c-81f0-e804f63e68e6/mappingItems
|
||||
* curl -X GET http://<dspace.restUrl>/api/core/collections/8b632938-77c2-487c-81f0-e804f63e68e6/mappedItems
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
@@ -84,7 +84,7 @@ public class MappingItemRestController {
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})
|
||||
public MappingItemResourceWrapper retrieve(@PathVariable UUID uuid, HttpServletResponse response,
|
||||
public MappedItemResourceWrapper retrieve(@PathVariable UUID uuid, HttpServletResponse response,
|
||||
HttpServletRequest request, Pageable pageable) throws Exception {
|
||||
Context context = ContextUtil.obtainContext(request);
|
||||
Collection collection = collectionService.find(context, uuid);
|
||||
@@ -99,13 +99,13 @@ public class MappingItemRestController {
|
||||
}
|
||||
}
|
||||
|
||||
MappingItemRestWrapper mappingItemRestWrapper = new MappingItemRestWrapper();
|
||||
mappingItemRestWrapper.setMappingItemRestList(mappedItemRestList);
|
||||
mappingItemRestWrapper.setCollectionUuid(uuid);
|
||||
MappingItemResourceWrapper mappingItemResourceWrapper =
|
||||
new MappingItemResourceWrapper(mappingItemRestWrapper, utils, totalElements);
|
||||
MappedItemRestWrapper mappedItemRestWrapper = new MappedItemRestWrapper();
|
||||
mappedItemRestWrapper.setMappedItemRestList(mappedItemRestList);
|
||||
mappedItemRestWrapper.setCollectionUuid(uuid);
|
||||
MappedItemResourceWrapper mappedItemResourceWrapper =
|
||||
new MappedItemResourceWrapper(mappedItemRestWrapper, utils, totalElements);
|
||||
|
||||
halLinkService.addLinks(mappingItemResourceWrapper, pageable);
|
||||
return mappingItemResourceWrapper;
|
||||
halLinkService.addLinks(mappedItemResourceWrapper, pageable);
|
||||
return mappedItemResourceWrapper;
|
||||
}
|
||||
}
|
@@ -9,24 +9,24 @@ package org.dspace.app.rest.link;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.dspace.app.rest.model.MappingCollectionRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappingCollectionResourceWrapper;
|
||||
import org.dspace.app.rest.model.MappedCollectionRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappedCollectionResourceWrapper;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
/**
|
||||
* This class' purpose is to add links to the MappingCollectionResourceWrapper objects
|
||||
* This class' purpose is to add links to the MappedCollectionResourceWrapper objects
|
||||
*/
|
||||
@Component
|
||||
public class MappingCollectionResourceWrapperHalLinkFactory
|
||||
extends MappingCollectionRestHalLinkFactory<MappingCollectionResourceWrapper> {
|
||||
public class MappedCollectionResourceWrapperHalLinkFactory
|
||||
extends MappedCollectionRestHalLinkFactory<MappedCollectionResourceWrapper> {
|
||||
|
||||
protected void addLinks(MappingCollectionResourceWrapper halResource, Pageable pageable, LinkedList<Link> list)
|
||||
protected void addLinks(MappedCollectionResourceWrapper halResource, Pageable pageable, LinkedList<Link> list)
|
||||
throws Exception {
|
||||
|
||||
MappingCollectionRestWrapper mappingCollectionRestWrapper = halResource.getContent();
|
||||
MappedCollectionRestWrapper mappingCollectionRestWrapper = halResource.getContent();
|
||||
if (mappingCollectionRestWrapper != null) {
|
||||
|
||||
UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn()
|
||||
@@ -38,7 +38,7 @@ public class MappingCollectionResourceWrapperHalLinkFactory
|
||||
}
|
||||
|
||||
|
||||
protected Class<MappingCollectionResourceWrapper> getResourceClass() {
|
||||
return MappingCollectionResourceWrapper.class;
|
||||
protected Class<MappedCollectionResourceWrapper> getResourceClass() {
|
||||
return MappedCollectionResourceWrapper.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.link;
|
||||
|
||||
import org.dspace.app.rest.MappedCollectionRestController;
|
||||
|
||||
/**
|
||||
* This class acts as an abstract class for the MappedCollectionResourceWrapperHalLinkFactory to inherit from
|
||||
* so it already has the Controller defined
|
||||
*/
|
||||
public abstract class MappedCollectionRestHalLinkFactory<T>
|
||||
extends HalLinkFactory<T, MappedCollectionRestController> {
|
||||
|
||||
@Override
|
||||
protected Class<MappedCollectionRestController> getControllerClass() {
|
||||
return MappedCollectionRestController.class;
|
||||
}
|
||||
}
|
@@ -9,10 +9,10 @@ package org.dspace.app.rest.link;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.dspace.app.rest.model.MappingItemRestWrapper;
|
||||
import org.dspace.app.rest.model.MappedItemRestWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.EmbeddedPageHeader;
|
||||
import org.dspace.app.rest.model.hateoas.ItemResource;
|
||||
import org.dspace.app.rest.model.hateoas.MappingItemResourceWrapper;
|
||||
import org.dspace.app.rest.model.hateoas.MappedItemResourceWrapper;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.hateoas.Link;
|
||||
@@ -20,15 +20,15 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
/**
|
||||
* This class' purpose is to add links to the MappingItemResourceWrapper objects
|
||||
* This class' purpose is to add links to the MappedItemResourceWrapper objects
|
||||
*/
|
||||
@Component
|
||||
public class MappingItemResourceWrapperHalLinkFactory
|
||||
extends MappingItemRestHalLinkFactory<MappingItemResourceWrapper> {
|
||||
protected void addLinks(MappingItemResourceWrapper halResource, Pageable pageable, LinkedList<Link> list)
|
||||
public class MappedItemResourceWrapperHalLinkFactory
|
||||
extends MappedItemRestHalLinkFactory<MappedItemResourceWrapper> {
|
||||
protected void addLinks(MappedItemResourceWrapper halResource, Pageable pageable, LinkedList<Link> list)
|
||||
throws Exception {
|
||||
|
||||
MappingItemRestWrapper mappingItemRestWrapper = halResource.getContent();
|
||||
MappedItemRestWrapper mappingItemRestWrapper = halResource.getContent();
|
||||
if (mappingItemRestWrapper != null) {
|
||||
|
||||
PageImpl<ItemResource> page = new PageImpl<>(halResource.getItemResources(), pageable,
|
||||
@@ -39,7 +39,7 @@ public class MappingItemResourceWrapperHalLinkFactory
|
||||
}
|
||||
|
||||
}
|
||||
private String getSelfLink(MappingItemRestWrapper mappingItemRestWrapper, Pageable pageable) throws Exception {
|
||||
private String getSelfLink(MappedItemRestWrapper mappingItemRestWrapper, Pageable pageable) throws Exception {
|
||||
if (mappingItemRestWrapper != null) {
|
||||
UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn()
|
||||
.retrieve(
|
||||
@@ -51,7 +51,7 @@ public class MappingItemResourceWrapperHalLinkFactory
|
||||
|
||||
}
|
||||
|
||||
protected Class<MappingItemResourceWrapper> getResourceClass() {
|
||||
return MappingItemResourceWrapper.class;
|
||||
protected Class<MappedItemResourceWrapper> getResourceClass() {
|
||||
return MappedItemResourceWrapper.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.link;
|
||||
|
||||
import org.dspace.app.rest.MappedItemRestController;
|
||||
|
||||
/**
|
||||
* This class acts as an abstract class for the MappedItemResourceWrapperHalLinkFactory to inherit from
|
||||
* so it already has the Controller defined
|
||||
*/
|
||||
public abstract class MappedItemRestHalLinkFactory<T> extends HalLinkFactory<T, MappedItemRestController> {
|
||||
|
||||
@Override
|
||||
protected Class<MappedItemRestController> getControllerClass() {
|
||||
return MappedItemRestController.class;
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.link;
|
||||
|
||||
import org.dspace.app.rest.MappingCollectionRestController;
|
||||
|
||||
/**
|
||||
* This class acts as an abstract class for the MappingCollectionResourceWrapperHalLinkFactory to inherit from
|
||||
* so it already has the Controller defined
|
||||
*/
|
||||
public abstract class MappingCollectionRestHalLinkFactory<T>
|
||||
extends HalLinkFactory<T, MappingCollectionRestController> {
|
||||
|
||||
@Override
|
||||
protected Class<MappingCollectionRestController> getControllerClass() {
|
||||
return MappingCollectionRestController.class;
|
||||
}
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.link;
|
||||
|
||||
import org.dspace.app.rest.MappingItemRestController;
|
||||
|
||||
/**
|
||||
* This class acts as an abstract class for the MappingItemResourceWrapperHalLinkFactory to inherit from
|
||||
* so it already has the Controller defined
|
||||
*/
|
||||
public abstract class MappingItemRestHalLinkFactory<T> extends HalLinkFactory<T, MappingItemRestController> {
|
||||
|
||||
@Override
|
||||
protected Class<MappingItemRestController> getControllerClass() {
|
||||
return MappingItemRestController.class;
|
||||
}
|
||||
}
|
@@ -10,25 +10,25 @@ package org.dspace.app.rest.model;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.MappingCollectionRestController;
|
||||
import org.dspace.app.rest.MappedCollectionRestController;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
/**
|
||||
* The REST object that will define a list of CollectionRest objects to be returned by the REST api
|
||||
*/
|
||||
public class MappingCollectionRestWrapper implements RestAddressableModel {
|
||||
public class MappedCollectionRestWrapper implements RestAddressableModel {
|
||||
|
||||
@JsonIgnore
|
||||
private List<CollectionRest> mappingCollectionRestList;
|
||||
private List<CollectionRest> mappedCollectionRestList;
|
||||
|
||||
@JsonIgnore
|
||||
private Item item;
|
||||
public List<CollectionRest> getMappingCollectionRestList() {
|
||||
return mappingCollectionRestList;
|
||||
public List<CollectionRest> getMappedCollectionRestList() {
|
||||
return mappedCollectionRestList;
|
||||
}
|
||||
|
||||
public void setMappingCollectionRestList(List<CollectionRest> mappingCollectionRestList) {
|
||||
this.mappingCollectionRestList = mappingCollectionRestList;
|
||||
public void setMappedCollectionRestList(List<CollectionRest> mappedCollectionRestList) {
|
||||
this.mappedCollectionRestList = mappedCollectionRestList;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
@@ -36,7 +36,7 @@ public class MappingCollectionRestWrapper implements RestAddressableModel {
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return MappingCollectionRestController.class;
|
||||
return MappedCollectionRestController.class;
|
||||
}
|
||||
|
||||
public String getType() {
|
@@ -11,15 +11,15 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.MappingItemRestController;
|
||||
import org.dspace.app.rest.MappedItemRestController;
|
||||
|
||||
/**
|
||||
* The REST object that will define a list of ItemRest objects to be returned by the REST api
|
||||
*/
|
||||
public class MappingItemRestWrapper implements RestAddressableModel {
|
||||
public class MappedItemRestWrapper implements RestAddressableModel {
|
||||
|
||||
@JsonIgnore
|
||||
private List<ItemRest> mappingItemRestList;
|
||||
private List<ItemRest> mappedItemRestList;
|
||||
|
||||
private UUID collectionUuid;
|
||||
|
||||
@@ -31,12 +31,12 @@ public class MappingItemRestWrapper implements RestAddressableModel {
|
||||
this.collectionUuid = collectionUuid;
|
||||
}
|
||||
|
||||
public List<ItemRest> getMappingItemRestList() {
|
||||
return mappingItemRestList;
|
||||
public List<ItemRest> getMappedItemRestList() {
|
||||
return mappedItemRestList;
|
||||
}
|
||||
|
||||
public void setMappingItemRestList(List<ItemRest> mappingItemRestList) {
|
||||
this.mappingItemRestList = mappingItemRestList;
|
||||
public void setMappedItemRestList(List<ItemRest> mappedItemRestList) {
|
||||
this.mappedItemRestList = mappedItemRestList;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
@@ -44,7 +44,7 @@ public class MappingItemRestWrapper implements RestAddressableModel {
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return MappingItemRestController.class;
|
||||
return MappedItemRestController.class;
|
||||
}
|
||||
|
||||
public String getType() {
|
@@ -22,6 +22,6 @@ public class CollectionResource extends DSpaceResource<CollectionRest> {
|
||||
public CollectionResource(CollectionRest collection, Utils utils, String... rels) {
|
||||
super(collection, utils, rels);
|
||||
add(utils.linkToSubResource(collection, CollectionRest.LICENSE));
|
||||
add(utils.linkToSubResource(collection, "mappingItems"));
|
||||
add(utils.linkToSubResource(collection, "mappedItems"));
|
||||
}
|
||||
}
|
||||
|
@@ -12,28 +12,28 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.model.CollectionRest;
|
||||
import org.dspace.app.rest.model.MappingCollectionRestWrapper;
|
||||
import org.dspace.app.rest.model.MappedCollectionRestWrapper;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
/**
|
||||
* This class will act as a HALResource object for the MappingCollectionRestWrapper data object and will transform
|
||||
* This class will act as a HALResource object for the MappedCollectionRestWrapper data object and will transform
|
||||
* this REST data object into a proper HAL Resource to be returned by the endpoint
|
||||
*/
|
||||
public class MappingCollectionResourceWrapper extends HALResource<MappingCollectionRestWrapper> {
|
||||
public class MappedCollectionResourceWrapper extends HALResource<MappedCollectionRestWrapper> {
|
||||
|
||||
@JsonIgnore
|
||||
private List<CollectionResource> collectionResources = new LinkedList<>();
|
||||
|
||||
public MappingCollectionResourceWrapper(MappingCollectionRestWrapper content, Utils utils, Pageable pageable,
|
||||
public MappedCollectionResourceWrapper(MappedCollectionRestWrapper content, Utils utils, Pageable pageable,
|
||||
String... rels) {
|
||||
super(content);
|
||||
addEmbeds(content, utils, pageable);
|
||||
}
|
||||
|
||||
private void addEmbeds(final MappingCollectionRestWrapper data, final Utils utils, Pageable pageable) {
|
||||
private void addEmbeds(final MappedCollectionRestWrapper data, final Utils utils, Pageable pageable) {
|
||||
|
||||
for (CollectionRest collectionRest : data.getMappingCollectionRestList()) {
|
||||
for (CollectionRest collectionRest : data.getMappedCollectionRestList()) {
|
||||
|
||||
collectionResources.add(new CollectionResource(collectionRest, utils));
|
||||
}
|
@@ -12,24 +12,24 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.app.rest.model.MappingItemRestWrapper;
|
||||
import org.dspace.app.rest.model.MappedItemRestWrapper;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class will act as a HALResource object for the MappingItemRestWrapper data object and will transform
|
||||
* This class will act as a HALResource object for the MappedItemRestWrapper data object and will transform
|
||||
* this REST data object into a proper HAL Resource to be returned by the endpoint
|
||||
*/
|
||||
public class MappingItemResourceWrapper extends HALResource<MappingItemRestWrapper> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MappingItemResourceWrapper.class);
|
||||
public class MappedItemResourceWrapper extends HALResource<MappedItemRestWrapper> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MappedItemResourceWrapper.class);
|
||||
|
||||
@JsonIgnore
|
||||
private List<ItemResource> itemResources;
|
||||
@JsonIgnore
|
||||
private Integer totalElements;
|
||||
|
||||
public MappingItemResourceWrapper(MappingItemRestWrapper content, Utils utils,
|
||||
public MappedItemResourceWrapper(MappedItemRestWrapper content, Utils utils,
|
||||
Integer totalElements, String... rels) {
|
||||
super(content);
|
||||
embed(utils);
|
||||
@@ -38,11 +38,11 @@ public class MappingItemResourceWrapper extends HALResource<MappingItemRestWrapp
|
||||
|
||||
private void embed(Utils utils) {
|
||||
List<ItemResource> itemResources = new LinkedList<>();
|
||||
for (ItemRest itemRest : getContent().getMappingItemRestList()) {
|
||||
for (ItemRest itemRest : getContent().getMappedItemRestList()) {
|
||||
itemResources.add(new ItemResource(itemRest, utils));
|
||||
}
|
||||
this.itemResources = itemResources;
|
||||
embedResource("mappingItems", itemResources);
|
||||
embedResource("mappedItems", itemResources);
|
||||
}
|
||||
|
||||
public List<ItemResource> getItemResources() {
|
@@ -30,7 +30,7 @@ import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
public class MappedCollectionRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private CollectionService collectionService;
|
||||
@@ -77,12 +77,12 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)));
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)));
|
||||
}
|
||||
@@ -131,16 +131,16 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -189,26 +189,26 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
|
||||
getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itemHasNoDuplicatesInMappingCollectionAndCollectionHasNoDuplicatesInMappingItemsTest()
|
||||
public void itemHasNoDuplicatesInMappedCollectionAndCollectionHasNoDuplicatesInMappedItemsTest()
|
||||
throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
@@ -255,14 +255,14 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.containsInAnyOrder(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.containsInAnyOrder(
|
||||
ItemMatcher.matchItemProperties(publicItem1),
|
||||
ItemMatcher.matchItemProperties(publicItem1)))
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itemHasNoOriginalCollectionInMappingCollectionAndCollectionHasNoOriginalItemInMappingItemsTest()
|
||||
public void itemHasNoOriginalCollectionInMappedCollectionAndCollectionHasNoOriginalItemInMappedItemsTest()
|
||||
throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
@@ -308,14 +308,14 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
;
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeMappingCollectionTest() throws Exception {
|
||||
public void removeMappedCollectionTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
@@ -359,10 +359,10 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
;
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
|
||||
getClient(adminToken)
|
||||
.perform(delete("/api/core/items/" + publicItem1.getID() + "/mappedCollections/" + col2.getID()));
|
||||
@@ -376,22 +376,22 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
.andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/items")));
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
|
||||
|
||||
getClient(adminToken)
|
||||
.perform(delete("/api/core/items/" + publicItem1.getID() + "/mappedCollections/" + col1.getID()));
|
||||
@@ -406,26 +406,26 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
;
|
||||
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
|
||||
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
)))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0)));;
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));;
|
||||
getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains(
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
|
||||
ItemMatcher.matchItemProperties(publicItem1))
|
||||
))
|
||||
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));;
|
||||
.andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doNotAllowMappingCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
|
||||
public void doNotAllowMappedCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
@@ -457,7 +457,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doNotAllowDeleteMappingCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
|
||||
public void doNotAllowDeleteMappedCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
@@ -487,7 +487,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doNotAllowMappingCollectionWithATemplateItem() throws Exception {
|
||||
public void doNotAllowMappedCollectionWithATemplateItem() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
@@ -517,7 +517,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doNotAllowDeleteMappingCollectionWithATemplateItem() throws Exception {
|
||||
public void doNotAllowDeleteMappedCollectionWithATemplateItem() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
@@ -545,7 +545,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappingCollectionNeedsValidIDs() throws Exception {
|
||||
public void mappedCollectionNeedsValidIDs() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
@@ -661,7 +661,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removingMappingCollectionCannotBeDoneAnonymouslyTest() throws Exception {
|
||||
public void removingMappedCollectionCannotBeDoneAnonymouslyTest() throws Exception {
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
//** GIVEN **
|
Reference in New Issue
Block a user