mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Update to stay in sync. with merged PRs
This commit is contained in:
@@ -11,7 +11,6 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -19,6 +18,7 @@ import org.joda.time.format.DateTimeFormatter;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
|
||||
import java.util.*;
|
||||
import org.dspace.content.Metadatum;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -167,8 +167,8 @@ public class AuthorityValue {
|
||||
/**
|
||||
* Replace an item's DCValue with this authority
|
||||
*/
|
||||
public void updateItem(Item currentItem, DCValue value) {
|
||||
DCValue newValue = value.copy();
|
||||
public void updateItem(Item currentItem, Metadatum value) {
|
||||
Metadatum newValue = value.copy();
|
||||
newValue.value = getValue();
|
||||
newValue.authority = getId();
|
||||
currentItem.replaceMetadataValue(value,newValue);
|
||||
|
@@ -9,7 +9,6 @@ package org.dspace.authority;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.ItemIterator;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
@@ -20,6 +19,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.dspace.content.Metadatum;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -150,9 +150,9 @@ public class UpdateAuthorities {
|
||||
ItemIterator itemIterator = Item.findByMetadataFieldAuthority(context, authority.getField(), authority.getId());
|
||||
while (itemIterator.hasNext()) {
|
||||
Item next = itemIterator.next();
|
||||
List<DCValue> metadata = next.getMetadata(authority.getField(), authority.getId());
|
||||
List<Metadatum> metadata = next.getMetadata(authority.getField(), authority.getId());
|
||||
authority.updateItem(next, metadata.get(0)); //should be only one
|
||||
List<DCValue> metadataAfter = next.getMetadata(authority.getField(), authority.getId());
|
||||
List<Metadatum> metadataAfter = next.getMetadata(authority.getField(), authority.getId());
|
||||
if (!metadata.get(0).value.equals(metadataAfter.get(0).value)) {
|
||||
print.println("Updated item with handle " + next.getHandle());
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import org.dspace.authority.AuthorityValueFinder;
|
||||
import org.dspace.authority.AuthorityValueGenerator;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Metadatum;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.ItemIterator;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
@@ -107,7 +107,7 @@ public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface {
|
||||
// 1. iterate over the metadata values
|
||||
|
||||
String metadataField = metadataFields.get(currentFieldIndex);
|
||||
DCValue[] values = currentItem.getMetadataByMetadataString(metadataField);
|
||||
Metadatum[] values = currentItem.getMetadataByMetadataString(metadataField);
|
||||
if (currentMetadataIndex < values.length) {
|
||||
prepareNextValue(metadataField, values[currentMetadataIndex]);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface {
|
||||
* @param metadataField Is one of the fields defined in dspace.cfg to be indexed.
|
||||
* @param value Is one of the values of the given metadataField in one of the items being indexed.
|
||||
*/
|
||||
private void prepareNextValue(String metadataField, DCValue value) {
|
||||
private void prepareNextValue(String metadataField, Metadatum value) {
|
||||
|
||||
nextValue = null;
|
||||
|
||||
|
@@ -703,18 +703,18 @@ public abstract class DSpaceObject
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<DCValue> getMetadata(String mdString, String authority) {
|
||||
public List<Metadatum> getMetadata(String mdString, String authority) {
|
||||
String[] elements = getElements(mdString);
|
||||
return getMetadata(elements[0], elements[1], elements[2], elements[3], authority);
|
||||
}
|
||||
|
||||
public List<DCValue> getMetadata(String schema, String element, String qualifier, String lang, String authority) {
|
||||
DCValue[] metadata = getMetadata(schema, element, qualifier, lang);
|
||||
List<DCValue> dcValues = Arrays.asList(metadata);
|
||||
public List<Metadatum> getMetadata(String schema, String element, String qualifier, String lang, String authority) {
|
||||
Metadatum[] metadata = getMetadata(schema, element, qualifier, lang);
|
||||
List<Metadatum> dcValues = Arrays.asList(metadata);
|
||||
if (!authority.equals(Item.ANY)) {
|
||||
Iterator<DCValue> iterator = dcValues.iterator();
|
||||
Iterator<Metadatum> iterator = dcValues.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
DCValue dcValue = iterator.next();
|
||||
Metadatum dcValue = iterator.next();
|
||||
if (!authority.equals(dcValue.authority)) {
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -759,7 +759,7 @@ public abstract class DSpaceObject
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void replaceMetadataValue(DCValue oldValue, DCValue newValue)
|
||||
public void replaceMetadataValue(Metadatum oldValue, Metadatum newValue)
|
||||
{
|
||||
// check both dcvalues are for the same field
|
||||
if (oldValue.hasSameFieldAs(newValue)) {
|
||||
@@ -769,9 +769,9 @@ public abstract class DSpaceObject
|
||||
String qualifier = oldValue.qualifier;
|
||||
|
||||
// Save all metadata for this field
|
||||
DCValue[] dcvalues = getMetadata(schema, element, qualifier, Item.ANY);
|
||||
Metadatum[] dcvalues = getMetadata(schema, element, qualifier, Item.ANY);
|
||||
clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
for (DCValue dcvalue : dcvalues) {
|
||||
for (Metadatum dcvalue : dcvalues) {
|
||||
if (dcvalue.equals(oldValue)) {
|
||||
addMetadata(schema, element, qualifier, newValue.language, newValue.value, newValue.authority, newValue.confidence);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user