X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fprocess%2Fmeta-import.cgi;h=5a97d1160ae8e0fc0cb0231431c43ae7ea4614e2;hp=4cdecafc44f2dafb54888c07151d81ae4b954b8f;hb=3ce7691203a7737406bf2d4442f7fd84b81f847e;hpb=c1bb4ddb71147d0571bd301a6d8c452fdf0e1bc9 diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi index 4cdecafc4..5a97d1160 100644 --- a/httemplate/misc/process/meta-import.cgi +++ b/httemplate/misc/process/meta-import.cgi @@ -1,5 +1,5 @@ -<%= include("/elements/header.html",'Map tables') %> +<% include("/elements/header.html",'Map tables') %>
+% +% #use DBIx::DBSchema; +% my $schema = new_native DBIx::DBSchema +% map { $cgi->param($_) } qw( data_source username password ); +% foreach my $field (qw( data_source username password )) { + + VALUE="<% $cgi->param($field) %>"> +% } +% +% my %schema; +% use Tie::DxHash; +% tie %schema, 'Tie::DxHash'; +% if ( $cgi->param('schema') ) { +% my $schema_string = $cgi->param('schema'); +% + +% +% %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ +% or die "guru meditation #420: $_"; +% ( $1 => $2 ); +% } +% split( /\n/, $schema_string ); +% } +% +% #first page +% unless ( $cgi->param('magic') ) { -<% - #use DBIx::DBSchema; - my $schema = new_native DBIx::DBSchema - map { $cgi->param($_) } qw( data_source username password ); - foreach my $field (qw( data_source username password )) { %> - VALUE="<%= $cgi->param($field) %>"> - <% } - - my %schema; - use Tie::DxHash; - tie %schema, 'Tie::DxHash'; - if ( $cgi->param('schema') ) { - my $schema_string = $cgi->param('schema'); - %> <% - %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ - or die "guru meditation #420: $_"; - ( $1 => $2 ); - } - split( /\n/, $schema_string ); - } - - #first page - unless ( $cgi->param('magic') ) { %> - <%= hashmaker('schema', [ $schema->tables ], + <% hashmaker('schema', [ $schema->tables ], [ grep !/^h_/, dbdef->tables ], ) %>
- <% +% +% +% #second page +% } elsif ( $cgi->param('magic') eq 'process' ) { - #second page - } elsif ( $cgi->param('magic') eq 'process' ) { %> - <% - - my %unique; - foreach my $table ( keys %schema ) { - - my @from_columns = $schema->table($table)->columns; - my @fs_columns = dbdef->table($schema{$table})->columns; - - %> - <%= hashmaker( $table.'__'.$unique{$table}++, +% +% +% my %unique; +% foreach my $table ( keys %schema ) { +% +% my @from_columns = $schema->table($table)->columns; +% my @fs_columns = dbdef->table($schema{$table})->columns; +% +% + + <% hashmaker( $table.'__'.$unique{$table}++, \@from_columns => \@fs_columns, $table => $schema{$table}, ) %>


- <% - - } +% +% +% } +% +% - %>
- <% +% +% +% #third (results) +% } elsif ( $cgi->param('magic') eq 'process2' ) { +% +% print "
\n";
+%
+%    my %unique;
+%    foreach my $table ( keys %schema ) {
+%      ( my $spaces = $table ) =~ s/./ /g;
+%      print "'$table' => { 'table' => '$schema{$table}',\n".
+%            #(length($table) x ' '). "         'map'   => {\n";
+%            "$spaces        'map'   => {\n";
+%      my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
+%                         or die "guru meditation #420: $_";
+%                       ( $1 => $2 );
+%                     }
+%                 split( /\n/, $cgi->param($table.'__'.$unique{$table}++) );
+%      foreach ( keys %map ) {
+%        print "$spaces                     '$_' => '$map{$_}',\n";
+%      }
+%      print "$spaces                   },\n";
+%      print "$spaces      },\n";
+%
+%    }
+%    print "\n
"; +% +% } else { +% warn "unrecognized magic: ". $cgi->param('magic'); +% } +% +% - #third (results) - } elsif ( $cgi->param('magic') eq 'process2' ) { - - print "
\n";
-
-    my %unique;
-    foreach my $table ( keys %schema ) {
-      ( my $spaces = $table ) =~ s/./ /g;
-      print "'$table' => { 'table' => '$schema{$table}',\n".
-            #(length($table) x ' '). "         'map'   => {\n";
-            "$spaces        'map'   => {\n";
-      my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
-                         or die "guru meditation #420: $_";
-                       ( $1 => $2 );
-                     }
-                 split( /\n/, $cgi->param($table.'__'.$unique{$table}++) );
-      foreach ( keys %map ) {
-        print "$spaces                     '$_' => '$map{$_}',\n";
-      }
-      print "$spaces                   },\n";
-      print "$spaces      },\n";
-
-    }
-    print "\n
"; - - } else { - warn "unrecognized magic: ". $cgi->param('magic'); - } - - %>
+% +% #hashmaker widget +% sub hashmaker { +% my($name, $from, $to, $labelfrom, $labelto) = @_; +% my $fromsize = scalar(@$from); +% my $tosize = scalar(@$to); +% "'. +% '
$labelfrom$labelto
". +% qq!\n
". +% qq!!. +% '
'. +% qq!\n
". +% qq!!. +% '
'. +% qq!!. +% '
'. +% qq!!. +% '
'. +% "". +% ''; +% } +% +% - <% - #hashmaker widget - sub hashmaker { - my($name, $from, $to, $labelfrom, $labelto) = @_; - my $fromsize = scalar(@$from); - my $tosize = scalar(@$to); - "'. - '
$labelfrom$labelto
". - qq!\n
". - qq!!. - '
'. - qq!\n
". - qq!!. - '
'. - qq!!. - '
'. - qq!!. - '
'. - "". - ''; - } - -%>