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:
Jelle Pelgrims
2019-08-02 13:10:36 +02:00
parent e51aebf09d
commit 763d9ce8e6
14 changed files with 158 additions and 158 deletions

View File

@@ -23,8 +23,8 @@ import org.dspace.app.rest.exception.MethodNotAllowedException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.link.HalLinkService; import org.dspace.app.rest.link.HalLinkService;
import org.dspace.app.rest.model.CollectionRest; 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.model.hateoas.MappingCollectionResourceWrapper; import org.dspace.app.rest.model.hateoas.MappedCollectionResourceWrapper;
import org.dspace.app.rest.utils.ContextUtil; import org.dspace.app.rest.utils.ContextUtil;
import org.dspace.app.rest.utils.Utils; import org.dspace.app.rest.utils.Utils;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
@@ -42,16 +42,16 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; 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 * This class will typically receive a UUID that resolves to an Item and it'll perform logic on its collections
*/ */
@RestController @RestController
@RequestMapping("/api/core/items/" + @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}}" + "{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") "/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 @Autowired
private ItemService itemService; 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 * 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 * 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 * curl -X GET http://<dspace.restUrl>/api/core/item/{uuid}/mappedCollections
* *
@@ -90,7 +90,7 @@ public class MappingCollectionRestController {
* @throws SQLException If something goes wrong * @throws SQLException If something goes wrong
*/ */
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD}) @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) HttpServletRequest request, Pageable pageable)
throws SQLException { throws SQLException {
Context context = ContextUtil.obtainContext(request); Context context = ContextUtil.obtainContext(request);
@@ -104,10 +104,10 @@ public class MappingCollectionRestController {
} }
} }
MappingCollectionRestWrapper mappingCollectionRestWrapper = new MappingCollectionRestWrapper(); MappedCollectionRestWrapper mappingCollectionRestWrapper = new MappedCollectionRestWrapper();
mappingCollectionRestWrapper.setMappingCollectionRestList(mappingCollectionRest); mappingCollectionRestWrapper.setMappedCollectionRestList(mappingCollectionRest);
mappingCollectionRestWrapper.setItem(item); mappingCollectionRestWrapper.setItem(item);
MappingCollectionResourceWrapper mappingCollectionResourceWrapper = new MappingCollectionResourceWrapper( MappedCollectionResourceWrapper mappingCollectionResourceWrapper = new MappedCollectionResourceWrapper(
mappingCollectionRestWrapper, utils, pageable); mappingCollectionRestWrapper, utils, pageable);

View File

@@ -18,8 +18,8 @@ import org.apache.log4j.Logger;
import org.dspace.app.rest.converter.ItemConverter; import org.dspace.app.rest.converter.ItemConverter;
import org.dspace.app.rest.link.HalLinkService; import org.dspace.app.rest.link.HalLinkService;
import org.dspace.app.rest.model.ItemRest; 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.model.hateoas.MappingItemResourceWrapper; import org.dspace.app.rest.model.hateoas.MappedItemResourceWrapper;
import org.dspace.app.rest.utils.ContextUtil; import org.dspace.app.rest.utils.ContextUtil;
import org.dspace.app.rest.utils.Utils; import org.dspace.app.rest.utils.Utils;
import org.dspace.content.Collection; import org.dspace.content.Collection;
@@ -42,9 +42,9 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/api/core/collections/" + @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") "{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 @Autowired
private CollectionService collectionService; 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. * 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 * 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. * 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: * Example:
* <pre> * <pre>
* {@code * {@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> * </pre>
* *
@@ -84,7 +84,7 @@ public class MappingItemRestController {
* @throws Exception * @throws Exception
*/ */
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD}) @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 { HttpServletRequest request, Pageable pageable) throws Exception {
Context context = ContextUtil.obtainContext(request); Context context = ContextUtil.obtainContext(request);
Collection collection = collectionService.find(context, uuid); Collection collection = collectionService.find(context, uuid);
@@ -99,13 +99,13 @@ public class MappingItemRestController {
} }
} }
MappingItemRestWrapper mappingItemRestWrapper = new MappingItemRestWrapper(); MappedItemRestWrapper mappedItemRestWrapper = new MappedItemRestWrapper();
mappingItemRestWrapper.setMappingItemRestList(mappedItemRestList); mappedItemRestWrapper.setMappedItemRestList(mappedItemRestList);
mappingItemRestWrapper.setCollectionUuid(uuid); mappedItemRestWrapper.setCollectionUuid(uuid);
MappingItemResourceWrapper mappingItemResourceWrapper = MappedItemResourceWrapper mappedItemResourceWrapper =
new MappingItemResourceWrapper(mappingItemRestWrapper, utils, totalElements); new MappedItemResourceWrapper(mappedItemRestWrapper, utils, totalElements);
halLinkService.addLinks(mappingItemResourceWrapper, pageable); halLinkService.addLinks(mappedItemResourceWrapper, pageable);
return mappingItemResourceWrapper; return mappedItemResourceWrapper;
} }
} }

