leftwards label vs left item

This commit is contained in:
Ben Bosman
2019-08-06 17:29:56 +02:00
parent d7a1015f70
commit 8f7c7da569

View File

@@ -85,19 +85,19 @@ 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.getLeftLabel()); hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftLabel());
otherItem = relationship.getRightItem(); otherItem = relationship.getRightItem();
relationName = relationship.getRelationshipType().getLeftLabel(); relationName = relationship.getRelationshipType().getLeftLabel();
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.getRightLabel()); hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightLabel());
otherItem = relationship.getLeftItem(); otherItem = relationship.getLeftItem();
relationName = relationship.getRelationshipType().getRightLabel(); relationName = relationship.getRelationshipType().getRightLabel();
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;
@@ -106,7 +106,7 @@ 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);
@@ -121,7 +121,7 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
//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, Item otherItem, String relationName, HashMap<String, VirtualMetadataConfiguration> hashMaps, Item otherItem, String relationName,
Relationship relationship, int place, boolean isLeft) throws SQLException { Relationship relationship, int place, boolean isLeftwards) 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()) {
@@ -129,7 +129,7 @@ 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(context, item, relationship.getID(), place, key, virtualBean, constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,