* Added mysql_character_set for 4.1+ -mda
* Two experimental filters. -mda
* Added build support for installing templates. -mda
+* Added the initial work on a template based Dia UML producer. -mda
# -----------------------------------------------------------
# 0.7 2005-06-10
--- /dev/null
+package SQL::Translator::Producer::DiaUml;
+
+# -------------------------------------------------------------------
+# $Id: DiaUml.pm,v 1.1 2006-01-20 16:17:21 grommit Exp $
+# -------------------------------------------------------------------
+# Copyright (C) 2002-4 SQLFairy Authors
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA
+# -------------------------------------------------------------------
+
+=pod
+
+=head1 NAME
+
+SQL::Translator::Producer::DiaUml -
+ Produces dia UML diagrams from schema.
+
+=head1 SYNOPSIS
+
+ use SQL::Translator;
+ my $translator = SQL::Translator->new(
+ from => 'MySQL',
+ filename => 'foo_schema.sql',
+ to => 'DiaUml',
+ );
+ print $translator->translate;
+
+=head1 DESCRIPTION
+
+Currently you will get one class (with the a table
+stereotype) generated per table in the schema. The fields are added as
+attributes of the classes and their datatypes set. It doesn't currently set any
+of the relationships. It doesn't do any layout, all the classses are in one big
+stack. However it is still useful as you can use the layout tools in Dia to
+automatically arrange them horizontally or vertically.
+
+=head2 Producer Args
+
+=over 4
+
+=back
+
+=cut
+
+# -------------------------------------------------------------------
+
+use strict;
+
+use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
+$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
+$DEBUG = 0 unless defined $DEBUG;
+
+use SQL::Translator::Utils 'debug';
+use SQL::Translator::ConfigData;
+use base qw/SQL::Translator::Producer::TT::Base/;
+# Convert produce call into a method call on our class
+sub produce { return __PACKAGE__->new( translator => shift )->run; };
+
+# Add the installed templates to the inc path.
+sub tt_config {
+ ( INCLUDE_PATH => SQL::Translator::ConfigData->config('template_dir')."/dia_uml" );
+}
+
+sub tt_schema { 'schema.tt2' }
+
+1;
+
+# -------------------------------------------------------------------
+
+=pod
+
+=head1 AUTHOR
+
+Mark Addison E<lt>grommit@users.sourceforge.netE<gt>.
+
+=head1 TODO
+
+* Add the foriegn keys from the schema as UML relations.
+
+* Layout the classes.
+
+=head1 SEE ALSO
+
+SQL::Translator.
+
+=cut
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
+ <dia:diagramdata>
+ <dia:attribute name="background">
+ <dia:color val="#ffffff"/>
+ </dia:attribute>
+ <dia:attribute name="pagebreak">
+ <dia:color val="#000099"/>
+ </dia:attribute>
+ <dia:attribute name="paper">
+ <dia:composite type="paper">
+ <dia:attribute name="name">
+ <dia:string>#A4#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="tmargin">
+ <dia:real val="2.8222000598907471"/>
+ </dia:attribute>
+ <dia:attribute name="bmargin">
+ <dia:real val="2.8222000598907471"/>
+ </dia:attribute>
+ <dia:attribute name="lmargin">
+ <dia:real val="2.8222000598907471"/>
+ </dia:attribute>
+ <dia:attribute name="rmargin">
+ <dia:real val="2.8222000598907471"/>
+ </dia:attribute>
+ <dia:attribute name="is_portrait">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="scaling">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="fitto">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="grid">
+ <dia:composite type="grid">
+ <dia:attribute name="width_x">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="width_y">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="visible_x">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:attribute name="visible_y">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:composite type="color"/>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="color">
+ <dia:color val="#d8e5e5"/>
+ </dia:attribute>
+ <dia:attribute name="guides">
+ <dia:composite type="guides">
+ <dia:attribute name="hguides"/>
+ <dia:attribute name="vguides"/>
+ </dia:composite>
+ </dia:attribute>
+ </dia:diagramdata>
+
+ [% content %]
+
+</dia:diagram>
--- /dev/null
+[%-
+ DEFAULT name="Layer1" visible="true"
+%]
+ <dia:layer name="[% name %]" visible="[% visible %]">
+ [% content %]
+ </dia:layer>
--- /dev/null
+[%# vim:ft=tt2 -%]
+[% WRAPPER diagram %]
+ [% WRAPPER layer name="Background" %]
+ [% FOREACH table IN schema.get_tables %]
+ [% INCLUDE 'uml-class-start'
+ name = table.name
+ stereotype = 'Table'
+ visible_operations = 'false'
+ %]
+ <dia:attribute name="attributes">
+ [% FOREACH field IN table.get_fields;
+ SET type = field.data_type;
+ SET type = "$type($field.size)" IF field.size;
+ INCLUDE "uml-attribute"
+ name = field.name
+ stereotype = 'Field'
+ type = type
+ value = field.default_value
+ ;
+ END %]
+ </dia:attribute>
+ <dia:attribute name="operations"/>
+ <dia:attribute name="template">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="templates"/>
+ [% INCLUDE 'uml-class-end' %]
+ [% END %]
+ [% END %]
+[% END %]
--- /dev/null
+[%# vim:ft=tt2
+-%]
+[%-
+ DEFAULT visibility=0 abstract="false" class_scope="false"
+%]
+ <dia:composite type="umlattribute">
+ <dia:attribute name="name">
+ <dia:string>#[% name %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="type">
+ <dia:string>#[% type %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="value">
+ <dia:string>#[% value %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="comment">
+ <dia:string>#[% comment %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="visibility">
+ <dia:enum val="[% visibility %]"/>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="[% abstract %]"/>
+ </dia:attribute>
+ <dia:attribute name="class_scope">
+ <dia:boolean val="[% class_scope %]"/>
+ </dia:attribute>
+ </dia:composite>
--- /dev/null
+[%# vim:ft=tt2
+-%]
+ [% INCLUDE 'uml-class-start' %]
+ <dia:attribute name="attributes">
+ [%- FOREACH attributes;
+ INCLUDE "uml-attribute";
+ END %]
+ </dia:attribute>
+ <dia:attribute name="operations"/>
+ <dia:attribute name="template">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="templates"/>
+ [% INCLUDE 'uml-class-end' %]
--- /dev/null
+[%# vim:ft=tt2
+-%]
+ <dia:object type="UML - Class" version="0" id="O0">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.05,-0.05;20.6,3.65"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="20.550000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="3.6000000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="name">
+ <dia:string>#[% name %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="stereotype">
+ <dia:string>#[% stereotype %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="comment">
+ <dia:string>#[% comment %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_attributes">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="visible_attributes">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="visible_operations">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="visible_comments">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_operations">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_after_char">
+ <dia:int val="40"/>
+ </dia:attribute>
+ <dia:attribute name="line_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="fill_color">
+ <dia:color val="#ffffff"/>
+ </dia:attribute>
+ <dia:attribute name="text_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="normal_font">
+ <dia:font family="monospace" style="0" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font">
+ <dia:font family="monospace" style="88" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font">
+ <dia:font family="monospace" style="8" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font">
+ <dia:font family="sans" style="80" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font">
+ <dia:font family="sans" style="88" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font">
+ <dia:font family="sans" style="8" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="attributes">
+ [% FOREACH attributes %]
+ [% INCLUDE "uml-attribute" %]
+ [% END %]
+ </dia:attribute>
+ <dia:attribute name="operations"/>
+ <dia:attribute name="template">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="templates"/>
+ </dia:object>
--- /dev/null
+[%# vim:ft=tt2
+-%]
+ </dia:object>
--- /dev/null
+[% # vim:ft=tt2
+ DEFAULT
+ visible_operations='true'
+-%]
+ <dia:object type="UML - Class" version="0" id="O0">
+ <dia:attribute name="obj_pos">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="-0.05,-0.05;20.6,3.65"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="0,0"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="20.550000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="3.6000000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="name">
+ <dia:string>#[% name %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="stereotype">
+ <dia:string>#[% stereotype %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="comment">
+ <dia:string>#[% comment %]#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="abstract">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_attributes">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="suppress_operations">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="visible_attributes">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="visible_operations">
+ <dia:boolean val="[% visible_operations %]"/>
+ </dia:attribute>
+ <dia:attribute name="visible_comments">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_operations">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="wrap_after_char">
+ <dia:int val="40"/>
+ </dia:attribute>
+ <dia:attribute name="line_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="fill_color">
+ <dia:color val="#ffffff"/>
+ </dia:attribute>
+ <dia:attribute name="text_color">
+ <dia:color val="#000000"/>
+ </dia:attribute>
+ <dia:attribute name="normal_font">
+ <dia:font family="monospace" style="0" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font">
+ <dia:font family="monospace" style="88" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font">
+ <dia:font family="monospace" style="8" name="Courier"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font">
+ <dia:font family="sans" style="80" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font">
+ <dia:font family="sans" style="88" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font">
+ <dia:font family="sans" style="8" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="polymorphic_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_font_height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="abstract_classname_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="comment_font_height">
+ <dia:real val="1"/>
+ </dia:attribute>