org.dspace.browse
Class BrowseCreateDAOOracle

java.lang.Object
  extended by org.dspace.browse.BrowseCreateDAOOracle
All Implemented Interfaces:
BrowseCreateDAO

public class BrowseCreateDAOOracle
extends Object
implements BrowseCreateDAO

This class implements the BrowseCreateDAO interface for the Oracle database as associated with the default DSpace installation. This class should not be instantiated directly, but should be obtained via the BrowseDAOFactory: Context context = new Context(); BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(context); This class will then be loaded if the appropriate configuration is made.

Author:
Graham Triggs

Constructor Summary
BrowseCreateDAOOracle(Context context)
          Required constructor for classes implementing the BrowseCreateDAO interface.
 
Method Summary
 String createCollectionView(String table, String view, boolean execute)
          Create the View of the full item index as seen from a collection.
 String createCommunityView(String table, String view, boolean execute)
          Create the View of the full item index as seen from a community If the boolean execute is true this operation should be carried out, and if it is false it should not.
 String[] createDatabaseIndices(String table, List<Integer> sortCols, boolean value, boolean execute)
          Create any indices that the implementing DAO sees fit to maximise performance.
 String createDistinctMap(String table, String map, boolean execute)
          Create a table to hold a mapping between an item and a distinct metadata value that can appear across multiple items (for example, author names).
 String createDistinctTable(String table, boolean execute)
          Create the table which will hold the distinct metadata values that appear in multiple items.
 String[] createMapIndices(String disTable, String mapTable, boolean execute)
          Create any indices that the implementing DAO sees fit to maximise performance.
 String createPrimaryTable(String table, List sortCols, boolean execute)
          Create the main index table.
 String createSequence(String sequence, boolean execute)
          Create the sequence with the given name.
 void deleteByItemID(String table, int itemID)
          Delete the record for the given item id from the specified table.
 void deleteCommunityMappings(int itemID)
           
 String dropIndexAndRelated(String table, boolean execute)
          Drop the given table name, and all other resources that are attached to it.
 String dropSequence(String sequence, boolean execute)
          Drop the given sequence name.
 String dropView(String view, boolean execute)
          Drop the given view name.
 int getDistinctID(String table, String value, String authority, String sortValue)
          Get the browse index's internal id for the location of the given string and sort value in the given table.
 int insertDistinctRecord(String table, String value, String authority, String sortValue)
          Insert the given value and sort value into the distinct index table.
 void insertIndex(String table, int itemID, Map sortCols)
          Insert an index record into the given table for the given item id.
 void pruneDistinct(String table, String map)
          So that there are no distinct values indexed which are no longer referenced from the map table, this method checks for values which are not referenced from the map, and removes them.
 void pruneExcess(String table, String map, boolean withdrawn)
          So that any left over indices for items which have been deleted can be assured to have been removed, this method checks for indicies for items which are not in the item table.
 boolean testTableExistance(String table)
          Find out of a given table exists.
 void updateCommunityMappings(int itemID)
           
 boolean updateDistinctMappings(String table, int itemID, int[] distinctIDs)
          Update a mapping between an item id and a distinct metadata field such as an author, who can appear in multiple items.
 boolean updateIndex(String table, int itemID, Map sortCols)
          Updates an index record into the given table for the given item id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowseCreateDAOOracle

public BrowseCreateDAOOracle(Context context)
                      throws BrowseException
Required constructor for classes implementing the BrowseCreateDAO interface. Takes a DSpace context to use to connect to the database with.

Parameters:
context - the DSpace context
Throws:
BrowseException
Method Detail

createCollectionView

public String createCollectionView(String table,
                                   String view,
                                   boolean execute)
                            throws BrowseException
Description copied from interface: BrowseCreateDAO
Create the View of the full item index as seen from a collection. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string array should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen).

