📄 ticketnotificationmanagerejb.java
字号:
//INFO("RUTEST: "+notification.getQw_mailbody());
//notificationLocal.setMessage("TEST MSG MMMMMM ");
notificationLocal.setMessage( ( notification.getQw_mailbody() == null ) ?
null : new String( notification.getQw_mailbody() ) );
//if( notification.getIncluderecord().intValue() == 1 ) {
// add record info
// notificationLocal.setForm( loadCaseForm() );
//} else {
// reset record info
// notificationLocal.setForm( null );
//}
// All recipients are in
if( notifRecipientHandlers != null ) {
// for all recipients do --
for( int j2 = 0; j2 < notifRecipientHandlers.size(); j2++ ) {
NotifRecipientFieldObjectHandler notifRecipientFieldObjectHandler =
( NotifRecipientFieldObjectHandler ) notifRecipientHandlers.get( j2 );
NotifRecipientFieldObject notifRecipientFieldObject =
( NotifRecipientFieldObject ) notifRecipientFieldObjectHandler.getJEObject();
Integer notifRecipient = notifRecipientFieldObject.getQw_recipient();
if( notifRecipient == null ) {
continue;
}
User notificationUser = null;
WorkGroup notificationGroup = null;
String notificationAddr = null;
// choose notifier
if( notifRecipient.intValue() == TicketNotificationHelper.CUSTOMER_RECIPIENT ) {
// to case customer..
if(isIntCustomer)
notificationUser = loadTicketIntCustomer(ticketCustomerId);
else
notificationAddr = loadTicketCustomer(ticketCustomerId);
} else if( notifRecipient.intValue() == TicketNotificationHelper.AGENT_RECIPIENT ) {
// to ticket agent..
notificationUser = loadTicketAgent();
} else if( notifRecipient.intValue() == TicketNotificationHelper.OWNER_RECIPIENT ) {
// to ticket owner..
notificationUser = loadTicketOwner();
} else if( notifRecipient.intValue() == TicketNotificationHelper.WORKGROUP_RECIPIENT ) {
// to ticket workgroup..
notificationGroup = loadTicketGroup();
} else if( notifRecipient.intValue() == TicketNotificationHelper.EMAIL_TO_RECIPIENT ) {
// send special email..
notificationAddr = notification.getQw_email();
}
if( getLogger().isInfoEnabled() ) {
INFO( "Notification action #" + i );
INFO( " recipient type: " + notifRecipient );
INFO( " method: " + notification.getQw_sendmode() );
INFO( " notification user: " + notificationUser );
INFO( " notification group: " + notificationGroup );
INFO( " notification addr: " + notificationAddr );
}
//
// 5. Get notification (action) method. Do this
// action.
//
if( notificationAddr != null ) {
//
// 5.1 always send email to addressee
//
notificationLocal
.notifyByMail( notificationAddr );
} else if( notification.getQw_sendmode() == null ) {
//
// 5.2 send default notification
//
if( notificationUser != null ) {
// send to user
notificationLocal.notify( notificationUser );
} else if( notificationGroup != null ) {
// send to group
notificationLocal.notify( notificationGroup,
null, null );
} else {
// warning!
WARN( "Can't send default notification. Recipient is empty." );
}
} else if( notification.getQw_sendmode().intValue() == TicketNotificationHelper.ALERT_METHOD ) {
//
// 5.3 send notification alert
//
if( notificationUser != null ) {
// send alert to user
notificationLocal
.notifyByAlert( notificationUser );
} else if( notificationGroup != null ) {
// send alert to group
notificationLocal.notifyByAlert(
notificationGroup, null );
} else {
// warning!
WARN( "Can't send notification alert. Recipient is empty." );
}
} else {
//
// 5.4 send notification mail
//
if( notificationUser != null ) {
// send mail to user
notificationLocal
.notifyByMail( notificationUser );
} else if( notificationGroup != null ) {
// send mail to group
notificationLocal
.notifyByMail( notificationGroup );
} else {
// warning!
WARN( "Can't send notification mail. Recipient is empty." );
}
}
} // --- for all recipients
} else {
WARN( "Can't send notification mail. Recipient is empty." );
}
}
}
} catch( EQLException ex ) {
throwException( ex );
} catch( Throwable t ) {
ErrorHelper.throwSystemException( t, this );
} finally {
// remove NotificationManager stateful EJB
try {
notificationLocal.remove();
} catch( Throwable t ) {
ERROR( t );
}
}
// Ok.
if( getLogger().isInfoEnabled() ) {
INFO( "Ticket notification done (pkey = " + ticketObject.getQw_ticketid()
+ ")." );
INFO( "Time (ms) - " + ( System.currentTimeMillis() - time ) );
}
}
/**
* Send case owner notification
*/
public void doOwnerNotification() {
/** @todo implement it */
}
// ----------------------------------------------------- private methods
//
// Load ticket agent
//
private User loadTicketAgent() {
if( agent == null ) {
INFO( "Trying to load ticket agent #" + ticketObject.getQw_agentid() );
agent = loadUser( ticketObject.getQw_agentid() );
}
return agent;
}
//
// Load ticket owner
//
private User loadTicketOwner() {
if( owner == null ) {
INFO( "Trying to load ticket owner #" + ticketObject.getQw_ownerid() );
owner = loadUser( ticketObject.getQw_ownerid() );
}
return owner;
}
//
// Load ticket Int Customer
//
private User loadTicketIntCustomer(Long intCustomerId) {
if( intCustomer == null ) {
INFO( "Trying to load ticket internal customer #" + intCustomerId );
intCustomer = loadEmployee( intCustomerId );
}
return intCustomer;
}
//
// Load ticket Customer
//
private String loadTicketCustomer(Long customerId) {
if( customerMail == null ) {
INFO( "Trying to load mail address for ticket internal customer #" + customerId );
customerMail = loadCustomerMail( customerId );
//customerMail = "test@mail.ru";
}
return customerMail;
}
//
// Load ticket group
//
private WorkGroup loadTicketGroup() {
if( group == null ) {
INFO( "Trying to load ticket group #" + ticketObject.getQw_workgroupid() );
group = loadGroup( ticketObject.getQw_workgroupid() );
}
return group;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -