line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Workbench::Parser::Index; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: An index of the ER model |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
71
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
305
|
|
6
|
11
|
|
|
11
|
|
46
|
use warnings; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
324
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
61
|
use Moo; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
61
|
|
9
|
11
|
|
|
11
|
|
3181
|
use Scalar::Util qw(blessed); |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
5517
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.09'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has node => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
isa => sub { |
18
|
|
|
|
|
|
|
blessed $_[0] && $_[0]->isa( 'XML::LibXML::Element' ); |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has table => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
isa => sub { |
26
|
|
|
|
|
|
|
blessed $_[0] && $_[0]->isa( 'MySQL::Workbench::Parser::Table' ); |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub BUILD { |
32
|
51
|
|
|
51
|
1
|
381
|
my $self = shift; |
33
|
51
|
|
|
|
|
110
|
$self->_parse; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has id => ( is => 'rwp' ); |
37
|
|
|
|
|
|
|
has name => ( is => 'rwp' ); |
38
|
|
|
|
|
|
|
has type => ( is => 'rwp' ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has columns => ( |
41
|
|
|
|
|
|
|
is => 'rwp', |
42
|
|
|
|
|
|
|
isa => sub { |
43
|
|
|
|
|
|
|
ref $_[0] && ref $_[0] eq 'ARRAY'; |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
lazy => 1, |
46
|
|
|
|
|
|
|
default => sub { [] }, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub as_hash { |
51
|
25
|
|
|
25
|
1
|
45
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
25
|
|
|
|
|
77
|
my %info; |
54
|
|
|
|
|
|
|
|
55
|
25
|
|
|
|
|
43
|
for my $attr ( qw(name type columns) ) { |
56
|
75
|
|
|
|
|
462
|
$info{$attr} = $self->$attr(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
25
|
|
|
|
|
184
|
return \%info; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse { |
63
|
51
|
|
|
51
|
|
74
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
51
|
|
|
|
|
114
|
my $node = $self->node; |
66
|
|
|
|
|
|
|
|
67
|
51
|
|
|
|
|
96
|
for my $key ( qw(id) ) { |
68
|
51
|
|
|
|
|
160
|
my $value = $node->findvalue( './value[@key="' . $key . '"]' ); |
69
|
51
|
|
|
|
|
3392
|
my $method = $self->can( '_set_' . $key ); |
70
|
51
|
|
|
|
|
182
|
$self->$method( $value ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
51
|
|
|
|
|
964
|
my $mapping = $self->table->column_mapping; |
74
|
51
|
|
|
|
|
395
|
my @column_ids = map{ $_->textContent }$node->findnodes( './/link[@key="referencedColumn"]' ); |
|
57
|
|
|
|
|
1955
|
|
75
|
51
|
|
|
|
|
142
|
my @columns = map{ $mapping->{$_} }@column_ids; |
|
57
|
|
|
|
|
717
|
|
76
|
51
|
|
|
|
|
908
|
$self->_set_columns( \@columns ); |
77
|
|
|
|
|
|
|
|
78
|
51
|
|
|
|
|
338
|
my $name = $node->findvalue( './value[@key="name"]' ); |
79
|
51
|
|
|
|
|
3841
|
$self->_set_name( $name ); |
80
|
|
|
|
|
|
|
|
81
|
51
|
|
|
|
|
113
|
my $type = $node->findvalue( './/value[@key="indexType"]' ); |
82
|
51
|
|
|
|
|
4138
|
$self->_set_type( $type ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |