Made some changes to the DB. ContentTest fails - will check when I have time

git-svn-id: http://scm.dspace.org/svn/repo/trunk@52 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robert Tansley
2002-05-30 14:50:46 +00:00
parent 7adfb999c7
commit 67fd4e93a9
5 changed files with 91 additions and 94 deletions

View File

@@ -49,13 +49,13 @@
--
-------------------------------------------------------
-- BitstreamTypeRegistry table
-- BitstreamFormatRegistry table
-------------------------------------------------------
DROP TABLE BitstreamTypeRegistry;
DROP TABLE BitstreamFormatRegistry;
CREATE TABLE BitstreamTypeRegistry
CREATE TABLE BitstreamFormatRegistry
(
bitstream_type_id INTEGER PRIMARY KEY,
bitstream_format_id INTEGER PRIMARY KEY,
mimetype VARCHAR(48),
short_description VARCHAR(128) UNIQUE,
description TEXT,
@@ -72,14 +72,13 @@ DROP TABLE Bitstream;
CREATE TABLE Bitstream
(
bitstream_id INTEGER PRIMARY KEY,
bitstream_type_id INTEGER REFERENCES
BitstreamTypeRegistry(bitstream_type_id),
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
name VARCHAR(256),
size INTEGER,
checksum VARCHAR(64),
checksum_algorithm VARCHAR(32),
description TEXT,
user_type_description TEXT,
user_format_description TEXT,
source VARCHAR(256),
internal_id VARCHAR(256),
deleted BOOL
@@ -300,13 +299,13 @@ CREATE TABLE Handle
);
-------------------------------------------------------
-- PersonalWorkspace table
-- WorkspaceItem table
-------------------------------------------------------
DROP TABLE PersonalWorkspace;
DROP TABLE WorkspaceItem;
CREATE TABLE PersonalWorkspace
CREATE TABLE WorkspaceItem
(
personal_workspace_id INTEGER PRIMARY KEY,
workspace_item_id INTEGER PRIMARY KEY,
item_id INTEGER REFERENCES Item(item_id),
collection_id INTEGER REFERENCES Collection(collection_id),
-- Answers to questions on first page of submit UI
@@ -352,8 +351,6 @@ CREATE TABLE TasklistItem
);
-------------------------------------------------------
-- RegistrationData table
-------------------------------------------------------
@@ -362,15 +359,12 @@ DROP TABLE RegistrationData;
CREATE TABLE RegistrationData
(
registrationdata_id INTEGER PRIMARY KEY,
lookup_key VARCHAR(64) UNIQUE,
creator VARCHAR(64),
created TIMESTAMP,
expires TIMESTAMP,
table_name VARCHAR(64),
column_name VARCHAR(64),
table_id INTEGER
eperson_id INTEGER REFERENCES EPerson(eperson_id),
token VARCHAR(48),
expires TIMESTAMP
);
-------------------------------------------------------
-- History table
-------------------------------------------------------

View File

@@ -90,16 +90,16 @@ public class Bitstream
bRow = row;
// Get the bitstream format
int bfID = row.getIntColumn("bitstream_type_id");
int bfID = row.getIntColumn("bitstream_format_id");
TableRow formatRow = DatabaseManager.find(context,
"bitstreamtyperegistry", bfID);
"bitstreamformatregistry", bfID);
if (formatRow == null)
{
// No format: use "Unknown"
formatRow = DatabaseManager.findByUnique(context,
"bitstreamtyperegistry", "short_description", "Unknown");
"bitstreamformatregistry", "short_description", "Unknown");
// Panic if we can't find it
if (formatRow == null)
@@ -309,7 +309,7 @@ public class Bitstream
// FIXME: Would be better if this didn't throw an SQLException,
// but we need to find the unknown format!
setFormat(null);
bRow.setColumn("user_type_description", desc);
bRow.setColumn("user_format_description", desc);
}
@@ -321,7 +321,7 @@ public class Bitstream
*/
public String getUserFormatDescription()
{
return bRow.getStringColumn("user_type_description");
return bRow.getStringColumn("user_format_description");
}
@@ -335,7 +335,7 @@ public class Bitstream
{
if (bitstreamFormat.getShortDescription().equals("Unknown"))
{
return bRow.getStringColumn("user_type_description");
return bRow.getStringColumn("user_format_description");
}
else
{
@@ -379,10 +379,10 @@ public class Bitstream
}
// Remove user type description
bRow.setColumnNull("user_type_description");
bRow.setColumnNull("user_format_description");
// Update the ID in the table row
bRow.setColumn("bitstream_type_id", bitstreamFormat.getID());
bRow.setColumn("bitstream_format_id", bitstreamFormat.getID());
}

View File

