Merge pull request #2409 from atmire/rename-VirtualBean-VirtualMetadataPopularConfiguration

Rename virtual bean virtual metadata configuration
This commit is contained in:
Tim Donohue
2019-04-26 10:44:16 -05:00
committed by GitHub
8 changed files with 53 additions and 50 deletions

View File

@@ -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<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
RelationshipType relationshipType = relationship.getRelationshipType();
HashMap<String, VirtualBean> hashMaps;
HashMap<String, VirtualMetadataConfiguration> 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<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
HashMap<String, VirtualBean>
hashMaps,
HashMap<String, VirtualMetadataConfiguration> hashMaps,
Item otherItem, String relationName,
Integer relationshipId, int place)
throws SQLException {
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
for (Map.Entry<String, VirtualMetadataConfiguration> 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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -22,13 +22,13 @@ public class VirtualMetadataPopulator {
/**
* The map that holds this representation
*/
private Map<String, HashMap<String, VirtualBean>> map;
private Map<String, HashMap<String, VirtualMetadataConfiguration>> map;
/**
* Standard setter for the map
* @param map The map to be used in the VirtualMetadataPopulator
*/
public void setMap(Map<String, HashMap<String, VirtualBean>> map) {
public void setMap(Map<String, HashMap<String, VirtualMetadataConfiguration>> 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<String, HashMap<String, VirtualBean>> getMap() {
public Map<String, HashMap<String, VirtualMetadataConfiguration>> 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<String, VirtualBean> hashMaps;
HashMap<String, VirtualMetadataConfiguration> hashMaps;
if (isLeft) {
hashMaps = this.getMap().get(relationshipType.getLeftLabel());
} else {
hashMaps = this.getMap().get(relationshipType.getRightLabel());
}
if (hashMaps != null) {
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
VirtualBean virtualBean = entry.getValue();
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
VirtualMetadataConfiguration virtualBean = entry.getValue();
boolean useForPlace = virtualBean.getUseForPlace();
if (useForPlace) {
return true;

View File

@@ -37,7 +37,7 @@
<!-- Config like this will tell our VirtualMetadataPopulator to include the virtual metadata field
'dc.contributor.author' on the appropriate item with the values defined in the value-ref.
This value-ref should be a bean of type VirtualBean -->
This value-ref should be a bean of type VirtualMetadataConfiguration -->
<util:map id="isAuthorOfPublicationMap">
<entry key="dc.contributor.author" value-ref="publicationAuthor_author"/>
</util:map>
@@ -62,7 +62,7 @@
<!-- Config like this will tell our VirtualMetadataPopulator to include the virtual metadata field
'dc.contributor.other' on the appropriate item with the values defined in the value-ref.
This value-ref should be a bean of type VirtualBean -->
This value-ref should be a bean of type VirtualMetadataConfiguration -->
<util:map id="isOrgUnitOfPublicationMap">
<entry key="dc.contributor.other" value-ref="publicationOrgUnit_name"/>
</util:map>
@@ -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 -->
<bean class="org.dspace.content.virtual.Related" id="volumeJournal_issn_related">
<property name="relationshipTypeString" value="isJournalOfVolume"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_issn"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_issn"/>
</bean>
<bean class="org.dspace.content.virtual.Related" id="volumeJournal_title_related">
<property name="relationshipTypeString" value="isJournalOfVolume"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_title"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_title"/>
</bean>
<util:map id="isJournalOfVolumeMap">
@@ -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 -->
<bean class="org.dspace.content.virtual.Related" id="issueVolumeJournal_issn_related">
<property name="relationshipTypeString" value="isJournalVolumeOfIssue"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_issn_related"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_issn_related"/>
</bean>
<bean class="org.dspace.content.virtual.Related" id="issueVolumeJournal_title_related">
<property name="relationshipTypeString" value="isJournalVolumeOfIssue"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_title_related"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_title_related"/>
</bean>
<bean class="org.dspace.content.virtual.Related" id="issueVolume_title_related">
<property name="relationshipTypeString" value="isJournalVolumeOfIssue"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="issueVolume_title"/>
<property name="virtualMetadataConfiguration" ref="issueVolume_title"/>
</bean>
<bean class="org.dspace.content.virtual.Related" id="issueVolumeJournal_uuid_related">
<property name="relationshipTypeString" value="isJournalVolumeOfIssue"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_uuid_related"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_uuid_related"/>
</bean>
<bean class="org.dspace.content.virtual.Related" id="volumeJournal_uuid_related">
<property name="relationshipTypeString" value="isJournalOfVolume"/>
<property name="place" value="1"/>
<property name="virtualBean" ref="volumeJournal_uuid"/>
<property name="virtualMetadataConfiguration" ref="volumeJournal_uuid"/>
</bean>
<bean class="org.dspace.content.virtual.UUIDValue" id="volumeJournal_uuid"/>
</beans>