X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FSchema%2FGraph.pm;h=897e53562bbc205d53d722022535a2180ab78c9c;hb=44659089c28216f1984873bc4aa8641e2e0e3410;hp=50b703be48ffabd244e73d5358a15cc8c1850d8a;hpb=10f36920865d9a07d6572df77e47ffb71f821a93;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Schema/Graph.pm b/lib/SQL/Translator/Schema/Graph.pm index 50b703b..897e535 100644 --- a/lib/SQL/Translator/Schema/Graph.pm +++ b/lib/SQL/Translator/Schema/Graph.pm @@ -2,11 +2,11 @@ package SQL::Translator::Schema::Graph; use strict; +use base 'Class::Base'; + use Data::Dumper; -$Data::Dumper::Maxdepth = 3; +local $Data::Dumper::Maxdepth = 3; -use Log::Log4perl qw(:easy); -Log::Log4perl->easy_init($ERROR); use SQL::Translator::Schema::Graph::Node; use SQL::Translator::Schema::Graph::Edge; use SQL::Translator::Schema::Graph::Port; @@ -22,12 +22,15 @@ use constant HyperEdge => 'SQL::Translator::Schema::Graph::HyperEdge'; use Class::MakeMethods::Template::Hash ( 'new --and_then_init' => 'new', object => [ - 'translator' => {class => 'SQL::Translator'}, - ], - 'hash' => [ qw( node translator) ], + 'translator' => {class => 'SQL::Translator'}, + ], + 'hash' => [ qw( node ) ], 'number --counter' => [ qw( order ) ], ); +use vars qw/$DEBUG/; +$DEBUG = 0 unless defined $DEBUG; + sub init { my $self = shift; @@ -173,7 +176,6 @@ sub init { } my $graph = $self; #hack - my $log = Log::Log4perl->get_logger('SQL.Translator.Schema.Graph'); # # create methods @@ -208,8 +210,8 @@ sub init { $hyperedge->push_thatfield($edge->thisfield); $hyperedge->push_thatviafield($edge->thatfield); } - $log->debug($edge->thisfield->name); - $log->debug($edge->thatfield->name); + $self->debug($edge->thisfield->name); + $self->debug($edge->thatfield->name); } if ($hyperedge->count_thisnode == 1 and $hyperedge->count_thatnode == 1) { @@ -222,18 +224,18 @@ sub init { $hyperedge->type('many2many'); } - $log->debug($_) foreach sort keys %::SQL::Translator::Schema::Graph::HyperEdge::; + $self->debug($_) foreach sort keys %::SQL::Translator::Schema::Graph::HyperEdge::; #node_to won't always be defined b/c of multiple edges to a single other node if (defined($node_to)) { - $log->debug($node_from->name); - $log->debug($node_to->name); + $self->debug($node_from->name); + $self->debug($node_to->name); if (scalar($hyperedge->thisnode) > 1) { - $log->debug($hyperedge->type ." via ". $hyperedge->vianode->name); + $self->debug($hyperedge->type ." via ". $hyperedge->vianode->name); my $i = 0; foreach my $thisnode ( $hyperedge->thisnode ) { - $log->debug($thisnode->name .' '. + $self->debug($thisnode->name .' '. $hyperedge->thisfield_index(0)->name .' -> '. $hyperedge->thisviafield_index($i)->name .' '. $hyperedge->vianode->name .' '. @@ -252,16 +254,4 @@ sub init { } -=head2 translator - -get the SQL::Translator instance that instatiated me - -=cut - -sub translator { - my $self = shift; - $self->{'translator'} = shift if @_; - return $self->{'translator'}; -} - 1;