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,19 +49,19 @@
-- --
------------------------------------------------------- -------------------------------------------------------
-- 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), mimetype VARCHAR(48),
short_description VARCHAR(128) UNIQUE, short_description VARCHAR(128) UNIQUE,
description TEXT, description TEXT,
support_level INTEGER, support_level INTEGER,
-- Identifies internal types -- Identifies internal types
internal BOOL internal BOOL
); );
------------------------------------------------------- -------------------------------------------------------
@@ -71,18 +71,17 @@ DROP TABLE Bitstream;
CREATE TABLE Bitstream CREATE TABLE Bitstream
( (
bitstream_id INTEGER PRIMARY KEY, bitstream_id INTEGER PRIMARY KEY,
bitstream_type_id INTEGER REFERENCES bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
BitstreamTypeRegistry(bitstream_type_id), name VARCHAR(256),
name VARCHAR(256), size INTEGER,
size INTEGER, checksum VARCHAR(64),
checksum VARCHAR(64), checksum_algorithm VARCHAR(32),
checksum_algorithm VARCHAR(32), description TEXT,
description TEXT, user_format_description TEXT,
user_type_description TEXT, source VARCHAR(256),
source VARCHAR(256), internal_id VARCHAR(256),
internal_id VARCHAR(256), deleted BOOL
deleted BOOL
); );
------------------------------------------------------- -------------------------------------------------------
@@ -300,21 +299,21 @@ 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), item_id INTEGER REFERENCES Item(item_id),
collection_id INTEGER REFERENCES Collection(collection_id), collection_id INTEGER REFERENCES Collection(collection_id),
-- Answers to questions on first page of submit UI -- Answers to questions on first page of submit UI
multiple_titles BOOL, multiple_titles BOOL,
published_before BOOL, published_before BOOL,
multiple_files BOOL, multiple_files BOOL,
-- How for the user has got in the submit process -- How for the user has got in the submit process
stage_reached INTEGER stage_reached INTEGER
); );
------------------------------------------------------- -------------------------------------------------------
@@ -352,8 +351,6 @@ CREATE TABLE TasklistItem
); );
------------------------------------------------------- -------------------------------------------------------
-- RegistrationData table -- RegistrationData table
------------------------------------------------------- -------------------------------------------------------
@@ -362,15 +359,12 @@ DROP TABLE RegistrationData;
CREATE TABLE RegistrationData CREATE TABLE RegistrationData
( (
registrationdata_id INTEGER PRIMARY KEY, registrationdata_id INTEGER PRIMARY KEY,
lookup_key VARCHAR(64) UNIQUE, eperson_id INTEGER REFERENCES EPerson(eperson_id),
creator VARCHAR(64), token VARCHAR(48),
created TIMESTAMP, expires TIMESTAMP
expires TIMESTAMP,
table_name VARCHAR(64),
column_name VARCHAR(64),
table_id INTEGER
); );
------------------------------------------------------- -------------------------------------------------------
-- History table -- History table
------------------------------------------------------- -------------------------------------------------------

View File