Specified by:
createCollectionView in interface BrowseCreateDAO
Parameters:
table - the table to create the view on
view - the name of the view to create
execute - whether to action the create or not
Returns:
the instructions (SQL) that effects the create
Throws:
BrowseException

createCommunityView

public String createCommunityView(String table,
                                  String view,
                                  boolean execute)
                           throws BrowseException
Description copied from interface: BrowseCreateDAO
Create the View of the full item index as seen from a community If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string array should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen).

Specified by:
createCommunityView in interface BrowseCreateDAO
Parameters:
table - the table to create the view on
view - the name of the view to create
execute - whether to action the create or not
Returns:
the instructions (SQL) that effects the create
Throws:
BrowseException

createDatabaseIndices

public String[] createDatabaseIndices(String table,
                                      List<Integer> sortCols,
                                      boolean value,
                                      boolean execute)
                               throws BrowseException
Description copied from interface: BrowseCreateDAO
Create any indices that the implementing DAO sees fit to maximise performance. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string array should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen). It's an array so that you can return each bit of SQL as an element if you want.

Specified by:
createDatabaseIndices in interface BrowseCreateDAO
Parameters:
table - the table upon which to create indices
sortCols - TODO
execute - whether to action the create or not
Returns:
the instructions (SQL) that effect the indices
Throws:
BrowseException

createMapIndices

public String[] createMapIndices(String disTable,
                                 String mapTable,
                                 boolean execute)
                          throws BrowseException
Description copied from interface: BrowseCreateDAO
Create any indices that the implementing DAO sees fit to maximise performance. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string array should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen). It's an array so that you can return each bit of SQL as an element if you want.

Specified by:
createMapIndices in interface BrowseCreateDAO
Parameters:
disTable - the distinct table upon which to create indices
mapTable - the mapping table upon which to create indices
execute - whether to action the create or not
Returns:
the instructions (SQL) that effect the indices
Throws:
BrowseException

createDistinctMap

public String createDistinctMap(String table,
                                String map,
                                boolean execute)
                         throws BrowseException
Description copied from interface: BrowseCreateDAO
Create a table to hold a mapping between an item and a distinct metadata value that can appear across multiple items (for example, author names). If the boolean execute is true this operation should be carried out, and if it is false it should not.

Specified by:
createDistinctMap in interface BrowseCreateDAO
Parameters:
table - the name of the distinct table which holds the target of the mapping
map - the name of the mapping table itself
execute - whether to execute the query or not
Returns:
Throws:
BrowseException

updateDistinctMappings

public boolean updateDistinctMappings(String table,
                                      int itemID,
                                      int[] distinctIDs)
                               throws BrowseException
Description copied from interface: BrowseCreateDAO
Update a mapping between an item id and a distinct metadata field such as an author, who can appear in multiple items. To get the id of the distinct record you should use either getDistinctID or insertDistinctRecord as defined above.

Specified by:
updateDistinctMappings in interface BrowseCreateDAO
Parameters:
table - the mapping table
itemID - the item id
distinctIDs - the id of the distinct record
Throws:
BrowseException

createDistinctTable

public String createDistinctTable(String table,
                                  boolean execute)
                           throws BrowseException
Description copied from interface: BrowseCreateDAO
Create the table which will hold the distinct metadata values that appear in multiple items. For example, this table may hold a list of unique authors, each name in the metadata for the entire system appearing only once. Or for subject classifications. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string array should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen).

Specified by:
createDistinctTable in interface BrowseCreateDAO
Parameters:
table - the table to create
execute - whether to action the create or not
Returns:
the instructions (SQL) that effects the create
Throws:
BrowseException

createPrimaryTable

public String createPrimaryTable(String table,
                                 List sortCols,
                                 boolean execute)
                          throws BrowseException
Description copied from interface: BrowseCreateDAO
Create the main index table. This is the one which will contain a single row per item. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen) This form is used for the primary item browse tables This should be used, for example, like this: List list = new ArrayList(); list.add(new Integer(1)); list.add(new Integer(2)); BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(); dao.createPrimaryTable("index_1", list, true);

