}
}
-if (!defined $tags) {$tags = 'Circs.Holds.Actors.Bibs.Assets.Money'};
+if (!defined $tags) {$tags = 'circs.holds.actors.bibs.assets.money'};
if (!defined $analyst) { abort('--analyst must be supplied'); }
if (!defined $report_title) { abort('--report_title must be supplied'); }
abort('must specify --added_page_file and --added_page_title') unless defined $added_page_file and defined $added_page_title;
}
if (defined $added_page_file) { $added_page_file = $MIGGITDIR . $added_page_file; }
-if ($MIGSCHEMA eq 'full') { $MIGSCHEMA = ''; }
my $dbh = Mig::db_connect();
my $report_file = create_report_name($report_title);
$report_file = $MIGGITDIR . $report_file;
-my $mig_func_schema = $MIGSCHEMA;
-open(my $fh, '>', $report_file) or die "Could not open output file!";
+open(my $fh, '>', $report_file) or abort("Could not open output file!");
write_title_page($report_title,$fh,$analyst);
print $fh "<<<\n";
print $fh "== $added_page_title\n";
print "$added_page_file\t$added_page_title\n";
- open(my $an,'<:encoding(UTF-8)', $added_page_file) or die "Could not open $added_page_file !";
+ open(my $an,'<:encoding(UTF-8)', $added_page_file) or abort("Could not open $added_page_file!");
while ( my $line = <$an> ) {
print $fh $line;
}
my $fdrop = $func->findvalue('./drop');
my $fcreate = $func->findvalue('./create');
my $fname = $func->findvalue('./name');
- $fdrop =~ s/mig_func_schema/$mig_func_schema/g;
- $fcreate =~ s/mig_func_schema/$mig_func_schema/g;
my $sdrop = $dbh->prepare($fdrop);
my $screate = $dbh->prepare($fcreate);
print "dropping function $fname ... ";
foreach my $t (@report_tags) {
print "\n\n=========== Starting to process tag $t\n";
print "==========================================\n";
+
+ my @asset_files;
+ foreach my $asset ($dom->findnodes('//asset')) {
+ if (index($asset->findvalue('./tag'),$t) != -1) {
+ push @asset_files, $asset->findvalue('./file');
+ }
+ }
+
+ foreach my $fname (@asset_files) {
+ my $asset_path = $mig_path . '../mig-asc/' . $fname;
+ open my $a, $asset_path or abort("Could not open $fname.");
+ while ( my $l = <$a> ) {
+ print $fh $l;
+ }
+ print $fh "<<<\n";
+ }
+
print_section_header(ucfirst($t),$fh);
my $linecount = $lines_per_page;
my $r;
- my @report_names;
+ my @asset_files;
+ foreach my $asset ($dom->findnodes('//asset')) {
+ if (index($asset->findvalue('./tag'),$t) != -1) {
+ push @asset_files, $asset->findvalue('./file');
+ }
+ }
+ my @report_names;
foreach my $report ($dom->findnodes('//report')) {
if (index($report->findvalue('./tag'),$t) != -1 and $report->findvalue('./iteration') eq '0') {
push @report_names, $report->findvalue('./name');
}
}
-
- print Dumper(@report_names);
#only has one level of failover now but could change to array of hashes and loops
+ #but this keeps it simple and in practice I haven't needed more than two
foreach my $rname (@report_names) {
my %report0;
my %report1;
}
}
}
-# end of main logic
print "\n";
close $fh;
+############ end of main logic
+
sub find_report {
my $dom = shift;
my $tag = shift;
print "iteration $iteration ";
foreach my $node ($dom->findnodes('//report')) {
if ($node->findvalue('./tag') =~ $tag and $node->findvalue('./iteration') eq $iteration and $node->findvalue('./name') eq $name) {
- print "succeeded ... ";
+ print "succeeded ... \n";
%report = (
name => $node->findvalue('./name'),
report_title => $node->findvalue('./report_title'),
return %report;
}
}
- print "failed ... ";
+ print "failed ... \n";
return %report = (
name => "eaten by grue"
);
my $query = shift;
my $MIGSCHEMA = shift;
- my $i = 0;
+ my $i;
my $return_flag = 1;
my @qe = split(/ /,$query);
- my @tables = grep /MIGSCHEMA/, @qe;
-
+ $i = @qe;
+ $i--;
+ my @tables;
+ while ($i > -1) {
+ if ($qe[$i] eq 'FROM' or $qe[$i] eq 'JOIN') {
+ my $q = $i + 1;
+ if ($qe[$q] ne '(SELECT') {
+ push @tables, $qe[$q];
+ }
+ }
+ $i--;
+ }
print "checking tables ... ";
+
+ $i = 0;
foreach my $table (@tables) {
- $table =~ s/MIGSCHEMA.//g;
$table =~ s/\)//g;
$table =~ s/\<//g;
- my $sql = 'SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = \'' . $MIGSCHEMA . '\' AND table_name = \'' . $table . '\');';
+ my $sql;
+ my $schema;
+ if (index($table,'.') != -1) {
+ $schema = (split /\./,$table)[0];
+ $table = (split /\./,$table)[1];
+ }
+ if (defined $schema) {
+ $sql = 'SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = \'' . $schema . '\' AND table_name = \'' . $table . '\');';
+ } else {
+ $sql = 'SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = \'' . $MIGSCHEMA . '\' AND table_name = \'' . $table . '\');';
+ }
my $sth = $dbh->prepare($sql);
$sth->execute();
while (my @row = $sth->fetchrow_array) {
my $fh = shift;
my %report = @_;
my $query = $report{query};
- $query =~ s/MIGSCHEMA/$MIGSCHEMA/g;
- $query =~ s/mig_func_schema/$mig_func_schema/g;
+ print "$query\n";
my $sth = $dbh->prepare($query);
$sth->execute();