3 |
use Carp; |
use Carp; |
4 |
use Text::Iconv; |
use Text::Iconv; |
5 |
use Config::IniFiles; |
use Config::IniFiles; |
6 |
|
use XML::Simple; |
7 |
|
|
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
35 |
|
|
36 |
=cut |
=cut |
37 |
|
|
38 |
|
# mapping between data type and tag which specify |
39 |
|
# format in XML file |
40 |
|
my %type2tag = ( |
41 |
|
'isis' => 'isis', |
42 |
|
# 'excel' => 'column', |
43 |
|
# 'marc' => 'marc', |
44 |
|
# 'feed' => 'feed' |
45 |
|
); |
46 |
|
|
47 |
sub new { |
sub new { |
48 |
my $class = shift; |
my $class = shift; |
49 |
my $self = {@_}; |
my $self = {@_}; |
77 |
|
|
78 |
$self->{indexer_config_file} = new Config::IniFiles( -file => $self->{config_file} ) || croak "can't open '$self->{config_file}'"; |
$self->{indexer_config_file} = new Config::IniFiles( -file => $self->{config_file} ) || croak "can't open '$self->{config_file}'"; |
79 |
|
|
|
# read global config parametars |
|
|
foreach my $var (qw( |
|
|
dbi_dbd |
|
|
dbi_dsn |
|
|
dbi_user |
|
|
dbi_passwd |
|
|
show_progress |
|
|
my_unac_filter |
|
|
)) { |
|
|
$self->{global_config}->{$var} = $self->{global_config_file}->val('global', $var); |
|
|
} |
|
|
|
|
80 |
return $self; |
return $self; |
81 |
} |
} |
82 |
|
|
125 |
# create Text::Iconv object |
# create Text::Iconv object |
126 |
my $cp = Text::Iconv->new($code_page,$self->{'code_page'}); |
my $cp = Text::Iconv->new($code_page,$self->{'code_page'}); |
127 |
|
|
128 |
|
print STDERR "reading ISIS database '",$arg->{'filename'},"'\n" if ($self->{'debug'}); |
129 |
|
|
130 |
my $isis_db = OpenIsis::open($arg->{'filename'}); |
my $isis_db = OpenIsis::open($arg->{'filename'}); |
131 |
|
|
132 |
my $maxmfn = OpenIsis::maxRowid( $isis_db ) || 1; |
my $maxmfn = OpenIsis::maxRowid( $isis_db ) || 1; |
133 |
|
|
134 |
$maxmfn = $self->{limit_mfn} if ($self->{limit_mfn}); |
$maxmfn = $self->{limit_mfn} if ($self->{limit_mfn}); |
135 |
|
|
136 |
|
print STDERR "processing $maxmfn records...\n" if ($self->{'debug'}); |
137 |
|
|
138 |
# read database |
# read database |
139 |
for (my $mfn = 1; $mfn <= $maxmfn; $mfn++) { |
for (my $mfn = 1; $mfn <= $maxmfn; $mfn++) { |
140 |
|
|
195 |
return $self->{'data'}->{$mfn}; |
return $self->{'data'}->{$mfn}; |
196 |
} |
} |
197 |
|
|
198 |
|
=head2 open_import_xml |
199 |
|
|
200 |
|
Read file from C<import_xml/> directory and parse it. |
201 |
|
|
202 |
|
$webpac->open_import_xml(type => 'isis'); |
203 |
|
|
204 |
|
=cut |
205 |
|
|
206 |
|
sub open_import_xml { |
207 |
|
my $self = shift; |
208 |
|
|
209 |
|
my $arg = {@_}; |
210 |
|
confess "need type to load file from import_xml/" if (! $arg->{'type'}); |
211 |
|
|
212 |
|
my $type = $arg->{'type'}; |
213 |
|
|
214 |
|
my $type_base = $type; |
215 |
|
$type_base =~ s/_.*$//g; |
216 |
|
|
217 |
|
my $f = "./import_xml/$type.xml"; |
218 |
|
confess "import_xml file '$f' doesn't exist!" if (! -e "$f"); |
219 |
|
|
220 |
|
print STDERR "reading '$f'\n" if ($self->{'debug'}); |
221 |
|
|
222 |
|
$self->{'import_xml'} = XMLin($f, |
223 |
|
ForceArray => [ $type2tag{$type_base}, 'config', 'format' ], |
224 |
|
ForceContent => 1 |
225 |
|
); |
226 |
|
|
227 |
|
print Dumper($self->{'import_xml'}); |
228 |
|
|
229 |
|
} |
230 |
|
|
231 |
=head2 create_lookup |
=head2 create_lookup |
232 |
|
|
233 |
Create lookup from record using lookup definition. |
Create lookup from record using lookup definition. |