mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +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;
|
||||
@@ -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
|
||||
|
||||
@@ -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++)
|
||||
|
Reference in New Issue
Block a user