#!/usr/bin/perl #TODO #SQL -> large box named by database name, include all tables names/files in there #pb to differentiate update dimension and update cube processes #dimension/attrs,attrn flow? #add drills (dotted lines)? #add view name on line #add foreach cell(get|put) use strict; sub cleanstring { my $name = lc(join('_',@_)); $name =~ s/[\}\{} \+\)\(\.\-\\\$]/_/g; $name =~ s/'//g; return $name; } my %ExistLink; my $dirname = $ARGV[0]; if ($dirname eq "") { print "graphviz file generator\n"; print "Usage: genflow.pl dirname > flow.dot\n"; print "dot -Tgif flow.dot > flow.gif\n;"; exit; } print "digraph TM1 {\nrankdir = LR;\n"; opendir THISDIR, $dirname or die "Cannot open $dirname $!"; while (my $thisfile = readdir THISDIR) { my $DataSource = ""; my $SourceType = ""; open(FLH, "$dirname/$thisfile"); if ($thisfile =~ /(.*)\.rux$/i) { #print "#$dirname/$thisfile\n"; my $cube = cleanstring($1); while () { #inter-cubes flow if(/.*=>\s*DB\(\'([^\']*)\'/) { my $destcube = cleanstring($1); #test if link already added in graph if ($ExistLink{'$cube'} ne $destcube) { $ExistLink{'$cube'} = $destcube; print "$cube -> $destcube [color=grey];\n"; } } if(/.*=[^>]*DB\(\'([^\']*)\'/) { foreach my $sourcecube (/DB\(\'([^\']*)\'/) { $sourcecube = cleanstring($sourcecube); if ($ExistLink{'$sourcecube'} ne $cube) { $ExistLink{'$sourcecube'} = $cube; print "$sourcecube -> $cube [color=green];\n"; } } } } } if ($thisfile =~ /(.*)\.pro$/i) { my $SourceType = ""; my $Source = ""; my $View = ""; my $process = cleanstring($1); print "$process [shape = invtrapezium,color=blue];\n"; while () { #replace $cube with SQL statement,ascii file import, TM1 view #add print for special shape #datasource type if (/^562,"([A-Z])"/) { $SourceType = $1; } if (/^586,"(.*)"/) { #ASCII or VIEW source $Source = cleanstring($1); if ($ExistLink{'$Source'} ne "shape") { $ExistLink{'$Source'} = "shape"; print "$Source [color=red];\n" } } #commented coz dont need view detail if ((/^570,(.*)/) && ($SourceType eq "VIEW")) { #VIEW name $View = cleanstring($1); $View = " [name=$View]"; } if(/Cell(Put|Get)(N|S)\(([^,]*),([^,]*)/i) { my $flow = $1; my $c3 = cleanstring($3); my $c4 = cleanstring($4); if (($flow =~ /put/i) && ($ExistLink{'$process'} ne $c4)) { $ExistLink{'$process'} = $c4; print "$process -> $c4 [color=blue];\n" if ($c4 ne ""); if ($ExistLink{'$Source'} ne $process) { $ExistLink{'$Source'} = $process; print "$Source -> $process [color=red];\n"; } } if (($flow =~ /get/i) && ($ExistLink{'$c3'} ne $process)) { $ExistLink{'$c3'} = $process; print "$c3 -> $process [color=blue];\n"; } } } } if ($thisfile =~ /(.*)\.cub$/i) { my $cube = cleanstring($1); #skip control cubes #print "$cube;\n" if ($cube !~ /^_/); } close FLH; } print "\}\n";