mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 20:43:18 +00:00
XMLUI My Archived Submissions to sort using DB rather than array loop
This commit is contained in:
@@ -244,6 +244,52 @@ public class Item extends DSpaceObject
|
|||||||
return new ItemIterator(context, rows);
|
return new ItemIterator(context, rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 \n" +
|
||||||
|
" item.item_id, \n" +
|
||||||
|
" item.submitter_id, \n" +
|
||||||
|
" item.in_archive, \n" +
|
||||||
|
" item.withdrawn, \n" +
|
||||||
|
" item.owning_collection, \n" +
|
||||||
|
" item.last_modified, \n" +
|
||||||
|
" metadatavalue.text_value\n" +
|
||||||
|
"FROM \n" +
|
||||||
|
" public.item, \n" +
|
||||||
|
" public.metadatafieldregistry, \n" +
|
||||||
|
" public.metadatavalue\n" +
|
||||||
|
"WHERE \n" +
|
||||||
|
" metadatafieldregistry.metadata_field_id = metadatavalue.metadata_field_id AND\n" +
|
||||||
|
" metadatavalue.item_id = item.item_id AND\n" +
|
||||||
|
" metadatafieldregistry.element = 'date' AND \n" +
|
||||||
|
" metadatafieldregistry.qualifier = 'accessioned' AND \n" +
|
||||||
|
" 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, eperson.getID(), limit);
|
||||||
|
} else {
|
||||||
|
querySorted += ";";
|
||||||
|
rows = DatabaseManager.query(context, querySorted, 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
|
||||||
|
@@ -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);
|
||||||
|
Reference in New Issue
Block a user