Proper Moose setup for addRevision...

This commit is contained in:
Colin Kuskie 2010-04-06 16:13:02 -07:00
parent 64f7bd9365
commit dee5bbe5d0
8 changed files with 58 additions and 120 deletions

View file

@ -158,9 +158,9 @@ Extent the method from the super class to handle iCalSequenceNumbers.
=cut =cut
sub addRevision { override addRevision => sub {
my $self = shift; my $self = shift;
my $newRev = $self->SUPER::addRevision(@_); my $newRev = super();
my $sequenceNumber = $newRev->iCalSequenceNumber; my $sequenceNumber = $newRev->iCalSequenceNumber;
if (defined $sequenceNumber) { if (defined $sequenceNumber) {
$sequenceNumber++; $sequenceNumber++;
@ -174,7 +174,7 @@ sub addRevision {
$newRev->update({storageId => $newStorage->getId}); $newRev->update({storageId => $newStorage->getId});
} }
return $newRev; return $newRev;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -93,9 +93,9 @@ Override the default method in order to deal with attachments.
=cut =cut
sub addRevision { override addRevision => sub {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = super();
if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) { if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) {
my $newStorage = $self->getStorageClass->get($self->session, $self->storageId)->copy; my $newStorage = $self->getStorageClass->get($self->session, $self->storageId)->copy;
@ -103,7 +103,7 @@ sub addRevision {
} }
return $newSelf; return $newSelf;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -139,23 +139,6 @@ These methods are available from this class:
=cut =cut
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to MatrixListing Assets.
=cut
sub addRevision {
my $self = shift;
my $newSelf = $self->next::method(@_);
return $newSelf;
}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
=head2 canAdd ( ) =head2 canAdd ( )
@ -195,22 +178,6 @@ sub canEdit {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating MatrixListing Assets. This method will be called
whenever a copy action is executed
=cut
sub duplicate {
my $self = shift;
my $newAsset = $self->next::method(@_);
return $newAsset;
}
#-------------------------------------------------------------------
=head2 getAutoCommitWorkflowId =head2 getAutoCommitWorkflowId
Gets the WebGUI::VersionTag workflow to use to automatically commit MatrixListings. Gets the WebGUI::VersionTag workflow to use to automatically commit MatrixListings.
@ -538,19 +505,6 @@ sub purge {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
sub purgeRevision {
my $self = shift;
return $self->next::method;
}
#-------------------------------------------------------------------
=head2 setRatings ( ratings ) =head2 setRatings ( ratings )
Sets the ratings for a matrix listing Sets the ratings for a matrix listing

View file

@ -77,9 +77,6 @@ with 'WebGUI::Role::Asset::AlwaysHidden';
with 'WebGUI::Role::Asset::SetStoragePermissions'; with 'WebGUI::Role::Asset::SetStoragePermissions';
use WebGUI::Asset::Template;
use WebGUI::Asset::Post::Thread;
use WebGUI::Group; use WebGUI::Group;
use WebGUI::HTML; use WebGUI::HTML;
use WebGUI::HTMLForm; use WebGUI::HTMLForm;
@ -139,27 +136,28 @@ Override the default method in order to deal with attachments.
=cut =cut
sub addRevision { override addRevision => sub {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = super();
if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) { if ( $newSelf->storageId && $newSelf->storageId eq $self->storageId ) {
my $newStorage = WebGUI::Storage->get($self->session,$self->storageId)->copy; my $newStorage = WebGUI::Storage->get( $self->session, $self->storageId )->copy;
$newSelf->update({storageId=>$newStorage->getId}); $newSelf->update( { storageId => $newStorage->getId } );
}
my $threadId = $newSelf->threadId;
my $now = time();
if ( $threadId eq "" ) { # new post
if ( $newSelf->getParent->isa("WebGUI::Asset::Wobject::Collaboration") ) {
$newSelf->update( { threadId => $newSelf->getId } );
} }
my $threadId = $newSelf->threadId; else {
my $now = time(); $newSelf->update( { threadId => $newSelf->getParent->threadId } );
if ($threadId eq "") { # new post }
if ($newSelf->getParent->isa("WebGUI::Asset::Wobject::Collaboration")) { delete $newSelf->{_thread};
$newSelf->update({threadId=>$newSelf->getId}); }
} else { $newSelf->getThread->unmarkRead;
$newSelf->update({threadId=>$newSelf->getParent->threadId});
}
delete $newSelf->{_thread};
}
$newSelf->getThread->unmarkRead;
return $newSelf; return $newSelf;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -269,20 +267,20 @@ increment replies for the parent thread.
=cut =cut
sub commit { override commit => sub {
my $self = shift; my $self = shift;
$self->SUPER::commit; super();
$self->notifySubscribers unless ($self->shouldSkipNotification); $self->notifySubscribers unless ( $self->shouldSkipNotification );
if ($self->isNew) { if ( $self->isNew ) {
if ($self->session->setting->get("useKarma") && $self->getThread->getParent->karmaPerPost) { if ( $self->session->setting->get("useKarma") && $self->getThread->getParent->karmaPerPost ) {
my $u = WebGUI::User->new($self->session, $self->ownerUserId); my $u = WebGUI::User->new( $self->session, $self->ownerUserId );
$u->karma($self->getThread->getParent->karmaPerPost, $self->getId, "Collaboration post"); $u->karma( $self->getThread->getParent->karmaPerPost, $self->getId, "Collaboration post" );
} }
$self->getThread->incrementReplies($self->revisionDate,$self->getId);# if ($self->isReply); $self->getThread->incrementReplies( $self->revisionDate, $self->getId ); # if ($self->isReply);
} }
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -85,12 +85,12 @@ Extend the base method to handle creating a subscription group for this Thread.
=cut =cut
sub addRevision { override addRevision => sub {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = super();
$newSelf->createSubscriptionGroup; $newSelf->createSubscriptionGroup;
return $newSelf; return $newSelf;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -178,9 +178,9 @@ Override the default method in order to deal with attachments.
=cut =cut
sub addRevision { override addRevision => sub {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = super();
if ($newSelf->getRevisionCount > 1) { if ($newSelf->getRevisionCount > 1) {
foreach my $field (qw(image1 image2 image3 brochure manual warranty)) { foreach my $field (qw(image1 image2 image3 brochure manual warranty)) {
if ($self->get($field)) { if ($self->get($field)) {
@ -190,7 +190,7 @@ sub addRevision {
} }
} }
return $newSelf; return $newSelf;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -126,20 +126,6 @@ These methods are available from this class:
#-------------------------------------------------------------------
=head2 addRevision ( properties, ... )
Force the packed snippet to be regenerated.
=cut
sub addRevision {
my ( $self, $properties, @args ) = @_;
delete $properties->{ snippetPacked };
return $self->SUPER::addRevision( $properties, @args );
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 exportGetUrlAsPath ( index ) =head2 exportGetUrlAsPath ( index )

View file

@ -157,13 +157,13 @@ Override the master addRevision to copy attachments
=cut =cut
sub addRevision { override addRevision => sub {
my ( $self, $properties, @args ) = @_; my ( $self, $properties, @args ) = @_;
my $asset = $self->SUPER::addRevision($properties, @args); my $asset = super();
delete $properties->{templatePacked}; delete $properties->{templatePacked};
$asset->addAttachments($self->getAttachments); $asset->addAttachments($self->getAttachments);
return $asset; return $asset;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -193,12 +193,12 @@ copy.
=cut =cut
sub duplicate { override duplicate => sub {
my $self = shift; my $self = shift;
my $newTemplate = $self->SUPER::duplicate; my $newTemplate = super();
$newTemplate->update({isDefault => 0}); $newTemplate->update({isDefault => 0});
return $newTemplate; return $newTemplate;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -710,11 +710,11 @@ Override the master purgeRevision to purge attachments
=cut =cut
sub purgeRevision { override purgeRevision => sub {
my $self = shift; my $self = shift;
$self->removeAttachments; $self->removeAttachments;
return $self->SUPER::purgeRevision(@_); return super();
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------