mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-2763] More serialization
This commit is contained in:

committed by
Mark H. Wood

parent
3b123a05e0
commit
e7060bdc2d
@@ -9,12 +9,8 @@ package org.dspace.app.bulkedit;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.app.bulkedit.DSpaceCSVLine;
|
||||
import org.dspace.app.bulkedit.MetadataImport;
|
||||
import org.dspace.app.bulkedit.MetadataImportInvalidHeadingException;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -73,10 +69,10 @@ public class DSpaceCSV implements Serializable
|
||||
/** The authority separator in an escaped form for using in regexes */
|
||||
protected String escapedAuthoritySeparator;
|
||||
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected final MetadataSchemaService metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
|
||||
protected final MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
|
||||
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
protected transient final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected transient final MetadataSchemaService metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
|
||||
protected transient final MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
|
||||
protected transient final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
|
||||
|
||||
/** Whether to export all metadata such as handles and provenance information */
|
||||
@@ -262,16 +258,16 @@ public class DSpaceCSV implements Serializable
|
||||
setAuthoritySeparator();
|
||||
|
||||
// Create the headings
|
||||
headings = new ArrayList<String>();
|
||||
headings = new ArrayList<>();
|
||||
|
||||
// Create the blank list of items
|
||||
lines = new ArrayList<DSpaceCSVLine>();
|
||||
lines = new ArrayList<>();
|
||||
|
||||
// Initialise the counter
|
||||
counter = 0;
|
||||
|
||||
// Set the metadata fields to ignore
|
||||
ignore = new HashMap<String, String>();
|
||||
ignore = new HashMap<>();
|
||||
String toIgnore = ConfigurationManager.getProperty("bulkedit", "ignore-on-export");
|
||||
if ((toIgnore == null) || ("".equals(toIgnore.trim())))
|
||||
{
|
||||
@@ -495,7 +491,7 @@ public class DSpaceCSV implements Serializable
|
||||
|
||||
// Split up on field separator
|
||||
String[] parts = line.split(escapedFieldSeparator);
|
||||
ArrayList<String> bits = new ArrayList<String>();
|
||||
ArrayList<String> bits = new ArrayList<>();
|
||||
bits.addAll(Arrays.asList(parts));
|
||||
|
||||
// Merge parts with embedded separators
|
||||
@@ -624,7 +620,7 @@ public class DSpaceCSV implements Serializable
|
||||
// Create the headings line
|
||||
String[] csvLines = new String[counter + 1];
|
||||
csvLines[0] = "id" + fieldSeparator + "collection";
|
||||
List<String> headingsCopy = new ArrayList<String>(headings);
|
||||
List<String> headingsCopy = new ArrayList<>(headings);
|
||||
Collections.sort(headingsCopy);
|
||||
for (String value : headingsCopy)
|
||||
{
|
||||
@@ -701,10 +697,11 @@ public class DSpaceCSV implements Serializable
|
||||
*
|
||||
* @return The formatted String as a csv
|
||||
*/
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
// Return the csv as one long string
|
||||
StringBuffer csvLines = new StringBuffer();
|
||||
StringBuilder csvLines = new StringBuilder();
|
||||
String[] lines = this.getCSVLinesAsStringArray();
|
||||
for (String line : lines)
|
||||
{
|
||||
|
@@ -22,15 +22,16 @@ import java.util.*;
|
||||
public class DSpaceCSVLine implements Serializable
|
||||
{
|
||||
/** The item id of the item represented by this line. -1 is for a new item */
|
||||
private UUID id;
|
||||
private final UUID id;
|
||||
|
||||
/** The elements in this line in a hashtable, keyed by the metadata type */
|
||||
private Map<String, ArrayList> items;
|
||||
private final Map<String, ArrayList> items;
|
||||
|
||||
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
protected transient final AuthorityValueService authorityValueService
|
||||
= AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
|
||||
/** ensuring that the order-sensible columns of the csv are processed in the correct order */
|
||||
private final Comparator<? super String> headerComparator = new Comparator<String>() {
|
||||
private transient final Comparator<? super String> headerComparator = new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String md1, String md2) {
|
||||
// The metadata coming from an external source should be processed after the others
|
||||
@@ -60,7 +61,7 @@ public class DSpaceCSVLine implements Serializable
|
||||
{
|
||||
// Store the ID + separator, and initialise the hashtable
|
||||
this.id = itemId;
|
||||
items = new TreeMap<String, ArrayList>(headerComparator);
|
||||
items = new TreeMap<>(headerComparator);
|
||||
// this.items = new HashMap<String, ArrayList>();
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ public class DSpaceCSVLine implements Serializable
|
||||
{
|
||||
// Set the ID to be null, and initialise the hashtable
|
||||
this.id = null;
|
||||
this.items = new TreeMap<String, ArrayList>(headerComparator);
|
||||
this.items = new TreeMap<>(headerComparator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +150,7 @@ public class DSpaceCSVLine implements Serializable
|
||||
* Write this line out as a CSV formatted string, in the order given by the headings provided
|
||||
*
|
||||
* @param headings The headings which define the order the elements must be presented in
|
||||
* @param fieldSeparator
|
||||
* @return The CSV formatted String
|
||||
*/
|
||||
protected String toCSV(List<String> headings, String fieldSeparator)
|
||||
@@ -177,6 +179,7 @@ public class DSpaceCSVLine implements Serializable
|
||||
* Internal method to create a CSV formatted String joining a given set of elements
|
||||
*
|
||||
* @param values The values to create the string from
|
||||
* @param valueSeparator
|
||||
* @return The line as a CSV formatted String
|
||||
*/
|
||||
protected String valueToCSV(List<String> values, String valueSeparator)
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -26,12 +27,12 @@ import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Andrea Bollini (CILEA)
|
||||
* @author Adán Román Ruiz at arvo.es (bugfix)
|
||||
* @author Panagiotis Koutsourakis (National Documentation Centre) (bugfix)
|
||||
* @author Kostas Stamatis (National Documentation Centre) (bugfix)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SolrBrowseDAO implements BrowseDAO
|
||||
{
|
||||
@@ -40,7 +41,8 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
static private class FacetValueComparator implements Comparator
|
||||
static private class FacetValueComparator
|
||||
implements Comparator, Serializable
|
||||
{
|
||||
@Override
|
||||
public int compare(Object o1, Object o2)
|
||||
@@ -64,10 +66,10 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
}
|
||||
|
||||
/** Log4j log */
|
||||
private static Logger log = Logger.getLogger(SolrBrowseDAO.class);
|
||||
private static final Logger log = Logger.getLogger(SolrBrowseDAO.class);
|
||||
|
||||
/** The DSpace context */
|
||||
private Context context;
|
||||
private final Context context;
|
||||
|
||||
// SQL query related attributes for this class
|
||||
|
||||
@@ -136,7 +138,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
private boolean itemsDiscoverable = true;
|
||||
|
||||
private boolean showFrequencies;
|
||||
|
||||
|
||||
private DiscoverResult getSolrResponse() throws BrowseException
|
||||
{
|
||||
if (sResponse == null)
|
||||
@@ -205,7 +207,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
}
|
||||
else if (!itemsDiscoverable)
|
||||
{
|
||||
query.addFilterQueries("discoverable:false");
|
||||
query.addFilterQueries("discoverable:false");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +256,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
int count = doCountQuery();
|
||||
int start = offset > 0 ? offset : 0;
|
||||
int max = limit > 0 ? limit : count; //if negative, return everything
|
||||
List<String[]> result = new ArrayList<String[]>();
|
||||
List<String[]> result = new ArrayList<>();
|
||||
if (ascending)
|
||||
{
|
||||
for (int i = start; i < (start + max) && i < count; i++)
|
||||
@@ -390,22 +392,22 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
return doCountQuery() - ascValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnableBrowseFrequencies()
|
||||
{
|
||||
return showFrequencies;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setEnableBrowseFrequencies(boolean enableBrowseFrequencies)
|
||||
{
|
||||
showFrequencies = enableBrowseFrequencies;
|
||||
showFrequencies = enableBrowseFrequencies;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getContainerID()
|
||||
*/
|
||||
@Override
|
||||
@@ -416,7 +418,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getContainerIDField()
|
||||
*/
|
||||
@Override
|
||||
@@ -427,7 +429,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getContainerTable()
|
||||
*/
|
||||
@Override
|
||||
@@ -445,7 +447,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getFocusField()
|
||||
*/
|
||||
@Override
|
||||
@@ -456,7 +458,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getFocusValue()
|
||||
*/
|
||||
@Override
|
||||
@@ -467,7 +469,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getLimit()
|
||||
*/
|
||||
@Override
|
||||
@@ -478,7 +480,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getOffset()
|
||||
*/
|
||||
@Override
|
||||
@@ -489,7 +491,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getOrderField()
|
||||
*/
|
||||
@Override
|
||||
@@ -507,7 +509,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getTable()
|
||||
*/
|
||||
@Override
|
||||
@@ -518,7 +520,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getValue()
|
||||
*/
|
||||
@Override
|
||||
@@ -529,7 +531,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#getValueField()
|
||||
*/
|
||||
@Override
|
||||
@@ -540,7 +542,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#isAscending()
|
||||
*/
|
||||
@Override
|
||||
@@ -551,7 +553,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#isDistinct()
|
||||
*/
|
||||
@Override
|
||||
@@ -562,7 +564,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setAscending(boolean)
|
||||
*/
|
||||
@Override
|
||||
@@ -574,7 +576,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setContainerID(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -586,7 +588,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setContainerIDField(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -598,7 +600,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setContainerTable(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -618,7 +620,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setDistinct(boolean)
|
||||
*/
|
||||
@Override
|
||||
@@ -630,7 +632,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setEqualsComparator(boolean)
|
||||
*/
|
||||
@Override
|
||||
@@ -642,7 +644,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setFocusField(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -654,7 +656,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setFocusValue(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -666,7 +668,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setLimit(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -678,7 +680,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setOffset(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -690,7 +692,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setOrderField(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -710,7 +712,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setTable(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -740,7 +742,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setValue(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -752,7 +754,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setFilterValuePartial(boolean)
|
||||
*/
|
||||
@Override
|
||||
@@ -764,7 +766,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#setValueField(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -776,7 +778,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.dspace.browse.BrowseDAO#useEqualsComparator()
|
||||
*/
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user