Specified by:
createPrimaryTable in interface BrowseCreateDAO
Parameters:
table - the raw table to create
sortCols - a List of Integers numbering the sort columns required
execute - whether to action the create or not
Returns:
the instructions (SQL) that effect the creation
Throws:
BrowseException

createSequence

public String createSequence(String sequence,
                             boolean execute)
                      throws BrowseException
Description copied from interface: BrowseCreateDAO
Create the sequence with the given name. This is relevant to most forms of database, but not all. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen)

Specified by:
createSequence in interface BrowseCreateDAO
Parameters:
sequence - the sequence to create
execute - whether to action the create or not
Returns:
the instructions (SQL) that effect the creation
Throws:
BrowseException

deleteByItemID

public void deleteByItemID(String table,
                           int itemID)
                    throws BrowseException
Description copied from interface: BrowseCreateDAO
Delete the record for the given item id from the specified table. Table names can be obtained from the BrowseIndex class

Specified by:
deleteByItemID in interface BrowseCreateDAO
Parameters:
table - the browse table to remove the index from
itemID - the database id of the item to remove the index for
Throws:
BrowseException

deleteCommunityMappings

public void deleteCommunityMappings(int itemID)
                             throws BrowseException
Specified by:
deleteCommunityMappings in interface BrowseCreateDAO
Throws:
BrowseException

dropIndexAndRelated

public String dropIndexAndRelated(String table,
                                  boolean execute)
                           throws BrowseException
Description copied from interface: BrowseCreateDAO
Drop the given table name, and all other resources that are attached to it. In normal relational database land this will include constraints and views. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen).

Specified by:
dropIndexAndRelated in interface BrowseCreateDAO
Parameters:
table - The table to drop
execute - Whether to action the removal or not
Returns:
The instructions (SQL) that effect the removal
Throws:
BrowseException

dropSequence

public String dropSequence(String sequence,
                           boolean execute)
                    throws BrowseException
Description copied from interface: BrowseCreateDAO
Drop the given sequence name. This is relevant to most forms of database, but not all. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen)

Specified by:
dropSequence in interface BrowseCreateDAO
Parameters:
sequence - the sequence to drop
execute - whether to action the removal or not
Returns:
The instructions (SQL) that effect the removal
Throws:
BrowseException

dropView

public String dropView(String view,
                       boolean execute)
                throws BrowseException
Description copied from interface: BrowseCreateDAO
Drop the given view name. This is relevant to most forms of database, but not all. If the boolean execute is true this operation should be carried out, and if it is false it should not. The returned string should contain the SQL (if relevant) that the caller can do with what they like (for example, output to the screen)

Specified by:
dropView in interface BrowseCreateDAO
Parameters:
view - the view to drop
execute - whether to action the removal or not
Returns:
The instructions (SQL) that effect the removal
Throws:
BrowseException

getDistinctID

public int getDistinctID(String table,
                         String value,
                         String authority,
                         String sortValue)
                  throws BrowseException
Description copied from interface: BrowseCreateDAO
Get the browse index's internal id for the location of the given string and sort value in the given table. This method should always return a positive integer, as if no existing ID is available for the given value then one should be inserted using the data supplied, and the ID returned. Generally this method is used in conjunction with createDistinctMapping thus: BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(); dao.createDistinctMapping("index_1_distinct_map", 21, dao.getDistinctID("index_1_distinct", "Human Readable", "human readable")); When it creates a distinct record, it would usually do so through insertDistinctRecord defined below.

Specified by:
getDistinctID in interface BrowseCreateDAO
Parameters:
table - the table in which to look for/create the id
value - the value on which to search
sortValue - the sort value to use in case of the need to create
Returns:
the database id of the distinct record
Throws:
BrowseException

updateCommunityMappings

