Merge pull request #679 from LongsightGroup/DS-2180-my-archived-submissions

DS-2180 Fix sorting by date accessioned in xmlui My Archived Submissions
This commit is contained in:
Peter Dietz
2014-10-27 18:37:53 -04:00
2 changed files with 49 additions and 4 deletions

View File

@@ -270,6 +270,43 @@ public class Item extends DSpaceObject
}
/**
* Retrieve the list of Items submitted by eperson, ordered by recently submitted, optionally limitable
* @param context
* @param eperson
* @param limit a positive integer to limit, -1 or null for unlimited
* @return
* @throws SQLException
*/
public static ItemIterator findBySubmitterDateSorted(Context context, EPerson eperson, Integer limit) throws SQLException
{
String querySorted = "SELECT item.item_id, item.submitter_id, item.in_archive, item.withdrawn, " +
"item.owning_collection, item.last_modified, metadatavalue.text_value " +
"FROM item, metadatafieldregistry, metadatavalue " +
"WHERE metadatafieldregistry.metadata_field_id = metadatavalue.metadata_field_id AND " +
" metadatavalue.resource_id = item.item_id AND " +
" metadatavalue.resource_type_id = ? AND " +
" metadatafieldregistry.element = 'date' AND " +
" metadatafieldregistry.qualifier = 'accessioned' AND " +
" item.submitter_id = ? AND \n" +
" item.in_archive = true\n" +
"ORDER BY\n" +
" metadatavalue.text_value desc";
TableRowIterator rows;
if(limit != null && limit > 0) {
querySorted += " limit ? ;";
rows = DatabaseManager.query(context, querySorted, Constants.ITEM, eperson.getID(), limit);
} else {
querySorted += ";";
rows = DatabaseManager.query(context, querySorted, Constants.ITEM, eperson.getID());
}
return new ItemIterator(context, rows);
}
/**
* Get the internal ID of this item. In general, this shouldn't be exposed
* to users