Package com.jtheory.jdring

Examples of com.jtheory.jdring.AlarmEntry


            reminderMail.setJob(job);
            MailJob mailJob = new MailJob(reminderMail);
           
            for(Object obj :  manager.getAlarmManager().getAllAlarms())
            {
                AlarmEntry alarmEntry = (AlarmEntry) obj;
                String name;
                if(alarmEntry.getName().equals("JOB" + job.getId())){
                    if(log.isDebugEnabled())
                        log.debug("removing mail job for [job]: " + job);
                    manager.getAlarmManager().removeAlarm(alarmEntry);
                }
            }
            try
            {
                if(log.isInfoEnabled())
                    log.info("adding mailJob for [job]: " + job);
                String name;
                Calendar reminderDate = GregorianCalendar.getInstance();
                reminderDate.setTime(job.getDueDate());
                reminderDate.add(Calendar.MINUTE, -1 * Settings.getInstance().getAlarmBeforeJob());
                AlarmEntry alarmEntry = new AlarmEntry("JOB" + job.getId(),reminderDate.getTime(),mailJob);
                alarmEntry.setRingInNewThead();
                manager.getAlarmManager().addAlarm(alarmEntry);
            }
            catch (PastDateException e)
            {
                log.info("ignoring old job alarm: " + job);
View Full Code Here


            EventVO eventVO = (EventVO) event.getObject();
            SchedulingManager manager = SchedulingManager.getInstance();
           
            for(Object obj :  manager.getAlarmManager().getAllAlarms())
            {
                AlarmEntry alarmEntry = (AlarmEntry) obj;
                if(alarmEntry.getName().contains("EVENT"+eventVO.getId())){
                    if(log.isDebugEnabled())
                        log.debug("removing mail job for: " + eventVO);
                    manager.getAlarmManager().removeAlarm(alarmEntry);
                }
            }
        }
        else if(event.getObject() instanceof JobVO)
        {
            JobVO job = (JobVO) event.getObject();
            SchedulingManager manager = SchedulingManager.getInstance();
           
            for(Object obj :  manager.getAlarmManager().getAllAlarms())
            {
                AlarmEntry alarmEntry = (AlarmEntry) obj;
                if(alarmEntry.getName().contains("JOB" + job.getId())){
                    if(log.isDebugEnabled())
                        log.debug("removing mail job for: " + job);
                    manager.getAlarmManager().removeAlarm(alarmEntry);
                }
            }
View Full Code Here

                if(dateNode != null && dateNode.getText() != null)
                {
                    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
                    try
                    {
                        AlarmEntry alarmEntry = new AlarmEntry(name,sdf.parse(dateNode.getText()), alarm);
                        alarmEntry.setRingInNewThead();
                        if(log.isDebugEnabled())
                            log.debug("adding event: "+ alarmEntry);
                        alarmManager.addAlarm(alarmEntry);
                    }
                    catch (ParseException e)
                    {
                        log.warn("unparseable date format of event: " + name,e);
                    }
                    catch (PastDateException e)
                    {
                        if(log.isInfoEnabled())
                            log.info("ignoring old event: " + name);
                    }
                   
                }
            }
            else if(alarm != null && type.equals("DELAY"))
            {
                Node minuteNode = root.selectSingleNode("//events/event/minute");
                if(minuteNode != null && minuteNode.getText() != null)
                {
                    int minute = Integer.parseInt(minuteNode.getText());
                    try
                    {
                        AlarmEntry alarmEntry = new AlarmEntry(name,minute,true,alarm);
                        alarmEntry.setRingInNewThead();
                        if(log.isDebugEnabled())
                            log.debug("adding event: "+ alarmEntry);
                        alarmManager.addAlarm(alarmEntry);
                    }
                    catch (PastDateException e)
                    {
                        if(log.isInfoEnabled())
                            log.info("ignoring old event: " + name);;
                    }
                }
            }
            else if(alarm != null && type.equals("CRON"))
            {
                //Minuten
                int minutes[] = getChildEntries(element, "minute");
                             
                //Stunden
                int hours[] = getChildEntries(element, "hour");
               
                //Tag des Monats
                int dayOfMonth[] = getChildEntries(element, "dayofmonth");
               
                //Monat
                int months[] = getChildEntries(element, "month");
               
                //Tag der Woche
                int dayOfWeek[] = getChildEntries(element, "dayofweek");
               
                //Jahr
                Node yearNode = root.selectSingleNode("//events/event/year");
                int year = -1;
                if(yearNode != null && yearNode.getText() != null)
                    year = Integer.parseInt(yearNode.getText());
               
                try
                {
                    AlarmEntry alarmEntry = new AlarmEntry(name,minutes,hours,dayOfMonth,months,dayOfWeek,year,alarm);
                    alarmEntry.setRingInNewThead();
                    if(log.isDebugEnabled())
                        log.debug("adding event: "+ alarmEntry);
                    alarmManager.addAlarm(alarmEntry);
                }
                catch (PastDateException e)
View Full Code Here

                       
                        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())){
                            if(log.isDebugEnabled())
                                log.debug("removing mail job for: " + job);
                            manager.getAlarmManager().removeAlarm(alarmEntry);
                        }
                    }
View Full Code Here

TOP

Related Classes of com.jtheory.jdring.AlarmEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.