Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author: daigle $'
7
 *     '$Date: 2008-07-06 21:25:34 -0700 (Sun, 06 Jul 2008) $'
8
 * '$Revision: 4080 $'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24
 
25
/*
26
 *Logging -- table to store metadata and data access log
27
 */
28
CREATE SEQUENCE access_log_id_seq;
29
CREATE TABLE access_log (
30
  entryid       INT8 default nextval ('access_log_id_seq'), -- the identifier for the log event
31
  ip_address    VARCHAR(512),   -- the ip address inititiating the event
32
  principal     VARCHAR(512),   -- the user initiiating the event
33
  docid         VARCHAR(250),	-- the document id #
34
  event         VARCHAR(512),   -- the code symbolizing the event type
35
  date_logged   TIMESTAMP,      -- the datetime on which the event occurred
36
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
37
);
38

    
39
/* 
40
 * harvest_site_schedule -- table to store harvest sites and schedule info
41
 */
42
CREATE TABLE harvest_site_schedule (
43
  site_schedule_id INT8,         -- unique id
44
  documentlisturl  VARCHAR(255), -- URL of the site harvest document list
45
  ldapdn           VARCHAR(255), -- LDAP distinguished name for site account
46
  datenextharvest  DATE,         -- scheduled date of next harvest
47
  datelastharvest  DATE,         -- recorded date of last harvest
48
  updatefrequency  INT8,         -- the harvest update frequency
49
  unit             VARCHAR(50),  -- update unit -- days weeks or months
50
  contact_email    VARCHAR(50),  -- email address of the site contact person
51
  ldappwd          VARCHAR(20),  -- LDAP password for site account
52
  CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
53
);
54

    
55
/* 
56
 * harvest_log -- table to log entries for harvest operations
57
 */
58
CREATE TABLE harvest_log (
59
  harvest_log_id         INT8,          -- unique id
60
  harvest_date           DATE,          -- date of the current harvest
61
  status                 INT8,          -- non-zero indicates an error status
62
  message                VARCHAR(1000), -- text message for this log entry
63
  harvest_operation_code VARCHAR(30),   -- the type of harvest operation
64
  site_schedule_id       INT8,          -- site schedule id, or 0 if no site
65
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
66
);
67

    
68
/* 
69
 * harvest_detail_log -- table to log detailed info about documents that
70
 *                       generated errors during the harvest
71
 */
72
CREATE TABLE harvest_detail_log (
73
  detail_log_id          INT8,          -- unique id
74
  harvest_log_id         INT8,          -- ponter to the related log entry
75
  scope                  VARCHAR(50),   -- document scope
76
  identifier             INT8,          -- document identifier
77
  revision               INT8,          -- document revision
78
  document_url           VARCHAR(255), -- document URL
79
  error_message          VARCHAR(1000), -- text error message
80
  document_type          VARCHAR(100),  -- document type
81
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
82
  CONSTRAINT harvest_detail_log_fk 
83
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
84
);
85

    
86
/*
87
 * Modify the xml_index.path to the new larger size
88
 */
89

    
90
/* Move data to the table 'temp'*/
91
CREATE TABLE temp AS 
92
	Select * from xml_index;
93
DROP TABLE xml_index;
94

    
95
/* Create the table again */
96
CREATE TABLE xml_index (
97
	nodeid INT8,		-- the unique node id
98
	path VARCHAR(1000),	-- precomputed path through tree
99
	docid VARCHAR(250),	-- index to the document id
100
	doctype VARCHAR(100),	-- public id indicating document type
101
        parentnodeid INT8,     -- id of the parent of the node represented
102
					-- by this row
103
   CONSTRAINT xml_index_pk PRIMARY KEY (nodeid,path),
104
   CONSTRAINT xml_index_nodeid_fk FOREIGN KEY (nodeid) REFERENCES xml_nodes,
105
   CONSTRAINT xml_index_docid_fk 
106
		FOREIGN KEY (docid) REFERENCES xml_documents
107
);
108

    
109
CREATE INDEX xml_index_idx1 ON xml_index (path);
110

    
111
/* Insert data */
112
INSERT INTO xml_index (nodeid, path, docid, doctype, parentnodeid)
113
	SELECT nodeid, path, docid, doctype, parentnodeid
114
		from temp;
115

    
116
/* Drop temp table */
117
DROP TABLE temp;
118

    
119
/*
120
 * Update the XML_CATALOG table with new entries, and change old ones
121
 */
122
INSERT INTO xml_catalog (entry_type, public_id, system_id)
123
  VALUES ('Schema', '@eml2_0_1namespace@', '/schema/eml-2.0.1/eml.xsd');
124
UPDATE xml_catalog
125
  SET system_id = '/schema/eml-2.0.0/eml.xsd'
126
  WHERE public_id = '@eml2_0_0namespace@';
127
UPDATE xml_catalog
128
  SET system_id = '/schema/eml-2.0.0/stmml.xsd'
129
  WHERE public_id = '@stmmlnamespace@';
(33-33/67)