Move get_tables from Meta/Class into Meta/Asset. s/getTables/meta->get_tables/;

This commit is contained in:
Colin Kuskie 2010-01-04 15:34:24 -08:00
parent b72e3a1cd1
commit ce3edcf743
8 changed files with 74 additions and 38 deletions

View file

@ -21,9 +21,9 @@ use JSON;
use HTML::Packer;
use WebGUI::Definition::Asset;
attribute assetName => 'asset',
attribute tableName => 'assetData',
attribute icon => 'assets.gif',
attribute assetName => 'asset';
attribute tableName => 'assetData';
attribute icon => 'assets.gif';
property title => (
tab => "properties",
label => ['99','Asset'],
@ -288,7 +288,7 @@ around BUILDARGS => sub {
my $placeHolders = [$assetId];
# join all the tables
foreach my $table ($className->getTables) {
foreach my $table ($className->meta->get_tables) {
$sql .= ",".$table;
$where .= " and (asset.assetId=".$table.".assetId and ".$table.".revisionDate=".$revisionDate.")";
}

View file

@ -617,7 +617,7 @@ sub getLineageSql {
if ( ! eval { require $module; 1 }) {
$self->session->errorHandler->fatal("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
}
foreach my $table ($self->getTables) {
foreach my $table ($self->meta->get_tables) {
unless ($table eq "asset" || $table eq "assetData") {
$tables .= " left join $table on assetData.assetId=".$table.".assetId and assetData.revisionDate=".$table.".revisionDate";
}

View file

@ -197,7 +197,7 @@ sub purge {
$outputSub->($i18n->get('Clearing asset tables'));
$session->db->beginTransaction;
$session->db->write("delete from metaData_values where assetId = ?",[$self->getId]);
foreach my $table ($self->getTables) {
foreach my $table ($self->meta->get_tables) {
$session->db->write("delete from ".$table." where assetId=?", [$self->getId]);
}
$session->db->write("delete from asset where assetId=?", [$self->getId]);

View file

@ -131,7 +131,7 @@ sub addRevision {
}
# prime the tables
foreach my $table ($self->getTables) {
foreach my $table ($self->meta->get_tables) {
unless ($table eq "assetData") {
$self->session->db->write( "insert into ".$table." (assetId,revisionDate) values (?,?)", [$self->getId, $now]);
}
@ -355,7 +355,7 @@ sub purgeRevision {
if ($self->getRevisionCount > 1) {
my $db = $self->session->db;
$db->beginTransaction;
foreach my $table ($self->getTables) {
foreach my $table ($self->meta->get_tables) {
$db->write("delete from ".$table." where assetId=? and revisionDate=?",[$self->getId, $self->get("revisionDate")]);
}
my $count = $db->quickScalar("select count(*) from assetData where assetId=? and status='pending'",[$self->getId]);

View file

@ -86,6 +86,25 @@ The second is the i18n namespace to find the asset's name.
=cut
#-------------------------------------------------------------------
=head2 get_tables ( )
Returns an array of the names of all tables in every class used by
this Class.
=cut
sub get_tables {
my $self = shift;
my @properties = ();
my %seen = ();
push @properties,
grep { ! $seen{$_}++ }
map { $_->tableName }
$self->get_all_properties
;
return @properties;
}
1;

View file

@ -106,27 +106,6 @@ sub get_property_list {
#-------------------------------------------------------------------
=head2 get_tables ( )
Returns an array of the names of all tables in every class used by
this Class.
=cut
sub get_tables {
my $self = shift;
my @properties = ();
my %seen = ();
push @properties,
grep { ! $seen{$_}++ }
map { $_->tableName }
$self->get_all_properties
;
return @properties;
}
#-------------------------------------------------------------------
=head2 property_meta ( )
Returns the name of the class for properties.