source: gs3-extensions/structured-image/trunk/perllib/sasOpenAnnotationBuilder.pm@ 38290

Last change on this file since 38290 was 38290, checked in by davidb, 8 months ago

Initial cut at Perl code to replace SUBMIT-ALL-OPENANNOTATIONS.sh script

File size: 4.0 KB
Line 
1###########################################################################
2#
3# sasOpenAnnotationBuilder.pm -- topup builder that gets sasOpenAnnotation 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 sasOpenAnnotationBuilder;
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 @sasOpenAnnotationBuilder::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'} = "sasOpenAnnotation";
48
49 return $self;
50}
51
52
53sub default_buildproc {
54 my $self = shift (@_);
55
56 return "sasOpenAnnotationBuildproc";
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*** SimpleAnnotationStore (SAS) Indexing/Storing OpenAnnotations\n" if ($verbosity >= 1);
69
70# my $sasOpenAnnotation_dir = &util::filename_cat($build_dir, "sasOpenAnnotation");
71
72# if (! -d $sasOpenAnnotation_dir) {
73# &FileUtils::makeAllDirectories($sasOpenAnnotation_dir);
74# }
75
76 my $opt_create_index = ($self->{'incremental'}) ? "" : "-removeold";
77
78
79 if ($opt_create_index) {
80
81 # init an sasOpenAnnotation database
82
83# my $adb_filename = &util::filename_cat($sasOpenAnnotation_dir,"lsh-features.adb");
84
85# print $outhandle "\n creating sasOpenAnnotation dataset for collection\n" if ($verbosity >= 1);
86
87# my $init_cmd = "sasOpenAnnotation -N -d $adb_filename";
88# my $init_status = system($init_cmd);
89# if ($init_status != 0) {
90# print STDERR "Error: failed to initialize the sasOpenAnnotation 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 sasOpenAnnotation 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 IIIFManifest graphs for this collection
108
109 if (!$self->{'keepold'}) {
110 print STDERR "**** Find out if it is possible to delete (for each document in the last build) \n";
111 print STDERR "***** all exising openannotation-list<num>.json entries\n";
112
113
114# my $collection = $self->{'collection'};
115# my $cmd = "gs-triplestore-reset3 $collection";
116#
117# my $status = system($cmd);
118# if ($status == 0) {
119# print $outhandle " => removeold: Deleting triplestore graph for $collection\n";
120# }
121# else {
122# print STDERR "Error: failed to run:\n $cmd\n$!\n";
123# print STDERR " Graph has not been deleted\n";
124# }
125 }
126
127 &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
128 $self->{'buildproc'}, $self->{'maxdocs'});
129 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
130 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
131 &plugin::end($self->{'pluginfo'});
132
133
134}
135
1361;
Note: See TracBrowser for help on using the repository browser.