View File

@@ -9,24 +9,24 @@ package org.dspace.app.rest.link;
import java.util.LinkedList; import java.util.LinkedList;
import org.dspace.app.rest.model.MappingCollectionRestWrapper; import org.dspace.app.rest.model.MappedCollectionRestWrapper;
import org.dspace.app.rest.model.hateoas.MappingCollectionResourceWrapper; import org.dspace.app.rest.model.hateoas.MappedCollectionResourceWrapper;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder; 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 @Component
public class MappingCollectionResourceWrapperHalLinkFactory public class MappedCollectionResourceWrapperHalLinkFactory
extends MappingCollectionRestHalLinkFactory<MappingCollectionResourceWrapper> { 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 { throws Exception {
MappingCollectionRestWrapper mappingCollectionRestWrapper = halResource.getContent(); MappedCollectionRestWrapper mappingCollectionRestWrapper = halResource.getContent();
if (mappingCollectionRestWrapper != null) { if (mappingCollectionRestWrapper != null) {
UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn() UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn()
@@ -38,7 +38,7 @@ public class MappingCollectionResourceWrapperHalLinkFactory
} }
protected Class<MappingCollectionResourceWrapper> getResourceClass() { protected Class<MappedCollectionResourceWrapper> getResourceClass() {
return MappingCollectionResourceWrapper.class; return MappedCollectionResourceWrapper.class;
} }
} }

View File

@@ -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;
}
}

View File

