diff --git a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java index d3021e95e9..be289826d8 100644 --- a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java @@ -44,7 +44,7 @@ import org.dspace.content.service.ItemService; import org.dspace.content.service.MetadataSchemaService; import org.dspace.content.service.RelationshipService; import org.dspace.content.service.WorkspaceItemService; -import org.dspace.content.virtual.VirtualBean; +import org.dspace.content.virtual.VirtualMetadataConfiguration; import org.dspace.content.virtual.VirtualMetadataPopulator; import org.dspace.core.Constants; import org.dspace.core.Context; @@ -1424,7 +1424,7 @@ prevent the generation of resource policy entry values with null dspace_object a throws SQLException { List resultingMetadataValueList = new LinkedList<>(); RelationshipType relationshipType = relationship.getRelationshipType(); - HashMap hashMaps; + HashMap hashMaps; String relationName = ""; Item otherItem = null; int place = 0; @@ -1460,15 +1460,14 @@ prevent the generation of resource policy entry values with null dspace_object a //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 handleRelationshipTypeMetadataMapping(Context context, Item item, - HashMap - hashMaps, + HashMap hashMaps, Item otherItem, String relationName, Integer relationshipId, int place) throws SQLException { List resultingMetadataValueList = new LinkedList<>(); - for (Map.Entry entry : hashMaps.entrySet()) { + for (Map.Entry entry : hashMaps.entrySet()) { String key = entry.getKey(); - VirtualBean virtualBean = entry.getValue(); + VirtualMetadataConfiguration virtualBean = entry.getValue(); for (String value : virtualBean.getValues(context, otherItem)) { RelationshipMetadataValue metadataValue = constructMetadataValue(context, key); diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/Collected.java b/dspace-api/src/main/java/org/dspace/content/virtual/Collected.java index 16daab017c..4820e34e4e 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/Collected.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/Collected.java @@ -18,12 +18,13 @@ import org.dspace.core.Context; import org.springframework.beans.factory.annotation.Autowired; /** - * A bean implementing the {@link VirtualBean} interface to achieve the generation of Virtual metadata + * A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of Virtual + * metadata * The Collected bean will take all the values of each metadata field defined in the list and it'll * create a list of virtual metadata fields defined by the map in which it's defined. * All values from the metadata fields will returned as separate elements */ -public class Collected implements VirtualBean { +public class Collected implements VirtualMetadataConfiguration { @Autowired private ItemService itemService; diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/Concatenate.java b/dspace-api/src/main/java/org/dspace/content/virtual/Concatenate.java index dd12355b75..04d3e911ec 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/Concatenate.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/Concatenate.java @@ -18,13 +18,14 @@ import org.dspace.core.Context; import org.springframework.beans.factory.annotation.Autowired; /** - * A bean implementing the {@link VirtualBean} interface to achieve the generation of Virtual metadata + * A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of Virtual + * metadata * The Concatenate bean will take all the values of each metadata field configured in the list * and it will join all of these together with the separator defined in this bean. This means that whichever * entry this bean belongs to, that metadata field will have the value of the related item's metadata values * joined together with this separator. Only one value will be returned */ -public class Concatenate implements VirtualBean { +public class Concatenate implements VirtualMetadataConfiguration { @Autowired private ItemService itemService; diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/Related.java b/dspace-api/src/main/java/org/dspace/content/virtual/Related.java index 6285d7d48f..09eb951f06 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/Related.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/Related.java @@ -25,16 +25,16 @@ import org.dspace.core.Context; import org.springframework.beans.factory.annotation.Autowired; /** - * A bean implementing the {@link VirtualBean} interface to achieve the generation of Virtual metadata - * by traversing the path of relation specified in the config for this bean + * A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of + * Virtual metadata by traversing the path of relation specified in the config for this bean * The Related bean will find the relationshiptype defined in the relationshipTypeString property on - * the current item and it'll use the related item from that relationship to pass it along to the virtualBean - * property which in turn refers to another VirtualBean instance and it continues the chain until it reaches - * either a Concatenate or Collected bean to retrieve the values. It will then return that value through the chain - * again and it'll fill the values into the virtual metadata fields that are defined in the map for the first - * Related bean. + * the current item and it'll use the related item from that relationship to pass it along to the + * virtualMetadataConfiguration property which in turn refers to another VirtualBean instance and it continues + * the chain until it reaches either a Concatenate or Collected bean to retrieve the values. It will then return + * that value through the chain again and it'll fill the values into the virtual metadata fields that are defined + * in the map for the first Related bean. */ -public class Related implements VirtualBean { +public class Related implements VirtualMetadataConfiguration { @Autowired private RelationshipTypeService relationshipTypeService; @@ -59,7 +59,7 @@ public class Related implements VirtualBean { /** * The next bean to call its getValues() method on */ - private VirtualBean virtualBean; + private VirtualMetadataConfiguration virtualMetadataConfiguration; /** * The boolean value indicating whether this field should be used for place or not @@ -99,19 +99,21 @@ public class Related implements VirtualBean { } /** - * Generic getter for the virtualBean property of this class - * @return The virtualBean property + * Generic getter for the virtualMetadataConfiguration property of this class + * @return The virtualMetadataConfiguration property */ - public VirtualBean getVirtualBean() { - return virtualBean; + public VirtualMetadataConfiguration getVirtualMetadataConfiguration() { + return virtualMetadataConfiguration; } /** - * Generic setter for the virtualBean property of this class - * @param virtualBean The VirtualBean to which the virtualBean property will be set to + * Generic setter for the virtualMetadataConfiguration property of this class + * @param virtualMetadataConfiguration The VirtualBean to which the + * virtualMetadataConfiguration property will be set to */ - public void setVirtualBean(VirtualBean virtualBean) { - this.virtualBean = virtualBean; + public void setVirtualMetadataConfiguration(VirtualMetadataConfiguration + virtualMetadataConfiguration) { + this.virtualMetadataConfiguration = virtualMetadataConfiguration; } /** @@ -162,12 +164,12 @@ public class Related implements VirtualBean { if (relationship.getRelationshipType().getLeftType() == entityType) { if (relationship.getLeftPlace() == place) { Item otherItem = relationship.getRightItem(); - return virtualBean.getValues(context, otherItem); + return virtualMetadataConfiguration.getValues(context, otherItem); } } else if (relationship.getRelationshipType().getRightType() == entityType) { if (relationship.getRightPlace() == place) { Item otherItem = relationship.getLeftItem(); - return virtualBean.getValues(context, otherItem); + return virtualMetadataConfiguration.getValues(context, otherItem); } } } diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/UUIDValue.java b/dspace-api/src/main/java/org/dspace/content/virtual/UUIDValue.java index 407ef2a459..c5c45cac8c 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/UUIDValue.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/UUIDValue.java @@ -18,7 +18,7 @@ import org.dspace.core.Context; * This class is used by the VirtualMetadataPopulator. It will simply take the ID of the item that's passed along * to this and return that as it's value */ -public class UUIDValue implements VirtualBean { +public class UUIDValue implements VirtualMetadataConfiguration { private boolean useForPlace; diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/VirtualBean.java b/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataConfiguration.java similarity index 97% rename from dspace-api/src/main/java/org/dspace/content/virtual/VirtualBean.java rename to dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataConfiguration.java index 5fe08c43fe..0cbb685c96 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/VirtualBean.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataConfiguration.java @@ -18,7 +18,7 @@ import org.dspace.core.Context; * The config is located in core-services.xml whilst the actual code implementation is located in * {@link org.dspace.content.ItemServiceImpl} */ -public interface VirtualBean { +public interface VirtualMetadataConfiguration { /** * This method will return a list filled with String values which will be determine by the bean that's responsible diff --git a/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataPopulator.java b/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataPopulator.java index 72bf89c002..94545ab9fe 100644 --- a/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataPopulator.java +++ b/dspace-api/src/main/java/org/dspace/content/virtual/VirtualMetadataPopulator.java @@ -22,13 +22,13 @@ public class VirtualMetadataPopulator { /** * The map that holds this representation */ - private Map> map; + private Map> map; /** * Standard setter for the map * @param map The map to be used in the VirtualMetadataPopulator */ - public void setMap(Map> map) { + public void setMap(Map> map) { this.map = map; } @@ -36,7 +36,7 @@ public class VirtualMetadataPopulator { * Standard getter for the map * @return The map that is used in the VirtualMetadataPopulator */ - public Map> getMap() { + public Map> getMap() { return map; } @@ -48,15 +48,15 @@ public class VirtualMetadataPopulator { * @return A boolean indicating whether the useForPlace is true or not for the given parameters */ public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) { - HashMap hashMaps; + HashMap hashMaps; if (isLeft) { hashMaps = this.getMap().get(relationshipType.getLeftLabel()); } else { hashMaps = this.getMap().get(relationshipType.getRightLabel()); } if (hashMaps != null) { - for (Map.Entry entry : hashMaps.entrySet()) { - VirtualBean virtualBean = entry.getValue(); + for (Map.Entry entry : hashMaps.entrySet()) { + VirtualMetadataConfiguration virtualBean = entry.getValue(); boolean useForPlace = virtualBean.getUseForPlace(); if (useForPlace) { return true; diff --git a/dspace/config/spring/api/virtual-metadata.xml b/dspace/config/spring/api/virtual-metadata.xml index 676626f3c8..3172346123 100644 --- a/dspace/config/spring/api/virtual-metadata.xml +++ b/dspace/config/spring/api/virtual-metadata.xml @@ -37,7 +37,7 @@ + This value-ref should be a bean of type VirtualMetadataConfiguration --> @@ -62,7 +62,7 @@ + This value-ref should be a bean of type VirtualMetadataConfiguration --> @@ -154,18 +154,18 @@ alone, we need to pass this call higher up the chain to the journalvolume's relationships to find the journal. Therefore we've created this Related bean which will look at the journalvolume's relationships with type 'isJournalOfVolume' to find the journal that this journalvolume is related to and it'll then call the next - VirtualBean with that journal to retrieve the value. This will leave the retrieving of the values to the - next bean in the chain --> + VirtualMetadataConfiguration with that journal to retrieve the value. This will leave the retrieving + of the values to the next bean in the chain --> - + - + @@ -224,39 +224,39 @@ alone, we need to pass this call higher up the chain to the journalissue's relationships to find the journal. Therefore we've created this Related bean which will look at the journalissue's relationships with type 'isJournalVolumeOfIssue' to find the journalvolume that this journalissue is related to and it'll then call the next - VirtualBean with that journalvolume to retrieve the value. This will leave the retrieving of the values to the - next bean in the chain. + VirtualMetadataConfiguration with that journalvolume to retrieve the value. This will leave the retrieving + of the values to the next bean in the chain. In this specific case, it'll call another Related bean to retrieve the journal for the journalvolume and it'll then retrieve the volume. This example has 2 Related beans chained to eachother to finally chain to a Collected bean to retrieve the final value --> - + - + - + - + - +