@@ -90,16 +90,16 @@ public class Bitstream
bRow = row; bRow = row;
// Get the bitstream format // Get the bitstream format
int bfID = row.getIntColumn("bitstream_type_id"); int bfID = row.getIntColumn("bitstream_format_id");
TableRow formatRow = DatabaseManager.find(context, TableRow formatRow = DatabaseManager.find(context,
"bitstreamtyperegistry", bfID); "bitstreamformatregistry", bfID);
if (formatRow == null) if (formatRow == null)
{ {
// No format: use "Unknown" // No format: use "Unknown"
formatRow = DatabaseManager.findByUnique(context, formatRow = DatabaseManager.findByUnique(context,
"bitstreamtyperegistry", "short_description", "Unknown"); "bitstreamformatregistry", "short_description", "Unknown");
// Panic if we can't find it // Panic if we can't find it
if (formatRow == null) if (formatRow == null)
@@ -309,7 +309,7 @@ public class Bitstream
// FIXME: Would be better if this didn't throw an SQLException, // FIXME: Would be better if this didn't throw an SQLException,
// but we need to find the unknown format! // but we need to find the unknown format!
setFormat(null); setFormat(null);
bRow.setColumn("user_type_description", desc); bRow.setColumn("user_format_description", desc);
} }
@@ -321,7 +321,7 @@ public class Bitstream
*/ */
public String getUserFormatDescription() 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")) if (bitstreamFormat.getShortDescription().equals("Unknown"))
{ {
return bRow.getStringColumn("user_type_description"); return bRow.getStringColumn("user_format_description");
} }
else else
{ {
@@ -379,10 +379,10 @@ public class Bitstream
} }
// Remove user type description // Remove user type description
bRow.setColumnNull("user_type_description"); bRow.setColumnNull("user_format_description");
// Update the ID in the table row // 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 throws SQLException
{ {
TableRow row = DatabaseManager.find(context, TableRow row = DatabaseManager.find(context,
"bitstreamtyperegistry", "bitstreamformatregistry",
id); id);
if (row == null) if (row == null)
@@ -125,7 +125,7 @@ public class BitstreamFormat
{ {
log.debug(LogManager.getHeader(context, log.debug(LogManager.getHeader(context,
"find_bitstream_format", "find_bitstream_format",
"not_found,bitstream_type_id=" + id)); "not_found,bitstream_format_id=" + id));
} }
return null; return null;
@@ -136,7 +136,7 @@ public class BitstreamFormat
{ {
log.debug(LogManager.getHeader(context, log.debug(LogManager.getHeader(context,
"find_bitstream", "find_bitstream",
"bitstream_type_id=" + id)); "bitstream_format_id=" + id));
} }
return new BitstreamFormat(context, row); return new BitstreamFormat(context, row);
@@ -158,7 +158,7 @@ public class BitstreamFormat
throws SQLException throws SQLException
{ {
TableRow formatRow = DatabaseManager.findByUnique(context, TableRow formatRow = DatabaseManager.findByUnique(context,
"bitstreamtyperegistry", "short_description", "Unknown"); "bitstreamformatregistry", "short_description", "Unknown");
if (formatRow == null) if (formatRow == null)
{ {
@@ -171,8 +171,8 @@ public class BitstreamFormat
{ {
log.debug(LogManager.getHeader(context, log.debug(LogManager.getHeader(context,
"find_bitstream", "find_bitstream",
"bitstream_type_id=" + formatRow.getIntColumn( "bitstream_format_id=" + formatRow.getIntColumn(
"bitstream_type_id"))); "bitstream_format_id")));
} }
return new BitstreamFormat(context, formatRow); return new BitstreamFormat(context, formatRow);
@@ -194,8 +194,8 @@ public class BitstreamFormat
List formats = new ArrayList(); List formats = new ArrayList();
TableRowIterator tri = DatabaseManager.query(context, TableRowIterator tri = DatabaseManager.query(context,
"bitstreamtyperegistry", "bitstreamformatregistry",
"SELECT * FROM bitstreamtyperegistry;"); "SELECT * FROM bitstreamformatregistry;");
while (tri.hasNext()) while (tri.hasNext())
{ {
@@ -222,11 +222,12 @@ public class BitstreamFormat
// FIXME: Check authorisation // FIXME: Check authorisation
// Create a table row // Create a table row
TableRow row = DatabaseManager.create(context, "bitstreamtyperegistry"); TableRow row = DatabaseManager.create(context,
"bitstreamformatregistry");
log.info(LogManager.getHeader(context, log.info(LogManager.getHeader(context,
"create_bitstream_format", "create_bitstream_format",
"bitstream_type_id=" + row.getIntColumn("bitstream_type_id"))); "bitstream_format_id=" + row.getIntColumn("bitstream_format_id")));
return new BitstreamFormat(context, row); return new BitstreamFormat(context, row);
} }
@@ -239,7 +240,7 @@ public class BitstreamFormat
*/ */
public int getID() 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, log.info(LogManager.getHeader(bfContext,
"update_bitstream_format", "update_bitstream_format",
"bitstream_type_id=" + getID())); "bitstream_format_id=" + getID()));
DatabaseManager.update(bfContext, bfRow); DatabaseManager.update(bfContext, bfRow);
} }
@@ -399,16 +400,15 @@ public class BitstreamFormat
// Set bitstreams with this format to "unknown" // Set bitstreams with this format to "unknown"
int numberChanged = DatabaseManager.updateQuery(bfContext, int numberChanged = DatabaseManager.updateQuery(bfContext,
"UPDATE bitstreams SET bitstream_type_id=" + unknown.getID() + "UPDATE bitstreams SET bitstream_format_id=" + unknown.getID() +
" WHERE bitstream_type_id=" + getID()); " WHERE bitstream_format_id=" + getID());
// Delete this format from database // Delete this format from database
DatabaseManager.delete(bfContext, bfRow); DatabaseManager.delete(bfContext, bfRow);
log.info(LogManager.getHeader(bfContext, log.info(LogManager.getHeader(bfContext,
"delete_bitstream_format", "delete_bitstream_format",
"bitstream_type_id=" + getID() + ",bitstreams_changed=" + "bitstream_format_id=" + getID() + ",bitstreams_changed=" +
numberChanged)); 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. * The workflow item is removed, and a workspace item created.
* *
* @return the personal workspace item * @return the workspace item
*/ */
public WorkspaceItem returnToWorkspace() public WorkspaceItem returnToWorkspace()
throws SQLException, AuthorizeException throws SQLException, AuthorizeException
@@ -163,8 +163,8 @@ public class WorkflowItem implements InProgressSubmission
item.clearDC("date", "accessioned", Item.ANY); item.clearDC("date", "accessioned", Item.ANY);
item.update(); item.update();
// Create the new personal workspace row // Create the new workspace item row
TableRow row = DatabaseManager.create(ourContext, "personalworkspace"); TableRow row = DatabaseManager.create(ourContext, "workspaceitem");
row.setColumn("item_id", item.getID()); row.setColumn("item_id", item.getID());
row.setColumn("collection_id", collection.getID()); row.setColumn("collection_id", collection.getID());
@@ -176,7 +176,7 @@ public class WorkflowItem implements InProgressSubmission
log.info(LogManager.getHeader(ourContext, log.info(LogManager.getHeader(ourContext,
"return_to_workspace", "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 // Now remove the workflow object
DatabaseManager.delete(ourContext, wfRow); DatabaseManager.delete(ourContext, wfRow);

View File

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