[open-ils-commits] r8159 - trunk/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 5 21:00:31 EST 2007
Author: miker
Date: 2007-12-05 20:40:49 -0500 (Wed, 05 Dec 2007)
New Revision: 8159
Modified:
trunk/Open-ILS/src/sql/Pg/020.schema.functions.sql
trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
Log:
removing erroneous commit -- thanks berick!
Modified: trunk/Open-ILS/src/sql/Pg/020.schema.functions.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/020.schema.functions.sql 2007-12-06 01:30:59 UTC (rev 8158)
+++ trunk/Open-ILS/src/sql/Pg/020.schema.functions.sql 2007-12-06 01:40:49 UTC (rev 8159)
@@ -1,3 +1,80 @@
+CREATE OR REPLACE FUNCTION public.non_filing_normalize ( TEXT, "char" ) RETURNS TEXT AS $$
+ SELECT SUBSTRING(
+ REGEXP_REPLACE(
+ REGEXP_REPLACE(
+ $1,
+ E'\W*$',
+ ''
+ ),
+ ' ',
+ ' '
+ ),
+ CASE
+ WHEN $2::INT NOT BETWEEN 48 AND 57 THEN 1
+ ELSE $2::TEXT::INT + 1
+ END
+ );
+$$ LANGUAGE SQL STRICT IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION public.naco_normalize( TEXT, TEXT ) RETURNS TEXT AS $func$
+ my $txt = lc(shift);
+ my $sf = shift;
+
+ $txt =~ s/\pM+//go; # Remove diacritics
+
+ $txt =~ s/\xE6/AE/go; # Convert ae digraph
+ $txt =~ s/\x{153}/OE/go;# Convert oe digraph
+ $txt =~ s/\xFE/TH/go; # Convert Icelandic thorn
+
+ $txt =~ tr/\x{2070}\x{2071}\x{2072}\x{2073}\x{2074}\x{2075}\x{2076}\x{2077}\x{2078}\x{2079}\x{207A}\x{207B}/0123456789+-/;# Convert superscript numbers
+ $txt =~ tr/\x{2080}\x{2081}\x{2082}\x{2083}\x{2084}\x{2085}\x{2086}\x{2087}\x{2088}\x{2089}\x{208A}\x{208B}/0123456889+-/;# Convert subscript numbers
+
+ $txt =~ tr/\x{0251}\x{03B1}\x{03B2}\x{0262}\x{03B3}/AABGG/; # Convert Latin and Greek
+ $txt =~ tr/\x{2113}\xF0\!\"\(\)\-\{\}\<\>\;\:\.\?\xA1\xBF\/\\\@\*\%\=\xB1\+\xAE\xA9\x{2117}\$\xA3\x{FFE1}\xB0\^\_\~\`/LD /; # Convert Misc
+ $txt =~ tr/\'\[\]\|//d; # Remove Misc
+
+ if ($sf =~ /^a/o) {
+ my $commapos = index($txt,',');
+ if ($commapos > -1) {
+ if ($commapos != length($txt) - 1) {
+ my @list = split /,/, $txt;
+ my $first = shift @list;
+ $txt = $first . ',' . join(' ', @list);
+ } else {
+ $txt =~ s/,/ /go;
+ }
+ }
+ } else {
+ $txt =~ s/,/ /go;
+ }
+
+ $txt =~ s/\s+/ /go; # Compress multiple spaces
+ $txt =~ s/^\s+//o; # Remove leading space
+ $txt =~ s/\s+$//o; # Remove trailing space
+
+ return $txt;
+$func$ LANGUAGE 'plperlu' STRICT IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION public.naco_normalize( TEXT ) RETURNS TEXT AS $func$
+ SELECT public.naco_normalize($1,'');
+$func$ LANGUAGE 'sql' STRICT IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION public.call_number_dewey( TEXT ) RETURNS TEXT AS $$
+ my $txt = shift;
+ $txt =~ s/^\s+//o;
+ $txt =~ s/[\[\]\{\}\(\)`'"#<>\*\?\-\+\$\\]+//o;
+ $txt =~ s/\s+$//o;
+ if (/(\d{3}(?:\.\d+)?)/o) {
+ return $1;
+ } else {
+ return (split /\s+/, $txt)[0];
+ }
+$$ LANGUAGE 'plperl' STRICT IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION public.call_number_dewey( TEXT, INT ) RETURNS TEXT AS $$
+ SELECT SUBSTRING(call_number_dewey($1) FROM 1 FOR $2);
+$$ LANGUAGE SQL STRICT IMMUTABLE;
+
CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement ) RETURNS anyelement AS $$
SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END;
$$ LANGUAGE SQL STABLE;
Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2007-12-06 01:30:59 UTC (rev 8158)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2007-12-06 01:40:49 UTC (rev 8159)
@@ -80,27 +80,26 @@
CREATE TABLE action.circulation (
- create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
- target_copy BIGINT NOT NULL, -- asset.copy.id
- circ_lib INT NOT NULL, -- actor.org_unit.id
- circ_staff INT NOT NULL, -- actor.usr.id
- checkin_staff INT, -- actor.usr.id
- checkin_lib INT, -- actor.org_unit.id
- renewal_remaining INT NOT NULL, -- derived from "circ duration" rule
+ target_copy BIGINT NOT NULL, -- asset.copy.id
+ circ_lib INT NOT NULL, -- actor.org_unit.id
+ circ_staff INT NOT NULL, -- actor.usr.id
+ checkin_staff INT, -- actor.usr.id
+ checkin_lib INT, -- actor.org_unit.id
+ renewal_remaining INT NOT NULL, -- derived from "circ duration" rule
due_date TIMESTAMP WITH TIME ZONE,
- stop_fines_time TIMESTAMP WITH TIME ZONE,
- checkin_time TIMESTAMP WITH TIME ZONE,
- duration INTERVAL, -- derived from "circ duration" rule
- fine_interval INTERVAL NOT NULL DEFAULT '1 day'::INTERVAL, -- derived from "circ fine" rule
- recuring_fine NUMERIC(6,2), -- derived from "circ fine" rule
- max_fine NUMERIC(6,2), -- derived from "max fine" rule
- phone_renewal BOOL NOT NULL DEFAULT FALSE,
- desk_renewal BOOL NOT NULL DEFAULT FALSE,
- opac_renewal BOOL NOT NULL DEFAULT FALSE,
- duration_rule TEXT NOT NULL, -- name of "circ duration" rule
- recuring_fine_rule TEXT NOT NULL, -- name of "circ fine" rule
- max_fine_rule TEXT NOT NULL, -- name of "max fine" rule
- stop_fines TEXT CHECK (stop_fines IN ('CHECKIN','CLAIMSRETURNED','LOST','MAXFINES','RENEW','LONGOVERDUE'))
+ stop_fines_time TIMESTAMP WITH TIME ZONE,
+ checkin_time TIMESTAMP WITH TIME ZONE,
+ duration INTERVAL, -- derived from "circ duration" rule
+ fine_interval INTERVAL NOT NULL DEFAULT '1 day'::INTERVAL, -- derived from "circ fine" rule
+ recuring_fine NUMERIC(6,2), -- derived from "circ fine" rule
+ max_fine NUMERIC(6,2), -- derived from "max fine" rule
+ phone_renewal BOOL NOT NULL DEFAULT FALSE,
+ desk_renewal BOOL NOT NULL DEFAULT FALSE,
+ opac_renewal BOOL NOT NULL DEFAULT FALSE,
+ duration_rule TEXT NOT NULL, -- name of "circ duration" rule
+ recuring_fine_rule TEXT NOT NULL, -- name of "circ fine" rule
+ max_fine_rule TEXT NOT NULL, -- name of "max fine" rule
+ stop_fines TEXT CHECK (stop_fines IN ('CHECKIN','CLAIMSRETURNED','LOST','MAXFINES','RENEW','LONGOVERDUE'))
) INHERITS (money.billable_xact);
ALTER TABLE action.circulation ADD PRIMARY KEY (id);
CREATE INDEX circ_open_xacts_idx ON action.circulation (usr) WHERE xact_finish IS NULL;
More information about the open-ils-commits
mailing list