Producer::Turnkey obsolete. now rely on TTSchema parser (see concommitant
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema / Graph / Node.pm
CommitLineData
0caaf4c3 1package SQL::Translator::Schema::Graph::Node;
2
3use strict;
4
5use Class::MakeMethods::Template::Hash (
6 new => [ 'new' ],
7 'array_of_objects -class SQL::Translator::Schema::Graph::Edge' => [ qw( edges ) ],
8 'array_of_objects -class SQL::Translator::Schema::Graph::CompoundEdge' => [ qw( compoundedges ) ],
9 'array_of_objects -class SQL::Translator::Schema::Graph::HyperEdge' => [ qw( hyperedges ) ],
7a1eb8c0 10 #'hash' => [ qw( many via has edgecount data_fields) ],
7611bcd7 11 #'hash' => [ qw( many via has data_fields) ],
a0249514 12 scalar => [ qw( base name order primary_key primary_key_accessor table is_trivial_link ) ],
0caaf4c3 13 number => [ qw( order ) ],
14);
15
7611bcd7 16sub many {
17 my($self) = shift;
18
19 $self->{_many} ||= {};
20
21 if(scalar(@_) == 1){
22 my $k = shift;
23 return $self->{_many}{$k};
24 } elsif(@_) {
25 my %arg = @_;
26
27 foreach my $k (keys %arg){
28 #warn $a,"\t",$arg{$k};
29 $self->{_many}{$k} = $arg{$k};
30 }
31
32 return %arg;
33 } else {
34 return $self->{_many};
35 }
36}
37
38sub via {
39 my($self) = shift;
40
41 $self->{_via} ||= {};
42
43 if(scalar(@_) == 1){
44 my $k = shift;
45 return $self->{_via}{$k};
46 } elsif(@_) {
47 my %arg = @_;
48
49 foreach my $k (keys %arg){
50 #warn $a,"\t",$arg{$k};
51 $self->{_via}{$k} = $arg{$k};
52 }
53
54 return %arg;
55 } else {
56 return $self->{_via};
57 }
58}
59
60sub has {
61 my($self) = shift;
62
63 $self->{_has} ||= {};
64
65 if(scalar(@_) == 1){
66 my $k = shift;
67 return $self->{_has}{$k};
68 } elsif(@_) {
69 my %arg = @_;
70
71 foreach my $k (keys %arg){
72 #warn $a,"\t",$arg{$k};
73 $self->{_has}{$k} = $arg{$k};
74 }
75
76 return %arg;
77 } else {
78 return $self->{_has};
79 }
80}
81
7a1eb8c0 82sub edgecount {
83 my($self) = shift;
84
85 $self->{_edgecount} ||= {};
86
87 if(scalar(@_) == 1){
88 my $k = shift;
89 return $self->{_edgecount}{$k};
90 } elsif(@_) {
91 my %arg = @_;
92
93 foreach my $k (keys %arg){
94 #warn $a,"\t",$arg{$k};
95 $self->{_edgecount}{$k} = $arg{$k};
96 }
97
98 return %arg;
99 } else {
100 return $self->{_edgecount};
101 }
102}
103
7611bcd7 104sub data_fields {
105 my($self) = shift;
106
107 $self->{_data_fields} ||= {};
108
109 if(scalar(@_) == 1){
110 my $k = shift;
111 return $self->{_data_fields}{$k};
112 } elsif(@_) {
113 my %arg = @_;
114
115 foreach my $k (keys %arg){
116 #warn $a,"\t",$arg{$k};
117 $self->{_data_fields}{$k} = $arg{$k};
118 }
119
120 return %arg;
121 } else {
122 return $self->{_data_fields};
123 }
124}
125
0caaf4c3 1261;