mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 07:53:08 +00:00
Merge branch 'feature-name-variants' of https://github.com/atmire/DSpace into feature-name-variants
# Conflicts: # dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java # dspace-api/src/main/java/org/dspace/content/RelationshipMetadataServiceImpl.java
This commit is contained in:
@@ -1341,8 +1341,8 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
//except for relation.type which is the type of item in the model
|
//except for relation.type which is the type of item in the model
|
||||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||||
|
|
||||||
List<RelationshipMetadataValue> relationMetadata =
|
List<RelationshipMetadataValue> relationMetadata = relationshipMetadataService
|
||||||
relationshipMetadataService.getRelationshipMetadata(item, false);
|
.getRelationshipMetadata(item, false);
|
||||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||||
for (MetadataValue metadataValue : relationMetadata) {
|
for (MetadataValue metadataValue : relationMetadata) {
|
||||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||||
@@ -1379,7 +1379,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
* This method will sort the List of MetadataValue objects based on the MetadataSchema, MetadataField Element,
|
* This method will sort the List of MetadataValue objects based on the MetadataSchema, MetadataField Element,
|
||||||
* MetadataField Qualifier and MetadataField Place in that order.
|
* MetadataField Qualifier and MetadataField Place in that order.
|
||||||
* @param listToReturn The list to be sorted
|
* @param listToReturn The list to be sorted
|
||||||
* @return The list sorted on those criteria
|
* @return The list sorted on those criteria
|
||||||
*/
|
*/
|
||||||
private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) {
|
private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) {
|
||||||
Comparator<MetadataValue> comparator = Comparator.comparing(
|
Comparator<MetadataValue> comparator = Comparator.comparing(
|
||||||
@@ -1398,6 +1398,4 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -85,19 +85,21 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
String relationName;
|
String relationName;
|
||||||
Item otherItem;
|
Item otherItem;
|
||||||
int place = 0;
|
int place = 0;
|
||||||
boolean isLeft;
|
boolean isLeftwards;
|
||||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
||||||
otherItem = relationship.getRightItem();
|
otherItem = relationship.getRightItem();
|
||||||
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
||||||
place = relationship.getLeftPlace();
|
place = relationship.getLeftPlace();
|
||||||
isLeft = true;
|
isLeftwards = false; //if the current item is stored on the left,
|
||||||
|
// the name variant is retrieved from the rightwards label
|
||||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
||||||
otherItem = relationship.getLeftItem();
|
otherItem = relationship.getLeftItem();
|
||||||
relationName = relationship.getRelationshipType().getRightwardLabel();
|
relationName = relationship.getRelationshipType().getRightwardLabel();
|
||||||
place = relationship.getRightPlace();
|
place = relationship.getRightPlace();
|
||||||
isLeft = false;
|
isLeftwards = true; //if the current item is stored on the right,
|
||||||
|
// the name variant is retrieved from the leftwards label
|
||||||
} else {
|
} else {
|
||||||
//No virtual metadata can be created
|
//No virtual metadata can be created
|
||||||
return resultingMetadataValueList;
|
return resultingMetadataValueList;
|
||||||
@@ -105,8 +107,8 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
|
|
||||||
if (hashMaps != null && enableVirtualMetadata) {
|
if (hashMaps != null && enableVirtualMetadata) {
|
||||||
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
||||||
otherItem, relationName,
|
otherItem, relationName,
|
||||||
relationship, place, isLeft));
|
relationship, place, isLeftwards));
|
||||||
}
|
}
|
||||||
RelationshipMetadataValue relationMetadataFromOtherItem =
|
RelationshipMetadataValue relationMetadataFromOtherItem =
|
||||||
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID(), place);
|
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID(), place);
|
||||||
@@ -120,10 +122,8 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
//hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
|
//hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
|
||||||
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
||||||
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
||||||
HashMap<String, VirtualMetadataConfiguration> hashMaps,
|
HashMap<String, VirtualMetadataConfiguration> hashMaps, Item otherItem, String relationName,
|
||||||
Item otherItem, String relationName,
|
Relationship relationship, int place, boolean isLeftwards) throws SQLException {
|
||||||
Relationship relationship, int place,
|
|
||||||
boolean isLeft) throws SQLException {
|
|
||||||
|
|
||||||
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||||
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||||
@@ -131,20 +131,18 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||||
|
|
||||||
if (virtualBean.getPopulateWithNameVariant()) {
|
if (virtualBean.getPopulateWithNameVariant()) {
|
||||||
String wardLabel = isLeft ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
String wardLabel = isLeftwards ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
||||||
if (wardLabel != null) {
|
if (wardLabel != null) {
|
||||||
resultingMetadataValueList.add(
|
resultingMetadataValueList.add(
|
||||||
constructRelationshipMetadataValue(
|
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,
|
||||||
context, item, relationship.getID(), place, key, virtualBean, wardLabel
|
wardLabel));
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
handleVirtualBeanValues(
|
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList,
|
||||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean);
|
key, virtualBean);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleVirtualBeanValues(
|
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList, key,
|
||||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean
|
virtualBean);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultingMetadataValueList;
|
return resultingMetadataValueList;
|
||||||
@@ -154,15 +152,20 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
int place, List<RelationshipMetadataValue> resultingMetadataValueList,
|
int place, List<RelationshipMetadataValue> resultingMetadataValueList,
|
||||||
String key, VirtualMetadataConfiguration virtualBean) throws SQLException {
|
String key, VirtualMetadataConfiguration virtualBean) throws SQLException {
|
||||||
for (String value : virtualBean.getValues(context, otherItem)) {
|
for (String value : virtualBean.getValues(context, otherItem)) {
|
||||||
resultingMetadataValueList.add(
|
RelationshipMetadataValue relationshipMetadataValue = constructRelationshipMetadataValue(context, item,
|
||||||
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean, value)
|
relationship
|
||||||
);
|
.getID(),
|
||||||
|
place,
|
||||||
|
key, virtualBean,
|
||||||
|
value);
|
||||||
|
if (relationshipMetadataValue != null) {
|
||||||
|
resultingMetadataValueList.add(relationshipMetadataValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RelationshipMetadataValue constructRelationshipMetadataValue(Context context, Item item,
|
private RelationshipMetadataValue constructRelationshipMetadataValue(Context context, Item item,
|
||||||
Integer relationshipId,
|
Integer relationshipId, int place,
|
||||||
int place,
|
|
||||||
String key,
|
String key,
|
||||||
VirtualMetadataConfiguration virtualBean,
|
VirtualMetadataConfiguration virtualBean,
|
||||||
String value) {
|
String value) {
|
||||||
|
@@ -38,7 +38,7 @@ import org.dspace.eperson.Group;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ItemService
|
public interface ItemService
|
||||||
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item>, IndexableObjectService<Item, UUID> {
|
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item>, IndexableObjectService<Item, UUID> {
|
||||||
|
|
||||||
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ public interface ItemService
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public Iterator<Item> findInArchiveOrWithdrawnNonDiscoverableModifiedSince(Context context, Date since)
|
public Iterator<Item> findInArchiveOrWithdrawnNonDiscoverableModifiedSince(Context context, Date since)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the items (including private and withdrawn) in this collection. The order is indeterminate.
|
* Get all the items (including private and withdrawn) in this collection. The order is indeterminate.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -84,4 +84,19 @@ public class RelationshipBuilder extends AbstractBuilder<Relationship, Relations
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withLeftWardLabel(String leftWardLabel) throws SQLException {
|
||||||
|
relationship.setLeftwardLabel(leftWardLabel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withRightWardLabel(String rightWardLabel) throws SQLException {
|
||||||
|
relationship.setRightwardLabel(rightWardLabel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withLeftPlace(int leftPlace) {
|
||||||
|
relationship.setLeftPlace(leftPlace);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.matcher;
|
package org.dspace.app.rest.matcher;
|
||||||
|
|
||||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
@@ -18,7 +18,8 @@ import org.hamcrest.Matcher;
|
|||||||
*/
|
*/
|
||||||
public class MetadataMatcher {
|
public class MetadataMatcher {
|
||||||
|
|
||||||
private MetadataMatcher() { }
|
private MetadataMatcher() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a matcher to ensure a given value is present among all values for a given metadata key.
|
* Gets a matcher to ensure a given value is present among all values for a given metadata key.
|
||||||
@@ -28,7 +29,7 @@ public class MetadataMatcher {
|
|||||||
* @return the matcher.
|
* @return the matcher.
|
||||||
*/
|
*/
|
||||||
public static Matcher<? super Object> matchMetadata(String key, String value) {
|
public static Matcher<? super Object> matchMetadata(String key, String value) {
|
||||||
return hasJsonPath("$.['" + key + "'][*].value", contains(value));
|
return hasJsonPath("$.['" + key + "'][*].value", hasItem(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user