Fixed the place attribute not being set to the virtual metadata

This commit is contained in:
Raf Ponsaerts
2019-01-14 15:29:54 +01:00
parent 612c8e315c
commit 7f225f1ad5

View File

@@ -1348,22 +1348,25 @@ prevent the generation of resource policy entry values with null dspace_object a
HashMap<String, VirtualBean> hashMaps = new HashMap<>(); HashMap<String, VirtualBean> hashMaps = new HashMap<>();
String relationName = ""; String relationName = "";
Item otherItem = null; Item otherItem = null;
int place = 0;
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) { if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
hashMaps = (HashMap<String, VirtualBean>) virtualMetadataPopulator hashMaps = (HashMap<String, VirtualBean>) virtualMetadataPopulator
.getMap().get(relationshipType.getLeftLabel()); .getMap().get(relationshipType.getLeftLabel());
otherItem = relationship.getRightItem(); otherItem = relationship.getRightItem();
relationName = relationship.getRelationshipType().getLeftLabel(); relationName = relationship.getRelationshipType().getLeftLabel();
place = relationship.getLeftPlace();
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) { } else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
hashMaps = (HashMap<String, VirtualBean>) virtualMetadataPopulator hashMaps = (HashMap<String, VirtualBean>) virtualMetadataPopulator
.getMap().get(relationshipType.getRightLabel()); .getMap().get(relationshipType.getRightLabel());
otherItem = relationship.getLeftItem(); otherItem = relationship.getLeftItem();
relationName = relationship.getRelationshipType().getRightLabel(); relationName = relationship.getRelationshipType().getRightLabel();
place = relationship.getRightPlace();
} }
if (hashMaps != null && extra) { if (hashMaps != null && extra) {
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(context, item, hashMaps, resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(context, item, hashMaps,
otherItem, relationName, otherItem, relationName,
relationship.getID())); relationship.getID(), place));
} }
resultingMetadataValueList resultingMetadataValueList
.add(getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID())); .add(getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID()));
@@ -1371,7 +1374,9 @@ prevent the generation of resource policy entry values with null dspace_object a
} }
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMappping(Context context, Item item, private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMappping(Context context, Item item,
HashMap<String, VirtualBean> hashMaps, Item otherItem, String relationName, Integer relationshipId) HashMap<String, VirtualBean> hashMaps,
Item otherItem, String relationName,
Integer relationshipId, int place)
throws SQLException { throws SQLException {
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>(); List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) { for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
@@ -1382,6 +1387,7 @@ prevent the generation of resource policy entry values with null dspace_object a
metadataValue = constructResultingMetadataValue(context, item, otherItem, virtualBean, metadataValue, metadataValue = constructResultingMetadataValue(context, item, otherItem, virtualBean, metadataValue,
relationshipId); relationshipId);
metadataValue.setUseForPlace(virtualBean.getUseForPlace()); metadataValue.setUseForPlace(virtualBean.getUseForPlace());
metadataValue.setPlace(place);
if (StringUtils.isNotBlank(metadataValue.getValue())) { if (StringUtils.isNotBlank(metadataValue.getValue())) {
resultingMetadataValueList.add(metadataValue); resultingMetadataValueList.add(metadataValue);
} }