@@ -9,10 +9,10 @@ package org.dspace.app.rest.link;
import java.util.LinkedList; 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.EmbeddedPageHeader;
import org.dspace.app.rest.model.hateoas.ItemResource; 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.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
@@ -20,15 +20,15 @@ import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder; 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 @Component
public class MappingItemResourceWrapperHalLinkFactory public class MappedItemResourceWrapperHalLinkFactory
extends MappingItemRestHalLinkFactory<MappingItemResourceWrapper> { extends MappedItemRestHalLinkFactory<MappedItemResourceWrapper> {
protected void addLinks(MappingItemResourceWrapper halResource, Pageable pageable, LinkedList<Link> list) protected void addLinks(MappedItemResourceWrapper halResource, Pageable pageable, LinkedList<Link> list)
throws Exception { throws Exception {
MappingItemRestWrapper mappingItemRestWrapper = halResource.getContent(); MappedItemRestWrapper mappingItemRestWrapper = halResource.getContent();
if (mappingItemRestWrapper != null) { if (mappingItemRestWrapper != null) {
PageImpl<ItemResource> page = new PageImpl<>(halResource.getItemResources(), pageable, 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) { if (mappingItemRestWrapper != null) {
UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn() UriComponentsBuilder uriBuilderSelfLink = uriBuilder(getMethodOn()
.retrieve( .retrieve(
@@ -51,7 +51,7 @@ public class MappingItemResourceWrapperHalLinkFactory
} }
protected Class<MappingItemResourceWrapper> getResourceClass() { protected Class<MappedItemResourceWrapper> getResourceClass() {
return MappingItemResourceWrapper.class; return MappedItemResourceWrapper.class;
} }
} }

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -10,25 +10,25 @@ package org.dspace.app.rest.model;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.MappingCollectionRestController; import org.dspace.app.rest.MappedCollectionRestController;
import org.dspace.content.Item; import org.dspace.content.Item;
/** /**
* The REST object that will define a list of CollectionRest objects to be returned by the REST api * 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 @JsonIgnore
private List<CollectionRest> mappingCollectionRestList; private List<CollectionRest> mappedCollectionRestList;
@JsonIgnore @JsonIgnore
private Item item; private Item item;
public List<CollectionRest> getMappingCollectionRestList() { public List<CollectionRest> getMappedCollectionRestList() {
return mappingCollectionRestList; return mappedCollectionRestList;
} }
public void setMappingCollectionRestList(List<CollectionRest> mappingCollectionRestList) { public void setMappedCollectionRestList(List<CollectionRest> mappedCollectionRestList) {
this.mappingCollectionRestList = mappingCollectionRestList; this.mappedCollectionRestList = mappedCollectionRestList;
} }
public String getCategory() { public String getCategory() {
@@ -36,7 +36,7 @@ public class MappingCollectionRestWrapper implements RestAddressableModel {
} }
public Class getController() { public Class getController() {
return MappingCollectionRestController.class; return MappedCollectionRestController.class;
} }
public String getType() { public String getType() {

View File

@@ -11,15 +11,15 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnore; 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 * 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 @JsonIgnore
private List<ItemRest> mappingItemRestList; private List<ItemRest> mappedItemRestList;
private UUID collectionUuid; private UUID collectionUuid;
@@ -31,12 +31,12 @@ public class MappingItemRestWrapper implements RestAddressableModel {
this.collectionUuid = collectionUuid; this.collectionUuid = collectionUuid;
} }
public List<ItemRest> getMappingItemRestList() { public List<ItemRest> getMappedItemRestList() {
return mappingItemRestList; return mappedItemRestList;
} }
public void setMappingItemRestList(List<ItemRest> mappingItemRestList) { public void setMappedItemRestList(List<ItemRest> mappedItemRestList) {
this.mappingItemRestList = mappingItemRestList; this.mappedItemRestList = mappedItemRestList;
} }
public String getCategory() { public String getCategory() {
@@ -44,7 +44,7 @@ public class MappingItemRestWrapper implements RestAddressableModel {
} }
public Class getController() { public Class getController() {
return MappingItemRestController.class; return MappedItemRestController.class;
} }
public String getType() { public String getType() {

View File

@@ -22,6 +22,6 @@ public class CollectionResource extends DSpaceResource<CollectionRest> {
public CollectionResource(CollectionRest collection, Utils utils, String... rels) { public CollectionResource(CollectionRest collection, Utils utils, String... rels) {
super(collection, utils, rels); super(collection, utils, rels);
add(utils.linkToSubResource(collection, CollectionRest.LICENSE)); add(utils.linkToSubResource(collection, CollectionRest.LICENSE));
add(utils.linkToSubResource(collection, "mappingItems")); add(utils.linkToSubResource(collection, "mappedItems"));
} }
} }

View File

@@ -12,28 +12,28 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.model.CollectionRest; 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.dspace.app.rest.utils.Utils;
import org.springframework.data.domain.Pageable; 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 * 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 @JsonIgnore
private List<CollectionResource> collectionResources = new LinkedList<>(); private List<CollectionResource> collectionResources = new LinkedList<>();
public MappingCollectionResourceWrapper(MappingCollectionRestWrapper content, Utils utils, Pageable pageable, public MappedCollectionResourceWrapper(MappedCollectionRestWrapper content, Utils utils, Pageable pageable,
String... rels) { String... rels) {
super(content); super(content);
addEmbeds(content, utils, pageable); 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)); collectionResources.add(new CollectionResource(collectionRest, utils));
} }

View File

@@ -12,24 +12,24 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.model.ItemRest; 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.dspace.app.rest.utils.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 * this REST data object into a proper HAL Resource to be returned by the endpoint
*/ */
public class MappingItemResourceWrapper extends HALResource<MappingItemRestWrapper> { public class MappedItemResourceWrapper extends HALResource<MappedItemRestWrapper> {
private static final Logger log = LoggerFactory.getLogger(MappingItemResourceWrapper.class); private static final Logger log = LoggerFactory.getLogger(MappedItemResourceWrapper.class);
@JsonIgnore @JsonIgnore
private List<ItemResource> itemResources; private List<ItemResource> itemResources;
@JsonIgnore @JsonIgnore
private Integer totalElements; private Integer totalElements;
public MappingItemResourceWrapper(MappingItemRestWrapper content, Utils utils, public MappedItemResourceWrapper(MappedItemRestWrapper content, Utils utils,
Integer totalElements, String... rels) { Integer totalElements, String... rels) {
super(content); super(content);
embed(utils); embed(utils);
@@ -38,11 +38,11 @@ public class MappingItemResourceWrapper extends HALResource<MappingItemRestWrapp
private void embed(Utils utils) { private void embed(Utils utils) {
List<ItemResource> itemResources = new LinkedList<>(); List<ItemResource> itemResources = new LinkedList<>();
for (ItemRest itemRest : getContent().getMappingItemRestList()) { for (ItemRest itemRest : getContent().getMappedItemRestList()) {
itemResources.add(new ItemResource(itemRest, utils)); itemResources.add(new ItemResource(itemRest, utils));
} }
this.itemResources = itemResources; this.itemResources = itemResources;
embedResource("mappingItems", itemResources); embedResource("mappedItems", itemResources);
} }
public List<ItemResource> getItemResources() { public List<ItemResource> getItemResources() {

View File

@@ -30,7 +30,7 @@ import org.hamcrest.Matchers;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegrationTest { public class MappedCollectionRestRepositoryIT extends AbstractControllerIntegrationTest {
@Autowired @Autowired
private CollectionService collectionService; private CollectionService collectionService;
@@ -77,12 +77,12 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
))); )));
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
))); )));
} }
@@ -131,16 +131,16 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
)) ))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1))); .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
} }
@Test @Test
@@ -189,26 +189,26 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
)) ))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1))); .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
} }
@Test @Test
public void itemHasNoDuplicatesInMappingCollectionAndCollectionHasNoDuplicatesInMappingItemsTest() public void itemHasNoDuplicatesInMappedCollectionAndCollectionHasNoDuplicatesInMappedItemsTest()
throws Exception { throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
@@ -255,14 +255,14 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .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),
ItemMatcher.matchItemProperties(publicItem1))) ItemMatcher.matchItemProperties(publicItem1)))
)); ));
} }
@Test @Test
public void itemHasNoOriginalCollectionInMappingCollectionAndCollectionHasNoOriginalItemInMappingItemsTest() public void itemHasNoOriginalCollectionInMappedCollectionAndCollectionHasNoOriginalItemInMappedItemsTest()
throws Exception { throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
@@ -308,14 +308,14 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
; ;
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
))) )))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0))); .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
} }
@Test @Test
public void removeMappingCollectionTest() throws Exception { public void removeMappedCollectionTest() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
@@ -359,10 +359,10 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
; ;
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
))) )))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(0))); .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(0)));
getClient(adminToken) getClient(adminToken)
.perform(delete("/api/core/items/" + publicItem1.getID() + "/mappedCollections/" + col2.getID())); .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"))); .andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/items")));
getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
)) ))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1))); .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));
getClient(adminToken) getClient(adminToken)
.perform(delete("/api/core/items/" + publicItem1.getID() + "/mappedCollections/" + col1.getID())); .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")) getClient().perform(get("/api/core/collections/" + col1.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col2.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.not(Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.not(Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) 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")) getClient().perform(get("/api/core/collections/" + col3.getID() + "/mappedItems"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.contains( .andExpect(jsonPath("$._embedded.mappedItems", Matchers.contains(
ItemMatcher.matchItemProperties(publicItem1)) ItemMatcher.matchItemProperties(publicItem1))
)) ))
.andExpect(jsonPath("$._embedded.mappingItems", Matchers.hasSize(1)));; .andExpect(jsonPath("$._embedded.mappedItems", Matchers.hasSize(1)));;
} }
@Test @Test
public void doNotAllowMappingCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception { public void doNotAllowMappedCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
@@ -457,7 +457,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
} }
@Test @Test
public void doNotAllowDeleteMappingCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception { public void doNotAllowDeleteMappedCollectionIfGivenCollectionIsOwningCollectionOfGivenItemTest() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
@@ -487,7 +487,7 @@ public class MappingCollectionRestRepositoryIT extends AbstractControllerIntegra
} }
@Test @Test
public void doNotAllowMappingCollectionWithATemplateItem() throws Exception { public void doNotAllowMappedCollectionWithATemplateItem() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections. //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 @Test
public void doNotAllowDeleteMappingCollectionWithATemplateItem() throws Exception { public void doNotAllowDeleteMappedCollectionWithATemplateItem() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections. //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 @Test
public void mappingCollectionNeedsValidIDs() throws Exception { public void mappedCollectionNeedsValidIDs() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections. //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 @Test
public void removingMappingCollectionCannotBeDoneAnonymouslyTest() throws Exception { public void removingMappedCollectionCannotBeDoneAnonymouslyTest() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//** GIVEN ** //** GIVEN **