mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
Merge pull request #3170 from atmire/w2p-77244_ItemMetadata-caching-bugfixes
Caching the item metadata for entities
This commit is contained in:
@@ -305,6 +305,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
// metadataValueService.update(context, metadataValue);
|
||||
dso.addDetails(metadataField.toString());
|
||||
}
|
||||
setMetadataModified(dso);
|
||||
return newMetadata;
|
||||
}
|
||||
|
||||
|
@@ -112,6 +112,16 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
@Transient
|
||||
private transient ItemService itemService;
|
||||
|
||||
/**
|
||||
* True if anything else was changed since last metadata retrieval()
|
||||
* (to drive metadata cache)
|
||||
*/
|
||||
@Transient
|
||||
private boolean modifiedMetadataCache = true;
|
||||
|
||||
@Transient
|
||||
private List<MetadataValue> cachedMetadata = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Protected constructor, create object using:
|
||||
* {@link org.dspace.content.service.ItemService#create(Context, WorkspaceItem)}
|
||||
@@ -373,4 +383,23 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
}
|
||||
return itemService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setMetadataModified() {
|
||||
super.setMetadataModified();
|
||||
modifiedMetadataCache = true;
|
||||
}
|
||||
|
||||
public boolean isModifiedMetadataCache() {
|
||||
return modifiedMetadataCache;
|
||||
}
|
||||
|
||||
protected List<MetadataValue> getCachedMetadata() {
|
||||
return cachedMetadata;
|
||||
}
|
||||
|
||||
protected void setCachedMetadata(List<MetadataValue> cachedMetadata) {
|
||||
this.cachedMetadata = cachedMetadata;
|
||||
modifiedMetadataCache = false;
|
||||
}
|
||||
}
|
||||
|
@@ -1328,42 +1328,33 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang,
|
||||
boolean enableVirtualMetadata) {
|
||||
//Fields of the relation schema are virtual metadata
|
||||
//except for relation.type which is the type of item in the model
|
||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||
|
||||
List<RelationshipMetadataValue> relationMetadata = relationshipMetadataService
|
||||
.getRelationshipMetadata(item, enableVirtualMetadata);
|
||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : relationMetadata) {
|
||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||
listToReturn.add(metadataValue);
|
||||
}
|
||||
}
|
||||
listToReturn = sortMetadataValueList(listToReturn);
|
||||
|
||||
return listToReturn;
|
||||
|
||||
} else {
|
||||
List<MetadataValue> dbMetadataValues = super.getMetadata(item, schema, element, qualifier, lang);
|
||||
if (!enableVirtualMetadata) {
|
||||
log.debug("Called getMetadata for " + item.getID() + " without enableVirtualMetadata");
|
||||
return super.getMetadata(item, schema, element, qualifier, lang);
|
||||
}
|
||||
if (item.isModifiedMetadataCache()) {
|
||||
log.debug("Called getMetadata for " + item.getID() + " with invalid cache");
|
||||
//rebuild cache
|
||||
List<MetadataValue> dbMetadataValues = item.getMetadata();
|
||||
|
||||
List<MetadataValue> fullMetadataValueList = new LinkedList<>();
|
||||
if (enableVirtualMetadata) {
|
||||
fullMetadataValueList.addAll(relationshipMetadataService.getRelationshipMetadata(item, true));
|
||||
|
||||
}
|
||||
fullMetadataValueList.addAll(relationshipMetadataService.getRelationshipMetadata(item, true));
|
||||
fullMetadataValueList.addAll(dbMetadataValues);
|
||||
|
||||
List<MetadataValue> finalList = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : fullMetadataValueList) {
|
||||
if (match(schema, element, qualifier, lang, metadataValue)) {
|
||||
finalList.add(metadataValue);
|
||||
}
|
||||
}
|
||||
finalList = sortMetadataValueList(finalList);
|
||||
return finalList;
|
||||
item.setCachedMetadata(sortMetadataValueList(fullMetadataValueList));
|
||||
}
|
||||
|
||||
log.debug("Called getMetadata for " + item.getID() + " based on cache");
|
||||
// Build up list of matching values based on the cache
|
||||
List<MetadataValue> values = new ArrayList<>();
|
||||
for (MetadataValue dcv : item.getCachedMetadata()) {
|
||||
if (match(schema, element, qualifier, lang, dcv)) {
|
||||
values.add(dcv);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an array of matching values
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -164,6 +164,7 @@ public class Relationship implements ReloadableEntity<Integer> {
|
||||
*/
|
||||
public void setLeftPlace(int leftPlace) {
|
||||
this.leftPlace = leftPlace;
|
||||
leftItem.setMetadataModified();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,6 +181,7 @@ public class Relationship implements ReloadableEntity<Integer> {
|
||||
*/
|
||||
public void setRightPlace(int rightPlace) {
|
||||
this.rightPlace = rightPlace;
|
||||
rightItem.setMetadataModified();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,11 +9,13 @@ package org.dspace.content;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.dspace.AbstractIntegrationTestWithDatabase;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -186,13 +188,38 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
public void testDeleteAuthorRelationshipCopyToLeftItem() throws Exception {
|
||||
initPublicationAuthor();
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the leftItem
|
||||
//leftItem is the publication
|
||||
relationshipService.delete(context, relationship, true, false);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -200,10 +227,15 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(1));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
//request the virtual metadata of the publication only
|
||||
List<RelationshipMetadataValue> list = relationshipMetadataService.getRelationshipMetadata(leftItem, true);
|
||||
@@ -227,18 +259,50 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//verify there's relation.isPublicationOfAuthor actual metadata on the author
|
||||
assertThat(rightItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isPublicationOfAuthor"))
|
||||
.collect(Collectors.toList()).size(), equalTo(1));
|
||||
assertThat(itemService
|
||||
.getMetadata(rightItem, MetadataSchemaEnum.RELATION.getName(), "isPublicationOfAuthor", null, Item.ANY)
|
||||
.size(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAuthorRelationshipCopyToBothItems() throws Exception {
|
||||
initPublicationAuthor();
|
||||
context.turnOffAuthorisationSystem();
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the both items
|
||||
relationshipService.delete(context, relationship, true, true);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -246,10 +310,21 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
//verify there's relation.isPublicationOfAuthor actual metadata
|
||||
assertEquals(1, rightItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isPublicationOfAuthor"))
|
||||
.collect(Collectors.toList()).size());
|
||||
assertEquals(1, itemService
|
||||
.getMetadata(rightItem, MetadataSchemaEnum.RELATION.getName(), "isPublicationOfAuthor", null, Item.ANY)
|
||||
.size());
|
||||
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
assertEquals(1, leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList()).size());
|
||||
assertEquals(1, itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY)
|
||||
.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -369,13 +444,38 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
public void testDeleteAuthorRelationshipCopyToLeftItemFromDefaultInDb() throws Exception {
|
||||
initPublicationAuthorWithCopyParams(true, false);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the leftItem
|
||||
//leftItem is the publication
|
||||
relationshipService.delete(context, relationship);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -383,10 +483,15 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(1));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
//request the virtual metadata of the publication only
|
||||
List<RelationshipMetadataValue> list = relationshipMetadataService.getRelationshipMetadata(leftItem, true);
|
||||
@@ -410,18 +515,50 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//verify there's relation.isPublicationOfAuthor actual metadata on the author
|
||||
assertThat(rightItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isPublicationOfAuthor"))
|
||||
.collect(Collectors.toList()).size(), equalTo(1));
|
||||
assertThat(itemService
|
||||
.getMetadata(rightItem, MetadataSchemaEnum.RELATION.getName(), "isPublicationOfAuthor", null, Item.ANY)
|
||||
.size(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAuthorRelationshipCopyToBothItemsFromDefaultsInDb() throws Exception {
|
||||
initPublicationAuthorWithCopyParams(true, true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the both items
|
||||
relationshipService.delete(context, relationship);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -429,10 +566,20 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata on the publication
|
||||
assertThat(leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList()).size(), equalTo(1));
|
||||
assertThat(itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY)
|
||||
.size(), equalTo(1));
|
||||
//verify there's relation.isPublicationOfAuthor actual metadata on the author
|
||||
assertThat(rightItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isPublicationOfAuthor"))
|
||||
.collect(Collectors.toList()).size(), equalTo(1));
|
||||
assertThat(itemService
|
||||
.getMetadata(rightItem, MetadataSchemaEnum.RELATION.getName(), "isPublicationOfAuthor", null, Item.ANY)
|
||||
.size(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -7,8 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.dspace.content.Item.ANY;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
||||
@@ -221,6 +225,35 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void testDeleteAuthorRelationshipCopyToLeftItem() throws Exception {
|
||||
initPublicationAuthor();
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata of the left item
|
||||
assertEquals(
|
||||
1,
|
||||
itemService
|
||||
.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY)
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the left item
|
||||
assertEquals(
|
||||
0,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the left item
|
||||
assertEquals(
|
||||
0,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/relationships/" + relationship.getID() + "?copyVirtualMetadata=left"))
|
||||
.andExpect(status().isNoContent());
|
||||
@@ -235,12 +268,35 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
|
||||
// Check that the relation metadata values are gone because the relationship is gone
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, "relation", "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the left item
|
||||
assertEquals(
|
||||
1,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isAuthorOfPublication actual metadata on the left item
|
||||
assertEquals(
|
||||
1,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Check right item to ensure that no metadata is copied
|
||||
|
||||
rightItem = context.reloadEntity(rightItem);
|
||||
relationshipMetadataList = itemService
|
||||
.getMetadata(rightItem, "relation", "isPublicationOfAuthor", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
@@ -250,6 +306,27 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void testAuthorDeleteRelationshipCopyToRightItem() throws Exception {
|
||||
initPublicationAuthor();
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the right item
|
||||
assertEquals(
|
||||
0,
|
||||
rightItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isPublicationOfAuthor actual metadata on the right item
|
||||
assertEquals(
|
||||
0,
|
||||
rightItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isPublicationOfAuthor"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/relationships/" + relationship.getID() + "?copyVirtualMetadata=right"))
|
||||
.andExpect(status().isNoContent());
|
||||
@@ -259,14 +336,27 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(0));
|
||||
|
||||
// Check that the relation metadata values are gone because the relationship is gone
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, "relation", "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
// Check right item to ensure that the metadata is copied
|
||||
|
||||
rightItem = itemService.find(context, rightItem.getID());
|
||||
relationshipMetadataList = itemService
|
||||
.getMetadata(rightItem, "relation", "isPublicationOfAuthor", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
// Verify there's relation.isPublicationOfAuthor actual metadata on the right item
|
||||
assertEquals(
|
||||
1,
|
||||
rightItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isPublicationOfAuthor"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// There is no additional Metadata to check on the rightItem because the configuration of the virtual
|
||||
// metadata holds no config to display virtual metadata on the author of the publication
|
||||
@@ -291,11 +381,44 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, "relation", "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the left item
|
||||
assertEquals(
|
||||
1,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isAuthorOfPublication actual metadata on the left item
|
||||
assertEquals(
|
||||
1,
|
||||
leftItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
rightItem = itemService.find(context, rightItem.getID());
|
||||
relationshipMetadataList = itemService
|
||||
.getMetadata(rightItem, "relation", "isPublicationOfAuthor", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
// Verify there's relation.isPublicationOfAuthor actual metadata on the right item
|
||||
assertEquals(
|
||||
1,
|
||||
rightItem.getMetadata()
|
||||
.stream()
|
||||
.filter(metadataValue -> "isPublicationOfAuthor"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// There is no additional Metadata to check on the rightItem because the configuration of the virtual
|
||||
// metadata holds no config to display virtual metadata on the author of the publication
|
||||
@@ -375,6 +498,32 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void deleteItemCopyVirtualMetadataAll() throws Exception {
|
||||
initPersonProjectPublication();
|
||||
|
||||
for (Item item : asList(publicationItem, projectItem)) {
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata
|
||||
assertEquals(
|
||||
1,
|
||||
itemService.getMetadata(item, "dc", "contributor", "author", ANY).size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
}
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/items/" + personItem.getID() + "?copyVirtualMetadata=all"))
|
||||
.andExpect(status().isNoContent());
|
||||
@@ -387,7 +536,26 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(publicationAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> publicationRelationships = itemService.getMetadata(publicationItem,
|
||||
"relation", "isAuthorOfPublication", Item.ANY, Item.ANY);
|
||||
assertThat(publicationRelationships.size(), equalTo(0));
|
||||
assertThat(publicationRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isAuthorOfPublication actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
projectItem = itemService.find(context, projectItem.getID());
|
||||
List<MetadataValue> projectAuthorList = itemService.getMetadata(projectItem,
|
||||
@@ -397,13 +565,58 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(projectAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> projectRelationships = itemService.getMetadata(projectItem,
|
||||
"relation", "isPersonOfProject", Item.ANY, Item.ANY);
|
||||
assertThat(projectRelationships.size(), equalTo(0));
|
||||
assertThat(projectRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isPersonOfProject actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isPersonOfProject"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteItemCopyVirtualMetadataOneType() throws Exception {
|
||||
initPersonProjectPublication();
|
||||
|
||||
for (Item item : asList(publicationItem, projectItem)) {
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata
|
||||
assertEquals(
|
||||
1,
|
||||
itemService.getMetadata(item, "dc", "contributor", "author", ANY).size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
}
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/items/" + personItem.getID() + "?copyVirtualMetadata="
|
||||
+ publicationPersonRelationshipType.getID()))
|
||||
@@ -417,7 +630,26 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(publicationAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> publicationRelationships = itemService.getMetadata(publicationItem,
|
||||
"relation", "isAuthorOfPublication", Item.ANY, Item.ANY);
|
||||
assertThat(publicationRelationships.size(), equalTo(0));
|
||||
assertThat(publicationRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isAuthorOfPublication actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
projectItem = itemService.find(context, projectItem.getID());
|
||||
List<MetadataValue> projectAuthorList = itemService.getMetadata(projectItem,
|
||||
@@ -432,6 +664,32 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void deleteItemCopyVirtualMetadataTwoTypes() throws Exception {
|
||||
initPersonProjectPublication();
|
||||
|
||||
for (Item item : asList(publicationItem, projectItem)) {
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata
|
||||
assertEquals(
|
||||
1,
|
||||
itemService.getMetadata(item, "dc", "contributor", "author", ANY).size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
}
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/items/" + personItem.getID()
|
||||
+ "?copyVirtualMetadata=" + publicationPersonRelationshipType.getID()
|
||||
@@ -446,7 +704,26 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(publicationAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> publicationRelationships = itemService.getMetadata(publicationItem,
|
||||
"relation", "isAuthorOfPublication", Item.ANY, Item.ANY);
|
||||
assertThat(publicationRelationships.size(), equalTo(0));
|
||||
assertThat(publicationRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isAuthorOfPublication actual metadata on the publication item
|
||||
assertEquals(
|
||||
1,
|
||||
publicationItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
projectItem = itemService.find(context, projectItem.getID());
|
||||
List<MetadataValue> projectAuthorList = itemService.getMetadata(projectItem,
|
||||
@@ -456,7 +733,26 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(projectAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> projectRelationships = itemService.getMetadata(projectItem,
|
||||
"relation", "isPersonOfProject", Item.ANY, Item.ANY);
|
||||
assertThat(projectRelationships.size(), equalTo(0));
|
||||
assertThat(projectRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isPersonOfProject actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isPersonOfProject"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -520,6 +816,32 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void deleteItemCopyVirtualMetadataAllNoPermissions() throws Exception {
|
||||
initPersonProjectPublication();
|
||||
|
||||
for (Item item : asList(publicationItem, projectItem)) {
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata
|
||||
assertEquals(
|
||||
1,
|
||||
itemService.getMetadata(item, "dc", "contributor", "author", ANY).size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
}
|
||||
|
||||
getClient(getAuthToken(eperson.getEmail(), password)).perform(
|
||||
delete("/api/core/items/" + personItem.getID()))
|
||||
.andExpect(status().isForbidden());
|
||||
@@ -608,6 +930,32 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
public void deleteItemCopyVirtualMetadataConfigured() throws Exception {
|
||||
initPersonProjectPublication();
|
||||
|
||||
for (Item item : asList(publicationItem, projectItem)) {
|
||||
|
||||
// Verify the dc.contributor.author virtual metadata
|
||||
assertEquals(
|
||||
1,
|
||||
itemService.getMetadata(item, "dc", "contributor", "author", ANY).size()
|
||||
);
|
||||
|
||||
// Verify there's no dc.contributor.author actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
|
||||
// Verify there's no relation.isAuthorOfPublication actual metadata on the item
|
||||
assertEquals(
|
||||
0,
|
||||
item.getMetadata().stream()
|
||||
.filter(metadataValue -> "isAuthorOfPublication"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList()).size()
|
||||
);
|
||||
}
|
||||
|
||||
getClient(adminAuthToken).perform(
|
||||
delete("/api/core/items/" + personItem.getID() + "?copyVirtualMetadata=configured"))
|
||||
.andExpect(status().isNoContent());
|
||||
@@ -629,7 +977,26 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(projectAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> projectRelationships = itemService.getMetadata(projectItem,
|
||||
"relation", "isPersonOfProject", Item.ANY, Item.ANY);
|
||||
assertThat(projectRelationships.size(), equalTo(0));
|
||||
assertThat(projectRelationships.size(), equalTo(1));
|
||||
|
||||
// Verify there's dc.contributor.author actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "author".equals(metadataValue.getMetadataField().getQualifier()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
|
||||
// Verify there's relation.isPersonOfProject actual metadata on the project item
|
||||
assertEquals(
|
||||
1,
|
||||
projectItem.getMetadata().stream()
|
||||
.filter(metadataValue -> "isPersonOfProject"
|
||||
.equals(metadataValue.getMetadataField().getElement()))
|
||||
.collect(toList())
|
||||
.size()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -653,7 +1020,7 @@ public class RelationshipDeleteRestRepositoryIT extends AbstractEntityIntegratio
|
||||
assertNull(publicationAuthorList.get(0).getAuthority());
|
||||
List<MetadataValue> publicationRelationships = itemService.getMetadata(publicationItem,
|
||||
"relation", "isAuthorOfPublication", Item.ANY, Item.ANY);
|
||||
assertThat(publicationRelationships.size(), equalTo(0));
|
||||
assertThat(publicationRelationships.size(), equalTo(1));
|
||||
|
||||
projectItem = itemService.find(context, projectItem.getID());
|
||||
List<MetadataValue> projectAuthorList = itemService.getMetadata(projectItem,
|
||||
|
@@ -775,6 +775,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
||||
.andExpect(status().isCreated())
|
||||
.andDo(result -> idRef2.set(read(result.getResponse().getContentAsString(), "$.id")));
|
||||
|
||||
publication1 = itemService.find(context, publication1.getID());
|
||||
list = itemService.getMetadata(publication1, "dc", "contributor", "author", Item.ANY);
|
||||
// Ensure that we now have three dc.contributor.author mdv ("Smith, Donald", "plain text", "Smith, Maria"
|
||||
// In that order which will be checked below the rest call
|
||||
@@ -801,6 +802,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
||||
itemService.update(context, publication1);
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
publication1 = itemService.find(context, publication1.getID());
|
||||
list = itemService.getMetadata(publication1, "dc", "contributor", "author", Item.ANY);
|
||||
|
||||
// Assert that the list of dc.contributor.author mdv is now of size 4 in the following order:
|
||||
@@ -838,6 +840,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
||||
.andExpect(status().isCreated())
|
||||
.andDo(result -> idRef3.set(read(result.getResponse().getContentAsString(), "$.id")));
|
||||
|
||||
publication1 = itemService.find(context, publication1.getID());
|
||||
list = itemService.getMetadata(publication1, "dc", "contributor", "author", Item.ANY);
|
||||
// Assert that our dc.contributor.author mdv list is now of size 5
|
||||
assertEquals(5, list.size());
|
||||
@@ -901,6 +904,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
||||
itemService.update(context, publication1);
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
publication1 = itemService.find(context, publication1.getID());
|
||||
list = itemService.getMetadata(publication1, "dc", "contributor", "author", Item.ANY);
|
||||
|
||||
assertEquals(10, list.size());
|
||||
|
Reference in New Issue
Block a user