source: gs2-extensions/apache-jena/trunk/src/perllib/jenaTDBBuilder.pm@ 28802

Last change on this file since 28802 was 28802, checked in by ak19, 10 years ago

Removed 'die' statements in favour of rint to STDERR to allow the perl process to continue, rather than stopping abruptly.

File size: 3.6 KB
Line 
1###########################################################################
2#
3# jenaTDBBuilder.pm -- topup builder that gets jenaTDB initialized correctly
4#
5# A component of the Greenstone digital library software
6# from the New Zealand Digital Library Project at the
7# University of Waikato, New Zealand.
8#
9# Copyright (C) 1999 New Zealand Digital Library Project
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24#
25###########################################################################
26
27package jenaTDBBuilder;
28
29use strict;
30no strict 'refs'; # allow filehandles to be variables and viceversa
31
32use util;
33use FileUtils;
34
35use extrabuilder;
36
37sub BEGIN {
38 @jenaTDBBuilder::ISA = ('extrabuilder');
39}
40
41
42sub new {
43 my $class = shift(@_);
44 my $self = new extrabuilder (@_);
45 $self = bless $self, $class;
46
47 $self->{'buildtype'} = "jenaTDB";
48
49 return $self;
50}
51
52
53sub default_buildproc {
54 my $self = shift (@_);
55
56 return "jenaTDBBuildproc";
57}
58
59
60sub build_indexes {
61 my $self = shift (@_);
62 my ($indexname) = @_;
63
64 my $outhandle = $self->{'outhandle'};
65 my $build_dir = $self->{'build_dir'};
66 my $verbosity = $self->{'verbosity'};
67
68 print $outhandle "\n*** Apache Jena TDB-configured Tripple store\n" if ($verbosity >= 1);
69
70 my $jenaTDB_dir = &util::filename_cat($build_dir, "jenaTDB");
71
72 if (! -d $jenaTDB_dir) {
73 &FileUtils::makeAllDirectories($jenaTDB_dir);
74 }
75
76 my $opt_create_index = ($self->{'incremental'}) ? "" : "-removeold";
77
78
79 if ($opt_create_index) {
80
81 # init an jenaTDB database
82
83# my $adb_filename = &util::filename_cat($jenaTDB_dir,"lsh-features.adb");
84
85 print $outhandle "\n creating jenaTDB dataset for collection\n" if ($verbosity >= 1);
86
87# my $init_cmd = "jenaTDB -N -d $adb_filename";
88# my $init_status = system($init_cmd);
89# if ($init_status != 0) {
90# print STDERR "Error: failed to initialize the jenaTDB database\n";
91# print STDERR " $adb_filename\n";
92# print STDERR " $!\n";
93# if ($verbosity>=2) {
94# print STDERR " cmd: $init_cmd\n";
95# }
96# return;
97# }
98
99 }
100
101 # Run the docs through the jenaTDB document processor
102
103 $self->{'buildproc'}->set_mode ('text');
104 $self->{'buildproc'}->reset();
105
106 # If '-removeold' in effect (i.e. *not* keepold), then clear out
107 # the triple-store graph for this collection
108
109 if (!$self->{'keepold'}) {
110 my $collection = $self->{'collection'};
111 my $cmd = "gs-triplestore-reset $collection";
112
113 my $status = system($cmd);
114 if ($status == 0) {
115 print $outhandle " => removeold: Deleting triplestore graph for $collection\n";
116 }
117 else {
118 print STDERR "Error: failed to run:\n $cmd\n$!\n";
119 print STDERR " Graph has not been deleted\n";
120 }
121 }
122
123 &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
124 $self->{'buildproc'}, $self->{'maxdocs'});
125 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
126 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
127 &plugin::end($self->{'pluginfo'});
128
129
130}
131
1321;
133
Note: See TracBrowser for help on using the repository browser.