mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
Some database changes for dealing with concurrent ID generation problems.
(SF bug #495059) - SQL file separated into database_schema.sql, for creating the schema, clean-database.sql, which removes tables, views etc. from an existing DSpace database, and update-sequences.sql which resets the ID generators, but is only used after an SQL dump which sets explicit primary keys. - Sequences for primary key generation added to SQL schema - SQL function "getnextid" added as an abstraction for access to those sequences - Database manager now uses getnextid() SQL function to get IDs - this means other DB backends can hide ID generation specifics behind this - Minor tweak to HistoryManager, which was accessing DB manager's in-memory ID generator directly - now it doesn't do this. - Old, now unnecessary "reset ID generator" admin servlet/JSP removed git-svn-id: http://scm.dspace.org/svn/repo/trunk@362 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -175,14 +175,14 @@ Common usage:
|
|||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Create the database tables, removing anything already there -->
|
<!-- Create the database tables -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
|
|
||||||
<!-- We execute InitializeDatabase, passing in the simple log4j properties
|
<!-- We execute InitializeDatabase, passing in the simple log4j properties
|
||||||
- file in etc/ and the DSpace configuration file using system
|
- file in etc/ and the DSpace configuration file using system
|
||||||
- properties -->
|
- properties -->
|
||||||
<target name="setup_database"
|
<target name="setup_database"
|
||||||
description="Create database tables, removing existing data">
|
description="Create database tables">
|
||||||
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
|
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
|
||||||
classpathref="build.class.path"
|
classpathref="build.class.path"
|
||||||
fork="yes"
|
fork="yes"
|
||||||
@@ -194,6 +194,26 @@ Common usage:
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- Remove the database tables -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
|
||||||
|
<!-- We execute InitializeDatabase, passing in the simple log4j properties
|
||||||
|
- file in etc/ and the DSpace configuration file using system
|
||||||
|
- properties -->
|
||||||
|
<target name="clean_database"
|
||||||
|
description="Removes DSpace database tables, destroying data">
|
||||||
|
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
|
||||||
|
classpathref="build.class.path"
|
||||||
|
fork="yes"
|
||||||
|
failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:${basedir}/etc/log4j.build.properties"/>
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}"/>
|
||||||
|
<arg value="${basedir}/etc/clean-database.sql"/>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Load the initial contents of the registries into the database -->
|
<!-- Load the initial contents of the registries into the database -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
|
129
dspace/etc/clean-database.sql
Normal file
129
dspace/etc/clean-database.sql
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
--
|
||||||
|
-- clean-database.sql
|
||||||
|
--
|
||||||
|
-- Version: $Revision$
|
||||||
|
--
|
||||||
|
-- Date: $Date$
|
||||||
|
--
|
||||||
|
-- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
||||||
|
-- Institute of Technology. All rights reserved.
|
||||||
|
--
|
||||||
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
|
-- modification, are permitted provided that the following conditions are
|
||||||
|
-- met:
|
||||||
|
--
|
||||||
|
-- - Redistributions of source code must retain the above copyright
|
||||||
|
-- notice, this list of conditions and the following disclaimer.
|
||||||
|
--
|
||||||
|
-- - Redistributions in binary form must reproduce the above copyright
|
||||||
|
-- notice, this list of conditions and the following disclaimer in the
|
||||||
|
-- documentation and/or other materials provided with the distribution.
|
||||||
|
--
|
||||||
|
-- - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||||
|
-- Massachusetts Institute of Technology nor the names of their
|
||||||
|
-- contributors may be used to endorse or promote products derived from
|
||||||
|
-- this software without specific prior written permission.
|
||||||
|
--
|
||||||
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
-- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
-- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
-- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
-- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||||
|
-- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
-- DAMAGE.
|
||||||
|
|
||||||
|
--
|
||||||
|
-- DSpace database cleaner
|
||||||
|
--
|
||||||
|
-- This SQL "cleans" a database used by a DSpace installation. It removes
|
||||||
|
-- all tables etc. so the database is completely empty and ready for a
|
||||||
|
-- fresh installation. Of course, this means all data is lost.
|
||||||
|
--
|
||||||
|
-- Caution: THIS IS POSTGRESQL-SPECIFC
|
||||||
|
-- * The sequences dropped below are automatically created by PostgreSQL
|
||||||
|
-- for the SERIAL typed fields.
|
||||||
|
--
|
||||||
|
-- This should be kept in sync if database_schema.sql is updated.
|
||||||
|
|
||||||
|
|
||||||
|
-- Drop indices
|
||||||
|
DROP INDEX dcvalue_dc_type_id_idx;
|
||||||
|
|
||||||
|
-- Drop the views
|
||||||
|
DROP VIEW CommunityItemsByDateAccessioned;
|
||||||
|
DROP VIEW CollectionItemsByDateAccessioned;
|
||||||
|
DROP VIEW CommunityItemsByDate;
|
||||||
|
DROP VIEW CollectionItemsByDate;
|
||||||
|
DROP VIEW CommunityItemsByTitle;
|
||||||
|
DROP VIEW CollectionItemsByTitle;
|
||||||
|
DROP VIEW CommunityItemsByAuthor;
|
||||||
|
DROP VIEW CollectionItemsByAuthor;
|
||||||
|
DROP VIEW Community2Item;
|
||||||
|
|
||||||
|
-- Then the tables
|
||||||
|
DROP TABLE ItemsByDateAccessioned;
|
||||||
|
DROP TABLE ItemsByDate;
|
||||||
|
DROP TABLE ItemsByTitle;
|
||||||
|
DROP TABLE ItemsByAuthor;
|
||||||
|
DROP TABLE HistoryState;
|
||||||
|
DROP TABLE History;
|
||||||
|
DROP TABLE RegistrationData;
|
||||||
|
DROP TABLE TasklistItem;
|
||||||
|
DROP TABLE WorkflowItem;
|
||||||
|
DROP TABLE WorkspaceItem;
|
||||||
|
DROP TABLE Handle;
|
||||||
|
DROP TABLE EPersonGroup2EPerson;
|
||||||
|
DROP TABLE ResourcePolicy;
|
||||||
|
DROP TABLE Collection2Item;
|
||||||
|
DROP TABLE Community2Collection;
|
||||||
|
DROP TABLE Collection;
|
||||||
|
DROP TABLE Community;
|
||||||
|
DROP TABLE DCValue;
|
||||||
|
DROP TABLE DCTypeRegistry;
|
||||||
|
DROP TABLE Bundle2Bitstream;
|
||||||
|
DROP TABLE Item2Bundle;
|
||||||
|
DROP TABLE Bundle;
|
||||||
|
DROP TABLE Item;
|
||||||
|
DROP TABLE EPersonGroup;
|
||||||
|
DROP TABLE EPerson;
|
||||||
|
DROP TABLE Bitstream;
|
||||||
|
DROP TABLE FileExtension;
|
||||||
|
DROP TABLE BitstreamFormatRegistry;
|
||||||
|
|
||||||
|
-- Now drop the sequences for ID (primary key) creation
|
||||||
|
DROP SEQUENCE bitstreamformatregistry_seq;
|
||||||
|
DROP SEQUENCE fileextension_seq;
|
||||||
|
DROP SEQUENCE bitstream_seq;
|
||||||
|
DROP SEQUENCE eperson_seq;
|
||||||
|
DROP SEQUENCE epersongroup_seq;
|
||||||
|
DROP SEQUENCE item_seq;
|
||||||
|
DROP SEQUENCE bundle_seq;
|
||||||
|
DROP SEQUENCE item2bundle_seq;
|
||||||
|
DROP SEQUENCE bundle2bitstream_seq;
|
||||||
|
DROP SEQUENCE dctyperegistry_seq;
|
||||||
|
DROP SEQUENCE dcvalue_seq;
|
||||||
|
DROP SEQUENCE community_seq;
|
||||||
|
DROP SEQUENCE collection_seq;
|
||||||
|
DROP SEQUENCE community2collection_seq;
|
||||||
|
DROP SEQUENCE collection2item_seq;
|
||||||
|
DROP SEQUENCE resourcepolicy_seq;
|
||||||
|
DROP SEQUENCE epersongroup2eperson_seq;
|
||||||
|
DROP SEQUENCE handle_seq;
|
||||||
|
DROP SEQUENCE workspaceitem_seq;
|
||||||
|
DROP SEQUENCE workflowitem_seq;
|
||||||
|
DROP SEQUENCE tasklistitem_seq;
|
||||||
|
DROP SEQUENCE registrationdata_seq;
|
||||||
|
DROP SEQUENCE history_seq;
|
||||||
|
DROP SEQUENCE historystate_seq;
|
||||||
|
DROP SEQUENCE itemsbyauthor_seq;
|
||||||
|
DROP SEQUENCE itemsbytitle_seq;
|
||||||
|
DROP SEQUENCE itemsbydate_seq;
|
||||||
|
DROP SEQUENCE itemsbydateaccessioned_seq;
|
||||||
|
|
||||||
|
-- Drop the getnextid() function
|
||||||
|
DROP FUNCTION getnextid(VARCHAR(40));
|
@@ -40,19 +40,77 @@
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- DSpace SQL table definitions
|
-- DSpace SQL schema
|
||||||
--
|
--
|
||||||
-- Authors: Peter Breton, Robert Tansley, David Stuve, Daniel Chudnov
|
-- Authors: Peter Breton, Robert Tansley, David Stuve, Daniel Chudnov
|
||||||
--
|
--
|
||||||
-- This file is used as-is to initialize a database. Therefore,
|
-- This file is used as-is to initialize a database. Therefore,
|
||||||
-- table and view definitions must be ordered correctly.
|
-- table and view definitions must be ordered correctly.
|
||||||
--
|
--
|
||||||
|
-- Caution: THIS IS POSTGRESQL-SPECIFIC:
|
||||||
|
--
|
||||||
|
-- * SEQUENCES are used for automatic ID generation
|
||||||
|
-- * FUNCTION getnextid used for automatic ID generation
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- To convert to work with another database, you need to ensure
|
||||||
|
-- an SQL function 'getnextid', which takes a table name as an
|
||||||
|
-- argument, will return a safe new ID to use to create a new
|
||||||
|
-- row in that table.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-------------------------------------------------------
|
||||||
|
-- Function for obtaining new IDs.
|
||||||
|
--
|
||||||
|
-- * The argument is a table name
|
||||||
|
-- * It returns a new ID safe to use for that table
|
||||||
|
--
|
||||||
|
-- The function reads the next value from the sequence
|
||||||
|
-- 'tablename_seq'
|
||||||
|
-------------------------------------------------------
|
||||||
|
CREATE FUNCTION getnextid(VARCHAR(40)) RETURNS INTEGER AS
|
||||||
|
'SELECT CAST (nextval($1 || ''_seq'') AS INTEGER) AS RESULT;' LANGUAGE SQL;
|
||||||
|
|
||||||
|
|
||||||
|
-------------------------------------------------------
|
||||||
|
-- Sequences for creating new IDs (primary keys) for
|
||||||
|
-- tables. Each table must have a corresponding
|
||||||
|
-- sequence called 'tablename_seq'.
|
||||||
|
-------------------------------------------------------
|
||||||
|
CREATE SEQUENCE bitstreamformatregistry_seq;
|
||||||
|
CREATE SEQUENCE fileextension_seq;
|
||||||
|
CREATE SEQUENCE bitstream_seq;
|
||||||
|
CREATE SEQUENCE eperson_seq;
|
||||||
|
CREATE SEQUENCE epersongroup_seq;
|
||||||
|
CREATE SEQUENCE item_seq;
|
||||||
|
CREATE SEQUENCE bundle_seq;
|
||||||
|
CREATE SEQUENCE item2bundle_seq;
|
||||||
|
CREATE SEQUENCE bundle2bitstream_seq;
|
||||||
|
CREATE SEQUENCE dctyperegistry_seq;
|
||||||
|
CREATE SEQUENCE dcvalue_seq;
|
||||||
|
CREATE SEQUENCE community_seq;
|
||||||
|
CREATE SEQUENCE collection_seq;
|
||||||
|
CREATE SEQUENCE community2collection_seq;
|
||||||
|
CREATE SEQUENCE collection2item_seq;
|
||||||
|
CREATE SEQUENCE resourcepolicy_seq;
|
||||||
|
CREATE SEQUENCE epersongroup2eperson_seq;
|
||||||
|
CREATE SEQUENCE handle_seq;
|
||||||
|
CREATE SEQUENCE workspaceitem_seq;
|
||||||
|
CREATE SEQUENCE workflowitem_seq;
|
||||||
|
CREATE SEQUENCE tasklistitem_seq;
|
||||||
|
CREATE SEQUENCE registrationdata_seq;
|
||||||
|
CREATE SEQUENCE history_seq;
|
||||||
|
CREATE SEQUENCE historystate_seq;
|
||||||
|
CREATE SEQUENCE itemsbyauthor_seq;
|
||||||
|
CREATE SEQUENCE itemsbytitle_seq;
|
||||||
|
CREATE SEQUENCE itemsbydate_seq;
|
||||||
|
CREATE SEQUENCE itemsbydateaccessioned_seq;
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- BitstreamFormatRegistry table
|
-- BitstreamFormatRegistry table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE BitstreamFormatRegistry;
|
|
||||||
|
|
||||||
CREATE TABLE BitstreamFormatRegistry
|
CREATE TABLE BitstreamFormatRegistry
|
||||||
(
|
(
|
||||||
bitstream_format_id INTEGER PRIMARY KEY,
|
bitstream_format_id INTEGER PRIMARY KEY,
|
||||||
@@ -67,8 +125,6 @@ CREATE TABLE BitstreamFormatRegistry
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- FileExtension table
|
-- FileExtension table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE FileExtension;
|
|
||||||
|
|
||||||
CREATE TABLE FileExtension
|
CREATE TABLE FileExtension
|
||||||
(
|
(
|
||||||
file_extension_id INTEGER PRIMARY KEY,
|
file_extension_id INTEGER PRIMARY KEY,
|
||||||
@@ -79,8 +135,6 @@ CREATE TABLE FileExtension
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Bitstream table
|
-- Bitstream table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Bitstream;
|
|
||||||
|
|
||||||
CREATE TABLE Bitstream
|
CREATE TABLE Bitstream
|
||||||
(
|
(
|
||||||
bitstream_id INTEGER PRIMARY KEY,
|
bitstream_id INTEGER PRIMARY KEY,
|
||||||
@@ -99,8 +153,6 @@ CREATE TABLE Bitstream
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- EPerson table
|
-- EPerson table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE EPerson;
|
|
||||||
|
|
||||||
CREATE TABLE EPerson
|
CREATE TABLE EPerson
|
||||||
(
|
(
|
||||||
eperson_id INTEGER PRIMARY KEY,
|
eperson_id INTEGER PRIMARY KEY,
|
||||||
@@ -116,8 +168,6 @@ CREATE TABLE EPerson
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- EPersonGroup table
|
-- EPersonGroup table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE EPersonGroup;
|
|
||||||
|
|
||||||
CREATE TABLE EPersonGroup
|
CREATE TABLE EPersonGroup
|
||||||
(
|
(
|
||||||
eperson_group_id INTEGER PRIMARY KEY,
|
eperson_group_id INTEGER PRIMARY KEY,
|
||||||
@@ -127,8 +177,6 @@ CREATE TABLE EPersonGroup
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Item table
|
-- Item table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Item;
|
|
||||||
|
|
||||||
CREATE TABLE Item
|
CREATE TABLE Item
|
||||||
(
|
(
|
||||||
item_id INTEGER PRIMARY KEY,
|
item_id INTEGER PRIMARY KEY,
|
||||||
@@ -139,8 +187,6 @@ CREATE TABLE Item
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Bundle table
|
-- Bundle table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Bundle;
|
|
||||||
|
|
||||||
CREATE TABLE Bundle
|
CREATE TABLE Bundle
|
||||||
(
|
(
|
||||||
bundle_id INTEGER PRIMARY KEY,
|
bundle_id INTEGER PRIMARY KEY,
|
||||||
@@ -150,8 +196,6 @@ CREATE TABLE Bundle
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Item2Bundle table
|
-- Item2Bundle table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Item2Bundle;
|
|
||||||
|
|
||||||
CREATE TABLE Item2Bundle
|
CREATE TABLE Item2Bundle
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -162,8 +206,6 @@ CREATE TABLE Item2Bundle
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Bundle2Bitstream table
|
-- Bundle2Bitstream table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Bundle2Bitstream;
|
|
||||||
|
|
||||||
CREATE TABLE Bundle2Bitstream
|
CREATE TABLE Bundle2Bitstream
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -174,8 +216,6 @@ CREATE TABLE Bundle2Bitstream
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- DCTypeRegistry table
|
-- DCTypeRegistry table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE DCTypeRegistry;
|
|
||||||
|
|
||||||
CREATE TABLE DCTypeRegistry
|
CREATE TABLE DCTypeRegistry
|
||||||
(
|
(
|
||||||
dc_type_id INTEGER PRIMARY KEY,
|
dc_type_id INTEGER PRIMARY KEY,
|
||||||
@@ -188,8 +228,6 @@ CREATE TABLE DCTypeRegistry
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- DCValue table
|
-- DCValue table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE DCValue;
|
|
||||||
|
|
||||||
CREATE TABLE DCValue
|
CREATE TABLE DCValue
|
||||||
(
|
(
|
||||||
dc_value_id INTEGER PRIMARY KEY,
|
dc_value_id INTEGER PRIMARY KEY,
|
||||||
@@ -202,14 +240,11 @@ CREATE TABLE DCValue
|
|||||||
);
|
);
|
||||||
|
|
||||||
-- An index for dctypes
|
-- An index for dctypes
|
||||||
DROP INDEX dcvalue_dc_type_id_idx;
|
|
||||||
CREATE INDEX dcvalue_dc_type_id_idx on DCValue(dc_type_id);
|
CREATE INDEX dcvalue_dc_type_id_idx on DCValue(dc_type_id);
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Community table
|
-- Community table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Community;
|
|
||||||
|
|
||||||
CREATE TABLE Community
|
CREATE TABLE Community
|
||||||
(
|
(
|
||||||
community_id INTEGER PRIMARY KEY,
|
community_id INTEGER PRIMARY KEY,
|
||||||
@@ -224,8 +259,6 @@ CREATE TABLE Community
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Collection table
|
-- Collection table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Collection;
|
|
||||||
|
|
||||||
CREATE TABLE Collection
|
CREATE TABLE Collection
|
||||||
(
|
(
|
||||||
collection_id INTEGER PRIMARY KEY,
|
collection_id INTEGER PRIMARY KEY,
|
||||||
@@ -246,8 +279,6 @@ CREATE TABLE Collection
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Community2Collection table
|
-- Community2Collection table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Community2Collection;
|
|
||||||
|
|
||||||
CREATE TABLE Community2Collection
|
CREATE TABLE Community2Collection
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -258,8 +289,6 @@ CREATE TABLE Community2Collection
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Collection2Item table
|
-- Collection2Item table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Collection2Item;
|
|
||||||
|
|
||||||
CREATE TABLE Collection2Item
|
CREATE TABLE Collection2Item
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -270,8 +299,6 @@ CREATE TABLE Collection2Item
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- ResourcePolicy table
|
-- ResourcePolicy table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE ResourcePolicy;
|
|
||||||
|
|
||||||
CREATE TABLE ResourcePolicy
|
CREATE TABLE ResourcePolicy
|
||||||
(
|
(
|
||||||
policy_id INTEGER PRIMARY KEY,
|
policy_id INTEGER PRIMARY KEY,
|
||||||
@@ -288,8 +315,6 @@ CREATE TABLE ResourcePolicy
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- EPersonGroup2EPerson table
|
-- EPersonGroup2EPerson table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE EPersonGroup2EPerson;
|
|
||||||
|
|
||||||
CREATE TABLE EPersonGroup2EPerson
|
CREATE TABLE EPersonGroup2EPerson
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -300,8 +325,6 @@ CREATE TABLE EPersonGroup2EPerson
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Handle table
|
-- Handle table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE Handle;
|
|
||||||
|
|
||||||
CREATE TABLE Handle
|
CREATE TABLE Handle
|
||||||
(
|
(
|
||||||
handle_id INTEGER PRIMARY KEY,
|
handle_id INTEGER PRIMARY KEY,
|
||||||
@@ -313,8 +336,6 @@ CREATE TABLE Handle
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- WorkspaceItem table
|
-- WorkspaceItem table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE WorkspaceItem;
|
|
||||||
|
|
||||||
CREATE TABLE WorkspaceItem
|
CREATE TABLE WorkspaceItem
|
||||||
(
|
(
|
||||||
workspace_item_id INTEGER PRIMARY KEY,
|
workspace_item_id INTEGER PRIMARY KEY,
|
||||||
@@ -331,8 +352,6 @@ CREATE TABLE WorkspaceItem
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- WorkflowItem table
|
-- WorkflowItem table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE WorkflowItem;
|
|
||||||
|
|
||||||
CREATE TABLE WorkflowItem
|
CREATE TABLE WorkflowItem
|
||||||
(
|
(
|
||||||
workflow_id INTEGER PRIMARY KEY,
|
workflow_id INTEGER PRIMARY KEY,
|
||||||
@@ -353,8 +372,6 @@ CREATE TABLE WorkflowItem
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- TasklistItem table
|
-- TasklistItem table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE TasklistItem;
|
|
||||||
|
|
||||||
CREATE TABLE TasklistItem
|
CREATE TABLE TasklistItem
|
||||||
(
|
(
|
||||||
tasklist_id INTEGER PRIMARY KEY,
|
tasklist_id INTEGER PRIMARY KEY,
|
||||||
@@ -366,8 +383,6 @@ CREATE TABLE TasklistItem
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- RegistrationData table
|
-- RegistrationData table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE RegistrationData;
|
|
||||||
|
|
||||||
CREATE TABLE RegistrationData
|
CREATE TABLE RegistrationData
|
||||||
(
|
(
|
||||||
registrationdata_id INTEGER PRIMARY KEY,
|
registrationdata_id INTEGER PRIMARY KEY,
|
||||||
@@ -380,22 +395,18 @@ CREATE TABLE RegistrationData
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- History table
|
-- History table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE History;
|
|
||||||
|
|
||||||
CREATE TABLE History
|
CREATE TABLE History
|
||||||
(
|
(
|
||||||
history_id INTEGER PRIMARY KEY,
|
history_id INTEGER PRIMARY KEY,
|
||||||
-- When it was stored
|
-- When it was stored
|
||||||
creation_date TIMESTAMP,
|
creation_date TIMESTAMP,
|
||||||
-- A checksum to keep serializations from being stored more than once
|
-- A checksum to keep INTEGERizations from being stored more than once
|
||||||
checksum VARCHAR(32) UNIQUE
|
checksum VARCHAR(32) UNIQUE
|
||||||
);
|
);
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- HistoryState table
|
-- HistoryState table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE HistoryState;
|
|
||||||
|
|
||||||
CREATE TABLE HistoryState
|
CREATE TABLE HistoryState
|
||||||
(
|
(
|
||||||
history_state_id INTEGER PRIMARY KEY,
|
history_state_id INTEGER PRIMARY KEY,
|
||||||
@@ -403,41 +414,21 @@ CREATE TABLE HistoryState
|
|||||||
);
|
);
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
-- Convenience views
|
-- Browse subsystem tables and views
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
-------------------------------------------------------
|
|
||||||
-- Item2Handle view
|
|
||||||
-------------------------------------------------------
|
|
||||||
-- Note: org.dspace.core.Constants.ITEM = 2
|
|
||||||
DROP VIEW Item2Handle;
|
|
||||||
|
|
||||||
CREATE VIEW Item2Handle as
|
|
||||||
select handle_id, handle, resource_id as item_id
|
|
||||||
from Handle where resource_type_id = 2
|
|
||||||
;
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- Community2Item view
|
-- Community2Item view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW Community2Item;
|
|
||||||
|
|
||||||
CREATE VIEW Community2Item as
|
CREATE VIEW Community2Item as
|
||||||
SELECT Community2Collection.community_id, Collection2Item.item_id
|
SELECT Community2Collection.community_id, Collection2Item.item_id
|
||||||
FROM Community2Collection, Collection2Item
|
FROM Community2Collection, Collection2Item
|
||||||
WHERE Collection2Item.collection_id = Community2Collection.collection_id
|
WHERE Collection2Item.collection_id = Community2Collection.collection_id
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------
|
|
||||||
-- Browse subsystem views
|
|
||||||
------------------------------------------------------------
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- ItemsByAuthor table
|
-- ItemsByAuthor table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE ItemsByAuthor;
|
|
||||||
|
|
||||||
CREATE TABLE ItemsByAuthor
|
CREATE TABLE ItemsByAuthor
|
||||||
(
|
(
|
||||||
items_by_author_id INTEGER PRIMARY KEY,
|
items_by_author_id INTEGER PRIMARY KEY,
|
||||||
@@ -448,8 +439,6 @@ CREATE TABLE ItemsByAuthor
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CollectionItemsByAuthor view
|
-- CollectionItemsByAuthor view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CollectionItemsByAuthor;
|
|
||||||
|
|
||||||
CREATE VIEW CollectionItemsByAuthor as
|
CREATE VIEW CollectionItemsByAuthor as
|
||||||
SELECT Collection2Item.collection_id, ItemsByAuthor.*
|
SELECT Collection2Item.collection_id, ItemsByAuthor.*
|
||||||
FROM ItemsByAuthor, Collection2Item
|
FROM ItemsByAuthor, Collection2Item
|
||||||
@@ -459,8 +448,6 @@ WHERE ItemsByAuthor.item_id = Collection2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CommunityItemsByAuthor view
|
-- CommunityItemsByAuthor view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CommunityItemsByAuthor;
|
|
||||||
|
|
||||||
CREATE VIEW CommunityItemsByAuthor as
|
CREATE VIEW CommunityItemsByAuthor as
|
||||||
SELECT Community2Item.community_id, ItemsByAuthor.*
|
SELECT Community2Item.community_id, ItemsByAuthor.*
|
||||||
FROM ItemsByAuthor, Community2Item
|
FROM ItemsByAuthor, Community2Item
|
||||||
@@ -470,9 +457,6 @@ WHERE ItemsByAuthor.item_id = Community2Item.item_id
|
|||||||
----------------------------------------
|
----------------------------------------
|
||||||
-- ItemsByTitle table
|
-- ItemsByTitle table
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
DROP TABLE ItemsByTitle;
|
|
||||||
|
|
||||||
CREATE TABLE ItemsByTitle
|
CREATE TABLE ItemsByTitle
|
||||||
(
|
(
|
||||||
items_by_title_id INTEGER PRIMARY KEY,
|
items_by_title_id INTEGER PRIMARY KEY,
|
||||||
@@ -484,8 +468,6 @@ CREATE TABLE ItemsByTitle
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CollectionItemsByTitle view
|
-- CollectionItemsByTitle view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CollectionItemsByTitle;
|
|
||||||
|
|
||||||
CREATE VIEW CollectionItemsByTitle as
|
CREATE VIEW CollectionItemsByTitle as
|
||||||
SELECT Collection2Item.collection_id, ItemsByTitle.*
|
SELECT Collection2Item.collection_id, ItemsByTitle.*
|
||||||
FROM ItemsByTitle, Collection2Item
|
FROM ItemsByTitle, Collection2Item
|
||||||
@@ -495,8 +477,6 @@ WHERE ItemsByTitle.item_id = Collection2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CommunityItemsByTitle view
|
-- CommunityItemsByTitle view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CommunityItemsByTitle;
|
|
||||||
|
|
||||||
CREATE VIEW CommunityItemsByTitle as
|
CREATE VIEW CommunityItemsByTitle as
|
||||||
SELECT Community2Item.community_id, ItemsByTitle.*
|
SELECT Community2Item.community_id, ItemsByTitle.*
|
||||||
FROM ItemsByTitle, Community2Item
|
FROM ItemsByTitle, Community2Item
|
||||||
@@ -506,8 +486,6 @@ WHERE ItemsByTitle.item_id = Community2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- ItemsByDate table
|
-- ItemsByDate table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE ItemsByDate;
|
|
||||||
|
|
||||||
CREATE TABLE ItemsByDate
|
CREATE TABLE ItemsByDate
|
||||||
(
|
(
|
||||||
items_by_date_id INTEGER PRIMARY KEY,
|
items_by_date_id INTEGER PRIMARY KEY,
|
||||||
@@ -518,8 +496,6 @@ CREATE TABLE ItemsByDate
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CollectionItemsByDate view
|
-- CollectionItemsByDate view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CollectionItemsByDate;
|
|
||||||
|
|
||||||
CREATE VIEW CollectionItemsByDate as
|
CREATE VIEW CollectionItemsByDate as
|
||||||
SELECT Collection2Item.collection_id, ItemsByDate.*
|
SELECT Collection2Item.collection_id, ItemsByDate.*
|
||||||
FROM ItemsByDate, Collection2Item
|
FROM ItemsByDate, Collection2Item
|
||||||
@@ -529,8 +505,6 @@ WHERE ItemsByDate.item_id = Collection2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CommunityItemsByDate view
|
-- CommunityItemsByDate view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CommunityItemsByDate;
|
|
||||||
|
|
||||||
CREATE VIEW CommunityItemsByDate as
|
CREATE VIEW CommunityItemsByDate as
|
||||||
SELECT Community2Item.community_id, ItemsByDate.*
|
SELECT Community2Item.community_id, ItemsByDate.*
|
||||||
FROM ItemsByDate, Community2Item
|
FROM ItemsByDate, Community2Item
|
||||||
@@ -540,8 +514,6 @@ WHERE ItemsByDate.item_id = Community2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- ItemsByDateAccessioned table
|
-- ItemsByDateAccessioned table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP TABLE ItemsByDateAccessioned;
|
|
||||||
|
|
||||||
CREATE TABLE ItemsByDateAccessioned
|
CREATE TABLE ItemsByDateAccessioned
|
||||||
(
|
(
|
||||||
items_by_date_accessioned_id INTEGER PRIMARY KEY,
|
items_by_date_accessioned_id INTEGER PRIMARY KEY,
|
||||||
@@ -552,8 +524,6 @@ CREATE TABLE ItemsByDateAccessioned
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CollectionItemsByDateAccessioned view
|
-- CollectionItemsByDateAccessioned view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CollectionItemsByDateAccessioned;
|
|
||||||
|
|
||||||
CREATE VIEW CollectionItemsByDateAccessioned as
|
CREATE VIEW CollectionItemsByDateAccessioned as
|
||||||
SELECT Collection2Item.collection_id, ItemsByDateAccessioned.*
|
SELECT Collection2Item.collection_id, ItemsByDateAccessioned.*
|
||||||
FROM ItemsByDateAccessioned, Collection2Item
|
FROM ItemsByDateAccessioned, Collection2Item
|
||||||
@@ -563,11 +533,10 @@ WHERE ItemsByDateAccessioned.item_id = Collection2Item.item_id
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- CommunityItemsByDateAccessioned view
|
-- CommunityItemsByDateAccessioned view
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DROP VIEW CommunityItemsByDateAccessioned;
|
|
||||||
|
|
||||||
CREATE VIEW CommunityItemsByDateAccessioned as
|
CREATE VIEW CommunityItemsByDateAccessioned as
|
||||||
SELECT Community2Item.community_id, ItemsByDateAccessioned.*
|
SELECT Community2Item.community_id, ItemsByDateAccessioned.*
|
||||||
FROM ItemsByDateAccessioned, Community2Item
|
FROM ItemsByDateAccessioned, Community2Item
|
||||||
WHERE ItemsByDateAccessioned.item_id = Community2Item.item_id
|
WHERE ItemsByDateAccessioned.item_id = Community2Item.item_id
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
85
dspace/etc/update-sequences.sql
Normal file
85
dspace/etc/update-sequences.sql
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
--
|
||||||
|
-- update-sequences.sql
|
||||||
|
--
|
||||||
|
-- Version: $Revision$
|
||||||
|
--
|
||||||
|
-- Date: $Date$
|
||||||
|
--
|
||||||
|
-- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
||||||
|
-- Institute of Technology. All rights reserved.
|
||||||
|
--
|
||||||
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
|
-- modification, are permitted provided that the following conditions are
|
||||||
|
-- met:
|
||||||
|
--
|
||||||
|
-- - Redistributions of source code must retain the above copyright
|
||||||
|
-- notice, this list of conditions and the following disclaimer.
|
||||||
|
--
|
||||||
|
-- - Redistributions in binary form must reproduce the above copyright
|
||||||
|
-- notice, this list of conditions and the following disclaimer in the
|
||||||
|
-- documentation and/or other materials provided with the distribution.
|
||||||
|
--
|
||||||
|
-- - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||||
|
-- Massachusetts Institute of Technology nor the names of their
|
||||||
|
-- contributors may be used to endorse or promote products derived from
|
||||||
|
-- this software without specific prior written permission.
|
||||||
|
--
|
||||||
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
-- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
-- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
-- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
-- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||||
|
-- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
-- DAMAGE.
|
||||||
|
|
||||||
|
-- SQL code to update the ID (primary key) generating sequences, if some
|
||||||
|
-- import operation has set explicit IDs.
|
||||||
|
--
|
||||||
|
-- Sequences are used to generate IDs for new rows in the database. If a
|
||||||
|
-- bulk import operation, such as an SQL dump, specifies primary keys for
|
||||||
|
-- imported data explicitly, the sequences are out of sync and need updating.
|
||||||
|
-- This SQL code does just that.
|
||||||
|
--
|
||||||
|
-- This should rarely be needed; any bulk import should be performed using the
|
||||||
|
-- org.dspace.content API which is safe to use concurrently and in multiple
|
||||||
|
-- JVMs. The SQL code below will typically only be required after a direct
|
||||||
|
-- SQL data dump from a backup or somesuch.
|
||||||
|
|
||||||
|
|
||||||
|
-- There should be one of these calls for every ID sequence defined in
|
||||||
|
-- database_schema.sql.
|
||||||
|
|
||||||
|
|
||||||
|
SELECT setval('bitstreamformatregistry_seq', max(bitstream_format_id)) FROM bitstreamformatregistry;
|
||||||
|
SELECT setval('fileextension_seq', max(file_extension_id)) FROM fileextension;
|
||||||
|
SELECT setval('bitstream_seq', max(bitstream_id)) FROM bitstream;
|
||||||
|
SELECT setval('eperson_seq', max(eperson_id)) FROM eperson;
|
||||||
|
SELECT setval('epersongroup_seq', max(eperson_group_id)) FROM epersongroup;
|
||||||
|
SELECT setval('item_seq', max(item_id)) FROM item;
|
||||||
|
SELECT setval('bundle_seq', max(bundle_id)) FROM bundle;
|
||||||
|
SELECT setval('item2bundle_seq', max(id)) FROM item2bundle;
|
||||||
|
SELECT setval('bundle2bitstream_seq', max(id)) FROM bundle2bitstream;
|
||||||
|
SELECT setval('dctyperegistry_seq', max(dc_type_id)) FROM dctyperegistry;
|
||||||
|
SELECT setval('dcvalue_seq', max(dc_value_id)) FROM dcvalue;
|
||||||
|
SELECT setval('community_seq', max(community_id)) FROM community;
|
||||||
|
SELECT setval('collection_seq', max(collection_id)) FROM collection;
|
||||||
|
SELECT setval('community2collection_seq', max(id)) FROM community2collection;
|
||||||
|
SELECT setval('collection2item_seq', max(id)) FROM collection2item;
|
||||||
|
SELECT setval('resourcepolicy_seq', max(policy_id)) FROM resourcepolicy;
|
||||||
|
SELECT setval('epersongroup2eperson_seq', max(id)) FROM epersongroup2eperson;
|
||||||
|
SELECT setval('handle_seq', max(handle_id)) FROM handle;
|
||||||
|
SELECT setval('workspaceitem_seq', max(workspace_item_id)) FROM workspaceitem;
|
||||||
|
SELECT setval('workflowitem_seq', max(workflow_id)) FROM workflowitem;
|
||||||
|
SELECT setval('tasklistitem_seq', max(tasklist_id)) FROM tasklistitem;
|
||||||
|
SELECT setval('registrationdata_seq', max(registrationdata_id)) FROM registrationdata;
|
||||||
|
SELECT setval('history_seq', max(history_id)) FROM history;
|
||||||
|
SELECT setval('historystate_seq', max(history_state_id)) FROM historystate;
|
||||||
|
SELECT setval('itemsbyauthor_seq', max(items_by_author_id)) FROM itemsbyauthor;
|
||||||
|
SELECT setval('itemsbytitle_seq', max(items_by_title_id)) FROM itemsbytitle;
|
||||||
|
SELECT setval('itemsbydate_seq', max(items_by_date_id)) FROM itemsbydate;
|
||||||
|
SELECT setval('itemsbydateaccessioned_seq', max(items_by_date_accessioned_id)) FROM itemsbydateaccessioned;
|
@@ -274,11 +274,6 @@
|
|||||||
</init-param>
|
</init-param>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>reset-id-generator</servlet-name>
|
|
||||||
<servlet-class>org.dspace.app.webui.servlet.admin.ResetIDGenServlet</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>retrieve</servlet-name>
|
<servlet-name>retrieve</servlet-name>
|
||||||
<servlet-class>org.dspace.app.webui.servlet.RetrieveServlet</servlet-class>
|
<servlet-class>org.dspace.app.webui.servlet.RetrieveServlet</servlet-class>
|
||||||
@@ -417,11 +412,6 @@
|
|||||||
<url-pattern>/register</url-pattern>
|
<url-pattern>/register</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>reset-id-generator</servlet-name>
|
|
||||||
<url-pattern>/admin/reset-id-generator</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>retrieve</servlet-name>
|
<servlet-name>retrieve</servlet-name>
|
||||||
<url-pattern>/retrieve/*</url-pattern>
|
<url-pattern>/retrieve/*</url-pattern>
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
<%--
|
|
||||||
- reset-id-generator.jsp
|
|
||||||
-
|
|
||||||
- Version: $Revision$
|
|
||||||
-
|
|
||||||
- Date: $Date$
|
|
||||||
-
|
|
||||||
- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
|
||||||
- Institute of Technology. All rights reserved.
|
|
||||||
-
|
|
||||||
- Redistribution and use in source and binary forms, with or without
|
|
||||||
- modification, are permitted provided that the following conditions are
|
|
||||||
- met:
|
|
||||||
-
|
|
||||||
- - Redistributions of source code must retain the above copyright
|
|
||||||
- notice, this list of conditions and the following disclaimer.
|
|
||||||
-
|
|
||||||
- - Redistributions in binary form must reproduce the above copyright
|
|
||||||
- notice, this list of conditions and the following disclaimer in the
|
|
||||||
- documentation and/or other materials provided with the distribution.
|
|
||||||
-
|
|
||||||
- - Neither the name of the Hewlett-Packard Company nor the name of the
|
|
||||||
- Massachusetts Institute of Technology nor the names of their
|
|
||||||
- contributors may be used to endorse or promote products derived from
|
|
||||||
- this software without specific prior written permission.
|
|
||||||
-
|
|
||||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
||||||
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
- DAMAGE.
|
|
||||||
--%>
|
|
||||||
|
|
||||||
<%--
|
|
||||||
- DB ID generator reset message
|
|
||||||
--%>
|
|
||||||
|
|
||||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
|
||||||
<dspace:layout locbar="link" navbar="admin" title="Administer">
|
|
||||||
<h1>Administration Tools</h1>
|
|
||||||
|
|
||||||
<P><Strong>Database ID generator has been reset.</P>
|
|
||||||
|
|
||||||
<P>Please select an operation from the navigation bar on the left.</P>
|
|
||||||
</dspace:layout>
|
|
||||||
|
|
@@ -76,9 +76,6 @@
|
|||||||
labels.add("Authorization");
|
labels.add("Authorization");
|
||||||
links.add("authorize");
|
links.add("authorize");
|
||||||
|
|
||||||
labels.add("Reset ID<br>Generator");
|
|
||||||
links.add("reset-id-generator");
|
|
||||||
|
|
||||||
// Get the current page, minus query string
|
// Get the current page, minus query string
|
||||||
String currentPage = UIUtil.getOriginalURL(request);
|
String currentPage = UIUtil.getOriginalURL(request);
|
||||||
int c = currentPage.indexOf( '?' );
|
int c = currentPage.indexOf( '?' );
|
||||||
|
@@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* ResetIDGenerator.java
|
|
||||||
*
|
|
||||||
* Version: $Revision$
|
|
||||||
*
|
|
||||||
* Date: $Date$
|
|
||||||
*
|
|
||||||
* Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
|
||||||
* Institute of Technology. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
|
||||||
* Massachusetts Institute of Technology nor the names of their
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
||||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
* DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dspace.app.webui.servlet.admin;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import org.dspace.app.webui.servlet.DSpaceServlet;
|
|
||||||
import org.dspace.app.webui.util.JSPManager;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.core.Context;
|
|
||||||
import org.dspace.core.LogManager;
|
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple servlet for resetting the database manager's ID generator. This is
|
|
||||||
* to work around a bug where the ID generator doesn't work when more than one
|
|
||||||
* JVM is accessing DSpace (e.g. the item importer).
|
|
||||||
*
|
|
||||||
* @author Robert Tansley
|
|
||||||
* @version $Revision$
|
|
||||||
*/
|
|
||||||
public class ResetIDGenServlet extends DSpaceServlet
|
|
||||||
{
|
|
||||||
// FIXME: This is a "tentacle" - app layer shouldn't access storage directly
|
|
||||||
|
|
||||||
/** Logger */
|
|
||||||
private static Logger log = Logger.getLogger(EditCommunitiesServlet.class);
|
|
||||||
|
|
||||||
|
|
||||||
protected void doDSGet(Context context,
|
|
||||||
HttpServletRequest request,
|
|
||||||
HttpServletResponse response)
|
|
||||||
throws ServletException, IOException, SQLException, AuthorizeException
|
|
||||||
{
|
|
||||||
DatabaseManager.resetIDGenerator();
|
|
||||||
JSPManager.showJSP(request, response,
|
|
||||||
"/admin/reset-id-generator.jsp");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -180,9 +180,15 @@ public class HistoryManager
|
|||||||
// Create a model
|
// Create a model
|
||||||
Model model = new ModelMem();
|
Model model = new ModelMem();
|
||||||
|
|
||||||
// An id for the new state
|
// A table row and id for the new state
|
||||||
Integer stateId = (flag == REMOVE) ? null :
|
Integer stateId = null;
|
||||||
new Integer(DatabaseManager.getID("HistoryState"));
|
TableRow row = null;
|
||||||
|
|
||||||
|
if (flag != REMOVE)
|
||||||
|
{
|
||||||
|
row = DatabaseManager.create(context, "HistoryState");
|
||||||
|
stateId = new Integer(row.getIntColumn("history_state_id"));
|
||||||
|
}
|
||||||
|
|
||||||
// This is the object that we're making statements about....
|
// This is the object that we're making statements about....
|
||||||
Resource obj = model.createResource(id);
|
Resource obj = model.createResource(id);
|
||||||
@@ -251,10 +257,9 @@ public class HistoryManager
|
|||||||
|
|
||||||
if (flag != REMOVE)
|
if (flag != REMOVE)
|
||||||
{
|
{
|
||||||
TableRow row = DatabaseManager.create(context, "HistoryState");
|
|
||||||
|
|
||||||
row.setColumn("history_state_id", stateId.intValue());
|
row.setColumn("history_state_id", stateId.intValue());
|
||||||
row.setColumn("object_id", id);
|
row.setColumn("object_id", id);
|
||||||
|
DatabaseManager.update(context, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringWriter swdata = new StringWriter();
|
StringWriter swdata = new StringWriter();
|
||||||
|
@@ -75,13 +75,6 @@ public class DatabaseManager
|
|||||||
/** True if initialization has been done */
|
/** True if initialization has been done */
|
||||||
private static boolean initialized = false;
|
private static boolean initialized = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* A map of unique ids.
|
|
||||||
* The key is the table name; the value is an Integer which is the
|
|
||||||
* highest value assigned.
|
|
||||||
*/
|
|
||||||
private static Map ids = new HashMap();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of database column information.
|
* A map of database column information.
|
||||||
* The key is the table name, a String; the value is
|
* The key is the table name, a String; the value is
|
||||||
@@ -263,7 +256,6 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
TableRow row = new TableRow(canonicalize(table),
|
TableRow row = new TableRow(canonicalize(table),
|
||||||
getColumnNames(table));
|
getColumnNames(table));
|
||||||
assignId(row);
|
|
||||||
insert(context, row);
|
insert(context, row);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -408,24 +400,36 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
String table = canonicalize(row.getTable());
|
String table = canonicalize(row.getTable());
|
||||||
|
|
||||||
|
// Get an ID (primary key) for this row by using the "getnextid"
|
||||||
|
// SQL function
|
||||||
|
Statement statement = context.getDBConnection().createStatement();
|
||||||
|
ResultSet rs = statement.executeQuery(
|
||||||
|
"SELECT getnextid('" + table + "') AS result");
|
||||||
|
rs.next();
|
||||||
|
int newID = rs.getInt(1);
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
// Set the ID in the table row object
|
||||||
|
row.setColumn(getPrimaryKeyColumn(table), newID);
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer()
|
StringBuffer sql = new StringBuffer()
|
||||||
.append("insert into ")
|
.append("INSERT INTO ")
|
||||||
.append(table)
|
.append(table)
|
||||||
.append(" ( ");
|
.append(" ( ");
|
||||||
|
|
||||||
ColumnInfo[] info = getColumnInfo(table);
|
ColumnInfo[] info = getColumnInfo(table);
|
||||||
|
|
||||||
for (int i = 0; i < info.length; i++ )
|
for (int i = 0; i < info.length; i++)
|
||||||
{
|
{
|
||||||
sql.append(i == 0 ? "" : ", ").append(info[i].getName());
|
sql.append(i == 0 ? "" : ",").append(info[i].getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.append(") values ( ");
|
sql.append(") VALUES ( ");
|
||||||
|
|
||||||
// Values to insert
|
// Values to insert
|
||||||
for (int i = 0; i < info.length; i++ )
|
for (int i = 0; i < info.length; i++)
|
||||||
{
|
{
|
||||||
sql.append(i == 0 ? "" : ", ").append("?");
|
sql.append(i == 0 ? "" : ",").append("?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch the syntax
|
// Watch the syntax
|
||||||
@@ -899,72 +903,6 @@ public class DatabaseManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assign an ID to row.
|
|
||||||
*
|
|
||||||
* @param row The row to assign an id to.
|
|
||||||
* @exception SQLException If a database error occurs
|
|
||||||
*/
|
|
||||||
private static synchronized void assignId (TableRow row)
|
|
||||||
throws SQLException
|
|
||||||
{
|
|
||||||
String table = canonicalize(row.getTable());
|
|
||||||
String pk = getPrimaryKeyColumn(table);
|
|
||||||
row.setColumn(pk, getID(table));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the next id for table.
|
|
||||||
*
|
|
||||||
* @param table The RDBMS table to obtain an ID for
|
|
||||||
* @return The next id
|
|
||||||
* @exception SQLException If a database error occurs
|
|
||||||
*/
|
|
||||||
public static synchronized int getID (String table)
|
|
||||||
throws SQLException
|
|
||||||
{
|
|
||||||
// Assigned ids are simply one plus the maximum value
|
|
||||||
// of the primary key column, and incremented from there.
|
|
||||||
|
|
||||||
String pk = getPrimaryKeyColumn(table);
|
|
||||||
Integer id = (Integer) ids.get(table);
|
|
||||||
int current_id = id == null ? -1 : id.intValue();
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
String sql = MessageFormat.format
|
|
||||||
("select max({0}) from {1}",
|
|
||||||
new Object[] { pk, table} );
|
|
||||||
|
|
||||||
Connection connection = null;
|
|
||||||
Statement statement = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection = getConnection();
|
|
||||||
statement = connection.createStatement();
|
|
||||||
ResultSet results = statement.executeQuery(sql);
|
|
||||||
current_id = results.next() ? results.getInt(1): -1;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (statement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException sqle) {}
|
|
||||||
}
|
|
||||||
if (connection != null)
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int new_id = current_id + 1;
|
|
||||||
ids.put(table, new Integer(new_id));
|
|
||||||
return new_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute SQL as a PreparedStatement on Connection.
|
* Execute SQL as a PreparedStatement on Connection.
|
||||||
* Bind parameters in columns to the values in the table row before
|
* Bind parameters in columns to the values in the table row before
|
||||||
@@ -1145,18 +1083,6 @@ public class DatabaseManager
|
|||||||
DriverManager.registerDriver(new SimplePool());
|
DriverManager.registerDriver(new SimplePool());
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple workaround method to reset the in-memory ID generator. This
|
|
||||||
* causes it to re-read the DB to find IDs to allocate to new objects.
|
|
||||||
* This should be invoked after another JVM has been writing to the DB.
|
|
||||||
*/
|
|
||||||
public static void resetIDGenerator()
|
|
||||||
{
|
|
||||||
// Remove cached IDs
|
|
||||||
ids = new HashMap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user