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 * Get the internal ID of this item. In general, this shouldn't be exposed
* to users * to users

View File

@@ -334,7 +334,16 @@ public class Submissions extends AbstractDSpaceTransformer
{ {
// Turn the iterator into a list (to get size info, in order to put in a table) // Turn the iterator into a list (to get size info, in order to put in a table)
List subList = new LinkedList(); List subList = new LinkedList();
ItemIterator subs = Item.findBySubmitter(context, context.getCurrentUser());
Integer limit;
if(displayAll) {
limit = -1;
} else {
//Set a default limit of 50
limit = 50;
}
ItemIterator subs = Item.findBySubmitterDateSorted(context, context.getCurrentUser(), limit);
//NOTE: notice we are adding each item to this list in *reverse* order... //NOTE: notice we are adding each item to this list in *reverse* order...
// this is a very basic attempt at making more recent submissions float // this is a very basic attempt at making more recent submissions float
@@ -344,7 +353,7 @@ public class Submissions extends AbstractDSpaceTransformer
{ {
while (subs.hasNext()) while (subs.hasNext())
{ {
subList.add(0, subs.next()); subList.add(subs.next());
} }
} }
finally finally
@@ -371,7 +380,6 @@ public class Submissions extends AbstractDSpaceTransformer
//Limit to showing just 50 archived submissions, unless overridden //Limit to showing just 50 archived submissions, unless overridden
//(This is a saftey measure for Admins who may have submitted //(This is a saftey measure for Admins who may have submitted
// thousands of items under their account via bulk ingest tools, etc.) // thousands of items under their account via bulk ingest tools, etc.)
int limit = 50;
int count = 0; int count = 0;
// Populate table // Populate table
@@ -420,7 +428,7 @@ public class Submissions extends AbstractDSpaceTransformer
}//end while }//end while
//Display limit text & link to allow user to override this default limit //Display limit text & link to allow user to override this default limit
if(!displayAll && count>limit) if(!displayAll && count == limit)
{ {
Para limitedList = completedSubmissions.addPara(); Para limitedList = completedSubmissions.addPara();
limitedList.addContent(T_c_limit); limitedList.addContent(T_c_limit);