mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +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:
@@ -85,19 +85,21 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
||||
String relationName;
|
||||
Item otherItem;
|
||||
int place = 0;
|
||||
boolean isLeft;
|
||||
boolean isLeftwards;
|
||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
||||
otherItem = relationship.getRightItem();
|
||||
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
||||
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)) {
|
||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
||||
otherItem = relationship.getLeftItem();
|
||||
relationName = relationship.getRelationshipType().getRightwardLabel();
|
||||
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 {
|
||||
//No virtual metadata can be created
|
||||
return resultingMetadataValueList;
|
||||
@@ -105,8 +107,8 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
||||
|
||||
if (hashMaps != null && enableVirtualMetadata) {
|
||||
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
||||
otherItem, relationName,
|
||||
relationship, place, isLeft));
|
||||
otherItem, relationName,
|
||||
relationship, place, isLeftwards));
|
||||
}
|
||||
RelationshipMetadataValue relationMetadataFromOtherItem =
|
||||
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
|
||||
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
||||
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
||||
HashMap<String, VirtualMetadataConfiguration> hashMaps,
|
||||
Item otherItem, String relationName,
|
||||
Relationship relationship, int place,
|
||||
boolean isLeft) throws SQLException {
|
||||
HashMap<String, VirtualMetadataConfiguration> hashMaps, Item otherItem, String relationName,
|
||||
Relationship relationship, int place, boolean isLeftwards) throws SQLException {
|
||||
|
||||
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||
@@ -131,20 +131,18 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
||||
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||
|
||||
if (virtualBean.getPopulateWithNameVariant()) {
|
||||
String wardLabel = isLeft ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
||||
String wardLabel = isLeftwards ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
||||
if (wardLabel != null) {
|
||||
resultingMetadataValueList.add(
|
||||
constructRelationshipMetadataValue(
|
||||
context, item, relationship.getID(), place, key, virtualBean, wardLabel
|
||||
));
|
||||
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,
|
||||
wardLabel));
|
||||
} else {
|
||||
handleVirtualBeanValues(
|
||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean);
|
||||
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList,
|
||||
key, virtualBean);
|
||||
}
|
||||
} else {
|
||||
handleVirtualBeanValues(
|
||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean
|
||||
);
|
||||
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList, key,
|
||||
virtualBean);
|
||||
}
|
||||
}
|
||||
return resultingMetadataValueList;
|
||||
@@ -154,15 +152,20 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
||||
int place, List<RelationshipMetadataValue> resultingMetadataValueList,
|
||||
String key, VirtualMetadataConfiguration virtualBean) throws SQLException {
|
||||
for (String value : virtualBean.getValues(context, otherItem)) {
|
||||
resultingMetadataValueList.add(
|
||||
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean, value)
|
||||
);
|
||||
RelationshipMetadataValue relationshipMetadataValue = constructRelationshipMetadataValue(context, item,
|
||||
relationship
|
||||
.getID(),
|
||||
place,
|
||||
key, virtualBean,
|
||||
value);
|
||||
if (relationshipMetadataValue != null) {
|
||||
resultingMetadataValueList.add(relationshipMetadataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RelationshipMetadataValue constructRelationshipMetadataValue(Context context, Item item,
|
||||
Integer relationshipId,
|
||||
int place,
|
||||
Integer relationshipId, int place,
|
||||
String key,
|
||||
VirtualMetadataConfiguration virtualBean,
|
||||
String value) {
|
||||
|
Reference in New Issue
Block a user