reminderMail.setEvent(event.getEvent());
try
{
reminderMail.setUser(user);
MailJob mailJob = new MailJob(reminderMail);
for(Object obj : manager.getAlarmManager().getAllAlarms())
{
AlarmEntry alarmEntry = (AlarmEntry) obj;
String name;
if(event.getRecurrenceNumber() != null)
name = "EVENT"+event.getEvent().getId()+"."+event.getRecurrenceNumber();
else
name = "EVENT" + event.getEvent().getId();
if(alarmEntry.getName().equals(name)){
if(log.isDebugEnabled())
log.debug("removing mail job for: " + event);
manager.getAlarmManager().removeAlarm(alarmEntry);
}
}
try
{
if(log.isInfoEnabled())
log.info("adding mailJob for: " + event);
String name;
if(event.getRecurrenceNumber() != null)
name = "EVENT"+event.getEvent().getId()+"."+event.getRecurrenceNumber();
else
name = "EVENT" + event.getEvent().getId();
AlarmEntry alarmEntry = new AlarmEntry(name,event.getReminderDate(),mailJob);
alarmEntry.setRingInNewThead();
manager.getAlarmManager().addAlarm(alarmEntry);
}
catch (PastDateException e)
{
if(log.isInfoEnabled())
log.info("ignoring old event alarm: " + event);
}
}catch(NoValidSenderException e)
{
log.warn("no person for user: " + user);
}
}
else
{
if(log.isInfoEnabled())
log.info("no reminder date of old reminder date for: " + event);
}
}
List<JobVO> jobs = new JobDAO().getByUser(user, startDate, endDate);
if(log.isDebugEnabled())
log.debug(jobs.size() + " job jobs found");
for(JobVO job : jobs)
{
if(log.isDebugEnabled())
log.debug("generating jobs for job: " + job);
JobReminderMail reminderMail;
try
{
reminderMail = new JobReminderMail();
}
catch (AddressException e1)
{
log.warn("cannot create reminder mail, incorrect sender address",e1);
return;
}
reminderMail.setJob(job);
try
{
reminderMail.setUser(user);
MailJob mailJob = new MailJob(reminderMail);
for(Object obj : manager.getAlarmManager().getAllAlarms())
{
AlarmEntry alarmEntry = (AlarmEntry) obj;
if(alarmEntry.getName().equals("EVENT"+job.getId())){