From: Brian O'Connor Date: Fri, 3 Oct 2003 05:55:20 +0000 (+0000) Subject: Stable 1.1 branch of the Turnkey producer. Needed for the current version of the... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74611019066dc6f287b625f8239b57547e76e28d;p=dbsrgits%2FSQL-Translator.git Stable 1.1 branch of the Turnkey producer. Needed for the current version of the Turnkey project but will be merged with Allen's recent changes soon. --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index db3d697..53f649a 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.1 2003-08-28 08:51:09 boconnor Exp $ +# $Id: Turnkey.pm,v 1.1.2.1 2003-10-03 05:55:20 boconnor Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Allen Day , # Ying Zhang @@ -23,7 +23,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.1.2.1 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -297,12 +297,12 @@ my $turnkey_atom_tt2 = <<'EOF'; ############################################## -package Durian::Atom::[% package.key FILTER ucfirst %]; +package Turnkey::Atom::[% package.key FILTER ucfirst %]; [% pname = package.key FILTER ucfirst%] -[% pkey = "Durian::Model::${pname}" %] +[% pkey = "Turnkey::Model::${pname}" %] -use base qw(Durian::Atom); +use base qw(Turnkey::Atom); use Data::Dumper; sub can_render { @@ -314,7 +314,7 @@ sub render { my $dbobject = shift; # Assumption here that if it's not rendering on it's own dbobject # then it's a list. This will be updated when AtomLists are implemented -boconnor - if(ref($dbobject) eq 'Durian::Model::[% package.key FILTER ucfirst %]') { + if(ref($dbobject) eq 'Turnkey::Model::[% package.key FILTER ucfirst %]') { return(_render_record($dbobject)); } else { return(_render_list($dbobject)); } @@ -328,6 +328,9 @@ sub _render_record { [% FOREACH field = packages.$pkey.columns_essential %] $field_hash->{[% field %]} = $dbobject->[% field %](); [% END %] + [% FOREACH field = packages.$pkey.columns_others %] + $field_hash->{[% field %]} = $dbobject->[% field %](); + [% END %] $row->{data} = $field_hash; $row->{id} = $dbobject->id(); push @output, $row; @@ -344,7 +347,11 @@ sub _render_list { my $field_hash = {}; [% FOREACH field = packages.$pkey.columns_essential %] $field_hash->{[% field %]} = $object->[% field %](); + [% END %] + [% FOREACH field = packages.$pkey.columns_others %] + $field_hash->{[% field %]} = $object->[% field %](); [% END %] + $row->{data} = $field_hash; $row->{id} = $object->id(); push @output, $row; @@ -433,7 +440,7 @@ sub [% arr.table_name -%]s { [% ###### DOCUMENT START ###### %] -package Durian::Model::DBI; +package Turnkey::Model::DBI; # Created by SQL::Translator::Producer::ClassDBI # Template used AutoDBI.tt2 @@ -441,7 +448,7 @@ package Durian::Model::DBI; use strict; use base qw(Class::DBI::Pg); -Durian::Model::DBI->set_db('Main', '[% db_str %]', '[% db_user %]', '[% db_pass %]'); +Turnkey::Model::DBI->set_db('Main', '[% db_str %]', '[% db_user %]', '[% db_pass %]'); [% FOREACH package = packages %] [% printPackage(package.value) %] @@ -450,11 +457,11 @@ EOF my $turnkey_xml_tt2 = < - - + + - + @@ -463,7 +470,7 @@ my $turnkey_xml_tt2 = < [% FOREACH package = linkable %] - + [% END %] @@ -477,7 +484,7 @@ my $turnkey_xml_tt2 = < [% FOREACH focus_atom = linkable %] - + [% FOREACH link_atom = focus_atom.value %] [% END %] @@ -487,16 +494,16 @@ my $turnkey_xml_tt2 = < - + [% FOREACH focus_atom = linkable %] - + [% END %] - + EOF my $turnkey_template_tt2 = <<'EOF'; @@ -511,16 +518,16 @@ my $turnkey_template_tt2 = <<'EOF'; [% IF p.type == 'Container' %] [% renderpanel(p,dbobject) %] [% ELSE %] - +
[% IF p.name %] - - + + [% END %] -
[% p.name %][% IF panel.type == 'major' %]: [% dbobject.name %][% END %]
[% p.name %][% IF panel.type == 'major' %]: [% dbobject.name %][% END %]
+
- +
[% renderatom(p,dbobject) %]
@@ -548,12 +555,15 @@ my $turnkey_template_tt2 = <<'EOF'; [% FOREACH record = lstArr %] [% fields = record.data %] [- pname = package.key FILTER ucfirst -] - [- pkey = "Durian::Model::${pname}" -] + [- pkey = "Turnkey::Model::${pname}" -] [- FOREACH field = packages.$pkey.columns_essential -] [- field -][% fields.[- field -] %] [- END -] + [- FOREACH field = packages.$pkey.columns_others -] + [- field -][% fields.[- field -] %] + [- END -] [% id = record.id %] - Link + Link [% END %] [% END %] [- END -]