in reply to Re: UML to Perl
in thread UML to Perl

Actually, you'll want to try ArgoUML with ummf

Replies are listed 'Best First'.
Re^3: UML to Perl
by biswanath_c (Beadle) on Jun 23, 2011 at 06:58 UTC

    that was a helpful tip. thanks! Just have one more question on this tip - i downloaded that module UMMF from CPAN - i did not find any executable named ummf in that download. The syntax for using that driver is shown like running an exe named ummf with a parameter -e. Should I build that executable using make or something? Pls help.


      I linked to http://search.cpan.org/perldoc?ummf

      It redirects to http://search.cpan.org/~kstephens/UMMF-1.02/bin/ummf

      When you install the module, you also install ummf , ex

      Installing C:\perl\site\5.12.2\bin\argo2xmi Installing C:\perl\site\5.12.2\bin\argo2xmi.bat Installing C:\perl\site\5.12.2\bin\argo2xmi.pl Installing C:\perl\site\5.12.2\bin\files2dirs Installing C:\perl\site\5.12.2\bin\files2dirs.bat Installing C:\perl\site\5.12.2\bin\files2dirs.pl Installing C:\perl\site\5.12.2\bin\uml2xmi Installing C:\perl\site\5.12.2\bin\uml2xmi.bat Installing C:\perl\site\5.12.2\bin\uml2xmi.pl Installing C:\perl\site\5.12.2\bin\ummf Installing C:\perl\site\5.12.2\bin\ummf.bat Installing C:\perl\site\5.12.2\bin\ummf.pl
      See A Guide To Installing Modules

      In any case, I'm not sure how truly helpful this tip was, UMMF has a few portability related bugs, it won't work out of the box on win32

        In any case, I'm not sure how truly helpful this tip was, UMMF has a few portability related bugs, it won't work out of the box on win32

        With this patch the examples will work (generate code files)

        To apply patch

        cd UMMF-1.02
        patch -p1 < path/to/patchfile 
        diff -ru UMMF-1.02/bin/files2dirs UMMF-1.02-new5/bin/files2dirs --- UMMF-1.02/bin/files2dirs 2006-05-13 18:40:03.000000000 -0700 +++ UMMF-1.02-new5/bin/files2dirs 2011-07-29 04:45:09.609375000 -07 +00 @@ -117,6 +117,7 @@ while ( @ARGV ) { local $_ = shift @ARGV; + next unless length $_; if ( $_ eq '-' ) { push(@input_files, $_); } diff -ru UMMF-1.02/bin/files2dirs.pl UMMF-1.02-new5/bin/files2dirs.pl --- UMMF-1.02/bin/files2dirs.pl 2006-05-13 18:40:03.000000000 -0700 +++ UMMF-1.02-new5/bin/files2dirs.pl 2011-07-29 04:45:20.875000000 +-0700 @@ -117,6 +117,7 @@ while ( @ARGV ) { local $_ = shift @ARGV; + next unless length $_; if ( $_ eq '-' ) { push(@input_files, $_); } diff -ru UMMF-1.02/bin/ummf UMMF-1.02-new5/bin/ummf --- UMMF-1.02/bin/ummf 2006-05-13 18:40:03.000000000 -0700 +++ UMMF-1.02-new5/bin/ummf 2011-07-29 04:41:24.281250000 -0700 @@ -155,7 +155,7 @@ ##################################################################### +## -use File::Path; +use File::Path qw[ make_path ]; use IO::Handle; use IO::Pipe; @@ -337,11 +337,16 @@ if ( $output eq '-' ) { $output_h = \*STDOUT; } else { - mkpath($output); + my $err; + make_path( $output, { verbose => 1, error => \$err }); + if( @$err ){ print STDERR " make_path failed : @{[%$_]} \n" for + @$err } + $output_h = new IO::Pipe; - my $cmd = "$_0dir/files2dirs $file2dirs_opts -d '$output' -"; - $output_h->writer($cmd) || die("Cannot pipe to 'cmd': $!"); - # print STDERR "Output to '$cmd'\n"; +#~ my $cmd = "$^X $_0dir/files2dirs $file2dirs_opts -d '$output +' -"; + my @cmd = ( $^X , "$_0dir/files2dirs", $file2dirs_opts, '-d', + $output, '-' ); +#~ local $" = ' '; + $output_h->writer(@cmd) || die("Cannot pipe to 'cmd': $!"); + print STDERR "$output_h Output to >> @cmd <<\n"; } } } @@ -350,7 +355,18 @@ sub close_output { if ( $output_h ) { - $output_h->close() unless $output_h eq \*STDOUT; + if( $output_h != \*STDOUT ){ + print STDERR "Trying to close $output_h \n"; + if( $^O ne 'MSWin32' ){ + $output_h -> close(); # hangs?? + } else { + $output_h -> IO::Pipe::End::SUPER::close() for 1 .. 5; + print STDERR " done ->SUPER::close() killing\n"; + kill 9, ${*$output_h}{'io_pipe_pid'} for 1 .. 3; + print STDERR " done killing \n"; + } + } + $output_h = undef; } } @@ -406,9 +422,10 @@ elsif ( $input =~ /\.(zargo|zuml)$/i ) { # $DB::single = 1; my $fh = IO::Pipe->new(); - my @cmd = ( "$basedir/bin/uml2xmi", $input ); + my @cmd = ( $^X, "$basedir/bin/uml2xmi", $input ); { - local $" = ' '; +#~ local $" = ' '; + print STDERR "IO::Pipe ummi >> @cmd << \n"; $fh->reader(@cmd) || die("Cannot run '@cmd': $!"); } diff -ru UMMF-1.02/bin/ummf.pl UMMF-1.02-new5/bin/ummf.pl --- UMMF-1.02/bin/ummf.pl 2006-05-13 18:40:03.000000000 -0700 +++ UMMF-1.02-new5/bin/ummf.pl 2011-07-29 04:41:25.984375000 -0700 @@ -155,7 +155,7 @@ ##################################################################### +## -use File::Path; +use File::Path qw[ make_path ]; use IO::Handle; use IO::Pipe; @@ -337,11 +337,16 @@ if ( $output eq '-' ) { $output_h = \*STDOUT; } else { - mkpath($output); + my $err; + make_path( $output, { verbose => 1, error => \$err }); + if( @$err ){ print STDERR " make_path failed : @{[%$_]} \n" for + @$err } + $output_h = new IO::Pipe; - my $cmd = "$_0dir/files2dirs $file2dirs_opts -d '$output' -"; - $output_h->writer($cmd) || die("Cannot pipe to 'cmd': $!"); - # print STDERR "Output to '$cmd'\n"; +#~ my $cmd = "$^X $_0dir/files2dirs $file2dirs_opts -d '$output +' -"; + my @cmd = ( $^X , "$_0dir/files2dirs", $file2dirs_opts, '-d', + $output, '-' ); +#~ local $" = ' '; + $output_h->writer(@cmd) || die("Cannot pipe to 'cmd': $!"); + print STDERR "$output_h Output to >> @cmd <<\n"; } } } @@ -350,7 +355,18 @@ sub close_output { if ( $output_h ) { - $output_h->close() unless $output_h eq \*STDOUT; + if( $output_h != \*STDOUT ){ + print STDERR "Trying to close $output_h \n"; + if( $^O ne 'MSWin32' ){ + $output_h -> close(); # hangs?? + } else { + $output_h -> IO::Pipe::End::SUPER::close() for 1 .. 5; + print STDERR " done ->SUPER::close() killing\n"; + kill 9, ${*$output_h}{'io_pipe_pid'} for 1 .. 3; + print STDERR " done killing \n"; + } + } + $output_h = undef; } } @@ -406,9 +422,10 @@ elsif ( $input =~ /\.(zargo|zuml)$/i ) { # $DB::single = 1; my $fh = IO::Pipe->new(); - my @cmd = ( "$basedir/bin/uml2xmi", $input ); + my @cmd = ( $^X, "$basedir/bin/uml2xmi", $input ); { - local $" = ' '; +#~ local $" = ' '; + print STDERR "IO::Pipe ummi >> @cmd << \n"; $fh->reader(@cmd) || die("Cannot run '@cmd': $!"); } diff -ru UMMF-1.02/lib/UMMF/Import/XMI.pm UMMF-1.02-new5/lib/UMMF/Impo +rt/XMI.pm --- UMMF-1.02/lib/UMMF/Import/XMI.pm 2006-05-13 18:40:03.000000000 +-0700 +++ UMMF-1.02-new5/lib/UMMF/Import/XMI.pm 2011-07-29 04:47:29.96875 +0000 -0700 @@ -573,7 +573,23 @@ # Handle <XMI.field>DATA</XMI.field> if ( $name eq 'XMI.field' ) { - return $node->getData; +#~ http://www.perlmonks.org/?node_id=62809# XML::DOM::Parser + sub XML::DOM::Element::getData { + package XML::DOM::Element; + my( $node ) = @_; + my $data = ""; + for my $child($node->getChildNodes) { + if($child->getNodeType == TEXT_NODE) { + $data .= $child->getData; + } + } + return $data; + } + my $ret = eval { $node->getData }; +#~ warn $@ ? $@ : "$ret "; + $ret = $node->getNodeValue unless length $ret; +#~ warn " $node ", $node->getNodeType , " " unless length $ret; + return $ret; } if ( $name eq 'XMI.any' ) { return $node->getData; diff -ru UMMF-1.02/lib/UMMF/XForm/Merge.pm UMMF-1.02-new5/lib/UMMF/XFo +rm/Merge.pm --- UMMF-1.02/lib/UMMF/XForm/Merge.pm 2005-04-11 22:40:43.000000000 + -0700 +++ UMMF-1.02-new5/lib/UMMF/XForm/Merge.pm 2011-07-29 04:40:38.0156 +25000 -0700 @@ -121,7 +121,7 @@ sub merge_ModelElements_1 { my ($self, $model, $modelx, $ns, $nsx) = @_; - +warn join "\n", map { "[ $_ ] " } @_; for my $objx ( $nsx->ownedElement ) { my $name = $objx->name; my $obj = Namespace_ownedElement_name($ns, $name); diff -ru UMMF-1.02/lib/UMMF.pm UMMF-1.02-new5/lib/UMMF.pm --- UMMF-1.02/lib/UMMF.pm 2006-05-13 18:40:03.000000000 -0700 +++ UMMF-1.02-new5/lib/UMMF.pm 2011-07-29 04:40:38.015625000 -0700 @@ -373,6 +373,8 @@ Returns a list of directories to search for files of type C<$type>. =cut + +use File::ShareDir qw' dist_dir '; sub resource_path { my ($self, $type) = @_; @@ -400,6 +402,7 @@ # Default installation path. &module_dir . "/data", + dist_dir('UMMF', 'ummf'), # it works ), ); } diff -ru UMMF-1.02/Makefile.PL UMMF-1.02-new5/Makefile.PL --- UMMF-1.02/Makefile.PL 2004-08-01 14:19:09.000000000 -0700 +++ UMMF-1.02-new5/Makefile.PL 2011-07-29 04:40:38.015625000 -0700 @@ -2,6 +2,9 @@ use 5.006001; use ExtUtils::MakeMaker; +use File::ShareDir::Install; +install_share 'dist', 'data'; # install data into + # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( @@ -47,3 +50,8 @@ (ABSTRACT_FROM => 'lib/UMMF.pm', # retrieve abstract from modu +le AUTHOR => 'Kurt Stephens <kstephens@users.sourceforge. +net>') : ()), ); + + package MY; + use File::ShareDir::Install qw(postamble); # it works + +
      Hi Ananymous Monk! Looks like you wanted to reply but the message has come out empty. Would be great if you can help me with this. Thanks!

        Hi Ananymous Monk! Looks like you wanted to reply but the message has come out empty. Would be great if you can help me with this. Thanks!

        Re^4: UML to Perl is not empty, so what are you talking about?

      Hi, I am also getting some errors while running the same module. The error msg says:


      Base class package "Template::Base" is empty. (Perhaps you need to 'use' the module which defines that package f +irst, or make that module available in @INC (@INC contains: C:/Perl/site +/lib C:/Pe rl/lib .). at C:/Perl/lib/Template.pm line 25 BEGIN failed--compilation aborted at C:/Perl/lib/Template.pm line 25. Compilation failed in require at C:/Perl/lib/UMMF.pm line 304. BEGIN failed--compilation aborted at C:/Perl/lib/UMMF.pm line 304. Compilation failed in require at (eval 4) line 2. BEGIN failed--compilation aborted at (eval 4) line 2. BEGIN failed--compilation aborted at C:\Perl\bin\ummf.pl line 146.


      pls help!

        How did you install UMMF? Did you install the prerequisites? Do they work?

        UMMF lists Template as prerequisite, which includes (and installs) Template::Base, but on your system, this module seems to be missing.