9 |
|
|
10 |
use WebPAC::Common 0.02; |
use WebPAC::Common 0.02; |
11 |
use WebPAC::Lookup; |
use WebPAC::Lookup; |
12 |
use WebPAC::Input::ISIS; |
use WebPAC::Input::ISIS 0.02; |
13 |
use WebPAC::Store 0.03; |
use WebPAC::Store 0.03; |
14 |
use WebPAC::Normalize::XML; |
use WebPAC::Normalize::XML; |
15 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
74 |
$log->info("database $database doesn't have inputs defined"); |
$log->info("database $database doesn't have inputs defined"); |
75 |
} |
} |
76 |
|
|
77 |
|
my @supported_inputs = keys %{ $config->{webpac}->{inputs} }; |
78 |
|
|
79 |
foreach my $input (@inputs) { |
foreach my $input (@inputs) { |
80 |
|
|
81 |
my $type = lc($input->{type}); |
my $type = lc($input->{type}); |
82 |
|
|
83 |
die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); |
die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs)); |
84 |
|
|
85 |
my $lookup = new WebPAC::Lookup( |
my $lookup = new WebPAC::Lookup( |
86 |
lookup_file => $input->{lookup}, |
lookup_file => $input->{lookup}, |
87 |
); |
); |
88 |
|
|
89 |
$log->info("working on input $input->{path} [$input->{type}]"); |
my $input_module = $config->{webpac}->{inputs}->{$type}; |
90 |
|
|
91 |
|
$log->info("working on input $input->{path} [$input->{type}] using $input_module"); |
92 |
|
|
93 |
|
sub new_input { |
94 |
|
my $name = shift; |
95 |
|
my $args = shift; |
96 |
|
new $name->($args); |
97 |
|
} |
98 |
|
|
99 |
my $isis = new WebPAC::Input::ISIS( |
my $input = new_input($input_module,{ |
100 |
code_page => $config->{webpac}->{webpac_encoding}, |
code_page => $config->{webpac}->{webpac_encoding}, |
101 |
limit_mfn => $input->{limit}, |
limit_mfn => $input->{limit}, |
102 |
lookup => $lookup, |
lookup => $lookup, |
103 |
); |
}); |
104 |
|
$log->logdie("can't create input using $input_module") unless ($input); |
105 |
|
|
106 |
my $maxmfn = $isis->open( |
my $maxmfn = $input->open( |
107 |
filename => $input->{path}, |
path => $input->{path}, |
108 |
code_page => $input->{encoding}, # database encoding |
code_page => $input->{encoding}, # database encoding |
109 |
); |
); |
110 |
|
|
116 |
prefix => $input->{name}, |
prefix => $input->{name}, |
117 |
); |
); |
118 |
|
|
119 |
$n->open( |
my $normalize_path = $input->{normalize}->{path}; |
120 |
tag => $input->{normalize}->{tag}, |
|
121 |
xml_file => $input->{normalize}->{path}, |
if ($normalize_path =~ m/\.xml$/i) { |
122 |
); |
$n->open( |
123 |
|
tag => $input->{normalize}->{tag}, |
124 |
|
xml_file => $input->{normalize}->{path}, |
125 |
|
); |
126 |
|
} elsif ($normalize_path =~ m/\.(?:yml|yaml)$/i) { |
127 |
|
$n->open_yaml( |
128 |
|
path => $normalize_path, |
129 |
|
tag => $input->{normalize}->{tag}, |
130 |
|
); |
131 |
|
} |
132 |
|
|
133 |
for ( 0 ... $isis->size ) { |
for ( 0 ... $input->size ) { |
134 |
|
|
135 |
my $row = $isis->fetch || next; |
my $row = $input->fetch || next; |
136 |
|
|
137 |
my $mfn = $row->{'000'}->[0] || die "can't find MFN"; |
my $mfn = $row->{'000'}->[0] || die "can't find MFN"; |
138 |
|
|