mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Fix jump to for descending browse lists and date indexes
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2684 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -115,10 +115,11 @@ public interface BrowseDAO
|
||||
*
|
||||
* @param column the column to interrogate
|
||||
* @param value the item id
|
||||
* @param isAscending browsing in ascending or descending order
|
||||
* @return the offset into the table
|
||||
* @throws BrowseException
|
||||
*/
|
||||
public int doOffsetQuery(String column, String value) throws BrowseException;
|
||||
public int doOffsetQuery(String column, String value, boolean isAscending) throws BrowseException;
|
||||
|
||||
/**
|
||||
* This executes a query which returns the offset where the value (or nearest greater
|
||||
@@ -126,10 +127,11 @@ public interface BrowseDAO
|
||||
*
|
||||
* @param column the column to interrogate
|
||||
* @param value the item id
|
||||
* @param isAscending browsing in ascending or descending order
|
||||
* @return the offset into the table
|
||||
* @throws BrowseException
|
||||
*/
|
||||
public int doDistinctOffsetQuery(String column, String value) throws BrowseException;
|
||||
public int doDistinctOffsetQuery(String column, String value, boolean isAscending) throws BrowseException;
|
||||
|
||||
/**
|
||||
* Does the query use the equals comparator when doing less than or greater than
|
||||
|
@@ -240,7 +240,7 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
/* (non-Javadoc)
|
||||
* @see org.dspace.browse.BrowseDAO#doOffsetQuery(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public int doOffsetQuery(String column, String value)
|
||||
public int doOffsetQuery(String column, String value, boolean isAscending)
|
||||
throws BrowseException
|
||||
{
|
||||
TableRowIterator tri = null;
|
||||
@@ -253,8 +253,16 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
queryBuf.append("COUNT(").append(column).append(") AS offset ");
|
||||
|
||||
buildSelectStatement(queryBuf, paramsList);
|
||||
if (isAscending)
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append("<?");
|
||||
paramsList.add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append(">?");
|
||||
paramsList.add(value + Character.MAX_VALUE);
|
||||
}
|
||||
|
||||
if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null))
|
||||
{
|
||||
@@ -291,7 +299,7 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
/* (non-Javadoc)
|
||||
* @see org.dspace.browse.BrowseDAO#doDistinctOffsetQuery(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public int doDistinctOffsetQuery(String column, String value)
|
||||
public int doDistinctOffsetQuery(String column, String value, boolean isAscending)
|
||||
throws BrowseException
|
||||
{
|
||||
TableRowIterator tri = null;
|
||||
@@ -304,8 +312,16 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
queryBuf.append("COUNT(").append(column).append(") AS offset ");
|
||||
|
||||
buildSelectStatementDistinct(queryBuf, paramsList);
|
||||
if (isAscending)
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append("<?");
|
||||
paramsList.add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append(">?");
|
||||
paramsList.add(value + Character.MAX_VALUE);
|
||||
}
|
||||
|
||||
if (containerTable != null && tableMap != null)
|
||||
{
|
||||
|
@@ -246,7 +246,7 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
/* (non-Javadoc)
|
||||
* @see org.dspace.browse.BrowseDAO#doOffsetQuery(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public int doOffsetQuery(String column, String value)
|
||||
public int doOffsetQuery(String column, String value, boolean isAscending)
|
||||
throws BrowseException
|
||||
{
|
||||
TableRowIterator tri = null;
|
||||
@@ -259,8 +259,16 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
queryBuf.append("COUNT(").append(column).append(") AS offset ");
|
||||
|
||||
buildSelectStatement(queryBuf, paramsList);
|
||||
if (isAscending)
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append("<?");
|
||||
paramsList.add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append(">?");
|
||||
paramsList.add(value + Character.MAX_VALUE);
|
||||
}
|
||||
|
||||
if (containerTable != null || (value != null && valueField != null && tableDis != null && tableMap != null))
|
||||
{
|
||||
@@ -297,7 +305,7 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
/* (non-Javadoc)
|
||||
* @see org.dspace.browse.BrowseDAO#doDistinctOffsetQuery(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public int doDistinctOffsetQuery(String column, String value)
|
||||
public int doDistinctOffsetQuery(String column, String value, boolean isAscending)
|
||||
throws BrowseException
|
||||
{
|
||||
TableRowIterator tri = null;
|
||||
@@ -310,8 +318,16 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
queryBuf.append("COUNT(").append(column).append(") AS offset ");
|
||||
|
||||
buildSelectStatementDistinct(queryBuf, paramsList);
|
||||
if (isAscending)
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append("<?");
|
||||
paramsList.add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryBuf.append(" WHERE ").append(column).append(">?");
|
||||
paramsList.add(value + Character.MAX_VALUE);
|
||||
}
|
||||
|
||||
if (containerTable != null && tableMap != null)
|
||||
{
|
||||
|
@@ -284,6 +284,17 @@ public class BrowseEngine
|
||||
}
|
||||
}
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults();
|
||||
|
||||
// assemble the ORDER BY clause
|
||||
String orderBy = browseIndex.getSortField(scope.isSecondLevel());
|
||||
if (scope.getSortBy() > 0)
|
||||
{
|
||||
orderBy = "sort_" + Integer.toString(scope.getSortBy());
|
||||
}
|
||||
dao.setOrderField(orderBy);
|
||||
|
||||
int offset = scope.getOffset();
|
||||
String rawFocusValue = null;
|
||||
if (offset < 1 && (scope.hasJumpToItem() || scope.hasJumpToValue() || scope.hasStartsWith()))
|
||||
@@ -295,16 +306,6 @@ public class BrowseEngine
|
||||
// make sure the incoming value is normalised
|
||||
String focusValue = normalizeJumpToValue(rawFocusValue);
|
||||
|
||||
// if the value was a "starts with" value, we need to append the
|
||||
// regular expression wildcard
|
||||
if (scope.hasStartsWith())
|
||||
{
|
||||
if (browseIndex.isDate())
|
||||
{
|
||||
focusValue = focusValue + "-32";
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("browsing using focus: " + focusValue);
|
||||
|
||||
// Now we have a value to focus on, we need to find out where it is
|
||||
@@ -320,20 +321,9 @@ public class BrowseEngine
|
||||
|
||||
dao.setOffset(offset);
|
||||
|
||||
// assemble the ORDER BY clause
|
||||
String orderBy = browseIndex.getSortField(scope.isSecondLevel());
|
||||
if (scope.getSortBy() > 0)
|
||||
{
|
||||
orderBy = "sort_" + Integer.toString(scope.getSortBy());
|
||||
}
|
||||
dao.setOrderField(orderBy);
|
||||
|
||||
// assemble the LIMIT clause
|
||||
dao.setLimit(scope.getResultsPerPage());
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults();
|
||||
|
||||
// Holder for the results
|
||||
List results = null;
|
||||
|
||||
@@ -450,9 +440,6 @@ public class BrowseEngine
|
||||
// tell the browse query whether we are ascending or descending on the value
|
||||
dao.setAscending(scope.isAscending());
|
||||
|
||||
// set the ordering field (there is only one option)
|
||||
dao.setOrderField("sort_value");
|
||||
|
||||
// set our constraints on community or collection
|
||||
if (scope.inCollection() || scope.inCommunity())
|
||||
{
|
||||
@@ -476,6 +463,12 @@ public class BrowseEngine
|
||||
}
|
||||
}
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults(true);
|
||||
|
||||
// set the ordering field (there is only one option)
|
||||
dao.setOrderField("sort_value");
|
||||
|
||||
// assemble the focus clase if we are to have one
|
||||
// it will look like one of the following
|
||||
// - sort_value < myvalue
|
||||
@@ -493,13 +486,6 @@ public class BrowseEngine
|
||||
// make sure the incoming value is normalised
|
||||
focusValue = normalizeJumpToValue(focusValue);
|
||||
|
||||
// if the value was a "starts with" and also a date, we need to
|
||||
// append -32, so that the sorted search works
|
||||
if (scope.hasStartsWith() && browseIndex.isDate())
|
||||
{
|
||||
focusValue = focusValue + "-32";
|
||||
}
|
||||
|
||||
offset = getOffsetForDistinctValue(focusValue);
|
||||
}
|
||||
|
||||
@@ -508,9 +494,6 @@ public class BrowseEngine
|
||||
dao.setOffset(offset);
|
||||
dao.setLimit(scope.getResultsPerPage());
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults(true);
|
||||
|
||||
// Holder for the results
|
||||
List results = null;
|
||||
|
||||
@@ -688,7 +671,7 @@ public class BrowseEngine
|
||||
// now get the DAO to do the query for us, returning the highest
|
||||
// string value in the given column in the given table for the
|
||||
// item (I think)
|
||||
return dao.doOffsetQuery(col, value);
|
||||
return dao.doOffsetQuery(col, value, scope.isAscending());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -711,7 +694,7 @@ public class BrowseEngine
|
||||
// now get the DAO to do the query for us, returning the highest
|
||||
// string value in the given column in the given table for the
|
||||
// item (I think)
|
||||
return dao.doDistinctOffsetQuery("sort_value", value);
|
||||
return dao.doDistinctOffsetQuery("sort_value", value, scope.isAscending());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -218,6 +218,11 @@ public abstract class AbstractBrowserServlet extends DSpaceServlet
|
||||
}
|
||||
|
||||
startsWith = year + "-" + month;
|
||||
|
||||
if ("ASC".equals(order))
|
||||
{
|
||||
startsWith = startsWith + "-32";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -656,6 +656,11 @@ public class WithdrawnItems extends AbstractDSpaceTransformer implements
|
||||
}
|
||||
|
||||
startsWith = params.year + "-" + params.month;
|
||||
|
||||
if ("ASC".equals(params.scope.getOrder()))
|
||||
{
|
||||
startsWith = startsWith + "-32";
|
||||
}
|
||||
}
|
||||
|
||||
params.scope.setStartsWith(startsWith);
|
||||
|
@@ -681,6 +681,11 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
|
||||
}
|
||||
|
||||
startsWith = params.year + "-" + params.month;
|
||||
|
||||
if ("ASC".equals(params.scope.getOrder()))
|
||||
{
|
||||
startsWith = startsWith + "-32";
|
||||
}
|
||||
}
|
||||
|
||||
params.scope.setStartsWith(startsWith);
|
||||
|
Reference in New Issue
Block a user