Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #541 from helix84/DS-2013-ItemDAOOracle

DS-2013 implement ItemDAOOracle to fix thumbnails in browse
Tested in JSPUI.
  • Loading branch information...
commit 73a14a5c76d1df7a6d076e73209f50cb2ceb897a 2 parents ddf2a8d + 4832ba3
@mwoodiupui mwoodiupui authored
Showing with 89 additions and 7 deletions.
  1. +89 −7 dspace-api/src/main/java/org/dspace/content/dao/ItemDAOOracle.java
View
96 dspace-api/src/main/java/org/dspace/content/dao/ItemDAOOracle.java
@@ -9,25 +9,107 @@
import org.dspace.core.Context;
import org.dspace.content.Bitstream;
+import org.dspace.storage.rdbms.DatabaseManager;
+import org.dspace.storage.rdbms.TableRowIterator;
+import org.dspace.storage.rdbms.TableRow;
import java.sql.SQLException;
public class ItemDAOOracle extends ItemDAO
-{
+{
+ private static final String selectPrimaryBitstreamID =
+ "SELECT bundle.primary_bitstream_id FROM item2bundle, bundle " +
+ "WHERE item2bundle.item_id=? AND item2bundle.bundle_id=bundle.bundle_id AND bundle.name=?";
+
+ private static final String selectFirstBitstreamID =
+ "SELECT bundle2bitstream.bitstream_id FROM item2bundle, bundle, bundle2bitstream " +
+ "WHERE item2bundle.item_id=? AND item2bundle.bundle_id=bundle.bundle_id AND bundle.name=? " +
+ "AND bundle.bundle_id=bundle2bitstream.bundle_id";
+
+ private static final String selectNamedBitstreamID =
+ "SELECT bitstream.bitstream_id FROM item2bundle, bundle, bundle2bitstream, bitstream " +
+ "WHERE item2bundle.item_id=? AND item2bundle.bundle_id=bundle.bundle_id AND bundle.name=? " +
+ "AND bundle.bundle_id=bundle2bitstream.bundle_id AND bundle2bitstream.bitstream_id=bitstream.bitstream_id " +
+ "AND bitstream.name=?";
+
ItemDAOOracle(Context ctx)
{
super(ctx);
}
- public Bitstream getPrimaryBitstream(int itemId, String bundleName) throws SQLException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ public Bitstream getPrimaryBitstream(int itemId, String bundleName) throws SQLException
+ {
+ TableRowIterator tri = null;
+
+ try
+ {
+ tri = DatabaseManager.query(context, selectPrimaryBitstreamID, itemId, bundleName);
+
+ if (tri.hasNext())
+ {
+ TableRow row = tri.next();
+ int bid = row.getIntColumn("primary_bitstream_id");
+ return Bitstream.find(context, bid);
+ }
+ }
+ finally
+ {
+ if (tri != null)
+ {
+ tri.close();
+ }
+ }
+
+ return null;
}
- public Bitstream getFirstBitstream(int itemId, String bundleName) throws SQLException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ public Bitstream getFirstBitstream(int itemId, String bundleName) throws SQLException
+ {
+ TableRowIterator tri = null;
+
+ try
+ {
+ tri = DatabaseManager.query(context, selectFirstBitstreamID, itemId, bundleName);
+ if (tri.hasNext())
+ {
+ TableRow row = tri.next();
+ int bid = row.getIntColumn("bitstream_id");
+ return Bitstream.find(context, bid);
+ }
+ }
+ finally
+ {
+ if (tri != null)
+ {
+ tri.close();
+ }
+ }
+
+ return null;
}
- public Bitstream getNamedBitstream(int itemId, String bundleName, String fileName) throws SQLException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ public Bitstream getNamedBitstream(int itemId, String bundleName, String fileName) throws SQLException
+ {
+ TableRowIterator tri = null;
+
+ try
+ {
+ tri = DatabaseManager.query(context, selectNamedBitstreamID, itemId, bundleName, fileName);
+ if (tri.hasNext())
+ {
+ TableRow row = tri.next();
+ int bid = row.getIntColumn("bitstream_id");
+ return Bitstream.find(context, bid);
+ }
+ }
+ finally
+ {
+ if (tri != null)
+ {
+ tri.close();
+ }
+ }
+
+ return null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.