initial coding on activities

lots of debugging
This commit is contained in:
daviddelikat 2009-10-29 09:05:42 -05:00
parent cd66dbb780
commit debcdd08a5
7 changed files with 88 additions and 39 deletions

View file

@ -360,13 +360,9 @@ dav::log 'EMSSubmission::www_editSubmission: got self param';
my $params = shift || { };
my $session = $parent->session;
my $i18n = WebGUI::International->new($parent->session,'Asset_EventManagementSystem');
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId');
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId') || 'new';
if( ! defined( $assetId ) ) {
# if somebody calls without an assetId then display the queue for the EMS (grandparent)
dav::log 'EMSSubmission::www_editSubmission: asseId not defined';
return $parent->getParent->www_viewSubmissionQueue;
} elsif( $assetId ne 'new' ) {
if( $assetId ne 'new' ) {
dav::log 'EMSSubmission::www_editSubmission: asseId ne new';
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
if (!defined $self) {

View file

@ -259,8 +259,16 @@ sub www_editSubmissionForm {
WebGUI::HTML::filter($_->get('description'),'all')
)
} ( @$res ) );
return $parent->processStyle( '<h1>' . $i18n->get('select form to edit') .
my $title = $i18n->get('select form to edit') ;
my $content = $parent->processStyle( '<h1>' . $title .
'</h1><ul>' . $listOfLinks . '</ul>' );
if( $session->form->get('asJson') ) {
$session->http->setMimeType( 'application/json' );
return JSON->new->encode( { text => $content, title => $title } );
} else {
$session->http->setMimeType( 'text/html' );
return $content;
}
}
} elsif( $assetId ne 'new' ) {
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);

View file

@ -50,7 +50,7 @@ sub addGroupToSubmitList {
my @ids = split(' ', $self->get('eventSubmissionGroups'));
my %h;
@ids = map { $h{$_}++ == 0 ? $_ : () } ( $groupId, @ids );
$self->update({eventSubmissionGroups => join( ' ', @ids ) });
$self->addRevision({eventSubmissionGroups => join( ' ', @ids ) });
}
#-------------------------------------------------------------------
@ -107,6 +107,7 @@ returns true is the current user can submit to any form attached to this EMS
sub canSubmit {
my $self = shift;
my $user = $self->session->user;
return 0 if ! $self->hasSubmissionForms;
for my $groupId (split ' ', $self->get('eventSubmissionGroups')) {
return 1 if $user->isInGroup($groupId);
}
@ -433,7 +434,7 @@ sub getNextSubmissionId {
my $self = shift;
#my $submissionId = $self->get('nextSubmissionId');
my ($submissionId) = $self->session->db->read('select nextSubmissionId from EventManagementSystem where assetId = ?', [ $self->getId ] )->array;
$self->update( { nextSubmissionId => ($submissionId + 1) } );
$self->addRevision( { nextSubmissionId => ($submissionId + 1) } );
return $submissionId;
}

View file

@ -72,29 +72,35 @@ sub execute {
my $self = shift;
my $session = $self->session;
my $root = WebGUI::Asset->getRoot($session);
return $self->ERROR;
# keep track of how much time it's taking
my $start = time;
my $limit = 2_500;
my $timeLimit = 120;
my $list = $root->getLineage( ['children'], { returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
while (my ($assetId) = $sth->array) {
my $hd = WebGUI::Asset->new($session,$assetId,"WebGUI::Asset::Wobject::HelpDesk");
next unless defined $hd;
my $closeAfter = $hd->get("closeTicketsAfter");
my $rules = {};
$rules->{'joinClass' } = "WebGUI::Asset::Ticket";
$rules->{'whereClause' } = qq{Ticket.ticketStatus = 'resolved' and (Ticket.resolvedDate + $closeAfter <= UNIX_TIMESTAMP(NOW()))};
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::Ticket'];
$rules->{'returnObjects' } = 1;
my $tickets = $hd->getLineage(['children'], $rules);
foreach my $ticket (@{$tickets}) {
$ticket->setStatus("closed");
}
for my $emsf ( @$list ) {
my whereClause = q{ ( submissionStatus='denied' }
if( $emsf->get('deleteCreatedItems') ) {
$whereClause .= q{ or submissionStatus='created'};
}
my $checkDate = time - ( 60*60*24* $emsf->get('daysBeforeCleanup') );
$whereClause .= q{ ) and lastModifiedDate < } . $checkDate;
my $res = $emsf->getLineage(['children'],{
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
whereClause => $whereClause,
} );
for my $submission ( @$res ) {
$submission->purge;
$limit--;
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
}
}
return $self->COMPLETE;
return $self->COMPLETE;
}
1;

View file

@ -68,6 +68,44 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $session = $self->session;
my $root = WebGUI::Asset->getRoot($session);
# keep track of how much time it's taking
my $start = time;
my $limit = 2_500;
my $timeLimit = 120;
my $list = $root->getLineage( ['children'], { returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
for my $emsf ( @$list ) {
my whereClause = q{ ( submissionStatus='approved' }
my $res = $emsf->getLineage(['children'],{
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
whereClause => $whereClause,
} );
for my $submission ( @$res ) {
my %properties = $submission->get;
delete $properties{submissionId};
delete $properties{submissionStatus};
delete $properties{sendEmailOnChange};
delete $properties{ticketId};
my $ticketId = $emsf->ems->addChild(
className => 'WebGUI::Asset::Sku::EMSTicket',
%properties;
);
$submission->update({ ticketId => $ticketId });
$limit--;
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
}
}
return $self->COMPLETE;
}
sub execute {
my $self = shift;
my $session = $self->session;

View file

@ -341,7 +341,7 @@ is($sub1->get('status'),'approved','set status to approved');
$sub2->update({ status => 'denied' });
is($sub2->get('status'),'denied','set status to denied');
SKIP: { skip "workflow activities not coded yet", 10 unless 0;
SKIP: { skip "workflow activities not coded yet", 10 if 0;
# create the workflows/activities for processing
my $approveSubmissions = WebGUI::Test::Activity->create( $session,

View file

@ -154,26 +154,26 @@ WebGUI.EMS = function (configs) {
}
alert(message);
return;
} else if( typeof(WebGUI.EMS.Items[response.submissionId]) == "undefined"
|| WebGUI.EMS.Items[response.submissionId] == null ) {
} else if( typeof(WebGUI.EMS.Items[response.title]) == "undefined"
|| WebGUI.EMS.Items[response.title] == null ) {
// if there is a tab .. close it,
// at least until I can get the JS/HTML re-written to handle multiple tabs
// there should only be one
for( var ticketId in WebGUI.EMS.Tickets ) { WebGUI.EMS.closeTab(ticketId) }
for( var item in WebGUI.EMS.Items ) { WebGUI.EMS.closeTab(item) }
var myContent = document.createElement("div");
myContent.innerHTML = response.itemText;
myContent.innerHTML = response.text;
myTab = new YAHOO.widget.Tab({
label: response.submissionId + '<span class="close"><img src="/extras/wobject/EMS/close12_1.gif" alt="X" title="' +
label: response.title + '<span class="close"><img src="/extras/wobject/EMS/close12_1.gif" alt="X" title="' +
WebGUI.EMS.i18n.get('Asset_EMSSubmission','close tab') + '" /></span>',
contentEl: myContent
});
WebGUI.EMS.Tabs.addTab( myTab );
YAHOO.util.Event.on(myTab.getElementsByClassName('close')[0], 'click', WebGUI.EMS.closeTab , myTab);
WebGUI.EMS.Items[response.submissionId] = new Object();
WebGUI.EMS.Items[response.submissionId].Tab = myTab;
WebGUI.EMS.Items[response.title] = new Object();
WebGUI.EMS.Items[response.title].Tab = myTab;
} else {
myTab = WebGUI.EMS.Tickets[response.submissionId].Tab;
myTab.set('content', response.itemText);
myTab = WebGUI.EMS.Tickets[response.title].Tab;
myTab.set('content', response.text);
}
// make sure the script on the ticket has run
// if( typeof( WebGUI.ticketJScriptRun ) == "undefined" ) {