mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
(Robert Tansley)
- Bitstream file sizes now stored in BIGINT column size_bytes. Fixes SF bug #1035366 - Queries involving booleans now have Oracle/PostgreSQL-neutral SQL syntax; removes some DB-dependent code from business logic layer git-svn-id: http://scm.dspace.org/svn/repo/trunk@1374 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
1.4 beta 1
|
||||
==========
|
||||
(Robert Tansley)
|
||||
- Bitstream file sizes now stored in BIGINT column size_bytes.
|
||||
Fixes SF bug #1035366
|
||||
- Queries involving booleans now have Oracle/PostgreSQL-neutral SQL syntax;
|
||||
removes some DB-dependent code from business logic layer
|
||||
|
||||
(Martin Hald, Larry Stone, Robert Tansley)
|
||||
- Support for multiple (flat) metadata schemas
|
||||
|
||||
|
@@ -148,7 +148,7 @@ CREATE TABLE Bitstream
|
||||
bitstream_id INTEGER PRIMARY KEY,
|
||||
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
||||
name VARCHAR(256),
|
||||
size INTEGER,
|
||||
size_bytes BIGINT,
|
||||
checksum VARCHAR(64),
|
||||
checksum_algorithm VARCHAR(32),
|
||||
description TEXT,
|
||||
|
@@ -138,3 +138,12 @@ CREATE VIEW dcvalue AS
|
||||
SELECT setval('metadatafieldregistry_seq', max(metadata_field_id)) FROM metadatafieldregistry;
|
||||
SELECT setval('metadatavalue_seq', max(metadata_value_id)) FROM metadatavalue;
|
||||
SELECT setval('metadataschemaregistry_seq', max(metadata_schema_id)) FROM metadataschemaregistry;
|
||||
|
||||
|
||||
------------------------------------------------------
|
||||
-- Bitstream table -- increase capacity of file size
|
||||
-- column, and bring in line with Oracle schema
|
||||
------------------------------------------------------
|
||||
ALTER TABLE bitstream ADD COLUMN size_bytes BIGINT;
|
||||
UPDATE bitstream SET size_bytes = size;
|
||||
ALTER TABLE bitstream DROP COLUMN size;
|
||||
|
@@ -229,8 +229,13 @@ public class DIDLCrosswalk extends Crosswalk
|
||||
metadata.append("\" encoding=\"base64\">");
|
||||
try
|
||||
{
|
||||
|
||||
byte[] buffer = new byte[bitstreams[k].getSize()];
|
||||
/*
|
||||
* Assume that size of in-line bitstreams will always be
|
||||
* smaller than MAXINT bytes
|
||||
*/
|
||||
int intSize = (int) bitstreams[k].getSize();
|
||||
|
||||
byte[] buffer = new byte[intSize];
|
||||
|
||||
//BufferedInputStream bis=new BufferedInputStream(bitstreams[k].retrieve());
|
||||
Context contextl= new Context();
|
||||
|
@@ -355,15 +355,9 @@ public class Bitstream extends DSpaceObject
|
||||
*
|
||||
* @return the size in bytes
|
||||
*/
|
||||
public int getSize()
|
||||
public long getSize()
|
||||
{
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
return bRow.getIntColumn("size_bytes");
|
||||
}
|
||||
|
||||
// default is column "size" for postgres
|
||||
return bRow.getIntColumn("size");
|
||||
return bRow.getLongColumn("size_bytes");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -305,21 +305,9 @@ public class BitstreamFormat
|
||||
{
|
||||
List formats = new ArrayList();
|
||||
|
||||
String myQuery = null;
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
myQuery = "SELECT * FROM bitstreamformatregistry WHERE internal=0 "
|
||||
+ "AND short_description NOT LIKE 'Unknown' "
|
||||
+ "ORDER BY support_level DESC, short_description";
|
||||
}
|
||||
else
|
||||
{
|
||||
// default postgres, use boolean
|
||||
myQuery = "SELECT * FROM bitstreamformatregistry WHERE internal=false "
|
||||
+ "AND short_description NOT LIKE 'Unknown' "
|
||||
+ "ORDER BY support_level DESC, short_description";
|
||||
}
|
||||
String myQuery = "SELECT * FROM bitstreamformatregistry WHERE internal='0' "
|
||||
+ "AND short_description NOT LIKE 'Unknown' "
|
||||
+ "ORDER BY support_level DESC, short_description";
|
||||
|
||||
TableRowIterator tri = DatabaseManager.query(context,
|
||||
"bitstreamformatregistry", myQuery);
|
||||
|
@@ -308,23 +308,10 @@ public class Collection extends DSpaceObject
|
||||
*/
|
||||
public ItemIterator getItems() throws SQLException
|
||||
{
|
||||
String myQuery = null;
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
myQuery = "SELECT item.* FROM item, collection2item WHERE "
|
||||
+ "item.item_id=collection2item.item_id AND "
|
||||
+ "collection2item.collection_id=" + getID()
|
||||
+ " AND item.in_archive=1";
|
||||
}
|
||||
else
|
||||
{
|
||||
// default postgres, use boolean
|
||||
myQuery = "SELECT item.* FROM item, collection2item WHERE "
|
||||
+ "item.item_id=collection2item.item_id AND "
|
||||
+ "collection2item.collection_id=" + getID()
|
||||
+ " AND item.in_archive=true";
|
||||
}
|
||||
String myQuery = "SELECT item.* FROM item, collection2item WHERE "
|
||||
+ "item.item_id=collection2item.item_id AND "
|
||||
+ "collection2item.collection_id=" + getID()
|
||||
+ " AND item.in_archive='1'";
|
||||
|
||||
TableRowIterator rows = DatabaseManager.query(ourContext, "item",
|
||||
myQuery);
|
||||
@@ -1144,19 +1131,15 @@ public class Collection extends DSpaceObject
|
||||
{
|
||||
Statement statement = ourContext.getDBConnection().createStatement();
|
||||
final ResultSet rs;
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
rs = statement.executeQuery(
|
||||
"SELECT count(*) FROM collection2item, item WHERE "
|
||||
+ "collection2item.collection_id = " + getID()
|
||||
+ " AND collection2item.item_id = item.item_id "
|
||||
+ "AND in_archive =1 AND item.withdrawn=0");
|
||||
else
|
||||
rs = statement.executeQuery(
|
||||
"SELECT count(*) FROM collection2item, item WHERE "
|
||||
+ "collection2item.collection_id = " + getID()
|
||||
+ " AND collection2item.item_id = item.item_id "
|
||||
+ "AND in_archive ='t' AND item.withdrawn='f'");
|
||||
int itemcount = 0;
|
||||
|
||||
rs = statement
|
||||
.executeQuery("SELECT count(*) FROM collection2item, item WHERE "
|
||||
+ "collection2item.collection_id = "
|
||||
+ getID()
|
||||
+ " AND collection2item.item_id = item.item_id "
|
||||
+ "AND in_archive ='1' AND item.withdrawn='0'");
|
||||
|
||||
int itemcount = 0;
|
||||
rs.next();
|
||||
itemcount = rs.getInt(1);
|
||||
|
||||
|
@@ -266,17 +266,7 @@ public class Item extends DSpaceObject
|
||||
*/
|
||||
public static ItemIterator findAll(Context context) throws SQLException
|
||||
{
|
||||
String myQuery = null;
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
myQuery = "SELECT * FROM item WHERE in_archive=1";
|
||||
}
|
||||
else
|
||||
{
|
||||
// default postgres
|
||||
myQuery = "SELECT * FROM item WHERE in_archive=true";
|
||||
}
|
||||
String myQuery = "SELECT * FROM item WHERE in_archive='1'";
|
||||
|
||||
TableRowIterator rows = DatabaseManager.query(context, "item", myQuery);
|
||||
|
||||
@@ -297,19 +287,8 @@ public class Item extends DSpaceObject
|
||||
public static ItemIterator findBySubmitter(Context context, EPerson eperson)
|
||||
throws SQLException
|
||||
{
|
||||
String myQuery = null;
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
myQuery = "SELECT * FROM item WHERE in_archive=1 AND submitter_id="
|
||||
+ eperson.getID();
|
||||
}
|
||||
else
|
||||
{
|
||||
// default postgres
|
||||
myQuery = "SELECT * FROM item WHERE in_archive=true AND submitter_id="
|
||||
+ eperson.getID();
|
||||
}
|
||||
String myQuery = "SELECT * FROM item WHERE in_archive='1' AND submitter_id="
|
||||
+ eperson.getID();
|
||||
|
||||
TableRowIterator rows = DatabaseManager.query(context, "item", myQuery);
|
||||
|
||||
|
@@ -343,15 +343,7 @@ public class BitstreamStorageManager
|
||||
fos.close();
|
||||
is.close();
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
bitstream.setColumn("size_bytes", (int) file.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
// postgres default
|
||||
bitstream.setColumn("size", (int) file.length());
|
||||
}
|
||||
bitstream.setColumn("size_bytes", file.length());
|
||||
|
||||
bitstream.setColumn("checksum", Utils.toHex(dis.getMessageDigest()
|
||||
.digest()));
|
||||
@@ -500,17 +492,7 @@ public class BitstreamStorageManager
|
||||
}
|
||||
|
||||
bitstream.setColumn("checksum_algorithm", "MD5");
|
||||
|
||||
// oracle v. postgresql - 'size' (legacy) is reserved word in oracle
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
bitstream.setColumn("size_bytes", (int) file.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
bitstream.setColumn("size", (int) file.length());
|
||||
}
|
||||
|
||||
bitstream.setColumn("size_bytes", (int) file.length());
|
||||
bitstream.setColumn("deleted", false);
|
||||
DatabaseManager.update(context, bitstream);
|
||||
|
||||
@@ -585,19 +567,10 @@ public class BitstreamStorageManager
|
||||
*/
|
||||
public static void delete(Context context, int id) throws SQLException
|
||||
{
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
// oracle uses 1 for true
|
||||
DatabaseManager.updateQuery(context,
|
||||
"update Bitstream set deleted = 1 where bitstream_id = "
|
||||
+ id);
|
||||
}
|
||||
else
|
||||
{
|
||||
DatabaseManager.updateQuery(context,
|
||||
"update Bitstream set deleted = 't' where bitstream_id = "
|
||||
+ id);
|
||||
}
|
||||
DatabaseManager
|
||||
.updateQuery(context,
|
||||
"update Bitstream set deleted = '1' where bitstream_id = "
|
||||
+ id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,17 +591,7 @@ public class BitstreamStorageManager
|
||||
{
|
||||
context = new Context();
|
||||
|
||||
String myQuery = null;
|
||||
|
||||
if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
|
||||
{
|
||||
myQuery = "select * from Bitstream where deleted = 1";
|
||||
}
|
||||
else
|
||||
{
|
||||
// postgres
|
||||
myQuery = "select * from Bitstream where deleted = 't'";
|
||||
}
|
||||
String myQuery = "select * from Bitstream where deleted = '1'";
|
||||
|
||||
List storage = DatabaseManager.query(context, "Bitstream", myQuery)
|
||||
.toList();
|
||||
|
@@ -1148,6 +1148,10 @@ public class DatabaseManager
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (jdbctype == Types.BIGINT)
|
||||
{
|
||||
statement.setLong(count, row.getLongColumn(column));
|
||||
}
|
||||
else if (jdbctype == Types.VARCHAR)
|
||||
{
|
||||
statement.setString(count, row.getStringColumn(column));
|
||||
|
Reference in New Issue
Block a user