From 377c49d141a3eb5a12105db56d4b8d19291f5f2b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 23 Oct 2009 11:07:02 -0500 Subject: [PATCH] fixed a bunch of bugs...almost working --- lib/WebGUI/Asset.pm | 7 +++---- lib/WebGUI/AssetVersioning.pm | 2 +- lib/WebGUI/Definition.pm | 6 ++++++ lib/WebGUI/Definition/Asset.pm | 9 +++++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 4da1c2c35..138712484 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1553,9 +1553,9 @@ sub new { my $placeHolders = [$assetId]; # join all the tables - foreach my $table ($self->getTables) { - $sql .= ",".$definition->{tableName}; - $where .= " and (asset.assetId=".$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate.")"; + foreach my $table ($class->getTables) { + $sql .= ",".$table; + $where .= " and (asset.assetId=".$table.".assetId and ".$table.".revisionDate=".$revisionDate.")"; } # fetch properties @@ -2290,7 +2290,6 @@ sub update { $setPairs{$table}{$property} = $value; } $self->{_properties}{$property} = $value; - } } # if there's anything to update, then do so diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 569147c1d..ff551f2f9 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -123,7 +123,7 @@ sub addRevision { my %defaults = (); # get the default values of each property foreach my $property ($self->getProperties) { - my $defintion = $self->getProperty($property); + my $definition = $self->getProperty($property); $defaults{$property} = $definition->{defaultValue}; if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{serialize}) { $defaults{$property} = $defaults{$property}->[0]; diff --git a/lib/WebGUI/Definition.pm b/lib/WebGUI/Definition.pm index 57b00834c..fbf22d1c0 100644 --- a/lib/WebGUI/Definition.pm +++ b/lib/WebGUI/Definition.pm @@ -50,6 +50,12 @@ sub import { # ensure we are using c3 method resolution mro::set_mro($super, 'c3'); mro::set_mro($caller, 'c3'); + $class->_build($super, $caller, $definition); + return; +} + +sub _build { + my ($class, $super, $caller, $definition) = @_; # construct an ordered list and hash of the properties my @propertyList; diff --git a/lib/WebGUI/Definition/Asset.pm b/lib/WebGUI/Definition/Asset.pm index f19dc687f..4951ba440 100644 --- a/lib/WebGUI/Definition/Asset.pm +++ b/lib/WebGUI/Definition/Asset.pm @@ -50,7 +50,6 @@ sub import { } } } - $class->_install($super, 'getTables', $class->_gen_getTables()); # WebGUI::Definition->import uses caller, so avoid the extra entry in the call stack my $next = $class->next::can; @@ -58,6 +57,12 @@ sub import { goto $next; } +#------------------------------------------------------------------- +sub _build { + my ($class, $super, $caller, $definition) = @_; + $class->_install($super, 'getTables', $class->_gen_getTables()); +} + #------------------------------------------------------------------- sub _gen_getTables { my $class = shift; @@ -66,7 +71,7 @@ sub _gen_getTables { my %tables; foreach my $property ($self->getProperties) { my $definition = $self->getProperty($property); - %tables{$definition->{tableName}} = 1; + $tables{$definition->{tableName}} = 1; } return keys %tables; };