root/gs2-extensions/tdb/trunk/perllib/DBDrivers/BaseDBDriver.pm @ 30318

Revision 30318, 5.0 KB (checked in by jmt12, 5 years ago)

Initial checkin of object-oriented rewrite of the dbutils stuff to bring it more into line with plugins and classifiers.

  • Property svn:executable set to *
Line 
1###############################################################################
2#
3# BaseDBDriver.pm -- base class for all the database drivers
4# A component of the Greenstone digital library software from the New Zealand
5# Digital Library Project at the University of Waikato, New Zealand.
6#
7# Copyright (C) 1999-2015 New Zealand Digital Library Project
8#
9# This program is free software; you can redistribute it and/or modify it under
10# the terms of the GNU General Public License as published by the Free Software
11# Foundation; either version 2 of the License, or (at your option) any later
12# version.
13#
14# This program is distributed in the hope that it will be useful, but WITHOUT
15# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17# more details.
18#
19# You should have received a copy of the GNU General Public License along with
20# this program; if not, write to the Free Software Foundation, Inc., 675 Mass
21# Ave, Cambridge, MA 02139, USA.
22#
23###############################################################################
24
25package BaseDBDriver;
26
27# Pragma
28use strict;
29
30# Libaries
31use gsprintf 'gsprintf';
32
33###############################################################################
34## Private Functions
35###############################################################################
36
37
38## @function _convert_infodb_hash_to_string(hashmap)
39#
40sub _convert_infodb_hash_to_string
41{
42    my $infodb_map = shift(@_);
43    my $infodb_entry_value = "";
44    foreach my $infodb_value_key (keys(%$infodb_map)) {
45        foreach my $infodb_value (@{$infodb_map->{$infodb_value_key}}) {
46            $infodb_entry_value .= "<$infodb_value_key>" . $infodb_value . "\n";
47        }
48    }
49    return $infodb_entry_value;
50}
51## _convert_infodb_hash_to_string(hashmap) => string ##
52
53
54## @function _convert_infodb_string_to_hash(string)
55#
56sub _convert_infodb_string_to_hash
57{
58    my $infodb_entry_value = shift(@_);
59    my $infodb_map = ();
60
61    if (!defined $infodb_entry_value) {
62    print STDERR "Warning: No value to convert into a infodb hashtable\n";
63    }
64    else {
65        while ($infodb_entry_value =~ /^<(.*?)>(.*)$/mg) {
66            my $infodb_value_key = $1;
67            my $infodb_value = $2;
68
69            if (!defined($infodb_map->{$infodb_value_key})) {
70                $infodb_map->{$infodb_value_key} = [ $infodb_value ];
71            }
72            else {
73                push(@{$infodb_map->{$infodb_value_key}}, $infodb_value);
74            }
75    }
76    }
77
78    return $infodb_map;
79}
80## _convert_infodb_string_to_hash(string) => hashmap ##
81
82
83###############################################################################
84## Public Functions
85###############################################################################
86
87
88## @function supports_datestamp()
89#
90sub supports_datestamp
91{
92    return 0;
93}
94## supports_datestamp() => integer ##
95
96
97## @function supports_merge()
98#
99sub supports_merge
100{
101    return 0;
102}
103## supports_merge() => integer ##
104
105
106## @function supports_rss()
107#
108sub supports_rss
109{
110    return 0;
111}
112## supports_rss() => integer ##
113
114
115###############################################################################
116## Virtual Functions
117###############################################################################
118
119
120## @function close_infodb_write_handle
121#
122sub close_infodb_write_handle
123{
124    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
125    die("\n");
126}
127## close_infodb_write_handle ##
128
129
130## @function delete_infodb_entry
131#
132sub delete_infodb_entry
133{
134    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
135    die("\n");
136}
137## delete_infodb_entry ##
138
139
140## @function get_infodb_file_path
141#
142sub get_infodb_file_path
143{
144    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
145    die("\n");
146}
147## get_infodb_file_path ##
148
149
150## @function merge_databases
151#
152sub merge_databases
153{
154    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
155    die("\n");
156}
157## merge_databases ##
158
159
160## @function open_infodb_write_handle
161#
162sub open_infodb_write_handle
163{
164    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
165    die("\n");
166}
167## open_infodb_write_handle ##
168
169
170## @function set_infodb_entry()
171#
172sub set_infodb_entry
173{
174    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
175    die("\n");
176}
177## set_infodb_entry() => void ##
178
179
180## @function read_infodb_file
181#
182sub read_infodb_file
183{
184    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
185    die("\n");
186}
187## read_infodb_file ##
188
189
190## @function read_infodb_keys
191#
192sub read_infodb_keys
193{
194    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
195    die("\n");
196}
197## read_infodb_keys ##
198
199
200## @function write_infodb_entry
201#
202sub write_infodb_entry
203{
204    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
205    die("\n");
206}
207## write_infodb_entry ##
208
209
210## @function write_infodb_rawentry
211#
212sub write_infodb_rawentry
213{
214    gsprintf(STDERR, (caller(0))[3] . " {common.must_be_implemented}\n");
215    die("\n");
216}
217## write_infodb_rawentry ##
218
2191;
Note: See TracBrowser for help on using the browser.