mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
[DS-749] - Allow for bitstream display order to be changed.
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6580 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -10,10 +10,7 @@ package org.dspace.content;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeConfiguration;
|
||||
@@ -117,6 +114,9 @@ public class Bundle extends DSpaceObject
|
||||
}
|
||||
else
|
||||
{
|
||||
//Since bitstreams can be ordered by a column in bundle2bitstream
|
||||
//We cannot use queryTable & so we need to add our table later on
|
||||
r.setTable("bitstream");
|
||||
bitstreams.add(new Bitstream(ourContext, r));
|
||||
}
|
||||
}
|
||||
@@ -466,18 +466,32 @@ public class Bundle extends DSpaceObject
|
||||
public void setOrder(int bitstreamIds[]) throws AuthorizeException, SQLException {
|
||||
AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
|
||||
|
||||
//Map the bitstreams of the bundle by identifier
|
||||
Map<Integer, Bitstream> bitstreamMap = new HashMap<Integer, Bitstream>();
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
bitstreamMap.put(bitstream.getID(), bitstream);
|
||||
}
|
||||
|
||||
//We need to also reoder our cached bitstreams list
|
||||
bitstreams = new ArrayList<Bitstream>();
|
||||
for (int i = 0; i < bitstreamIds.length; i++) {
|
||||
int bitstreamId = bitstreamIds[i];
|
||||
|
||||
//TODO: take into account the asc & desc ! from the dspace.cfg
|
||||
TableRow row = DatabaseManager.querySingleTable(ourContext, "bundle2bitstream",
|
||||
"SELECT * FROM bundle2bitstream WHERE bitstream_id= ? ", bitstreamId);
|
||||
|
||||
if(row == null){
|
||||
//This should never occur but just in case
|
||||
log.warn(LogManager.getHeader(ourContext, "Invalid bitstream id while changing bitstream order", "Bundle: " + getID() + ", bitstream id: " + bitstreamId));
|
||||
}else{
|
||||
row.setColumn("bitstream_order", i);
|
||||
DatabaseManager.update(ourContext, row);
|
||||
}
|
||||
|
||||
// Place the bitstream in the list of bitstreams in this bundle
|
||||
bitstreams.add(bitstreamMap.get(bitstreamId));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user