@@ -116,7 +116,7 @@ public class BitstreamFormat
throws SQLException
{
TableRow row = DatabaseManager.find(context,
"bitstreamtyperegistry",
"bitstreamformatregistry",
id);
if (row == null)
@@ -125,7 +125,7 @@ public class BitstreamFormat
{
log.debug(LogManager.getHeader(context,
"find_bitstream_format",
"not_found,bitstream_type_id=" + id));
"not_found,bitstream_format_id=" + id));
}
return null;
@@ -136,7 +136,7 @@ public class BitstreamFormat
{
log.debug(LogManager.getHeader(context,
"find_bitstream",
"bitstream_type_id=" + id));
"bitstream_format_id=" + id));
}
return new BitstreamFormat(context, row);
@@ -158,7 +158,7 @@ public class BitstreamFormat
throws SQLException
{
TableRow formatRow = DatabaseManager.findByUnique(context,
"bitstreamtyperegistry", "short_description", "Unknown");
"bitstreamformatregistry", "short_description", "Unknown");
if (formatRow == null)
{
@@ -171,8 +171,8 @@ public class BitstreamFormat
{
log.debug(LogManager.getHeader(context,
"find_bitstream",
"bitstream_type_id=" + formatRow.getIntColumn(
"bitstream_type_id")));
"bitstream_format_id=" + formatRow.getIntColumn(
"bitstream_format_id")));
}
return new BitstreamFormat(context, formatRow);
@@ -194,8 +194,8 @@ public class BitstreamFormat
List formats = new ArrayList();
TableRowIterator tri = DatabaseManager.query(context,
"bitstreamtyperegistry",
"SELECT * FROM bitstreamtyperegistry;");
"bitstreamformatregistry",
"SELECT * FROM bitstreamformatregistry;");
while (tri.hasNext())
{
@@ -222,11 +222,12 @@ public class BitstreamFormat
// FIXME: Check authorisation
// Create a table row
TableRow row = DatabaseManager.create(context, "bitstreamtyperegistry");
TableRow row = DatabaseManager.create(context,
"bitstreamformatregistry");
log.info(LogManager.getHeader(context,
"create_bitstream_format",
"bitstream_type_id=" + row.getIntColumn("bitstream_type_id")));
"bitstream_format_id=" + row.getIntColumn("bitstream_format_id")));
return new BitstreamFormat(context, row);
}
@@ -239,7 +240,7 @@ public class BitstreamFormat
*/
public int getID()
{
return bfRow.getIntColumn("bitstream_type_id");
return bfRow.getIntColumn("bitstream_format_id");
}
@@ -379,7 +380,7 @@ public class BitstreamFormat
log.info(LogManager.getHeader(bfContext,
"update_bitstream_format",
"bitstream_type_id=" + getID()));
"bitstream_format_id=" + getID()));
DatabaseManager.update(bfContext, bfRow);
}
@@ -399,16 +400,15 @@ public class BitstreamFormat
// Set bitstreams with this format to "unknown"
int numberChanged = DatabaseManager.updateQuery(bfContext,
"UPDATE bitstreams SET bitstream_type_id=" + unknown.getID() +
" WHERE bitstream_type_id=" + getID());
"UPDATE bitstreams SET bitstream_format_id=" + unknown.getID() +
" WHERE bitstream_format_id=" + getID());
// Delete this format from database
DatabaseManager.delete(bfContext, bfRow);
log.info(LogManager.getHeader(bfContext,
"delete_bitstream_format",
"bitstream_type_id=" + getID() + ",bitstreams_changed=" +
"bitstream_format_id=" + getID() + ",bitstreams_changed=" +
numberChanged));
}
}

View File

@@ -147,10 +147,10 @@ public class WorkflowItem implements InProgressSubmission
/**
* Return the workflow item to the personal workspace of the submitter.
* Return the workflow item to the workspace of the submitter.
* The workflow item is removed, and a workspace item created.
*
* @return the personal workspace item
* @return the workspace item
*/
public WorkspaceItem returnToWorkspace()
throws SQLException, AuthorizeException
@@ -163,8 +163,8 @@ public class WorkflowItem implements InProgressSubmission
item.clearDC("date", "accessioned", Item.ANY);
item.update();
// Create the new personal workspace row
TableRow row = DatabaseManager.create(ourContext, "personalworkspace");
// Create the new workspace item row
TableRow row = DatabaseManager.create(ourContext, "workspaceitem");
row.setColumn("item_id", item.getID());
row.setColumn("collection_id", collection.getID());
@@ -176,7 +176,7 @@ public class WorkflowItem implements InProgressSubmission
log.info(LogManager.getHeader(ourContext,
"return_to_workspace",
"workflow_item_id=" + getID() + "workspace_id=" + wi.getID()));
"workflow_item_id=" + getID() + "workspace_item_id=" + wi.getID()));
// Now remove the workflow object
DatabaseManager.delete(ourContext, wfRow);

View File

