org.dspace.browse
Class IndexBrowse

java.lang.Object
  extended by org.dspace.browse.IndexBrowse

public class IndexBrowse
extends Object

Tool to create Browse indexes. This class is used from the command line to create and destroy the browse indices from configuration, and also from within the application to add and remove content from those tables. To see a full definition of the usage of this class just run it without any arguments, and you will get the help message.

Author:
Richard Jones

Constructor Summary
IndexBrowse()
          Construct a new index browse.
IndexBrowse(Context context)
          Create a new IndexBrowse object.
 
Method Summary
 void clearDatabase()
          delete all the existing browse tables
 boolean delete()
           
 boolean execute()
           
 String getOutFile()
           
 int getStart()
           
 void indexItem(Item item)
          Index the given item
 void initBrowse()
          index everything
 String[] interpretField(String mfield, String init)
          Take a string representation of a metadata field, and return it as an array.
 boolean isFileOut()
           
 boolean isVerbose()
           
 boolean itemAdded(Item item)
          Deprecated.  
 boolean itemChanged(Item item)
          Deprecated.  
 boolean itemRemoved(int itemID)
           
 boolean itemRemoved(Item item)
          remove all the indices for the given item
static void main(String[] argv)
          Creates Browse indexes, destroying the old ones.
 boolean rebuild()
           
 void setDelete(boolean bool)
           
 void setExecute(boolean bool)
           
 void setFileOut(boolean bool)
           
 void setOutFile(String file)
           
 void setRebuild(boolean bool)
           
 void setStart(int start)
           
 void setStdOut(boolean bool)
           
 void setVerbose(boolean verbose)
           
 boolean toStdOut()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexBrowse

public IndexBrowse()
            throws SQLException,
                   BrowseException
Construct a new index browse. If done this way, an internal DSpace context will be created. Better instead to call new IndexBrowse(context); with your desired context (when using with the application)

Throws:
SQLException
BrowseException

IndexBrowse

public IndexBrowse(Context context)
            throws SQLException,
                   BrowseException
Create a new IndexBrowse object. This will ignore any authorisations applied to the Context

Parameters:
context -
Throws:
SQLException
BrowseException
Method Detail

isVerbose

public boolean isVerbose()
Returns:
Returns the verbose.

setVerbose

public void setVerbose(boolean verbose)
Parameters:
verbose - The verbose to set.

rebuild

public boolean rebuild()
Returns:
true if to rebuild the database, false if not

setRebuild

public void setRebuild(boolean bool)
Parameters:
bool - whether to rebuild the database or not

delete

public boolean delete()
Returns:
true if to delete the database, false if not

setDelete

public void setDelete(boolean bool)
Parameters:
bool - whetehr to delete the database or not

setStart

public void setStart(int start)
Parameters:
start - the index to start working up from

getStart

public int getStart()
Returns:
the index to start working up from

setExecute

public void setExecute(boolean bool)
Parameters:
bool - whether to execute the database commands or not

execute

public boolean execute()
Returns:
true if to execute database commands, false if not

setFileOut

public void setFileOut(boolean bool)
Parameters:
bool - whether to use an output file

isFileOut

public boolean isFileOut()
Returns:
true if using an output file, false if not

setStdOut

public void setStdOut(boolean bool)
Parameters:
bool - whether to write to standard out

toStdOut

public boolean toStdOut()
Returns:
true if to write to standard out, false if not

setOutFile

public void setOutFile(String file)
Parameters:
file - the name of the output file

getOutFile

public String getOutFile()
Returns:
the name of the output file

indexItem

public void indexItem(Item item)
               throws BrowseException
Index the given item

Parameters:
item - the item to index
Throws:
BrowseException

itemAdded

public boolean itemAdded(Item item)
                  throws BrowseException
Deprecated. 

Parameters:
item -
Returns:
Throws:
BrowseException

itemChanged

public boolean itemChanged(Item item)
                    throws BrowseException
Deprecated. 

Parameters:
item -
Returns:
Throws:
BrowseException

itemRemoved

public boolean itemRemoved(Item item)
                    throws BrowseException
remove all the indices for the given item

Parameters:
item - the item to be removed
Returns:
Throws:
BrowseException

itemRemoved

public boolean itemRemoved(int itemID)
                    throws BrowseException
Throws:
BrowseException

main

public static void main(String[] argv)
                 throws SQLException,
                        BrowseException,
                        org.apache.commons.cli.ParseException
Creates Browse indexes, destroying the old ones.

Parameters:
argv - Command-line arguments
Throws:
SQLException
BrowseException
org.apache.commons.cli.ParseException

clearDatabase

public void clearDatabase()
                   throws BrowseException
delete all the existing browse tables

Throws:
BrowseException

initBrowse

public void initBrowse()
                throws SQLException,
                       BrowseException
index everything

Throws:
SQLException
BrowseException

interpretField

public String[] interpretField(String mfield,
                               String init)
                        throws IOException
Take a string representation of a metadata field, and return it as an array. This is just a convenient utility method to basically break the metadata representation up by its delimiter (.), and stick it in an array, inserting the value of the init parameter when there is no metadata field part.

Parameters:
mfield - the string representation of the metadata
init - the default value of the array elements
Returns:
a three element array with schema, element and qualifier respectively
Throws:
IOException


Copyright © 2010 DuraSpace. All Rights Reserved.