line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Autodia::Handler::umbrello; |
2
|
|
|
|
|
|
|
require Exporter; |
3
|
1
|
|
|
1
|
|
1318
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Autodia::Handler::umbrello - AutoDia handler for umbrello |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This provides Autodia with the ability to read umbrello files, allowing you to convert them via the Diagram Export methods to images (using GraphViz and VCG) or html/xml using custom templates. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
The umbrello handler will parse umbrello xml/xmi files using XML::Simple and populating the diagram object with class, superclass and package objects. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
the umbrello handler is registered in the Autodia.pm module, which contains a hash of language names and the name of their respective language - in this case: |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Autodia::Handler::umbrello; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $handler = Autodia::Handler::umbrello->New(\%Config); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$handler->Parse(filename); # where filename includes full or relative path. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
28
|
1
|
|
|
1
|
|
5
|
use Autodia::Handler; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@ISA = ('Autodia::Handler' ,'Exporter'); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
7
|
use Autodia::Diagram; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
33
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
393
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 CONSTRUCTION METHOD |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use Autodia::Handler::umbrello; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $handler = Autodia::Handler::umbrello->New(\%Config); |
44
|
|
|
|
|
|
|
This creates a new handler using the Configuration hash to provide rules selected at the command line. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 ACCESS METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$handler->Parse(filename); # where filename includes full or relative path. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This parses the named file and returns 1 if successful or 0 if the file could not be opened. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
##################### |
56
|
|
|
|
|
|
|
# Constructor Methods |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# new inherited from Autodia::Handler |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
# Access Methods |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# parse_file inherited from Autodia::Handler |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
66
|
|
|
|
|
|
|
# Internal Methods |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# _initialise inherited from Autodia::Handler |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _parse { |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
my $fh = shift; |
73
|
|
|
|
|
|
|
my $filename = shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $Diagram = $self->{Diagram}; |
76
|
|
|
|
|
|
|
my $xmldoc = XMLin($filename, ForceArray => 1, ForceContent => 1); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# get version |
79
|
|
|
|
|
|
|
my $version = $xmldoc->{'XMI.header'}[0]{'XMI.documentation'}[0]{'XMI.exporterVersion'}[0]{content}; |
80
|
|
|
|
|
|
|
my $is_newstyle = 0; |
81
|
|
|
|
|
|
|
if ($version =~ /(\d\.\d).\d/) { |
82
|
|
|
|
|
|
|
$is_newstyle = 1 if ($1 > 1.1); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
my $umlclasses_are_here = ( $is_newstyle ) ? 'UML:Model' : 'umlobjects' ; |
85
|
|
|
|
|
|
|
my @relationships; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
foreach my $classname (keys %{$xmldoc->{'XMI.content'}[0]{$umlclasses_are_here}[0]{'UML:Class'}}) { |
88
|
|
|
|
|
|
|
print "handling Class $classname : \n"; |
89
|
|
|
|
|
|
|
my $class = $xmldoc->{'XMI.content'}[0]{$umlclasses_are_here}[0]{'UML:Class'}{$classname}; |
90
|
|
|
|
|
|
|
my $Class = Autodia::Diagram::Class->new($classname); |
91
|
|
|
|
|
|
|
$Diagram->add_class($Class); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
foreach my $method ( @{get_methods($class)} ) { |
94
|
|
|
|
|
|
|
$Class->add_operation($method); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
foreach my $attribute (@{get_attributes($class)}) { |
97
|
|
|
|
|
|
|
$Class->add_attribute( $attribute ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# get superclass / stereotype |
101
|
|
|
|
|
|
|
if ($class->{stereotype}) { |
102
|
|
|
|
|
|
|
my $Superclass = Autodia::Diagram::Superclass->new($class->{stereotype}); |
103
|
|
|
|
|
|
|
# add superclass to diagram |
104
|
|
|
|
|
|
|
my $exists_already = $Diagram->add_superclass($Superclass); |
105
|
|
|
|
|
|
|
if (ref $exists_already) { |
106
|
|
|
|
|
|
|
$Superclass = $exists_already; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
# create new inheritance |
109
|
|
|
|
|
|
|
my $Inheritance = Autodia::Diagram::Inheritance->new($Class, $Superclass); |
110
|
|
|
|
|
|
|
# add inheritance to superclass |
111
|
|
|
|
|
|
|
$Superclass->add_inheritance($Inheritance); |
112
|
|
|
|
|
|
|
# add inheritance to class |
113
|
|
|
|
|
|
|
$Class->add_inheritance($Inheritance); |
114
|
|
|
|
|
|
|
# add inheritance to diagram |
115
|
|
|
|
|
|
|
$Diagram->add_inheritance($Inheritance); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
return; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
############################ |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub get_methods { |
125
|
|
|
|
|
|
|
my $class = shift; |
126
|
|
|
|
|
|
|
my $return = []; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
foreach my $methodname (keys %{$class->{'UML:Operation'}}) { |
129
|
|
|
|
|
|
|
my $type = $class->{'UML:Operation'}{$methodname}{type}; |
130
|
|
|
|
|
|
|
my $arguments = get_parameters($class->{'UML:Operation'}{$methodname}{'UML:Parameter'}); |
131
|
|
|
|
|
|
|
push(@$return,{name=>$methodname,type=>$type,Params=>$arguments, visibility=>0}); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
return $return; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub get_attributes { |
137
|
|
|
|
|
|
|
my $class = shift; |
138
|
|
|
|
|
|
|
my $return = []; |
139
|
|
|
|
|
|
|
foreach my $attrname (keys %{$class->{'UML:Attribute'}}) { |
140
|
|
|
|
|
|
|
my $type = $class->{'UML:Attribute'}{$attrname}{type}; |
141
|
|
|
|
|
|
|
push(@$return,{name=>$attrname,type=>$type, visibility=>0}); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
return $return; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub get_parameters { |
148
|
|
|
|
|
|
|
my $arguments = shift; |
149
|
|
|
|
|
|
|
my $return = []; |
150
|
|
|
|
|
|
|
if (ref $arguments) { |
151
|
|
|
|
|
|
|
@$return = map ( {Type=>$arguments->{$_}{type},Name=>$_}, keys %$arguments); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
return $return; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
############################################################################### |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Autodia::Handler |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Autodia::Diagram |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Aaron Trevena, Eaaron.trevena@gmail.comE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Copyright (C) 2001-2007 by Aaron Trevena |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
173
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.1 or, |
174
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |