migrate to getLineageIterator to save memory
This commit is contained in:
parent
cc87552a22
commit
2c75ab27e6
34 changed files with 794 additions and 187 deletions
|
|
@ -579,8 +579,7 @@ sub getEventNext {
|
|||
'assetData.assetId',
|
||||
);
|
||||
|
||||
my $events = $self->getLineage(['siblings'], {
|
||||
#returnObjects => 1,
|
||||
my $events = $self->getLineageIterator(['siblings'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::Event'],
|
||||
joinClass => 'WebGUI::Asset::Event',
|
||||
orderByClause => join(",", @orderByColumns),
|
||||
|
|
@ -588,9 +587,12 @@ sub getEventNext {
|
|||
limit => 1,
|
||||
});
|
||||
|
||||
|
||||
return undef unless $events->[0];
|
||||
return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]);
|
||||
my $nextEvent;
|
||||
eval { $nextEvent = $events->() };
|
||||
if ( WebGUI::Error->caught('WebGUI::Error::ObjecNotFound') ) {
|
||||
return undef; # Normal error
|
||||
}
|
||||
return $nextEvent;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -636,8 +638,7 @@ sub getEventPrev {
|
|||
'assetData.assetId DESC',
|
||||
);
|
||||
|
||||
my $events = $self->getLineage(['siblings'], {
|
||||
#returnObjects => 1,
|
||||
my $events = $self->getLineageIterator(['siblings'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::Event'],
|
||||
joinClass => 'WebGUI::Asset::Event',
|
||||
orderByClause => join(",",@orderByColumns),
|
||||
|
|
@ -645,8 +646,12 @@ sub getEventPrev {
|
|||
limit => 1,
|
||||
});
|
||||
|
||||
return undef unless $events->[0];
|
||||
return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]);
|
||||
my $prevEvent;
|
||||
eval { $prevEvent = $events->() };
|
||||
if ( WebGUI::Error->caught( 'WebGUI::Error::ObjectNotFound' ) ) {
|
||||
return undef; # Normal error
|
||||
}
|
||||
return $prevEvent;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1483,35 +1488,46 @@ sub processPropertiesFromFormPost {
|
|||
|
||||
# Delete old events
|
||||
if ($old_id) {
|
||||
my $events = $self->getLineage(["siblings"], {
|
||||
returnObjects => 1,
|
||||
my $events = $self->getLineageIterator(["siblings"], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::Event'],
|
||||
joinClass => 'WebGUI::Asset::Event',
|
||||
whereClause => qq{Event.recurId = "$old_id"},
|
||||
});
|
||||
$_->purge for @$events;
|
||||
while ( 1 ) {
|
||||
my $event;
|
||||
eval { $event = $events->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error(sprintf "Couldn't instance event asset %s to delete it", $x->id);
|
||||
next;
|
||||
}
|
||||
last unless $event;
|
||||
$event->purge;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# TODO: Give users a form property to decide what events to update
|
||||
# TODO: Make a workflow activity to do this, so that updating
|
||||
# 1 million events doesn't kill the server.
|
||||
# TODO: Make this use WebGUI::ProgressBar so 1 million events doesn't kill the server.
|
||||
# Just update related events
|
||||
my %properties = %{ $self->get };
|
||||
delete $properties{startDate};
|
||||
delete $properties{endDate};
|
||||
delete $properties{url}; # addRevision will create a new url for us
|
||||
|
||||
my $events = $self->getLineage(["siblings"], {
|
||||
#returnObjects => 1,
|
||||
my $events = $self->getLineageIterator(["siblings"], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::Event'],
|
||||
joinClass => 'WebGUI::Asset::Event',
|
||||
whereClause => q{Event.recurId = "}.$self->get("recurId").q{"},
|
||||
});
|
||||
|
||||
for my $eventId (@{$events}) {
|
||||
my $event = WebGUI::Asset->newByDynamicClass($session, $eventId);
|
||||
|
||||
while ( 1 ) {
|
||||
my $event;
|
||||
eval { $event = $events->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error(sprintf "Couldn't instance event asset %s to update it", $x->id);
|
||||
next;
|
||||
}
|
||||
last unless $event;
|
||||
# Add a revision
|
||||
$properties{ startDate } = $event->get("startDate");
|
||||
$properties{ endDate } = $event->get("endDate");
|
||||
|
|
|
|||
|
|
@ -59,14 +59,12 @@ sub _fixReplyCount {
|
|||
my $self = shift;
|
||||
my $asset = shift;
|
||||
|
||||
my $lastPost = $asset->getLineage( [ qw{ self descendants } ], {
|
||||
returnObjects => 1,
|
||||
my $lastPostId = $asset->getLineage( [ qw{ self descendants } ], {
|
||||
isa => 'WebGUI::Asset::Post',
|
||||
orderByClause => 'assetData.revisionDate desc',
|
||||
limit => 1,
|
||||
} )->[0];
|
||||
|
||||
if ($lastPost) {
|
||||
if (my $lastPost = WebGUI::Asset->newByDynamicClass( $self->session, $lastPostId ) ) {
|
||||
$asset->incrementReplies( $lastPost->get( 'revisionDate' ), $lastPost->getId );
|
||||
}
|
||||
else {
|
||||
|
|
@ -1024,10 +1022,7 @@ sub paste {
|
|||
$self->next::method(@_);
|
||||
|
||||
# First, figure out what Thread we're under
|
||||
my $thread = $self->getLineage( [ qw{ self ancestors } ], {
|
||||
returnObjects => 1,
|
||||
isa => 'WebGUI::Asset::Post::Thread',
|
||||
} )->[0];
|
||||
my $thread = $self->getThread;
|
||||
|
||||
# If the pasted asset is not a thread we'll have to update the threadId of it and all posts below it.
|
||||
if ( $self->get('threadId') ne $self->getId ) {
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ Returns a list of the post objects in this thread, including the thread post its
|
|||
|
||||
sub getPosts {
|
||||
my $self = shift;
|
||||
$self->getLineage(["self","descendants"], {
|
||||
return $self->getLineage(["self","descendants"], {
|
||||
returnObjects => 1,
|
||||
includeArchived => 1,
|
||||
includeOnlyClasses => ["WebGUI::Asset::Post","WebGUI::Asset::Post::Thread"],
|
||||
|
|
|
|||
|
|
@ -356,7 +356,15 @@ sub getThingOptions {
|
|||
tie my %options, 'Tie::IxHash', ( "" => "" );
|
||||
my $thingyIter = WebGUI::Asset->getRoot($session)
|
||||
->getLineageIterator( ['descendants'], { includeOnlyClasses => ['WebGUI::Asset::Wobject::Thingy'], } );
|
||||
while ( my $thingy = $thingyIter->() ) {
|
||||
while ( 1 ) {
|
||||
my $thingy;
|
||||
eval { $thingy = $thingyIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $thingy;
|
||||
|
||||
tie my %things, 'Tie::IxHash', (
|
||||
$session->db->buildHash( "SELECT thingId, label FROM Thingy_things WHERE assetId=?", [ $thingy->getId ] ) );
|
||||
$options{ $thingy->get('title') } = \%things;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ use base qw(WebGUI::AssetAspect::RssFeed WebGUI::Asset::Wobject);
|
|||
#-------------------------------------------------------------------
|
||||
sub _computePostCount {
|
||||
my $self = shift;
|
||||
return scalar @{$self->getLineage(['descendants'], {includeOnlyClasses => ['WebGUI::Asset::Post']})};
|
||||
return $self->getDescendantCount({includeOnlyClasses => ['WebGUI::Asset::Post']});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _computeThreadCount {
|
||||
my $self = shift;
|
||||
return scalar @{$self->getLineage(['children'], {includeOnlyClasses => ['WebGUI::Asset::Post::Thread']})};
|
||||
return $self->getChildCount({includeOnlyClasses => ['WebGUI::Asset::Post::Thread']});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1387,11 +1387,19 @@ sub processPropertiesFromFormPost {
|
|||
$self->createSubscriptionGroup;
|
||||
}
|
||||
if ($updatePrivs) {
|
||||
foreach my $descendant (@{$self->getLineage(["descendants"],{returnObjects=>1})}) {
|
||||
$descendant->update({
|
||||
groupIdView=>$self->get("groupIdView"),
|
||||
groupIdEdit=>$self->get("groupIdEdit")
|
||||
});
|
||||
my $descendantIter = $self->getLineageIterator(['descendants']);
|
||||
while ( 1 ) {
|
||||
my $descendant;
|
||||
eval { $descendant = $descendantIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $descendant;
|
||||
$descendant->update({
|
||||
groupIdView=>$self->get("groupIdView"),
|
||||
groupIdEdit=>$self->get("groupIdEdit")
|
||||
});
|
||||
}
|
||||
}
|
||||
$self->session->scratch->delete($self->getId."_sortBy");
|
||||
|
|
@ -1686,16 +1694,21 @@ sub www_unarchiveAll {
|
|||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
|
||||
$pb->start($i18n->get('unarchive all'), $self->getUrl('func=edit'));
|
||||
my $threadIds = $self->getLineage(['children'],{
|
||||
my $threadIter = $self->getLineageIterator(['children'],{
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Post::Thread' ],
|
||||
statusToInclude => [ 'archived' ],
|
||||
} );
|
||||
ASSET: foreach my $threadId (@$threadIds) {
|
||||
my $thread = WebGUI::Asset->newPending($session, $threadId);
|
||||
if (!$thread || !$thread->canEdit) {
|
||||
next ASSET;
|
||||
ASSET: while ( 1 ) {
|
||||
my $thread;
|
||||
eval { $thread = $threadIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $thread;
|
||||
if ($thread->canEdit) {
|
||||
$thread->unarchive;
|
||||
}
|
||||
$thread->unarchive;
|
||||
}
|
||||
return $pb->finish( $self->getUrl('func=edit') );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,9 +189,16 @@ sub getEditForm {
|
|||
my $i18n = WebGUI::International->new($self->session, "Asset_Dashboard");
|
||||
if ($self->session->form->process("func") ne "add") {
|
||||
my @assetsToHide = split("\n",$self->getValue("assetsToHide"));
|
||||
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||
my %childIds;
|
||||
foreach my $child (@{$children}) {
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
$childIds{$child->getId} = $child->getTitle.' ['.ref($child).']';
|
||||
}
|
||||
$tabform->getTab("display")->checkList(
|
||||
|
|
@ -255,9 +262,16 @@ their templates.
|
|||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView;
|
||||
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
||||
my @hidden = split("\n",$self->get("assetsToHide"));
|
||||
foreach my $child (@{$children}) {
|
||||
my $childIter = $self->getLineageIterator( ["children"], {excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
unless (isIn($child->getId, @hidden) || !($child->canView)) {
|
||||
$self->session->style->setRawHeadTags($child->getExtraHeadTags);
|
||||
$child->prepareView;
|
||||
|
|
@ -323,8 +337,9 @@ sub view {
|
|||
);
|
||||
|
||||
my $templateId = $self->get("templateId");
|
||||
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
||||
# XXX Not using getLineageIterator because we loop over the children three times...
|
||||
# I'm sure there's a more efficient way to do this. We'll figure it out someday.
|
||||
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
|
||||
my @positions = split(/\./,$self->getContentPositions);
|
||||
my @hidden = split("\n",$self->get("assetsToHide"));
|
||||
foreach my $child (@{$children}) {
|
||||
|
|
|
|||
|
|
@ -607,10 +607,10 @@ returns true if the EMS has subission forms attached
|
|||
sub hasSubmissionForms {
|
||||
my $self = shift;
|
||||
# are there ~any~ forms attached to this ems?
|
||||
my $res = $self->getLineage(['children'],{ limit => 1,
|
||||
my $count = $self->getDescendantCount({
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
return scalar(@$res);
|
||||
return $count;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1038,12 +1038,12 @@ then call www_editSubmission on it
|
|||
sub www_editSubmission {
|
||||
my $self = shift;
|
||||
my $submissionId = $self->session->form->get('submissionId');
|
||||
my $asset = $self->getLineage(['descendants'], { returnObjects => 1,
|
||||
my $asset = $self->getLineageIterator(['descendants'], {
|
||||
joinClass => "WebGUI::Asset::EMSSubmission",
|
||||
whereClause => 'submissionId = ' . int($submissionId),
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
} );
|
||||
return $asset->[0]->www_editSubmission;
|
||||
return $asset->()->www_editSubmission;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1389,6 +1389,7 @@ sub www_getBadgesAsJson {
|
|||
my ($db, $form) = $session->quick(qw(db form));
|
||||
my %results = ();
|
||||
$results{records} = [];
|
||||
# TODO: Use getLineageIterator here instead
|
||||
BADGE: foreach my $badge (@{$self->getBadges}) {
|
||||
next BADGE unless $badge->canView;
|
||||
push(@{$results{records}}, {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,15 @@ Overridden to check the revision dates of children as well
|
|||
sub getContentLastModified {
|
||||
my $self = shift;
|
||||
my $mtime = $self->get("revisionDate");
|
||||
foreach my $child (@{ $self->getLineage(["children"],{returnObjects=>1}) }) {
|
||||
my $childIter = $self->getLineageIterator(["children"]);
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
my $child_mtime = $child->getContentLastModified;
|
||||
$mtime = $child_mtime if ($child_mtime > $mtime);
|
||||
}
|
||||
|
|
@ -233,7 +241,7 @@ sub view {
|
|||
my $vars = $self->getTemplateVars;
|
||||
# TODO: Getting the children template vars should be a seperate method.
|
||||
|
||||
my %rules = ( returnObjects => 1);
|
||||
my %rules = ( );
|
||||
if ( $self->get( "sortAlphabetically" ) ) {
|
||||
$rules{ orderByClause } = "assetData.title " . $self->get( "sortOrder" );
|
||||
}
|
||||
|
|
@ -241,9 +249,16 @@ sub view {
|
|||
$rules{ orderByClause } = "asset.lineage " . $self->get( "sortOrder" );
|
||||
}
|
||||
|
||||
my $children = $self->getLineage( ["children"], \%rules);
|
||||
foreach my $child ( @{ $children } ) {
|
||||
# TODO: Instead of this it should be using $child->getTemplateVars || $child->get
|
||||
my $childIter = $self->getLineageIterator( ["children"], \%rules);
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
# TODO: Instead of this it should be using $child->getTemplateVars || $child->get
|
||||
if ( $child->isa("WebGUI::Asset::Wobject::Folder") ) {
|
||||
push @{ $vars->{ "subfolder_loop" } }, {
|
||||
id => $child->getId,
|
||||
|
|
|
|||
|
|
@ -927,17 +927,21 @@ sub hasSpaceAvailable {
|
|||
# Compile the amount of disk space used
|
||||
my $maxSpace = $self->get( "maxSpacePerUser" ) * ( 1_024 ** 2 ); # maxSpacePerUser is in MB
|
||||
my $spaceUsed = 0;
|
||||
my $fileIds
|
||||
= $self->getLineage( [ 'descendants' ], {
|
||||
my $fileIter
|
||||
= $self->getLineageIterator( [ 'descendants' ], {
|
||||
joinClass => 'WebGUI::Asset::File::GalleryFile',
|
||||
whereClause => 'ownerUserId = ' . $db->quote( $userId ),
|
||||
} );
|
||||
|
||||
for my $assetId ( @{ $fileIds } ) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $self->session, $assetId );
|
||||
next unless $asset;
|
||||
$spaceUsed += $asset->get( 'assetSize' );
|
||||
|
||||
while ( 1 ) {
|
||||
my $file;
|
||||
eval { $file = $fileIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $file;
|
||||
$spaceUsed += $file->get( 'assetSize' );
|
||||
return 0 if ( $spaceUsed + $spaceWanted >= $maxSpace );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,9 +180,16 @@ sub getEditForm {
|
|||
}
|
||||
else {
|
||||
my @assetsToHide = split("\n",$self->getValue("assetsToHide"));
|
||||
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
|
||||
my %childIds;
|
||||
foreach my $child (@{$children}) {
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
$childIds{$child->getId} = $child->getTitle;
|
||||
}
|
||||
$extraFields{assetsToHide} = {
|
||||
|
|
@ -256,11 +263,18 @@ sub prepareView {
|
|||
|
||||
my %placeHolder;
|
||||
my @children;
|
||||
|
||||
for my $child ( @{ $self->getLineage( ["children"], {
|
||||
returnObjects => 1,
|
||||
|
||||
my $childIter = $self->getLineageIterator( ["children"], {
|
||||
excludeClasses => ["WebGUI::Asset::Wobject::Layout"],
|
||||
} ) } ) {
|
||||
} );
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
my $assetId = $child->getId;
|
||||
next
|
||||
if ($hidden{$assetId} || ! $child->canView);
|
||||
|
|
@ -412,7 +426,15 @@ sub getContentLastModified {
|
|||
# Buggo: this is a little too conservative. Children that are hidden maybe shouldn't count. Hm.
|
||||
my $self = shift;
|
||||
my $mtime = $self->SUPER::getContentLastModified;
|
||||
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1, excludeClasses=>['WebGUI::Asset::Wobject::Layout']})}) {
|
||||
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>['WebGUI::Asset::Wobject::Layout']});
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
my $child_mtime = $child->getContentLastModified;
|
||||
$mtime = $child_mtime if ($child_mtime > $mtime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,11 +315,17 @@ sub deleteAttribute {
|
|||
[$attributeId,$self->getId]);
|
||||
|
||||
# recalculate scores for MatrixListings
|
||||
my @listings = @{ $self->getLineage(['descendants'], {
|
||||
my $listingIter = $self->getLineageIterator(['descendants'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
|
||||
returnObjects => 1,
|
||||
}) };
|
||||
foreach my $listing (@listings){
|
||||
});
|
||||
while ( 1 ) {
|
||||
my $listing;
|
||||
eval { $listing = $listingIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $listing;
|
||||
$listing->updateScore;
|
||||
}
|
||||
|
||||
|
|
@ -661,17 +667,23 @@ sub view {
|
|||
|
||||
if ($self->canEdit){
|
||||
# Get all the MatrixListings that are still pending.
|
||||
my @pendingListings = @{ $self->getLineage(['descendants'], {
|
||||
my $pendingIter = $self->getLineageIterator(['descendants'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
|
||||
orderByClause => "revisionDate asc",
|
||||
returnObjects => 1,
|
||||
statusToInclude => ['pending'],
|
||||
}) };
|
||||
foreach my $pendingListing (@pendingListings){
|
||||
});
|
||||
while ( 1 ) {
|
||||
my $pending;
|
||||
eval { $pending = $pendingIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $pending;
|
||||
push (@{ $var->{pending_loop} }, {
|
||||
url => $pendingListing->getUrl
|
||||
."?func=view;revision=".$pendingListing->get('revisionDate'),
|
||||
name => $pendingListing->get('title'),
|
||||
url => $pending->getUrl
|
||||
."?func=view;revision=".$pending->get('revisionDate'),
|
||||
name => $pending->get('title'),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -747,18 +759,23 @@ sub view {
|
|||
|
||||
# Get the 5 MatrixListings that were last updated as objects using getLineage.
|
||||
|
||||
my @lastUpdatedListings = @{ $self->getLineage(['descendants'], {
|
||||
my $lastUpdatedIter = $self->getLineageIterator(['descendants'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
|
||||
joinClass => "WebGUI::Asset::MatrixListing",
|
||||
orderByClause => "lastUpdated desc",
|
||||
limit => 5,
|
||||
returnObjects => 1,
|
||||
}) };
|
||||
foreach my $lastUpdatedListing (@lastUpdatedListings){
|
||||
});
|
||||
for ( 1..5 ) {
|
||||
my $lastUpdated;
|
||||
eval { $lastUpdated = $lastUpdatedIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $lastUpdated;
|
||||
push (@{ $varStatistics->{last_updated_loop} }, {
|
||||
url => $lastUpdatedListing->getUrl,
|
||||
name => $lastUpdatedListing->get('title'),
|
||||
lastUpdated => $session->datetime->epochToHuman($lastUpdatedListing->get('lastUpdated'),"%z")
|
||||
url => $lastUpdated->getUrl,
|
||||
name => $lastUpdated->get('title'),
|
||||
lastUpdated => $session->datetime->epochToHuman($lastUpdated->get('lastUpdated'),"%z")
|
||||
});
|
||||
}
|
||||
$varStatistics->{lastUpdated_sortButton} = "<span id='sortByUpdated'><button type='button'>"
|
||||
|
|
|
|||
|
|
@ -114,8 +114,15 @@ sub view {
|
|||
my $first;
|
||||
my @forum_loop;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_MessageBoard");
|
||||
my $children = $self->getLineage(["children"],{includeOnlyClasses=>["WebGUI::Asset::Wobject::Collaboration"],returnObjects=>1});
|
||||
foreach my $child (@{$children}) {
|
||||
my $childIter = $self->getLineageIterator(["children"],{includeOnlyClasses=>["WebGUI::Asset::Wobject::Collaboration"]});
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
$count++;
|
||||
next unless ($child->canView);
|
||||
if ($count == 1) {
|
||||
|
|
|
|||
|
|
@ -372,13 +372,28 @@ sub view {
|
|||
# we've got to determine what our start point is based upon user conditions
|
||||
my $start;
|
||||
$self->session->asset(WebGUI::Asset->newByUrl($self->session)) unless ($self->session->asset);
|
||||
my $current = $self->session->asset;
|
||||
|
||||
my $var = {'page_loop' => []};
|
||||
|
||||
my $current = $self->session->asset;
|
||||
# no current asset is set
|
||||
unless (defined $current) {
|
||||
$current = WebGUI::Asset->getDefault($self->session);
|
||||
}
|
||||
|
||||
# Add properties from current asset
|
||||
foreach my $property (@interestingProperties) {
|
||||
$var->{'currentPage.'.$property} = $current->get($property);
|
||||
}
|
||||
$var->{'currentPage.menuTitle'} = $current->getMenuTitle;
|
||||
$var->{'currentPage.title'} = $current->getTitle;
|
||||
$var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage"));
|
||||
$var->{'currentPage.url'} = $current->getUrl;
|
||||
$var->{'currentPage.hasChild'} = $current->hasChildren;
|
||||
$var->{'currentPage.rank'} = $current->getRank;
|
||||
$var->{'currentPage.rankIs'.$current->getRank} = 1;
|
||||
|
||||
# Build the asset tree
|
||||
if ($self->get("startType") eq "specificUrl") {
|
||||
$start = WebGUI::Asset->newByUrl($self->session,$self->get("startPoint"));
|
||||
} elsif ($self->get("startType") eq "relativeToRoot") {
|
||||
|
|
@ -392,24 +407,12 @@ sub view {
|
|||
my @includedRelationships = split("\n",$self->get("assetsToInclude"));
|
||||
|
||||
my %rules;
|
||||
$rules{returnObjects} = 1;
|
||||
$rules{endingLineageLength} = $start->getLineageLength+$self->get("descendantEndPoint");
|
||||
$rules{assetToPedigree} = $current if (isIn("pedigree",@includedRelationships));
|
||||
$rules{ancestorLimit} = $self->get("ancestorEndPoint");
|
||||
$rules{orderByClause} = 'rpad(asset.lineage, 255, 9) desc' if ($self->get('reversePageLoop'));
|
||||
my @interestingProperties = ('assetId', 'parentId', 'ownerUserId', 'synopsis', 'newWindow');
|
||||
my $assets = $start->getLineage(\@includedRelationships,\%rules);
|
||||
my $var = {'page_loop' => []};
|
||||
foreach my $property (@interestingProperties) {
|
||||
$var->{'currentPage.'.$property} = $current->get($property);
|
||||
}
|
||||
$var->{'currentPage.menuTitle'} = $current->getMenuTitle;
|
||||
$var->{'currentPage.title'} = $current->getTitle;
|
||||
$var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage"));
|
||||
$var->{'currentPage.url'} = $current->getUrl;
|
||||
$var->{'currentPage.hasChild'} = $current->hasChildren;
|
||||
$var->{'currentPage.rank'} = $current->getRank;
|
||||
$var->{'currentPage.rankIs'.$current->getRank} = 1;
|
||||
my $currentLineage = $current->get("lineage");
|
||||
my $lineageToSkip = "noskip";
|
||||
my $absoluteDepthOfLastPage;
|
||||
|
|
@ -417,8 +420,7 @@ sub view {
|
|||
my %lastChildren;
|
||||
my $previousPageData = undef;
|
||||
my $eh = $self->session->errorHandler;
|
||||
foreach my $asset (@{$assets}) {
|
||||
|
||||
while ( my $asset = $assets->() ) {
|
||||
# skip pages we shouldn't see
|
||||
my $pageLineage = $asset->get("lineage");
|
||||
next if ($pageLineage =~ m/^$lineageToSkip/);
|
||||
|
|
|
|||
|
|
@ -288,7 +288,15 @@ sub view {
|
|||
|
||||
# get other shelves
|
||||
my @childShelves = ();
|
||||
SHELF: foreach my $child (@{$self->getLineage(['children'],{returnObjects=>1,includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']})}) {
|
||||
my $childIter = $self->getLineageIterator(['children'],{includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']});
|
||||
SHELF: while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
next SHELF unless $child->canView;
|
||||
my $properties = $child->get;
|
||||
$properties->{url} = $child->getUrl;
|
||||
|
|
|
|||
|
|
@ -400,14 +400,21 @@ for generating an RSS and Atom feeds.
|
|||
|
||||
sub getRssFeedItems {
|
||||
my $self = shift;
|
||||
my $stories = $self->getLineageIterator(['descendants'],{
|
||||
my $storyIter = $self->getLineageIterator(['descendants'],{
|
||||
excludeClasses => ['WebGUI::Asset::Wobject::Folder'],
|
||||
orderByClause => 'creationDate desc, lineage',
|
||||
returnObjects => 1,
|
||||
limit => $self->get('itemsPerFeed'),
|
||||
});
|
||||
my $storyData = [];
|
||||
while (my $story = $stories->()) {
|
||||
while ( 1 ) {
|
||||
my $story;
|
||||
eval { $story = $storyIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $story;
|
||||
push @{ $storyData }, $story->getRssData;
|
||||
}
|
||||
return $storyData;
|
||||
|
|
|
|||
|
|
@ -79,15 +79,19 @@ sub appendMostPopular {
|
|||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $limit = shift || $self->get("mostPopularCount");
|
||||
foreach my $asset (@{$self->getLineage(["children"],{returnObjects=>1, limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"], joinClass => 'WebGUI::Asset::WikiPage', orderByClause => 'WikiPage.views DESC'})}) {
|
||||
if (defined $asset) {
|
||||
my $assetIter = $self->getLineageIterator(["children"],{limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"], joinClass => 'WebGUI::Asset::WikiPage', orderByClause => 'WikiPage.views DESC'});
|
||||
while ( 1 ) {
|
||||
my $asset;
|
||||
eval { $asset = $assetIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $asset;
|
||||
push(@{$var->{mostPopular}}, {
|
||||
title=>$asset->getTitle,
|
||||
url=>$asset->getUrl,
|
||||
});
|
||||
} else {
|
||||
$self->session->errorHandler->error("Couldn't instanciate wikipage for master ".$self->getId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +738,16 @@ sub processPropertiesFromFormPost {
|
|||
or ($self->session->form->process('groupIdEdit') ne $self->get('groupIdEdit')));
|
||||
my $ret = $self->next::method(@_);
|
||||
if ($groupsChanged) {
|
||||
foreach my $child (@{$self->getLineage(['children'], {returnObjects => 1})}) {
|
||||
# XXX Should this do descendants for WikiPage attachments?
|
||||
my $childIter = $self->getLineageIterator(['children']);
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
$child->update({ groupIdView => $self->get('groupIdView'),
|
||||
groupIdEdit => $self->get('groupIdEdit') });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue