mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
(Stuart Lewis) SF Patch #1642563 bin/update-handle-prefix rewritten in Java
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2525 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -45,6 +45,8 @@ import java.io.InputStreamReader;
|
|||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
import org.dspace.storage.rdbms.DatabaseManager;
|
||||||
import org.dspace.storage.rdbms.TableRow;
|
import org.dspace.storage.rdbms.TableRow;
|
||||||
|
import org.dspace.search.DSIndexer;
|
||||||
|
import org.dspace.browse.IndexBrowse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sciprt to update the handle values in the database. This is typically used
|
* A sciprt to update the handle values in the database. This is typically used
|
||||||
@@ -83,23 +85,39 @@ public class UpdateHandlePrefix
|
|||||||
{
|
{
|
||||||
// Make the changes
|
// Make the changes
|
||||||
System.out.print("Updating handle table... ");
|
System.out.print("Updating handle table... ");
|
||||||
sql = "update handle set handle = " +
|
sql = "update handle set handle = '" + newH + "' || '/' || handle_id " +
|
||||||
"overlay ( handle placing '" + newH + "' from 1 for " +
|
"where handle like '" + oldH + "/%'";
|
||||||
oldH.length() + ") where handle like '" + oldH + "%'";
|
|
||||||
int updated = DatabaseManager.updateQuery(context, sql, new Object[] {});
|
int updated = DatabaseManager.updateQuery(context, sql, new Object[] {});
|
||||||
System.out.println(updated + " items updated");
|
System.out.println(updated + " items updated");
|
||||||
|
|
||||||
System.out.print("Updating metadatavalues table... ");
|
System.out.print("Updating metadatavalues table... ");
|
||||||
sql = "update metadatavalue set " +
|
sql = "UPDATE metadatavalue SET text_value= (SELECT 'http://hdl.handle.net/' || " +
|
||||||
"text_value = overlay ( text_value placing '" + newH + "' " +
|
"handle FROM handle WHERE handle.resource_id=item_id AND " +
|
||||||
"from 23 for " + oldH.length() + ") where text_value like " +
|
"handle.resource_type_id=2) WHERE text_value LIKE 'http://hdl.handle.net/%';";
|
||||||
"'http://hdl.handle.net/" + oldH + "%'";
|
|
||||||
updated = DatabaseManager.updateQuery(context, sql, new Object[] {});
|
updated = DatabaseManager.updateQuery(context, sql, new Object[] {});
|
||||||
System.out.println(updated + " metadata values updated");
|
System.out.println(updated + " metadata values updated");
|
||||||
|
|
||||||
// Commit the changes
|
// Commit the changes
|
||||||
context.complete();
|
context.complete();
|
||||||
|
|
||||||
|
System.out.print("Re-creating browse and search indexes... ");
|
||||||
|
|
||||||
|
// Reinitialise the browse system
|
||||||
|
IndexBrowse.main(new String[] {"-i"});
|
||||||
|
|
||||||
|
// Reinitialise the browse system
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DSIndexer.main(new String[0]);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Not a lot we can do
|
||||||
|
System.out.println("Error re-indexing:");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("\nPlease manually run [dspace]/bin/index-all");
|
||||||
|
}
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
System.out.println("\nHandles successfully updated.");
|
System.out.println("\nHandles successfully updated.");
|
||||||
}
|
}
|
||||||
|
@@ -44,12 +44,8 @@
|
|||||||
|
|
||||||
# Shell script for updating a handle prefix (e.g. when moving from development
|
# Shell script for updating a handle prefix (e.g. when moving from development
|
||||||
# to production).
|
# to production).
|
||||||
#
|
|
||||||
# NOTE: Currently only compatible with installs running a PostgreSQL database
|
|
||||||
#
|
|
||||||
|
|
||||||
# Get the DSPACE/bin directory
|
# Get the DSPACE/bin directory
|
||||||
BINDIR=`dirname $0`
|
BINDIR=`dirname $0`
|
||||||
|
|
||||||
$BINDIR/dsrun org.dspace.handle.UpdateHandlePrefix $@
|
$BINDIR/dsrun org.dspace.handle.UpdateHandlePrefix $@
|
||||||
$BINDIR/index-all
|
|
Reference in New Issue
Block a user