line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FabForce::DBDesigner4; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Parse/Analyse XML-Files created by DBDesigner 4 (FabForce) |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
217088
|
use strict; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
461
|
|
6
|
10
|
|
|
10
|
|
50
|
use warnings; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
291
|
|
7
|
10
|
|
|
10
|
|
42
|
use Carp; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
530
|
|
8
|
10
|
|
|
10
|
|
4168
|
use FabForce::DBDesigner4::XML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use FabForce::DBDesigner4::SQL; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.34'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new{ |
14
|
|
|
|
|
|
|
my ($class,%args) = @_; |
15
|
|
|
|
|
|
|
croak "only one filetype" if(defined $args{sql} and defined $args{xml}); |
16
|
|
|
|
|
|
|
my $self = {}; |
17
|
|
|
|
|
|
|
bless $self,$class; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$self->{sql} = $args{sql} if(defined $args{sql}); |
20
|
|
|
|
|
|
|
$self->{xml} = $args{xml} if(defined $args{xml}); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return $self; |
23
|
|
|
|
|
|
|
}# new |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parsefile{ |
26
|
|
|
|
|
|
|
my ($self,%args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->{xml} = $args{xml} if(defined $args{xml}); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if( defined $self->{xml} ) { |
31
|
|
|
|
|
|
|
my $xml = FabForce::DBDesigner4::XML->new; |
32
|
|
|
|
|
|
|
$self->{structure} = $xml->parsefile( $self->{xml} ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else{ |
35
|
|
|
|
|
|
|
croak "No valid filetype defined!" |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
}# parsefile |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub writeSQL{ |
40
|
|
|
|
|
|
|
my ($self,$filename,$args) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $sql = FabForce::DBDesigner4::SQL->new(); |
43
|
|
|
|
|
|
|
my $struct = delete $args->{structure}; |
44
|
|
|
|
|
|
|
$args->{type} ||= 'other'; |
45
|
|
|
|
|
|
|
my $structForFile = $struct || $self->{structure} || ''; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$sql->writeSQL($structForFile, $filename, $args); |
48
|
|
|
|
|
|
|
}# writeSQL |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub getTables{ |
51
|
|
|
|
|
|
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
return @{$self->{structure}}; |
53
|
|
|
|
|
|
|
}# getTables |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub getSQL{ |
56
|
|
|
|
|
|
|
my ($self,$args) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $sql = FabForce::DBDesigner4::SQL->new(); |
59
|
|
|
|
|
|
|
$args->{type} ||= 'other'; |
60
|
|
|
|
|
|
|
my @creates = $sql->getSQL($self->{structure},$args); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return @creates; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |