org.dspace.browse
Class BrowseDAOPostgres

java.lang.Object
  extended by org.dspace.browse.BrowseDAOPostgres
All Implemented Interfaces:
BrowseDAO

public class BrowseDAOPostgres
extends Object
implements BrowseDAO

This class is the PostgreSQL driver class for reading information from the Browse tables. It implements the BrowseDAO interface, and also has a constructor of the form: BrowseDAOPostgres(Context context) As required by BrowseDAOFactory. This class should only ever be loaded by that Factory object.

Author:
Richard Jones, Graham Triggs

Constructor Summary
BrowseDAOPostgres(Context context)
          Required constructor for use by BrowseDAOFactory
 
Method Summary
 int doCountQuery()
          This executes a query which will count the number of results for the parameters you set.
 int doDistinctOffsetQuery(String column, String value, boolean isAscending)
          This executes a query which returns the offset where the value (or nearest greater equivalent) can be found in the specified table ordered by the column.
 String doMaxQuery(String column, String table, int itemID)
          This executes a query which returns the value of the "highest" (max) value in the given table's column for the given item id.
 int doOffsetQuery(String column, String value, boolean isAscending)
          This executes a query which returns the offset where the value (or nearest greater equivalent) can be found in the specified table ordered by the column.
 List doQuery()
          This executes a query which returns a List object containing BrowseItem objects represening the results of a full item browse.
 List doValueQuery()
          This executes a query which returns a List object containing String values which represent the results of a single value browse (for example, the list of all subject headings).
 String getAuthorityValue()
           
 int getContainerID()
          Get the database ID of the container object.
 String getContainerIDField()
          get the name of the field in which to look for the container id.
 String getContainerTable()
          Get the name of the container table that is being used to map items to distinct values when in a container constrained browse
 String[] getCountValues()
          Get the array of fields that we will be counting on.
 String getFilterValue()
          Get the value which we are constraining all our browse results to contain.
 String getFilterValueField()
          Get the name of the field in which the value to constrain results is contained
 String getJumpToField()
          Get the field in which we will match a focus value from which to start the browse.
 String getJumpToValue()
          Get the value at which the browse will start.
 int getLimit()
          get the integer number which is the limit of the results that will be returned by any query.
 int getOffset()
          Get the offset from the first result from which to return results.
 String getOrderField()
          Get the database field which will be used to do the sorting of result sets on.
 String[] getSelectValues()
          Get the array of values that we will be selecting on.
 String getTable()
          get the name of the table that we are querying
 boolean isAscending()
          Is the sort order ascending or descending? Default value is true
 boolean isDistinct()
          Is this a distinct value browse?
 void setAscending(boolean ascending)
          Set whether the results should be sorted in ascending order (on the given sort column) or descending order.
 void setAuthorityValue(String value)
           
 void setContainerID(int containerID)
          Set the database id of the container object.
 void setContainerIDField(String containerIDField)
          set the name of the field in which to look for the container id.
 void setContainerTable(String containerTable)
          If we have specified a container id and container field, we must also specify a container table.
 void setCountValues(String[] fields)
          Set the array of columns that we will be counting over.
 void setDistinct(boolean bool)
          Set whether this is a distinct value browse or not
 void setEqualsComparator(boolean equalsComparator)
          Set whether the query should use an equals comparator when doing less than or greater than comparisons.
 void setFilterMappingTables(String tableDis, String tableMap)
          Set the name of the mapping tables to use for filtering
 void setFilterValue(String value)
          Set the value to which all our browse results should be constrained.
 void setFilterValueField(String valueField)
          Set he name of the field in which the value to constrain results is contained
 void setFilterValuePartial(boolean part)
          Sets whether we will treat the filter value as partial (like match), or exact
 void setJumpToField(String focusField)
          Set the focus field upon which we will match a value from which to start the browse.
 void setJumpToValue(String focusValue)
          Set the value upon which to start the browse from.
 void setLimit(int limit)
          Set the limit for how many results should be returned.
 void setOffset(int offset)
          Get the offset from the first result from which to return results.
 void setOrderField(String orderField)
          Set the database field which will be used to sort result sets on
 void setSelectValues(String[] selectValues)
          Set the array of values to select on.
 void setTable(String table)
          Set the name of the table to query
 boolean useEqualsComparator()
          Does the query use the equals comparator when doing less than or greater than comparisons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowseDAOPostgres

