Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DS-1084] authority field in Batch Metadata Editor #73

Merged
merged 1 commit into from
Sep 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public class DSpaceCSV implements Serializable
/** The field separator in an escaped form for using in regexs */
protected static String escapedFieldSeparator;

/** The authority separator (defaults to dobule colon '::') */
protected static String authoritySeparator;

/** The authority separator in an escaped form for using in regexs */
protected static String escapedAuthoritySeparator;


/** Whether to export all metadata such as handles and provenance information */
private boolean exportAll;

Expand Down Expand Up @@ -226,6 +233,9 @@ private void init()
// Set the field separator
setFieldSeparator();

// Set the authority separator
setAuthoritySeparator();

// Create the headings
headings = new ArrayList<String>();

Expand Down Expand Up @@ -340,6 +350,32 @@ else if ("hash".equals(fieldSeparator))
escapedFieldSeparator = match.replaceAll("\\\\$1");
}

/**
* Set the authority separator for value with authority data.
*
* Is set in dspace.cfg as bulkedit.authorityseparator
*
* If not set, defaults to double colon '::'
*/
private void setAuthoritySeparator()
{
// Get the value separator
authoritySeparator = ConfigurationManager.getProperty("bulkedit", "authorityseparator");
if ((authoritySeparator != null) && (!"".equals(authoritySeparator.trim())))
{
authoritySeparator = authoritySeparator.trim();
}
else
{
authoritySeparator = "::";
}

// Now store the escaped version
Pattern spchars = Pattern.compile("([\\\\*+\\[\\](){}\\$.?\\^|])");
Matcher match = spchars.matcher(authoritySeparator);
escapedAuthoritySeparator = match.replaceAll("\\\\$1");
}

/**
* Add a DSpace item to the CSV file
*
Expand Down Expand Up @@ -390,7 +426,13 @@ public final void addItem(Item i) throws Exception
// Store the item
if (exportAll || okToExport(value))
{
line.add(key, value.value);
// Add authority and confidence if authority is not null
String mdValue = value.value;
if (value.authority != null && !"".equals(value.authority))
{
mdValue += authoritySeparator + value.authority + authoritySeparator + value.confidence;
}
line.add(key, mdValue);
if (!headings.contains(key))
{
headings.add(key);
Expand Down
Loading