mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-23 09:53:09 +00:00
Added DBMS build tasks:
- Added schema file - Add InitializeDatabase command line class - Can now pass in "dspace.configuration" system property which will get ConfigurationManager to load a specific configuration - Added a simple log4j properties file for use during builds (e.g. when executing InitializeDatabase) - Changed a couple of INFO level logs to DEBUG in DatabaseManager git-svn-id: http://scm.dspace.org/svn/repo/trunk@7 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -55,18 +55,15 @@
|
||||
<!-- ============================================================= -->
|
||||
|
||||
<!-- Default configuration to use. This may be overridden. -->
|
||||
<property file="${basedir}/config/dspace.cfg" />
|
||||
|
||||
<!-- Default configuration directory to use. This may be overridden. -->
|
||||
<!--<property name="config.dir" value="${basedir}/config" />-->
|
||||
|
||||
<!-- Include the main DSpace configuration -->
|
||||
<!--<property file="${config.dir}/dspace.cfg" />-->
|
||||
<property name="config" value="${basedir}/config/dspace.cfg" />
|
||||
|
||||
<!-- Give user a chance to override without editing this file
|
||||
(and without typing -D each time s/he compiles it) -->
|
||||
<property file="${user.home}/.dspace.properties" />
|
||||
|
||||
<!-- Load the configuration -->
|
||||
<property file="${config}" />
|
||||
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- The DSpace class path for building -->
|
||||
@@ -75,6 +72,7 @@
|
||||
<!-- We will include the environment CLASSPATH -->
|
||||
<path id="build.class.path">
|
||||
<pathelement path="${env.CLASSPATH}"/>
|
||||
<pathelement path="${basedir}/build/classes"/>
|
||||
<fileset dir="${basedir}/lib">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
@@ -101,8 +99,6 @@
|
||||
<!-- Update the code, without clobbering existing data -->
|
||||
<!-- ============================================================= -->
|
||||
|
||||
<!-- Copies classes, lib, jsp and bin -->
|
||||
|
||||
<target name="update"
|
||||
description="Update installed code (install without clobbering data)">
|
||||
<mkdir dir="${dspace.dir}/bin"/>
|
||||
@@ -123,14 +119,13 @@
|
||||
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Do a fresh system install -->
|
||||
<!-- Do a fresh install of the code and configuration files -->
|
||||
<!-- ============================================================= -->
|
||||
|
||||
<!-- FIXME: Add dependency on DB creation/initialisation target -->
|
||||
<!-- Installs code, then config, and symlinks WEB-INF/classes to config -->
|
||||
<target name="fresh_install"
|
||||
<target name="install_code"
|
||||
depends="update"
|
||||
description="Do a fresh install of the system, overwriting any data">
|
||||
description="Do a fresh install of the system, not touching database">
|
||||
<mkdir dir="${dspace.dir}/config" />
|
||||
<mkdir dir="${assetstore.dir}" />
|
||||
<mkdir dir="${history.dir}" />
|
||||
@@ -145,6 +140,36 @@
|
||||
</target>
|
||||
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Create the database tables, removing anything already there -->
|
||||
<!-- ============================================================= -->
|
||||
|
||||
<!-- We execute InitializeDatabase, passing in the simple log4j properties
|
||||
- file in etc/ and the DSpace configuration file using system
|
||||
- properties -->
|
||||
<target name="setup_database"
|
||||
description="Create database tables, removing existing data">
|
||||
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
|
||||
classpathref="build.class.path"
|
||||
fork="yes"
|
||||
failonerror="yes">
|
||||
<jvmarg value="-Dlog4j.configuration=file:${basedir}/etc/log4j.build.properties"/>
|
||||
<jvmarg value="-Ddspace.configuration=${config}"/>
|
||||
<arg value="${basedir}/etc/database_schema.sql"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Do a fresh system install -->
|
||||
<!-- ============================================================= -->
|
||||
|
||||
<target name="fresh_install"
|
||||
depends="install_code,setup_database"
|
||||
description="Do a fresh install of the system, overwriting any data">
|
||||
</target>
|
||||
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Clean source code -->
|
||||
<!-- ============================================================= -->
|
||||
|
798
dspace/etc/database_schema.sql
Normal file
798
dspace/etc/database_schema.sql
Normal file
@@ -0,0 +1,798 @@
|
||||
--
|
||||
-- database_schema.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 SQL table definitions
|
||||
--
|
||||
-- Author: Peter Breton
|
||||
--
|
||||
-- This file is used as-is to initialize a database. Therefore,
|
||||
-- table and view definitions must be ordered correctly.
|
||||
--
|
||||
|
||||
-------------------------------------------------------
|
||||
-- BitstreamTypeRegistry table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE BitstreamTypeRegistry;
|
||||
|
||||
CREATE TABLE BitstreamTypeRegistry
|
||||
(
|
||||
bitstream_type_id INTEGER PRIMARY KEY,
|
||||
mimetype VARCHAR(48),
|
||||
short_description VARCHAR(128) UNIQUE,
|
||||
description TEXT,
|
||||
support_level INTEGER,
|
||||
-- Identifies internal types
|
||||
internal BOOL
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Bitstream table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Bitstream;
|
||||
|
||||
CREATE TABLE Bitstream
|
||||
(
|
||||
bitstream_id INTEGER PRIMARY KEY,
|
||||
bitstream_type_id INTEGER REFERENCES BitstreamTypeRegistry(bitstream_type_id),
|
||||
name VARCHAR(256),
|
||||
size INTEGER,
|
||||
checksum VARCHAR(64),
|
||||
checksum_algorithm VARCHAR(32),
|
||||
description TEXT,
|
||||
user_type_description TEXT,
|
||||
source VARCHAR(256),
|
||||
deleted BOOL
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- EPerson table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE EPerson;
|
||||
|
||||
CREATE TABLE EPerson
|
||||
(
|
||||
eperson_id INTEGER PRIMARY KEY,
|
||||
email VARCHAR(64) UNIQUE,
|
||||
password VARCHAR(64),
|
||||
firstname VARCHAR(64),
|
||||
lastname VARCHAR(64),
|
||||
active BOOL,
|
||||
require_certificate BOOL,
|
||||
phone VARCHAR(32)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- EPersonGroup table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE EPersonGroup;
|
||||
|
||||
CREATE TABLE EPersonGroup
|
||||
(
|
||||
eperson_group_id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(256) UNIQUE
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Item table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Item;
|
||||
|
||||
CREATE TABLE Item
|
||||
(
|
||||
item_id INTEGER PRIMARY KEY,
|
||||
submitter_id INTEGER REFERENCES EPerson(eperson_id),
|
||||
in_archive BOOL
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Bundle table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Bundle;
|
||||
|
||||
CREATE TABLE Bundle
|
||||
(
|
||||
bundle_id INTEGER PRIMARY KEY,
|
||||
mets_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Item2Bundle table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Item2Bundle;
|
||||
|
||||
CREATE TABLE Item2Bundle
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
item_id INTEGER REFERENCES Item(item_id),
|
||||
bundle_id INTEGER REFERENCES Bundle(bundle_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Bundle2Bitstream table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Bundle2Bitstream;
|
||||
|
||||
CREATE TABLE Bundle2Bitstream
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
bundle_id INTEGER REFERENCES Bundle(bundle_id),
|
||||
-- FIXME: UNIQUE?
|
||||
bitstream_id INTEGER REFERENCES Bitstream(bitstream_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- DCTypeRegistry table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE DCTypeRegistry;
|
||||
|
||||
CREATE TABLE DCTypeRegistry
|
||||
(
|
||||
dc_type_id INTEGER PRIMARY KEY,
|
||||
element VARCHAR(64),
|
||||
qualifier VARCHAR(64),
|
||||
scope_note TEXT,
|
||||
UNIQUE(element, qualifier)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- DCValue table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE DCValue;
|
||||
|
||||
CREATE TABLE DCValue
|
||||
(
|
||||
dc_value_id INTEGER PRIMARY KEY,
|
||||
text_value TEXT,
|
||||
text_lang VARCHAR(24),
|
||||
source_id INTEGER
|
||||
);
|
||||
|
||||
-- An index for text_value
|
||||
-- CREATE INDEX dcvalue_text_value_idx ON DCValue(text_value);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Item2DCValue table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Item2DCValue;
|
||||
|
||||
CREATE TABLE Item2DCValue
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
item_id INTEGER REFERENCES Item(item_id),
|
||||
dc_value_id INTEGER REFERENCES DCValue(dc_value_id),
|
||||
dc_type_id INTEGER REFERENCES DCTypeRegistry(dc_type_id),
|
||||
-- index, position, etc are reserved words!
|
||||
place INTEGER
|
||||
);
|
||||
|
||||
-- An index for dctypes
|
||||
CREATE INDEX dcvalue_dc_type_id_idx on Item2DCValue(dc_type_id);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- ItemVersion table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE ItemVersion;
|
||||
|
||||
CREATE TABLE ItemVersion
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
old_item_id INTEGER REFERENCES Item(item_id),
|
||||
new_item_id INTEGER REFERENCES Item(item_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Community table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Community;
|
||||
|
||||
CREATE TABLE Community
|
||||
(
|
||||
community_id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(128) UNIQUE,
|
||||
short_description VARCHAR(512),
|
||||
introductory_text TEXT,
|
||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||
copyright_text TEXT,
|
||||
side_bar_text TEXT
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Collection table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Collection;
|
||||
|
||||
CREATE TABLE Collection
|
||||
(
|
||||
collection_id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(128),
|
||||
short_description VARCHAR(512),
|
||||
introductory_text TEXT,
|
||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||
template_item_id INTEGER REFERENCES Item(item_id),
|
||||
provenance_description TEXT,
|
||||
license TEXT,
|
||||
copyright_text TEXT,
|
||||
side_bar_text TEXT,
|
||||
reviewers INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||
approvers INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||
editors INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Community2Collection table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Community2Collection;
|
||||
|
||||
CREATE TABLE Community2Collection
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
community_id INTEGER REFERENCES Community(community_id),
|
||||
collection_id INTEGER REFERENCES Collection(collection_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Collection2Item table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Collection2Item;
|
||||
|
||||
CREATE TABLE Collection2Item
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
collection_id INTEGER REFERENCES Collection(collection_id),
|
||||
item_id INTEGER REFERENCES Item(item_id)
|
||||
);
|
||||
-------------------------------------------------------
|
||||
-- ResourcePolicy table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE ResourcePolicy;
|
||||
|
||||
CREATE TABLE ResourcePolicy
|
||||
(
|
||||
policy_id INTEGER PRIMARY KEY,
|
||||
resource_type_id INTEGER,
|
||||
resource_id INTEGER,
|
||||
resource_filter INTEGER,
|
||||
resource_filter_arg INTEGER,
|
||||
action_id INTEGER,
|
||||
policy_statement VARCHAR(256),
|
||||
priority INTEGER,
|
||||
notes TEXT,
|
||||
owner_eperson_id INTEGER REFERENCES EPerson(eperson_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- EPersonGroup2EPerson table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE EPersonGroup2EPerson;
|
||||
|
||||
CREATE TABLE EPersonGroup2EPerson
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
eperson_group_id INTEGER REFERENCES EPersonGroup(eperson_group_id),
|
||||
eperson_id INTEGER REFERENCES EPerson(eperson_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Handle table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Handle;
|
||||
|
||||
CREATE TABLE Handle
|
||||
(
|
||||
handle_id INTEGER PRIMARY KEY,
|
||||
handle VARCHAR(256) UNIQUE,
|
||||
resource_type_id INTEGER,
|
||||
resource_id INTEGER
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Storage table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Storage;
|
||||
|
||||
CREATE TABLE Storage
|
||||
(
|
||||
storage_id INTEGER PRIMARY KEY,
|
||||
storage_name VARCHAR(256),
|
||||
internal_id VARCHAR(256),
|
||||
UNIQUE(storage_name, internal_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Bitstream2Storage table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE Bitstream2Storage;
|
||||
|
||||
CREATE TABLE Bitstream2Storage
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||
storage_id INTEGER REFERENCES Storage(storage_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- PersonalWorkspace table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE PersonalWorkspace;
|
||||
|
||||
CREATE TABLE PersonalWorkspace
|
||||
(
|
||||
personal_workspace_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
|
||||
multiple_titles BOOL,
|
||||
published_before BOOL,
|
||||
multiple_files BOOL,
|
||||
-- How for the user has got in the submit process
|
||||
stage_reached INTEGER
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- WorkflowItem table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE WorkflowItem;
|
||||
|
||||
CREATE TABLE WorkflowItem
|
||||
(
|
||||
workflow_id INTEGER PRIMARY KEY,
|
||||
item_id INTEGER REFERENCES Item(item_id) UNIQUE,
|
||||
collection_id INTEGER REFERENCES Collection(collection_id),
|
||||
state INTEGER,
|
||||
owner INTEGER REFERENCES EPerson(eperson_id),
|
||||
|
||||
-- Answers to questions on first page of submit UI
|
||||
multiple_titles BOOL,
|
||||
published_before BOOL,
|
||||
multiple_files BOOL
|
||||
-- Note: stage reached not applicable here - people involved in workflow
|
||||
-- can always jump around submission UI
|
||||
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- TasklistItem table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE TasklistItem;
|
||||
|
||||
CREATE TABLE TasklistItem
|
||||
(
|
||||
tasklist_id INTEGER PRIMARY KEY,
|
||||
eperson_id INTEGER REFERENCES EPerson(eperson_id),
|
||||
workflow_id INTEGER REFERENCES WorkflowItem(workflow_id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------
|
||||
-- RegistrationData table
|
||||
-------------------------------------------------------
|
||||
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
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- History table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE History;
|
||||
|
||||
CREATE TABLE History
|
||||
(
|
||||
history_id INTEGER PRIMARY KEY,
|
||||
-- The RDF
|
||||
data TEXT,
|
||||
-- When it was stored
|
||||
creation_date TIMESTAMP,
|
||||
-- A checksum to keep serializations from being stored more than once
|
||||
checksum VARCHAR(32) UNIQUE
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- HistoryState table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE HistoryState;
|
||||
|
||||
CREATE TABLE HistoryState
|
||||
(
|
||||
history_state_id INTEGER PRIMARY KEY,
|
||||
-- The id of the object
|
||||
object_id VARCHAR(64)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Example table for test purposes
|
||||
-------------------------------------------------------
|
||||
DROP TABLE TestTable;
|
||||
|
||||
CREATE TABLE TestTable
|
||||
(
|
||||
Id INTEGER PRIMARY KEY,
|
||||
Name VARCHAR(64),
|
||||
Date DATE,
|
||||
Stuff VARCHAR(255),
|
||||
Amount INTEGER
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Test table
|
||||
-------------------------------------------------------
|
||||
DROP TABLE TestTable2;
|
||||
|
||||
CREATE TABLE TestTable2
|
||||
(
|
||||
Id INTEGER PRIMARY KEY,
|
||||
Name VARCHAR(64) UNIQUE,
|
||||
Test_Table_Id INTEGER REFERENCES TestTable(Id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Test table for mapping
|
||||
-------------------------------------------------------
|
||||
DROP TABLE TestTableMapping;
|
||||
|
||||
CREATE TABLE TestTableMapping
|
||||
(
|
||||
Id INTEGER PRIMARY KEY,
|
||||
Test_Table_Id INTEGER REFERENCES TestTable(Id),
|
||||
Test_Table2_Id INTEGER REFERENCES TestTable2(Id)
|
||||
);
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- Convenience views
|
||||
------------------------------------------------------------
|
||||
|
||||
-- Views for CM API
|
||||
|
||||
-------------------------------------------------------
|
||||
-- DCResult view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW DCResult;
|
||||
|
||||
CREATE VIEW DCResult as
|
||||
SELECT Item.item_id, Item.in_archive, Item.submitter_id, dc_type_id, DCValue.*
|
||||
FROM Item2DCValue, DCValue, Item
|
||||
WHERE Item2DCValue.dc_value_id = DCValue.dc_value_id
|
||||
AND Item.item_id = Item2DCValue.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Community2Item view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW Community2Item;
|
||||
|
||||
CREATE VIEW Community2Item as
|
||||
SELECT Community2Collection.community_id, Collection2Item.item_id
|
||||
FROM Community2Collection, Collection2Item
|
||||
WHERE Collection2Item.collection_id = Community2Collection.collection_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- ItemsByAuthor view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW ItemsByAuthor;
|
||||
|
||||
CREATE VIEW ItemsByAuthor as
|
||||
SELECT DCResult.item_id, DCResult.text_value as Author
|
||||
FROM DCResult, DCTypeRegistry
|
||||
WHERE DCTypeRegistry.element = 'contributor'
|
||||
AND DCTypeRegistry.qualifier = 'author'
|
||||
AND DCTypeRegistry.dc_type_id = DCResult.dc_type_id
|
||||
AND DCResult.in_archive = 't'
|
||||
ORDER BY Author, DCResult.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CollectionItemsByAuthor view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CollectionItemsByAuthor;
|
||||
|
||||
CREATE VIEW CollectionItemsByAuthor as
|
||||
SELECT Collection2Item.collection_id, ItemsByAuthor.*
|
||||
FROM ItemsByAuthor, Collection2Item
|
||||
WHERE ItemsByAuthor.item_id = Collection2Item.item_id
|
||||
ORDER BY Author, ItemsByAuthor.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CommunityItemsByAuthor view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CommunityItemsByAuthor;
|
||||
|
||||
CREATE VIEW CommunityItemsByAuthor as
|
||||
SELECT Community2Item.community_id, ItemsByAuthor.*
|
||||
FROM ItemsByAuthor, Community2Item
|
||||
WHERE ItemsByAuthor.item_id = Community2Item.item_id
|
||||
ORDER BY Author, ItemsByAuthor.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Function sorttitle
|
||||
-------------------------------------------------------
|
||||
DROP FUNCTION sorttitle(varchar);
|
||||
|
||||
CREATE FUNCTION sorttitle(varchar) RETURNS varchar AS
|
||||
'
|
||||
declare
|
||||
title alias for $1;
|
||||
ltitle TEXT;
|
||||
stitle TEXT;
|
||||
stop TEXT;
|
||||
begin
|
||||
-- Strip out whitespace
|
||||
select into stitle trim(title);
|
||||
-- Lower-case the title (ONLY FOR COMPARISON PURPOSES)
|
||||
select into ltitle lower(stitle);
|
||||
|
||||
-- Check for occurrences of the
|
||||
select into stop ''the '';
|
||||
if position(stop in ltitle) = 1 then
|
||||
return substring(stitle, char_length(stop) + 1) || '', '' || substring(stitle, 0, char_length(stop));
|
||||
end if;
|
||||
|
||||
-- Check for occurrences of an
|
||||
select into stop ''an '';
|
||||
if position(stop in ltitle) = 1 then
|
||||
return substring(stitle, char_length(stop) + 1) || '', '' || substring(stitle, 0, char_length(stop));
|
||||
end if;
|
||||
|
||||
-- Check for occurrences of a
|
||||
select into stop ''a '';
|
||||
if position(stop in ltitle) = 1 then
|
||||
return substring(stitle, char_length(stop) + 1) || '', '' || substring(stitle, 0, char_length(stop));
|
||||
end if;
|
||||
|
||||
return stitle;
|
||||
end;
|
||||
' language 'plpgsql';
|
||||
|
||||
----------------------------------------
|
||||
-- ItemsByTitle view
|
||||
----------------------------------------
|
||||
|
||||
DROP VIEW ItemsByTitle;
|
||||
|
||||
CREATE VIEW ItemsByTitle as
|
||||
SELECT DCResult.item_id,
|
||||
DCResult.text_value as Title,
|
||||
sorttitle(DCResult.text_value) as SortTitle
|
||||
FROM DCResult, DCTypeRegistry
|
||||
WHERE DCTypeRegistry.element = 'title'
|
||||
AND DCTypeRegistry.qualifier is null
|
||||
AND DCTypeRegistry.dc_type_id = DCResult.dc_type_id
|
||||
AND DCResult.in_archive = 't'
|
||||
ORDER BY SortTitle, DCResult.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CollectionItemsByTitle view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CollectionItemsByTitle;
|
||||
|
||||
CREATE VIEW CollectionItemsByTitle as
|
||||
SELECT Collection2Item.collection_id, ItemsByTitle.*
|
||||
FROM ItemsByTitle, Collection2Item
|
||||
WHERE ItemsByTitle.item_id = Collection2Item.item_id
|
||||
ORDER BY Title, ItemsByTitle.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CommunityItemsByTitle view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CommunityItemsByTitle;
|
||||
|
||||
CREATE VIEW CommunityItemsByTitle as
|
||||
SELECT Community2Item.community_id, ItemsByTitle.*
|
||||
FROM ItemsByTitle, Community2Item
|
||||
WHERE ItemsByTitle.item_id = Community2Item.item_id
|
||||
ORDER BY Title, ItemsByTitle.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- ItemsByDate view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW ItemsByDate;
|
||||
|
||||
CREATE VIEW ItemsByDate as
|
||||
SELECT DCResult.item_id, DCResult.text_value as DateIssued
|
||||
FROM DCResult, DCTypeRegistry
|
||||
WHERE DCTypeRegistry.element = 'date'
|
||||
AND DCTypeRegistry.qualifier = 'issued'
|
||||
AND DCTypeRegistry.dc_type_id = DCResult.dc_type_id
|
||||
AND DCResult.in_archive = 't'
|
||||
ORDER BY DateIssued desc, DCResult.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CollectionItemsByDate view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CollectionItemsByDate;
|
||||
|
||||
CREATE VIEW CollectionItemsByDate as
|
||||
SELECT Collection2Item.collection_id, ItemsByDate.*
|
||||
FROM ItemsByDate, Collection2Item
|
||||
WHERE ItemsByDate.item_id = Collection2Item.item_id
|
||||
ORDER BY DateIssued desc, ItemsByDate.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CommunityItemsByDate view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CommunityItemsByDate;
|
||||
|
||||
CREATE VIEW CommunityItemsByDate as
|
||||
SELECT Community2Item.community_id, ItemsByDate.*
|
||||
FROM ItemsByDate, Community2Item
|
||||
WHERE ItemsByDate.item_id = Community2Item.item_id
|
||||
ORDER BY DateIssued desc, ItemsByDate.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- AllStorage view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW AllStorage;
|
||||
|
||||
CREATE VIEW AllStorage as
|
||||
SELECT Bitstream.*, Storage.*,
|
||||
BitstreamTypeRegistry.mimetype, BitstreamTypeRegistry.short_description
|
||||
FROM Bitstream, Storage, Bitstream2Storage, BitstreamTypeRegistry
|
||||
WHERE Bitstream.bitstream_id = Bitstream2Storage.bitstream_id
|
||||
AND Storage.storage_id = Bitstream2Storage.storage_id
|
||||
AND Bitstream.bitstream_type_id = BitstreamTypeRegistry.bitstream_type_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Item2Bitstream view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW Item2Bitstream;
|
||||
|
||||
CREATE VIEW Item2Bitstream as
|
||||
SELECT Item2Bundle.item_id, Bundle2Bitstream.bitstream_id
|
||||
FROM Item2Bundle, Bundle2Bitstream
|
||||
WHERE Item2Bundle.bundle_id = Bundle2Bitstream.bundle_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Collection2Bitstream view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW Collection2Bitstream;
|
||||
|
||||
CREATE VIEW Collection2Bitstream as
|
||||
SELECT Collection2Item.collection_id, Bundle2Bitstream.bitstream_id
|
||||
FROM Collection2Item, Item2Bundle, Bundle2Bitstream
|
||||
WHERE Collection2Item.item_id = Item2Bundle.item_id
|
||||
AND Item2Bundle.bundle_id = Bundle2Bitstream.bundle_id
|
||||
;
|
||||
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Community2Bitstream view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW Community2Bitstream;
|
||||
|
||||
CREATE VIEW Community2Bitstream as
|
||||
SELECT Community2Collection.community_id, Collection2Bitstream.bitstream_id
|
||||
FROM Community2Collection, Collection2Bitstream
|
||||
WHERE Community2Collection.collection_id = Collection2Bitstream.collection_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- WorkflowItemsBySubmitter view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW WorkflowItemBySubmitter;
|
||||
|
||||
CREATE VIEW WorkflowItemBySubmitter as
|
||||
SELECT WorkflowItem.*, Item.submitter_id
|
||||
FROM WorkflowItem, Item
|
||||
WHERE WorkflowItem.item_id = Item.item_id;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- PersonalWorkspaceBySubmitter view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW PersonalWorkspaceBySubmitter;
|
||||
|
||||
CREATE VIEW PersonalWorkspaceBySubmitter as
|
||||
SELECT PersonalWorkspace.*, Item.submitter_id
|
||||
FROM PersonalWorkspace, Item
|
||||
WHERE PersonalWorkspace.item_id = Item.item_id;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- ItemsByDateAccessioned view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW ItemsByDateAccessioned;
|
||||
|
||||
CREATE VIEW ItemsByDateAccessioned as
|
||||
SELECT DCResult.item_id, DCResult.text_value as DateAccessioned
|
||||
FROM DCResult, DCTypeRegistry
|
||||
WHERE DCTypeRegistry.element = 'date'
|
||||
AND DCTypeRegistry.qualifier = 'accessioned'
|
||||
AND DCTypeRegistry.dc_type_id = DCResult.dc_type_id
|
||||
AND DCResult.in_archive = 't'
|
||||
ORDER BY DateAccessioned, DCResult.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CollectionItemsByDateAccessioned view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CollectionItemsByDateAccessioned;
|
||||
|
||||
CREATE VIEW CollectionItemsByDateAccessioned as
|
||||
SELECT Collection2Item.collection_id, ItemsByDateAccessioned.*
|
||||
FROM ItemsByDateAccessioned, Collection2Item
|
||||
WHERE ItemsByDateAccessioned.item_id = Collection2Item.item_id
|
||||
ORDER BY DateAccessioned desc, ItemsByDateAccessioned.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- CommunityItemsByDateAccessioned view
|
||||
-------------------------------------------------------
|
||||
DROP VIEW CommunityItemsByDateAccessioned;
|
||||
|
||||
CREATE VIEW CommunityItemsByDateAccessioned as
|
||||
SELECT Community2Item.community_id, ItemsByDateAccessioned.*
|
||||
FROM ItemsByDateAccessioned, Community2Item
|
||||
WHERE ItemsByDateAccessioned.item_id = Community2Item.item_id
|
||||
ORDER BY DateAccessioned desc, ItemsByDateAccessioned.item_id
|
||||
;
|
||||
|
||||
-------------------------------------------------------
|
||||
-- Item2Handle view
|
||||
-------------------------------------------------------
|
||||
-- Note: DSpaceTypes.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
|
||||
|
||||
;
|
13
dspace/etc/log4j.build.properties
Normal file
13
dspace/etc/log4j.build.properties
Normal file
@@ -0,0 +1,13 @@
|
||||
##########################################################
|
||||
# Simple log4j configuration file used during build tasks
|
||||
##########################################################
|
||||
|
||||
# Set root category priority to INFO and its only appender to A1.
|
||||
log4j.rootCategory=INFO, A1
|
||||
|
||||
# A1 is set to be a ConsoleAppender.
|
||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||
|
||||
# A1 uses PatternLayout.
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.A1.layout.ConversionPattern=%d %-5p %c @ %m%n
|
BIN
dspace/lib/postgresql.jar
Normal file
BIN
dspace/lib/postgresql.jar
Normal file
Binary file not shown.
@@ -41,13 +41,33 @@
|
||||
|
||||
package org.dspace.core;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
|
||||
|
||||
/**
|
||||
* Class for reading the DSpace system configuration. The main configuration
|
||||
* is read in as properties from a standard properties file. Email templates
|
||||
* and configuration files for other tools are also be accessed via this class.
|
||||
* <P>
|
||||
* The main configuration is by default read from the <em>resource</em>
|
||||
* <code>/dspace.cfg</code>. To specify a different configuration, the
|
||||
* system property <code>dspace.configuration</code> should be set to the
|
||||
* <em>filename</em> of the configuration file.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ConfigurationManager
|
||||
{
|
||||
/** log4j category */
|
||||
private static Category log =
|
||||
Category.getInstance(ConfigurationManager.class);
|
||||
|
||||
/** The configuration properties */
|
||||
private static Properties properties = null;
|
||||
|
||||
@@ -99,8 +119,7 @@ public class ConfigurationManager
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// FIXME: Should be logged properly
|
||||
System.err.println("Warning: Number format error in property"
|
||||
log.warn("Warning: Number format error in property: "
|
||||
+ property);
|
||||
}
|
||||
}
|
||||
@@ -168,20 +187,41 @@ public class ConfigurationManager
|
||||
*/
|
||||
private static void loadProperties()
|
||||
{
|
||||
InputStream is;
|
||||
|
||||
if (properties != null) return;
|
||||
|
||||
try
|
||||
{
|
||||
InputStream is = ConfigurationManager.class.getResourceAsStream(
|
||||
// Has the default configuration location been overridden?
|
||||
String configProperty = System.getProperty("dspace.configuration");
|
||||
|
||||
if (configProperty != null)
|
||||
{
|
||||
// Load the overriding configuration
|
||||
is = new FileInputStream(configProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load configuration from default location
|
||||
is = ConfigurationManager.class.getResourceAsStream(
|
||||
"/dspace.cfg");
|
||||
}
|
||||
|
||||
if (is==null)
|
||||
{
|
||||
log.fatal("Cannot find dspace.cfg");
|
||||
System.exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
properties = new Properties();
|
||||
properties.load(is);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// FIXME: Should be logged properly
|
||||
System.err.println("Can't load configuration: " + e);
|
||||
e.printStackTrace();
|
||||
log.fatal("Can't load configuration", e);
|
||||
// FIXME: Maybe something more graceful here, but with the
|
||||
// configuration we can't do anything
|
||||
System.exit(1);
|
||||
|
@@ -552,8 +552,8 @@ public class DatabaseManager
|
||||
if (endMarker == -1)
|
||||
continue;
|
||||
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Running database query \"" + sql + "\"");
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Running database query \"" + sql + "\"");
|
||||
|
||||
SQL = sql.toString();
|
||||
|
||||
@@ -565,8 +565,8 @@ public class DatabaseManager
|
||||
}
|
||||
catch (SQLWarning sqlw)
|
||||
{
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Got SQL Warning: " + sqlw, sqlw);
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Got SQL Warning: " + sqlw, sqlw);
|
||||
}
|
||||
catch (SQLException sqle)
|
||||
{
|
||||
|
103
dspace/src/org/dspace/storage/rdbms/InitializeDatabase.java
Normal file
103
dspace/src/org/dspace/storage/rdbms/InitializeDatabase.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* InitializeDatabase.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.storage.rdbms;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
|
||||
/**
|
||||
* Command-line executed class for initializing the DSpace database. This
|
||||
* should be invoked with a single argument, the filename of the database
|
||||
* schema file.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class InitializeDatabase
|
||||
{
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Category log =
|
||||
Category.getInstance(InitializeDatabase.class);
|
||||
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
// Usage checks
|
||||
if (argv.length != 1)
|
||||
{
|
||||
log.warn("Schema file not specified");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
log.info("Initializing Database");
|
||||
|
||||
Connection connection = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DatabaseManager.getConnection();
|
||||
DatabaseManager.loadSql(new FileReader(argv[0]));
|
||||
System.exit(0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.fatal("Caught exception:", e);
|
||||
System.exit(1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
{
|
||||
DatabaseManager.freeConnection(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user