- * DISTINCT( [value 1], [value 2] )
- *
- *
- * @return the distinct clause
- */
- private String distinctClause()
- {
- String selectArgs = "";
- if (distinctValues != null)
- {
- for (int i = 0; i < distinctValues.length; i++)
- {
- if (i == 0)
- {
- selectArgs = selectArgs + " DISTINCT(";
- }
- if (i > 0)
- {
- selectArgs = selectArgs + " , ";
- }
- selectArgs = selectArgs + escape(distinctValues[i]);
- if (i == distinctValues.length - 1)
- {
- selectArgs = selectArgs + ") ";
- }
- }
- }
- return selectArgs;
- }
-
- /**
- * Build a clause for counting results. Will return something of the form:
- *
- *
- * COUNT( [value 1], [value 2] ) AS number
- *
- *
- * @return the count clause
- */
- private String countClause()
- {
- String selectArgs = "";
- if (countValues != null)
- {
- for (int i = 0; i < countValues.length; i++)
- {
- if (i == 0)
- {
- selectArgs = selectArgs + " COUNT(";
- }
- if (i > 0)
- {
- selectArgs = selectArgs + " , ";
- }
- selectArgs = selectArgs + escape(countValues[i]);
- if (i == countValues.length - 1)
- {
- selectArgs = selectArgs + ") AS number";
- }
- }
- }
- return selectArgs;
- }
-
- /**
- * Prepare the list of values to be selected on. Will return something of the form:
- *
- *
- * [value 1], [value 2]
- *
- *
- * @return the select value list
- */
- private String selectValues()
- {
- String selectArgs = "";
- if (selectValues != null)
- {
- for (int i = 0; i < selectValues.length; i++)
- {
- if ((!"".equals(selectArgs) && i == 0) || i > 0)
- {
- selectArgs = selectArgs + " , ";
- }
- selectArgs = selectArgs + escape(selectValues[i]);
- }
- }
- return selectArgs;
- }
-
- /**
- * Get the comparator which should be used to compare focus values
- * with values in the database. This will return one of the 4 following
- * possible values: <, >, <=, >=
- *
- * @return the focus comparator
- */
- private String getFocusComparator()
- {
- // now decide whether we will use an equals comparator;
- String equals = "=";
- if (!useEqualsComparator())
- {
- equals = "";
- }
-
- // get the comparator for the match of the browsable index value
- // the rule is: if the scope has a value, then the comparator is always "="
- // if, the order is set to ascending then we want to use
- // WHERE sort_value >
- * [field] (<[=] | >[=]) '[value]'
- *
- *
- * such as:
- *
- *
- * sort_value <= 'my text'
- *
- *
- * @return the focus clause
- */
- private String getFocusClause()
- {
- // get the operator (<[=] | >[=]) which the focus of the browse will
- // be matched using
- String focusComparator = getFocusComparator();
-
- // assemble the focus clase if we are to have one
- // it will look like one of the following
- // - sort_value <= myvalue
- // - sort_1 >= myvalue
- String focusClause = "";
- if (focusField != null && focusValue != null)
- {
- focusClause = " " + escape(focusField) + " " + focusComparator + " '" + escape(focusValue) + "' ";
- }
-
- return focusClause;
- }
-
- /**
- * Return the clause to constrain the browse to a specific value.
- * Will return something of the form:
- *
- *
- * [field] = '[value]'
- *
- *
- * such as:
- *
- *
- * sort_value = 'some author'
- *
- *
- * @return the value clause
- */
- private String getValueClause()
- {
- // assemble the value clause if we are to have one
- String valueClause = "";
- if (value != null && valueField != null)
- {
- String valueComparator = "=";
- valueClause = " " + escape(valueField) + " " + valueComparator + " '" + escape(value) + "' ";
- }
- return valueClause;
- }
-
- /**
- * assemble a WHERE clause with the given constraints. This will return something
- * of the form:
- *
- *
- * WHERE [focus clause] [AND] [value clause] [AND] [container constraint]
- *
- *
- * The container constraint is described in one of either getFullConstraint or
- * getDistinctConstraint, and the form of that section of the query can be
- * found in their documentation.
- *
- * If either of focusClause or valueClause is null, they will be duly omitted from
- * the WHERE clause.
- *
- * @param focusClause the focus clause, as returned by getFocusClause
- * @param valueClause the value clause, as returned by getValue Clause
- * @param useContainer whether to constrain to a container
- * @param isDistinct whether this is a distinct browse
- * @return the WHERE clause
- */
- private String getWhereClause(String focusClause, String valueClause, boolean useContainer, boolean isDistinct)
- {
- // assemble the where clause out of the two possible value clauses
- String whereClause = "";
-
- if (!"".equals(focusClause) && focusClause != null)
- {
- whereClause = whereClause + focusClause;
- }
-
- if (!"".equals(valueClause) && valueClause != null)
- {
- if (!"".equals(whereClause))
- {
- whereClause = whereClause + " AND ";
- }
- whereClause = whereClause + valueClause;
- }
-
- // add the constraint to community or collection if necessary
- // and desired
- if (useContainer)
- {
- String constraint = "";
- if (isDistinct)
- {
- constraint = getDistinctConstraint();
- }
- else
- {
- constraint = getFullConstraint();
- }
-
- if (!"".equals(constraint))
- {
- if (!"".equals(whereClause))
- {
- whereClause = whereClause + " AND ";
- }
- whereClause = whereClause + constraint;
- }
-
- }
-
- // now finalise the construction of the where clause
- if (!"".equals(whereClause))
- {
- whereClause = " WHERE " + whereClause;
- }
-
- return whereClause;
- }
-
- /**
- * Get a sub-query to obtain the ids for a distinct browse within a given
- * constraint. This will produce something of the form:
- *
- *
- * id IN (SELECT distinct_id FROM [container table] WHERE [container field] = [container id])
- *
- *
- * This is for use inside the overall WHERE clause only
- *
- * @return the sub-query
- */
- private String getDistinctConstraint()
- {
- String constraint = "";
- if (containerIDField != null && containerID != -1 && containerTable != null)
- {
- constraint = " id IN (SELECT distinct_id FROM " + escape(containerTable) +
- " WHERE " + escape(containerIDField) + " = " + containerID + ") ";
- }
- return constraint;
- }
-
- /**
- * Get a clause to obtain the ids for a full browse within a given
- * constraint. This will produce something of the form:
- *
- *
- * [container field] = [container id]
- *
- *
- * This is for use inside the overall WHERE clause only
- *
- * @return the constraint clause
- */
- private String getFullConstraint()
- {
- String constraint = "";
- if (containerIDField != null && containerID != -1)
- {
- constraint = escape(containerIDField) + " = " + containerID + " ";
- }
- return constraint;
- }
-
- /**
- * Get the clause to perform search result ordering. This will
- * return something of the form:
- *
- *
- * ORDER BY [order field] (ASC | DESC)
- *
- *
- * @return the ORDER BY clause
- */
- private String getOrderBy()
- {
- // assemble the order by field
- String orderBy = "";
- if (orderField != null)
- {
- orderBy = " " + escape(orderField);
- if (isAscending())
- {
- orderBy = orderBy + " ASC ";
- }
- else
- {
- orderBy = orderBy + " DESC ";
- }
- orderBy = " ORDER BY " + orderBy;
- }
-
- return orderBy;
- }
-
- /**
- * Get the limit clause to perform search result truncation. Will return
- * something of the form:
- *
- *
- * LIMIT [limit]
- *
- *
- * @return the limit clause
- */
- private String getLimitClause()
- {
- // prepare the LIMIT clause
- String limitClause = "";
- if (limit != -1)
- {
- limitClause = " LIMIT " + Integer.toString(limit);
- }
-
- return limitClause;
- }
-
- /**
- * Get the offset clause to offset the start point of search results
- *
- * @return
- * @deprecated
- */
- private String getOffsetClause()
- {
- // prepare the OFFSET clause
- String offsetClause = "";
- if (offset != -1)
- {
- offsetClause = " OFFSET " + Integer.toString(offset);
- }
-
- return offsetClause;
- }
-
- /**
- * Prepare the select clause using the pre-prepared arguments. This will produce something
- * of the form:
- *
- *
- * SELECT [arguments] FROM [table]
- *
- *
- * @param args the string value obtained from distinctClause, countClause or selectValues
- * @return the SELECT part of the query
- */
- private String selectClause(String args)
- {
- String selectFrom = "SELECT " + args + " FROM " + escape(table) + " ";
- return selectFrom;
- }
-
- /**
- * Assemble a query from the various component parts passed in here. If any of those
- * parts are null, they will be duly omitted from the final query. This will
- * produce something of the form:
- *
- *
- * [select] [where] [order by] [limit] [offset]
- *
- *
- * @param selectFrom SELECT part of the query
- * @param whereClause WHERE clause
- * @param orderBy ORDER BY clause
- * @param limitClause LIMIT clause
- * @param offsetClause OFFSET clause
- * @return the final query to be executed
- * @throws BrowseException
- */
- private String assembleQuery(String selectFrom, String whereClause, String orderBy, String limitClause, String offsetClause)
- throws BrowseException
- {
- if (selectFrom == null)
- {
- throw new BrowseException("Cannot generate query: the SELECT clause does not exist");
- }
-
- if (whereClause == null) { whereClause = ""; }
- if (orderBy == null) { orderBy = ""; }
- if (limitClause == null) { limitClause = ""; }
- if (offsetClause == null) { offsetClause = ""; }
-
- String query = selectFrom + whereClause + orderBy + limitClause + offsetClause;
- return query;
- }
-
- /**
- * Build the query that will be used for a distinct select. This incorporates
- * only the parts of the parameters that are actually useful for this type
- * of browse
- *
- * @return the query to be executed
- * @throws BrowseException
- */
- private String buildDistinctQuery()
- throws BrowseException
- {
- String selectArgs = countClause();
- if ("".equals(selectArgs) || selectArgs == null)
- {
- selectArgs = selectValues();
- }
- if ("".equals(selectArgs) || selectArgs == null)
- {
- throw new BrowseException("No arguments for SELECT statement");
- }
- String selectFrom = selectClause(selectArgs);
-
- // assemble the focus clase if we are to have one
- // it will look like one of the following, for example
- // sort_value <= myvalue
- // sort_1 >= myvalue
- String focusClause = getFocusClause();
-
- // assemble the where clause out of the two possible value clauses
- // and include container support
- String whereClause = getWhereClause(focusClause, null, true, true);
-
- // assemble the order by field
- String orderBy = getOrderBy();
-
- // prepare the LIMIT clause
- String limitClause = getLimitClause();
-
- // finally, put the query together and return it
- String query = assembleQuery(selectFrom, whereClause, orderBy, limitClause, null);
- return query;
- }
-
- /**
- * Build the query that will be used for a full browse.
- *
- * @return the query to be executed
- * @throws BrowseException
- */
- private String buildQuery()
- throws BrowseException
- {
- // build the SELECT part of the query
- String selectArgs = countClause();
- if ("".equals(selectArgs) || selectArgs == null)
- {
- selectArgs = distinctClause();
- selectArgs = selectArgs + selectValues();
- }
- if ("".equals(selectArgs) || selectArgs == null)
- {
- throw new BrowseException("No arguments for SELECT statement");
- }
- String selectFrom = selectClause(selectArgs);
-
- // assemble the focus clase if we are to have one
- // it will look like one of the following, for example
- // sort_value <= myvalue
- // sort_1 >= myvalue
- String focusClause = getFocusClause();
-
- // assemble the value clause if we are to have one
- String valueClause = getValueClause();
-
- // assemble the where clause out of the two possible value clauses
- // and include container support
- String whereClause = getWhereClause(focusClause, valueClause, true, false);
-
- // assemble the order by field
- String orderBy = getOrderBy();
-
- // prepare the LIMIT clause
- String limitClause = getLimitClause();
-
- // prepare the OFFSET clause
- String offsetClause = getOffsetClause();
-
- // finally, put the query together and return it
- String query = assembleQuery(selectFrom, whereClause, orderBy, limitClause, offsetClause);
- return query;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#doMaxQuery(java.lang.String, java.lang.String, int)
- */
- public String doMaxQuery(String column, String table, int itemID)
- throws BrowseException
- {
- TableRowIterator tri = null;
-
- try
- {
- String query = "SELECT max(" + column + ") FROM " + table + " WHERE item_id = ?";
-
- Object[] params = { new Integer(itemID) };
- tri = DatabaseManager.query(context, query, params);
-
- TableRow row;
- if (tri.hasNext())
- {
- row = tri.next();
- return row.getStringColumn("max");
- }
- else
- {
- return null;
- }
- }
- catch (SQLException e)
- {
- throw new BrowseException(e);
- }
- finally
- {
- if (tri != null)
- tri.close();
- }
- }
-
- /**
- * Tell the class that the query needs to be rebuilt again. This should be
- * called after any modification of the parameters.
- *
- * @param bool whether to rebuild the query again or not
- */
- private void setRebuildQuery(boolean bool)
- {
- this.rebuildQuery = bool;
- }
-
- /**
- * Should the query be rebuilt?
- * @return
- */
- private boolean rebuild()
- {
- return this.rebuildQuery;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#useEqualsComparator()
- */
- public boolean useEqualsComparator()
- {
- return equalsComparator;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setEqualsComparator(boolean)
- */
- public void setEqualsComparator(boolean equalsComparator)
- {
- this.equalsComparator = equalsComparator;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#isAscending()
- */
- public boolean isAscending()
- {
- return ascending;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setAscending(boolean)
- */
- public void setAscending(boolean ascending)
- {
- this.ascending = ascending;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getContainerID()
- */
- public int getContainerID()
- {
- return containerID;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setContainerID(int)
- */
- public void setContainerID(int containerID)
- {
- this.containerID = containerID;
- setRebuildQuery(true);
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getContainerIDField()
- */
- public String getContainerIDField()
- {
- return containerIDField;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setContainerIDField(java.lang.String)
- */
- public void setContainerIDField(String containerIDField)
- {
- this.containerIDField = containerIDField;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getFocusField()
- */
- public String getJumpToField()
- {
- return focusField;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setFocusField(java.lang.String)
- */
- public void setJumpToField(String focusField)
- {
- this.focusField = focusField;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getFocusValue()
- */
- public String getJumpToValue()
- {
- return focusValue;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setFocusValue(java.lang.String)
- */
- public void setJumpToValue(String focusValue)
- {
- this.focusValue = focusValue;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getLimit()
- */
- public int getLimit()
- {
- return limit;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setLimit(int)
- */
- public void setLimit(int limit)
- {
- this.limit = limit;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getOffset()
- */
- public int getOffset()
- {
- return offset;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setOffset(int)
- */
- public void setOffset(int offset)
- {
- this.offset = offset;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getOrderField()
- */
- public String getOrderField()
- {
- return orderField;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setOrderField(java.lang.String)
- */
- public void setOrderField(String orderField)
- {
- this.orderField = orderField;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getSelectValues()
- */
- public String[] getSelectValues()
- {
- return selectValues;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setSelectValues(java.lang.String[])
- */
- public void setSelectValues(String[] selectValues)
- {
- this.selectValues = selectValues;
- setRebuildQuery(true);
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#selectDistinctOn(java.lang.String[])
- */
- public void selectDistinctOn(String[] fields)
- {
- this.distinctValues = fields;
- setRebuildQuery(true);
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getCountValues()
- */
- public String[] getCountValues()
- {
- return this.countValues;
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getDistinctValues()
- */
- public String[] getDistinctValues()
- {
- return this.distinctValues;
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setCountValues(java.lang.String[])
- */
- public void setCountValues(String[] fields)
- {
- this.countValues = fields;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getTable()
- */
- public String getTable()
- {
- return table;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setTable(java.lang.String)
- */
- public void setTable(String table)
- {
- this.table = table;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getValue()
- */
- public String getFilterValue()
- {
- return value;
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setValue(java.lang.String)
- */
- public void setFilterValue(String value)
- {
- this.value = value;
- setRebuildQuery(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getValueField()
- */
- public String getFilterValueField()
- {
- return valueField;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setValueField(java.lang.String)
- */
- public void setFilterValueField(String valueField)
- {
- this.valueField = valueField;
- setRebuildQuery(true);
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setDistinct(boolean)
- */
- public void setDistinct(boolean bool)
- {
- this.distinct = bool;
- setRebuildQuery(true);
- }
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#isDistinct()
- */
- public boolean isDistinct()
- {
- return this.distinct;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#getContainerTable()
- */
- public String getContainerTable()
- {
- return containerTable;
- }
-
-
- /* (non-Javadoc)
- * @see org.dspace.browse.BrowseDAO#setContainerTable(java.lang.String)
- */
- public void setContainerTable(String containerTable)
- {
- this.containerTable = containerTable;
- }
-
- /**
- * Escape the passed string so that it is safe to run against the database. We
- * don't use the usual PreparedStatement because the query is too complicated
- * to assemble in a way that makes that feasible.
- *
- * @param source the string to be escaped
- * @return the escaped string
- */
- private String escape(String source)
- {
- // escape is simply the process of converting ' to \' (I think!) (which is double escaped in Java)
- String result = source.replace("'", "''");
- return result;
- }
-
-}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java b/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java
index 1fb7f29d17..df51e83964 100644
--- a/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java
@@ -43,7 +43,6 @@ package org.dspace.browse;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.apache.log4j.Logger;
import org.dspace.content.Collection;
@@ -213,6 +212,8 @@ public class BrowseEngine
browseInfo.setResultsPerPage(scope.getResultsPerPage());
+ browseInfo.setEtAl(scope.getEtAl());
+
return browseInfo;
}
@@ -367,8 +368,13 @@ public class BrowseEngine
}
if (prevID != -1)
{
- prev = new BrowseItem(context, prevID);
- }
+ // If we are browsing the withdrawn index, create a 'withdrawn' browse item
+ // Otherwise, assume that the item is in the archive and not withdrawn
+ if (bs.getBrowseIndex() == BrowseIndex.getWithdrawnBrowseIndex())
+ prev = new BrowseItem(context, prevID, false, true);
+ else
+ prev = new BrowseItem(context, prevID, true, false);
+ }
}
// now we need to process the position, total and offset for the results
@@ -447,6 +453,8 @@ public class BrowseEngine
}
browseInfo.setResultsPerPage(scope.getResultsPerPage());
+
+ browseInfo.setEtAl(scope.getEtAl());
return browseInfo;
}
@@ -708,7 +716,7 @@ public class BrowseEngine
* Return a normalized focus value. If there is no normalization that can be performed,
* return the focus value that is passed in.
*
- * @param String a focus value to normalize
+ * @param value a focus value to normalize
* @return the normalized focus value
* @throws BrowseException
*/
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
index a90db7af67..316b303191 100644
--- a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
@@ -42,7 +42,6 @@ package org.dspace.browse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -84,9 +83,6 @@ public class BrowseIndex
/** a three part array of the metadata bits (e.g. dc.contributor.author) */
private String[] mdBits;
- /** array of the configured indexes */
- private static BrowseIndex[] browseIndexes = null;
-
/** additional 'internal' tables that are always defined */
private static BrowseIndex itemIndex = new BrowseIndex("bi_item");
private static BrowseIndex withdrawnIndex = new BrowseIndex("bi_withdrawn");
@@ -100,7 +96,7 @@ public class BrowseIndex
/**
* Constructor for creating generic / internal index objects
- * @param baseName
+ * @param baseName The base of the table name
*/
private BrowseIndex(String baseName)
{
@@ -133,7 +129,7 @@ public class BrowseIndex
*
* @param definition the configuration definition of this index
* @param number the configuration number of this index
- * @throws BrowseException
+ * @throws BrowseException
*/
private BrowseIndex(String definition, int number)
throws BrowseException
@@ -770,7 +766,6 @@ public class BrowseIndex
/**
* Does this browse index represent one of the internal item indexes
*
- * @param bi
* @return
*/
public boolean isInternalIndex()
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseItem.java b/dspace-api/src/main/java/org/dspace/browse/BrowseItem.java
index 3f750744fc..a42986ac77 100644
--- a/dspace-api/src/main/java/org/dspace/browse/BrowseItem.java
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseItem.java
@@ -35,24 +35,18 @@
*/
package org.dspace.browse;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeManager;
-import org.dspace.content.Bitstream;
-import org.dspace.content.Bundle;
-import org.dspace.content.DCValue;
-import org.dspace.content.DSpaceObject;
-import org.dspace.content.Item;
+import org.dspace.content.*;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.handle.HandleManager;
-import org.dspace.storage.rdbms.DatabaseManager;
-import org.dspace.storage.rdbms.TableRow;
-import org.dspace.storage.rdbms.TableRowIterator;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
/**
* Entity class to represent an item that is being used to generate Browse
@@ -81,79 +75,35 @@ public class BrowseItem extends DSpaceObject
/** database id of the item */
private int id = -1;
-
- /** item handle */
+
+ /** is the item in the archive */
+ private boolean in_archive = true;
+
+ /** is the item withdrawn */
+ private boolean withdrawn = false;
+
+ /** item handle */
private String handle = null;
-
- /** query to obtain all the items from the database */
- private String findAll = "SELECT * FROM item WHERE in_archive = true AND withdrawn = false";
-
- /** query to check the existance of an item id */
- private String getByID = "SELECT id FROM item WHERE item_id = ?";
-
- /** query to get the text value of a metadata element only (qualifier is NULL) */
- private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
- "WHERE metadatavalue.item_id = ? " +
- " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
- " AND metadatafieldregistry.element = ? " +
- " AND metadatafieldregistry.qualifier IS NULL " +
- " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
- " AND metadataschemaregistry.short_id = ?";
-
- /** query to get the text value of a metadata element and qualifier */
- private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
- "WHERE metadatavalue.item_id = ? " +
- " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
- " AND metadatafieldregistry.element = ? " +
- " AND metadatafieldregistry.qualifier = ? " +
- " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
- " AND metadataschemaregistry.short_id = ?";
-
- /** query to get the text value of a metadata element with the wildcard qualifier (*) */
- private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
- "WHERE metadatavalue.item_id = ? " +
- " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
- " AND metadatafieldregistry.element = ? " +
- " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
- " AND metadataschemaregistry.short_id = ?";
/** inner item, if we really absolutely have to instantiate it */
private Item item;
-
- /**
+
+ /**
* Construct a new browse item with the given context and the database id
*
* @param context the DSpace context
- * @param id the database id of the item
- */
- public BrowseItem(Context context, int id)
+ * @param id the database id of the item
+ * @param in_archive
+ * @param withdrawn
+ */
+ public BrowseItem(Context context, int id, boolean in_archive, boolean withdrawn)
{
this.context = context;
this.id = id;
- }
+ this.in_archive = in_archive;
+ this.withdrawn = withdrawn;
+ }
- /**
- * Get an integer array of all the item ids in the database
- *
- * @return integer array of item ids
- * @throws SQLException
- */
- public Integer[] findAll()
- throws SQLException
- {
- TableRowIterator tri = DatabaseManager.query(context, findAll);
- ArrayList ids = new ArrayList();
-
- while (tri.hasNext())
- {
- TableRow row = tri.next();
- ids.add(new Integer(row.getIntColumn("item_id")));
- }
-
- Integer[] ints = new Integer[ids.size()];
- return (Integer[]) ids.toArray((Integer[]) ints);
- }
-
/**
* Get String array of metadata values matching the given parameters
*
@@ -167,44 +117,58 @@ public class BrowseItem extends DSpaceObject
public DCValue[] getMetadata(String schema, String element, String qualifier, String lang)
throws SQLException
{
- // if the qualifier is a wildcard, we have to get it out of the
- // database
- if (Item.ANY.equals(qualifier))
- {
- return queryMetadata(schema, element, qualifier, lang);
- }
-
- if (!metadata.isEmpty())
- {
- List values = new ArrayList();
- Iterator i = metadata.iterator();
-
- while (i.hasNext())
- {
- DCValue dcv = (DCValue) i.next();
-
- if (match(schema, element, qualifier, lang, dcv))
- {
- values.add(dcv);
- }
- }
-
- if (values.isEmpty())
- {
- return queryMetadata(schema, element, qualifier, lang);
- }
-
- // else, Create an array of matching values
- DCValue[] valueArray = new DCValue[values.size()];
- valueArray = (DCValue[]) values.toArray(valueArray);
-
- return valueArray;
- }
- else
- {
- return queryMetadata(schema, element, qualifier, lang);
- }
- }
+ try
+ {
+ BrowseItemDAO dao = BrowseDAOFactory.getItemInstance(context);
+
+ // if the qualifier is a wildcard, we have to get it out of the
+ // database
+ if (Item.ANY.equals(qualifier))
+ {
+ return dao.queryMetadata(id, schema, element, qualifier, lang);
+ }
+
+ if (!metadata.isEmpty())
+ {
+ List values = new ArrayList();
+ Iterator i = metadata.iterator();
+
+ while (i.hasNext())
+ {
+ DCValue dcv = (DCValue) i.next();
+
+ if (match(schema, element, qualifier, lang, dcv))
+ {
+ values.add(dcv);
+ }
+ }
+
+ if (values.isEmpty())
+ {
+ DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
+ Collections.addAll(metadata, dcvs);
+ return dcvs;
+ }
+
+ // else, Create an array of matching values
+ DCValue[] valueArray = new DCValue[values.size()];
+ valueArray = (DCValue[]) values.toArray(valueArray);
+
+ return valueArray;
+ }
+ else
+ {
+ DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
+ Collections.addAll(metadata, dcvs);
+ return dcvs;
+ }
+ }
+ catch (BrowseException be)
+ {
+ log.error("caught exception: ", be);
+ return null;
+ }
+ }
/**
* Get the type of object. This object masquerates as an Item, so this
@@ -332,67 +296,6 @@ public class BrowseItem extends DSpaceObject
// If we get this far, we have a match
return true;
}
-
- /**
- * perform a database query to obtain the string array of values corresponding to
- * the passed parameters. In general you should use:
- *
- *
- * getMetadata(schema, element, qualifier, lang);
- *
- *
- * As this will obtain the value from cache if available first.
- *
- * @param schema
- * @param element
- * @param qualifier
- * @param lang
- * @return
- * @throws SQLException
- */
- public DCValue[] queryMetadata(String schema, String element, String qualifier, String lang)
- throws SQLException
- {
- ArrayList values = new ArrayList();
- TableRowIterator tri;
-
- if (qualifier == null)
- {
- Object[] params = { new Integer(id), element, schema };
- tri = DatabaseManager.query(context, getByMetadataElement, params);
- }
- else if (Item.ANY.equals(qualifier))
- {
- Object[] params = { new Integer(id), element, schema };
- tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
- }
- else
- {
- Object[] params = { new Integer(id), element, qualifier, schema };
- tri = DatabaseManager.query(context, getByMetadata, params);
- }
-
- if (!tri.hasNext())
- {
- return null;
- }
-
- while (tri.hasNext())
- {
- TableRow tr = tri.next();
- DCValue dcv = new DCValue();
- dcv.schema = schema;
- dcv.element = tr.getStringColumn("element");
- dcv.qualifier = tr.getStringColumn("qualifier");
- dcv.language = tr.getStringColumn("text_lang");
- dcv.value = tr.getStringColumn("text_value");
- metadata.add(dcv);
- values.add(dcv);
- }
-
- DCValue[] dcvs = new DCValue[values.size()];
- return (DCValue[]) values.toArray(dcvs);
- }
/* (non-Javadoc)
* @see org.dspace.content.DSpaceObject#getHandle()
@@ -506,4 +409,14 @@ public class BrowseItem extends DSpaceObject
return null;
}
}
+
+ public boolean isArchived()
+ {
+ return in_archive;
+ }
+
+ public boolean isWithdrawn()
+ {
+ return withdrawn;
+ }
}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAO.java b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAO.java
new file mode 100644
index 0000000000..8ed9fce207
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAO.java
@@ -0,0 +1,73 @@
+/*
+ * BrowseItemDAO.java
+ *
+ * Copyright (c) 2002-2007, Hewlett-Packard Company and Massachusetts
+ * Institute of Technology. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Hewlett-Packard Company nor the name of the
+ * Massachusetts Institute of Technology nor the names of their
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package org.dspace.browse;
+
+import org.dspace.content.DCValue;
+
+import java.sql.SQLException;
+
+public interface BrowseItemDAO
+{
+ /**
+ * Get an array of all the items in the database
+ *
+ * @return array of items
+ * @throws java.sql.SQLException
+ */
+ public BrowseItem[] findAll()
+ throws SQLException;
+
+ /**
+ * perform a database query to obtain the string array of values corresponding to
+ * the passed parameters. In general you should use:
+ *
+ *
+ * getMetadata(schema, element, qualifier, lang);
+ *
+ *
+ * As this will obtain the value from cache if available first.
+ *
+ * @param itemId
+ * @param schema
+ * @param element
+ * @param qualifier
+ * @param lang
+ * @return
+ * @throws SQLException
+ */
+ public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
+ throws SQLException;
+}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOOracle.java b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOOracle.java
new file mode 100644
index 0000000000..04271e6496
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOOracle.java
@@ -0,0 +1,147 @@
+/*
+ * BrowseItemDAOOracle.java
+ *
+ * Copyright (c) 2002-2007, Hewlett-Packard Company and Massachusetts
+ * Institute of Technology. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Hewlett-Packard Company nor the name of the
+ * Massachusetts Institute of Technology nor the names of their
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package org.dspace.browse;
+
+import org.dspace.storage.rdbms.TableRowIterator;
+import org.dspace.storage.rdbms.DatabaseManager;
+import org.dspace.storage.rdbms.TableRow;
+import org.dspace.core.Context;
+import org.dspace.content.DCValue;
+import org.dspace.content.Item;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class BrowseItemDAOOracle implements BrowseItemDAO
+{
+ /** query to obtain all the items from the database */
+ private String findAll = "SELECT item_id, in_archive, withdrawn FROM item WHERE in_archive = 1 OR withdrawn = 1";
+
+ /** query to get the text value of a metadata element only (qualifier is NULL) */
+ private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.qualifier IS NULL " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** query to get the text value of a metadata element and qualifier */
+ private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.qualifier = ? " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** query to get the text value of a metadata element with the wildcard qualifier (*) */
+ private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** DSpace context */
+ private Context context;
+
+ public BrowseItemDAOOracle(Context context)
+ throws BrowseException
+ {
+ this.context = context;
+ }
+
+ public BrowseItem[] findAll() throws SQLException
+ {
+ TableRowIterator tri = DatabaseManager.query(context, findAll);
+ ArrayList items = new ArrayList();
+
+ while (tri.hasNext())
+ {
+ TableRow row = tri.next();
+ items.add(new BrowseItem(context, row.getIntColumn("item_id"),
+ row.getBooleanColumn("in_archive"),
+ row.getBooleanColumn("withdrawn")));
+ }
+
+ BrowseItem[] bis = new BrowseItem[items.size()];
+ return (BrowseItem[]) items.toArray((BrowseItem[]) bis);
+ }
+
+ public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
+ throws SQLException
+ {
+ ArrayList values = new ArrayList();
+ TableRowIterator tri;
+
+ if (qualifier == null)
+ {
+ Object[] params = { new Integer(itemId), element, schema };
+ tri = DatabaseManager.query(context, getByMetadataElement, params);
+ }
+ else if (Item.ANY.equals(qualifier))
+ {
+ Object[] params = { new Integer(itemId), element, schema };
+ tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
+ }
+ else
+ {
+ Object[] params = { new Integer(itemId), element, qualifier, schema };
+ tri = DatabaseManager.query(context, getByMetadata, params);
+ }
+
+ if (!tri.hasNext())
+ {
+ return null;
+ }
+
+ while (tri.hasNext())
+ {
+ TableRow tr = tri.next();
+ DCValue dcv = new DCValue();
+ dcv.schema = schema;
+ dcv.element = tr.getStringColumn("element");
+ dcv.qualifier = tr.getStringColumn("qualifier");
+ dcv.language = tr.getStringColumn("text_lang");
+ dcv.value = tr.getStringColumn("text_value");
+ values.add(dcv);
+ }
+
+ DCValue[] dcvs = new DCValue[values.size()];
+ return (DCValue[]) values.toArray(dcvs);
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOPostgres.java b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOPostgres.java
new file mode 100644
index 0000000000..1bf306d8bc
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseItemDAOPostgres.java
@@ -0,0 +1,147 @@
+/*
+ * BrowseItemDAOPostgres.java
+ *
+ * Copyright (c) 2002-2007, Hewlett-Packard Company and Massachusetts
+ * Institute of Technology. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Hewlett-Packard Company nor the name of the
+ * Massachusetts Institute of Technology nor the names of their
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package org.dspace.browse;
+
+import org.dspace.storage.rdbms.TableRowIterator;
+import org.dspace.storage.rdbms.DatabaseManager;
+import org.dspace.storage.rdbms.TableRow;
+import org.dspace.core.Context;
+import org.dspace.content.DCValue;
+import org.dspace.content.Item;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class BrowseItemDAOPostgres implements BrowseItemDAO
+{
+ /** query to obtain all the items from the database */
+ private String findAll = "SELECT item_id, in_archive, withdrawn FROM item WHERE in_archive = true OR withdrawn = true";
+
+ /** query to get the text value of a metadata element only (qualifier is NULL) */
+ private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.qualifier IS NULL " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** query to get the text value of a metadata element and qualifier */
+ private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.qualifier = ? " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** query to get the text value of a metadata element with the wildcard qualifier (*) */
+ private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
+ "WHERE metadatavalue.item_id = ? " +
+ " AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
+ " AND metadatafieldregistry.element = ? " +
+ " AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
+ " AND metadataschemaregistry.short_id = ?";
+
+ /** DSpace context */
+ private Context context;
+
+ public BrowseItemDAOPostgres(Context context)
+ throws BrowseException
+ {
+ this.context = context;
+ }
+
+ public BrowseItem[] findAll() throws SQLException
+ {
+ TableRowIterator tri = DatabaseManager.query(context, findAll);
+ ArrayList items = new ArrayList();
+
+ while (tri.hasNext())
+ {
+ TableRow row = tri.next();
+ items.add(new BrowseItem(context, row.getIntColumn("item_id"),
+ row.getBooleanColumn("in_archive"),
+ row.getBooleanColumn("withdrawn")));
+ }
+
+ BrowseItem[] bis = new BrowseItem[items.size()];
+ return (BrowseItem[]) items.toArray((BrowseItem[]) bis);
+ }
+
+ public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
+ throws SQLException
+ {
+ ArrayList values = new ArrayList();
+ TableRowIterator tri;
+
+ if (qualifier == null)
+ {
+ Object[] params = { new Integer(itemId), element, schema };
+ tri = DatabaseManager.query(context, getByMetadataElement, params);
+ }
+ else if (Item.ANY.equals(qualifier))
+ {
+ Object[] params = { new Integer(itemId), element, schema };
+ tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
+ }
+ else
+ {
+ Object[] params = { new Integer(itemId), element, qualifier, schema };
+ tri = DatabaseManager.query(context, getByMetadata, params);
+ }
+
+ if (!tri.hasNext())
+ {
+ return null;
+ }
+
+ while (tri.hasNext())
+ {
+ TableRow tr = tri.next();
+ DCValue dcv = new DCValue();
+ dcv.schema = schema;
+ dcv.element = tr.getStringColumn("element");
+ dcv.qualifier = tr.getStringColumn("qualifier");
+ dcv.language = tr.getStringColumn("text_lang");
+ dcv.value = tr.getStringColumn("text_value");
+ values.add(dcv);
+ }
+
+ DCValue[] dcvs = new DCValue[values.size()];
+ return (DCValue[]) values.toArray(dcvs);
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java b/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java
index 5a3ae0b3b8..8d2f65bcb5 100644
--- a/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java
@@ -35,8 +35,6 @@
*/
package org.dspace.browse;
-import java.util.Map;
-
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
@@ -96,7 +94,9 @@ public class BrowserScope
/** the browse level */
private int level = 0;
-
+
+ /** the number of authors to display in the results */
+ private int etAl = 0;
/**
* Construct a new BrowserScope using the given Context
*
@@ -208,6 +208,22 @@ public class BrowserScope
this.browseIndex = browseIndex;
}
+ /**
+ * @return Returns the author limit.
+ */
+ public int getEtAl()
+ {
+ return etAl;
+ }
+
+ /**
+ * @param etAl the author limit
+ */
+ public void setEtAl(int etAl)
+ {
+ this.etAl = etAl;
+ }
+
/**
* @return Returns the collection.
*/
diff --git a/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java b/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
index 1d06ba2a27..9f480d003e 100644
--- a/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
+++ b/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
@@ -40,10 +40,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
import org.apache.commons.cli.CommandLine;
@@ -360,21 +358,17 @@ public class IndexBrowse
removeIndex(item.getID(), BrowseIndex.getItemBrowseIndex().getTableName());
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
- // Index any archived item
- if (item.isArchived())
+ // Index any archived item that isn't withdrawn
+ if (item.isArchived() && !item.isWithdrawn())
+ {
+ Map