@@ -74,7 +74,7 @@ public class WorkspaceItem implements InProgressSubmission
private Context ourContext;
/** The table row corresponding to this workspace item */
private TableRow pwRow;
private TableRow wiRow;
/** The collection the item is being submitted to */
private Collection collection;
@@ -90,11 +90,11 @@ public class WorkspaceItem implements InProgressSubmission
throws SQLException
{
ourContext = context;
pwRow = row;
wiRow = row;
item = Item.find(context, pwRow.getIntColumn("item_id"));
item = Item.find(context, wiRow.getIntColumn("item_id"));
collection = Collection.find(context,
pwRow.getIntColumn("collection_id"));
wiRow.getIntColumn("collection_id"));
}
@@ -111,7 +111,7 @@ public class WorkspaceItem implements InProgressSubmission
throws SQLException
{
TableRow row = DatabaseManager.find(context,
"personalworkspace",
"workspaceitem",
id);
if (row == null)
@@ -161,15 +161,15 @@ public class WorkspaceItem implements InProgressSubmission
i.setSubmitter(sub);
i.update();
// Create the personal workspace row
TableRow row = DatabaseManager.create(context, "personalworkspace");
// Create the workspace item row
TableRow row = DatabaseManager.create(context, "workspaceitem");
row.setColumn("item_id", i.getID());
row.setColumn("collection_id", coll.getID());
log.info(LogManager.getHeader(context,
"create_workspace_item",
"workspace_item_id=" + row.getIntColumn("personal_workspace_id") +
"workspace_item_id=" + row.getIntColumn("workspace_item_id") +
"item_id=" + i.getID() + "collection_id=" + coll.getID()));
DatabaseManager.update(context, row );
@@ -179,7 +179,9 @@ public class WorkspaceItem implements InProgressSubmission
/**
* Get all workspace items for a particular e-person
* Get all workspace items for a particular e-person. These are ordered by
* workspace item ID, since this should likely keep them in the order in
* which they were created.
*
* @param context the context object
* @param ep the eperson
@@ -192,10 +194,11 @@ public class WorkspaceItem implements InProgressSubmission
List wsItems = new ArrayList();
TableRowIterator tri = DatabaseManager.query(context,
"personalworkspace",
"SELECT personalworkspace.* FROM personalworkspace, item WHERE " +
"personalworkspace.item_id=item.item_id AND " +
"item.submitter_id=" + ep.getID() + ";");
"workspaceitem",
"SELECT workspaceitem.* FROM workspaceitem, item WHERE " +
"workspaceitem.item_id=item.item_id AND " +
"item.submitter_id=" + ep.getID() +
" ORDER BY workspaceitem.workspace_item_id;");
while (tri.hasNext())
{
@@ -218,13 +221,13 @@ public class WorkspaceItem implements InProgressSubmission
*/
public int getID()
{
return pwRow.getIntColumn("personal_workspace_id");
return wiRow.getIntColumn("workspace_item_id");
}
/**
* Start the relevant workflow for this workspace item. The entry in
* PersonalWorkspace is removed, a workflow item is created, and the
* workspaceitem is removed, a workflow item is created, and the
* relevant workflow initiated. If there is no workflow, i.e. the
* item goes straight into the archive, <code>null</code> is returned.
* <P>
@@ -291,12 +294,12 @@ public class WorkspaceItem implements InProgressSubmission
item.update();
// Update ourselves
DatabaseManager.update(ourContext, pwRow);
DatabaseManager.update(ourContext, wiRow);
}
/**
* Delete the workspace item. The entry in PersonalWorkspace, the
* Delete the workspace item. The entry in workspaceitem, the
* unarchived item and its contents are all removed (multiple inclusion
* notwithstanding.)
*/
@@ -311,9 +314,9 @@ public class WorkspaceItem implements InProgressSubmission
"item_id=" + item.getID() +
"collection_id=" + collection.getID()));
// Need to delete the personalworkspace row first since it refers
// Need to delete the workspaceitem row first since it refers
// to item ID
DatabaseManager.delete(ourContext, pwRow);
DatabaseManager.delete(ourContext, wiRow);
// Delete item
item.deleteWithContents();
@@ -342,36 +345,36 @@ public class WorkspaceItem implements InProgressSubmission
public boolean hasMultipleFiles()
{
return pwRow.getBooleanColumn("multiple_files");
return wiRow.getBooleanColumn("multiple_files");
}
public void setMultipleFiles(boolean b)
{
pwRow.setColumn("multiple_files", b);
wiRow.setColumn("multiple_files", b);
}
public boolean hasMultipleTitles()
{
return pwRow.getBooleanColumn("multiple_titles");
return wiRow.getBooleanColumn("multiple_titles");
}
public void setMultipleTitles(boolean b)
{
pwRow.setColumn("multiple_titles", b);
wiRow.setColumn("multiple_titles", b);
}
public boolean isPublishedBefore()
{
return pwRow.getBooleanColumn("published_before");
return wiRow.getBooleanColumn("published_before");
}
public void setPublishedBefore(boolean b)
{
pwRow.setColumn("published_before", b);
wiRow.setColumn("published_before", b);
}
}