public BrowseDAOPostgres(Context context)
                  throws BrowseException
Required constructor for use by BrowseDAOFactory

Parameters:
context - DSpace context
Throws:
BrowseException
Method Detail

doCountQuery

public int doCountQuery()
                 throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which will count the number of results for the parameters you set.

Specified by:
doCountQuery in interface BrowseDAO
Returns:
the integer value of the number of results found
Throws:
BrowseException

doMaxQuery

public String doMaxQuery(String column,
                         String table,
                         int itemID)
                  throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which returns the value of the "highest" (max) value in the given table's column for the given item id.

Specified by:
doMaxQuery in interface BrowseDAO
Parameters:
column - the column to interrogate
table - the table to query
itemID - the item id
Returns:
String representing the max value in the given column
Throws:
BrowseException

doOffsetQuery

public int doOffsetQuery(String column,
                         String value,
                         boolean isAscending)
                  throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which returns the offset where the value (or nearest greater equivalent) can be found in the specified table ordered by the column.

Specified by:
doOffsetQuery in interface BrowseDAO
Parameters:
column - the column to interrogate
value - the item id
isAscending - browsing in ascending or descending order
Returns:
the offset into the table
Throws:
BrowseException

doDistinctOffsetQuery

public int doDistinctOffsetQuery(String column,
                                 String value,
                                 boolean isAscending)
                          throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which returns the offset where the value (or nearest greater equivalent) can be found in the specified table ordered by the column.

Specified by:
doDistinctOffsetQuery in interface BrowseDAO
Parameters:
column - the column to interrogate
value - the item id
isAscending - browsing in ascending or descending order
Returns:
the offset into the table
Throws:
BrowseException

doQuery

public List doQuery()
             throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which returns a List object containing BrowseItem objects represening the results of a full item browse.

Specified by:
doQuery in interface BrowseDAO
Returns:
List of BrowseItem objects
Throws:
BrowseException

doValueQuery

public List doValueQuery()
                  throws BrowseException
Description copied from interface: BrowseDAO
This executes a query which returns a List object containing String values which represent the results of a single value browse (for example, the list of all subject headings). This is most commonly used with a Distinct browse type.

Specified by:
doValueQuery in interface BrowseDAO
Returns:
List of Strings representing the single value query results
Throws:
BrowseException

getContainerID

public int getContainerID()
Description copied from interface: BrowseDAO
Get the database ID of the container object. The container object will be a Community or a Collection.

Specified by:
getContainerID in interface BrowseDAO
Returns:
the database id of the container, or -1 if none is set

getContainerIDField

public String getContainerIDField()
Description copied from interface: BrowseDAO
get the name of the field in which to look for the container id. This is principally for use internal to the DAO.

Specified by:
getContainerIDField in interface BrowseDAO
Returns:
the name of the container id field. For example "collection_id" or "community_id"

getContainerTable

public String getContainerTable()
Description copied from interface: BrowseDAO
Get the name of the container table that is being used to map items to distinct values when in a container constrained browse

Specified by:
getContainerTable in interface BrowseDAO
Returns:
the name of the table

getCountValues

public String[] getCountValues()
Description copied from interface: BrowseDAO
Get the array of fields that we will be counting on.

Specified by:
getCountValues in interface BrowseDAO
Returns:
an array of fields to be counted over

getJumpToField

public String getJumpToField()
Description copied from interface: BrowseDAO
Get the field in which we will match a focus value from which to start the browse. This will either be the "sort_value" field or one of the additional sort fields defined by configuration

Specified by:
getJumpToField in interface BrowseDAO
Returns:
the name of the focus field

getJumpToValue

public String getJumpToValue()
Description copied from interface: BrowseDAO
Get the value at which the browse will start. The value supplied here will be the top result on the page of results.

Specified by:
getJumpToValue in interface BrowseDAO
Returns:
the value to start browsing on

getLimit

public int getLimit()
Description copied from interface: BrowseDAO
get the integer number which is the limit of the results that will be returned by any query. The default is -1, which means unlimited results.

Specified by:
getLimit in interface BrowseDAO
Returns:
the maximum possible number of results allowed to be returned

getOffset

public int getOffset()
Description copied from interface: BrowseDAO
Get the offset from the first result from which to return results. This functionality is present for backwards compatibility, but is ill advised. All normal browse operations can be completed without it. The default is -1, which means do not offset.

Specified by:
getOffset in interface BrowseDAO
Returns:
the offset

getOrderField

public String getOrderField()
Description copied from interface: BrowseDAO
Get the database field which will be used to do the sorting of result sets on.

Specified by:
getOrderField in interface BrowseDAO
Returns:
the field by which results will be sorted

getSelectValues

public String[] getSelectValues()
Description copied from interface: BrowseDAO
Get the array of values that we will be selecting on. The default is to select all of the values from a given table

Specified by:
getSelectValues in interface BrowseDAO
Returns:
an array of values to select on

getTable

public String getTable()
Description copied from interface: BrowseDAO
get the name of the table that we are querying

Specified by:
getTable in interface BrowseDAO
Returns:
the name of the table

getFilterValue

public String getFilterValue()
Description copied from interface: BrowseDAO
Get the value which we are constraining all our browse results to contain.

Specified by:
getFilterValue in interface BrowseDAO
Returns:
the value to which to constrain results

getFilterValueField

public String getFilterValueField()
Description copied from interface: BrowseDAO
Get the name of the field in which the value to constrain results is contained

Specified by:
getFilterValueField in interface BrowseDAO
Returns:
the name of the field

isAscending

public boolean isAscending()
Description copied from interface: BrowseDAO
Is the sort order ascending or descending? Default value is true

Specified by:
isAscending in interface BrowseDAO
Returns:
true for ascending, false for descending

isDistinct

public boolean isDistinct()
Description copied from interface: BrowseDAO
Is this a distinct value browse?

Specified by:
isDistinct in interface BrowseDAO
Returns:
true if distinct, false if not

setAscending

public void setAscending(boolean ascending)
Description copied from interface: BrowseDAO
Set whether the results should be sorted in ascending order (on the given sort column) or descending order.

Specified by:
setAscending in interface BrowseDAO
Parameters:
ascending - true to ascend, false to descend

setContainerID

public void setContainerID(int containerID)
Description copied from interface: BrowseDAO
Set the database id of the container object. This should be the id of a Community or Collection. This will constrain the results of the browse to only items or values within items that appear in the given container.

Specified by:
setContainerID in interface BrowseDAO

setContainerIDField

public void setContainerIDField(String containerIDField)
Description copied from interface: BrowseDAO
set the name of the field in which to look for the container id.

Specified by:
setContainerIDField in interface BrowseDAO
Parameters:
containerIDField - the name of the container id field. For example "collection_id" or "community_id"

setContainerTable

public void setContainerTable(String containerTable)
Description copied from interface: BrowseDAO
If we have specified a container id and container field, we must also specify a container table. This is the name of the table that maps the item onto the distinct value. Since we are in a container, this value will actually be the view which allows us to select only items which are within a given container

Specified by:
setContainerTable in interface BrowseDAO
Parameters:
containerTable - the name of the container table mapping

setCountValues

public void setCountValues(String[] fields)
Description copied from interface: BrowseDAO
Set the array of columns that we will be counting over. In general, the wildcard (*) will suffice

Specified by:
setCountValues in interface BrowseDAO
Parameters:
fields - an array of fields to be counted over

setDistinct

public void setDistinct(boolean bool)
Description copied from interface: BrowseDAO
Set whether this is a distinct value browse or not

Specified by:
setDistinct in interface BrowseDAO
Parameters:
bool - true if distinct value, false if not

setEqualsComparator

public void setEqualsComparator(boolean equalsComparator)
Description copied from interface: BrowseDAO
Set whether the query should use an equals comparator when doing less than or greater than comparisons. That is, if true then comparisons will be made using the equivalent of "<=" and ">=", while if false it will use the equivalent of "<" and ">"

Specified by:
setEqualsComparator in interface BrowseDAO
Parameters:
equalsComparator - true to use, false to not.

setJumpToField

public void setJumpToField(String focusField)
Description copied from interface: BrowseDAO
Set the focus field upon which we will match a value from which to start the browse. This will either be the "sort_value" field or one of the additional sort fields defined by configuration param focusField the name of the focus field

Specified by:
setJumpToField in interface BrowseDAO

setJumpToValue

public void setJumpToValue(String focusValue)
Description copied from interface: BrowseDAO
Set the value upon which to start the browse from. The value supplied here will be the top result on the page of results

Specified by:
setJumpToValue in interface BrowseDAO
Parameters:
focusValue - the value in the focus field on which to start browsing

setLimit

public void setLimit(int limit)
Description copied from interface: BrowseDAO
Set the limit for how many results should be returned. This is generally for use in paging or limiting the number of items be be displayed. The default is -1, meaning unlimited results. Note that if the number of results of the query is less than this number, the size of the result set will be smaller than this limit.

Specified by:
setLimit in interface BrowseDAO
Parameters:
limit - the maximum number of results to return.

setOffset

public void setOffset(int offset)
Description copied from interface: BrowseDAO
Get the offset from the first result from which to return results. This functionality is present for backwards compatibility, but is ill advised. All normal browse operations can be completed without it. The default is -1, which means do not offset.

Specified by:
setOffset in interface BrowseDAO

setOrderField

public void setOrderField(String orderField)
Description copied from interface: BrowseDAO
Set the database field which will be used to sort result sets on

Specified by:
setOrderField in interface BrowseDAO
Parameters:
orderField - the field by which results will be sorted

setSelectValues

public void setSelectValues(String[] selectValues)
Description copied from interface: BrowseDAO
Set the array of values to select on. This should be a list of the columns available in the target table, or the SQL wildcards. The default is single element array with the standard wildcard (*)

Specified by:
setSelectValues in interface BrowseDAO
Parameters:
selectValues - the values to select on

setTable

public void setTable(String table)
Description copied from interface: BrowseDAO
Set the name of the table to query

Specified by:
setTable in interface BrowseDAO
Parameters:
table - the name of the table

setFilterMappingTables

public void setFilterMappingTables(String tableDis,
                                   String tableMap)
Description copied from interface: BrowseDAO
Set the name of the mapping tables to use for filtering

Specified by:
setFilterMappingTables in interface BrowseDAO
Parameters:
tableDis - the name of the table holding the distinct values
tableMap - the name of the table holding the mappings

setFilterValue

public void setFilterValue(String value)
Description copied from interface: BrowseDAO
Set the value to which all our browse results should be constrained. For example, if you are listing all of the publications by a single author your value would be the author name.

Specified by:
setFilterValue in interface BrowseDAO
Parameters:
value - the value to which to constrain results

setFilterValuePartial

public void setFilterValuePartial(boolean part)
Description copied from interface: BrowseDAO
Sets whether we will treat the filter value as partial (like match), or exact

Specified by:
setFilterValuePartial in interface BrowseDAO
Parameters:
part - true if partial, false if exact

setFilterValueField

public void setFilterValueField(String valueField)
Description copied from interface: BrowseDAO
Set he name of the field in which the value to constrain results is contained

Specified by:
setFilterValueField in interface BrowseDAO
Parameters:
valueField - the name of the field

useEqualsComparator

public boolean useEqualsComparator()
Description copied from interface: BrowseDAO
Does the query use the equals comparator when doing less than or greater than comparisons. @see setEqualsComparator Default value is true

Specified by:
useEqualsComparator in interface BrowseDAO
Returns:
true if using it, false if not

setAuthorityValue

public void setAuthorityValue(String value)
Specified by:
setAuthorityValue in interface BrowseDAO

getAuthorityValue

public String getAuthorityValue()
Specified by:
getAuthorityValue in interface BrowseDAO


Copyright © 2010 DuraSpace. All Rights Reserved.