#!/usr/bin/perl #problem: variables such as dimension[a-z]* -> will trigger parser/mapping use strict; sub cleanstring { my $name = lc(join('_',@_)); $name =~ s/[\}\{} \+\)\(\.\-\\\$\:\&]/_/g; $name =~ s/'//g; return $name; } my %ExistLink; print "Enter the path to your TM1 server data folder: "; my $dirname = ; chomp($dirname); if ($dirname eq "") { print "graphviz file generator\n"; print "Usage: dimflow.pl dirname > dim.dot\n"; print "fdp -Tgif dim.dot > dim.gif\n;"; exit; } open(FLR, "> dim.dot") or die "Cannot create output file dim.dot!\n"; print FLR "digraph TM1Dims {\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 =~ /(.*)\.pro$/i) { my $SourceType = ""; my $Source = ""; my $View = ""; my $process = cleanstring($1); 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]"; } foreach my $flow (/dimension[a-z]*\(([^,\)]*)/i) { # my $flow = $1; my $c3 = cleanstring($1); if (($ExistLink{"$c3$process"} ne "yes")) { $ExistLink{"$c3$process"} = "yes"; #print $_; print FLR "$c3 [color = blue];\n"; print FLR "$process [shape = rectangle,color=red];\n"; print FLR "$process -> $c3 [color=blue];\n" if ($c3 ne ""); } if ($ExistLink{$process} ne "shape") { $ExistLink{$process} = "shape"; #print "$process [shape = invtrapezium,color=blue];\n"; } } } } if ($thisfile =~ /(.*)\.cub$/i) { my $cube = cleanstring($1); #skip control cubes #print "$cube;\n" if ($cube !~ /^_/); } close FLH; } print FLR "\}\n"; close FLR; system("fdp -Tgif dim.dot > dim.gif");