public void updateCommunityMappings(int itemID)
                             throws BrowseException
Specified by:
updateCommunityMappings in interface BrowseCreateDAO
Throws:
BrowseException

insertDistinctRecord

public int insertDistinctRecord(String table,
                                String value,
                                String authority,
                                String sortValue)
                         throws BrowseException
Description copied from interface: BrowseCreateDAO
Insert the given value and sort value into the distinct index table. This returns an integer which represents the database id of the created record, so that it can be used, for example in createDistinctMapping thus: BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(); dao.createDistinctMapping("index_1_distinct_map", 21, dao.insertDistinctRecord("index_1_distinct", "Human Readable", "human readable")); This is less good than using getDistinctID defined above, as if there is already a distinct value in the table it may throw an exception

Specified by:
insertDistinctRecord in interface BrowseCreateDAO
Parameters:
table - the table into which to insert the record
value - the value to insert
sortValue - the sort value to insert
Returns:
the database id of the created record
Throws:
BrowseException

insertIndex

public void insertIndex(String table,
                        int itemID,
                        Map sortCols)
                 throws BrowseException
Description copied from interface: BrowseCreateDAO
Insert an index record into the given table for the given item id. The Map should contain key value pairs representing the sort column integer representation and the normalised value for that field. For example, the caller might do as follows: Map map = new HashMap(); map.put(new Integer(1), "the title"); map.put(new Integer(2), "the subject"); BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(); dao.insertIndex("index_1", 21, map);

Specified by:
insertIndex in interface BrowseCreateDAO
Parameters:
table - the browse table to insert the index in
itemID - the database id of the item being indexed
sortCols - an Integer-String map of sort column numbers and values
Throws:
BrowseException

updateIndex

public boolean updateIndex(String table,
                           int itemID,
                           Map sortCols)
                    throws BrowseException
Description copied from interface: BrowseCreateDAO
Updates an index record into the given table for the given item id. The Map should contain key value pairs representing the sort column integer representation and the normalised value for that field. For example, the caller might do as follows: Map map = new HashMap(); map.put(new Integer(1), "the title"); map.put(new Integer(2), "the subject"); BrowseCreateDAO dao = BrowseDAOFactory.getCreateInstance(); dao.updateIndex("index_1", 21, map);

Specified by:
updateIndex in interface BrowseCreateDAO
Parameters:
table - the browse table to insert the index in
itemID - the database id of the item being indexed
sortCols - an Integer-String map of sort column numbers and values
Returns:
true if the record is updated, false if not found
Throws:
BrowseException

pruneDistinct

public void pruneDistinct(String table,
                          String map)
                   throws BrowseException
Description copied from interface: BrowseCreateDAO
So that there are no distinct values indexed which are no longer referenced from the map table, this method checks for values which are not referenced from the map, and removes them.

Specified by:
pruneDistinct in interface BrowseCreateDAO
Parameters:
table - the name of the distinct index table
map - the name of the associated distinct mapping table.
Throws:
BrowseException

pruneExcess

public void pruneExcess(String table,
                        String map,
                        boolean withdrawn)
                 throws BrowseException
Description copied from interface: BrowseCreateDAO
So that any left over indices for items which have been deleted can be assured to have been removed, this method checks for indicies for items which are not in the item table. If it finds an index which does not have an associated item it removes it.

Specified by:
pruneExcess in interface BrowseCreateDAO
Parameters:
table - the index table to check
map - the name of the associated distinct mapping table
withdrawn - TODO
Throws:
BrowseException

testTableExistance

public boolean testTableExistance(String table)
                           throws BrowseException
Description copied from interface: BrowseCreateDAO
Find out of a given table exists.

Specified by:
testTableExistance in interface BrowseCreateDAO
Parameters:
table - the table to test
Returns:
true if exists, false if not
Throws:
BrowseException


Copyright © 2010 DuraSpace. All Rights Reserved.