String topiaId = cron.getTopiaId(); String label = cron.getLabel(); if (topiaId == null || "".equals(topiaId)) { if (cronDAO.findByLabel(label) != null) { } else { newCron = cronDAO.findByTopiaId(topiaId); if (!newCron.getLabel().equals(label) && cronDAO.findByLabel(label) != null) { throw new LogicException("error.service.cron.already.exists"); newCron.setDateEnd(cron.getDateEnd()); newCron.setDateStart(cron.getDateStart()); newCron.setEnable(cron.getEnable()); newCron.setLabel(label); newCron.setTemplate(cron.getTemplate()); if (cron.getAuthor() != null && !cron.getAuthor().isEmpty()) { newCron.setAuthor(cron.getAuthor()); } else { newCron.setAuthor(SecurityHelper.getUser().getTopiaId()); Event event = eventDAO.findByTopiaId(cron.getEvent().getTopiaId()); newCron.setEvent(event); String expression = cron.getExpression(); if (expression != null && !"".equals(expression) && !CronExpression.isValidExpression(expression)) { throw new LogicException("error.service.cron.expression.invalid"); newCron.setExpression(expression);
/** * Ajout d'une notification */ public void add(Cron cron) { try { boolean enable = cron.getEnable(); String expression = cron.getExpression(); if (enable && expression != null && !"".equals(expression)) { addCron(cron); } } catch (Exception e) { log.error("Adding failed", e); } }
/** * Ajout dans le Scheduler d'un notification */ protected void addCron(Cron cron) throws Exception { CronTrigger cronTrigger = new CronTrigger(cron.getLabel(), Scheduler.DEFAULT_GROUP, cron.getLabel(), Scheduler.DEFAULT_GROUP, cron.getDateStart(), cron.getDateEnd(), cron.getExpression()); JobDetail jobDetail = new JobDetail(cron.getLabel(), Scheduler.DEFAULT_GROUP, NotifierJob.class); JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put("cronTopiaId", cron.getTopiaId()); jobDetail.setJobDataMap(jobDataMap); scheduler.scheduleJob(jobDetail, cronTrigger); log.info("Added cron : " + cron.getLabel()); }
"event", cron.getEvent(), "cron", cron, "date", cron.getTopiaCreateDate()); log.debug("NotifyCron " + cron.getTopiaId() + " in queue " + queues.size()); log.info("Nothing to do for cron " + cron.getTopiaId());
TaasUser author = userDAO.findByTopiaId(cron.getAuthor()); Collection<String> recipients = cron.getRecipients(); Set<String> to = new HashSet<String>(); if (log.isDebugEnabled()) { log.info("No recipient cron " + cron.getTopiaId());
log.debug("Send cron " + cron.getTopiaId() + " to " + to); context.put("event", events.get(0)); String templateName = cron.getTemplate(); log.info("Nothing to do " + cron.getTopiaId() + " to " + to);
@Override public void delete(E entity) throws TopiaException { { List<Cron> list = getContext() .getDAO(Cron.class) .findAllByProperties(Cron.PROPERTY_EVENT, entity); for (Cron item : list) { // sletellier : Set null only if target is concerned by deletion if (entity.equals(item.getEvent())) { item.setEvent(null); } } } { List<Queue> list = getContext() .getDAO(Queue.class) .findAllByProperties(Queue.PROPERTY_EVENT, entity); for (Queue item : list) { // sletellier : Set null only if target is concerned by deletion if (entity.equals(item.getEvent())) { item.setEvent(null); } } } super.delete(entity); }
log.debug("Send cron " + cron.getTopiaId() + " to " + to); log.info("Nothing to do " + cron.getTopiaId() + " to " + to);
/** * Suppression d'une notification */ public void del(Cron cron) { try { boolean result = scheduler.deleteJob(cron.getLabel(), Scheduler.DEFAULT_GROUP); if (result) { log.info("Deleted cron : " + cron.getLabel()); } else { log.info("Failed delete cron : " + cron.getLabel()); } } catch (Exception e) { log.error("Deleting failed", e); } }
String fileName = dirName + cron.getTemplate() + SandraSchedulerConfigHelper.getNotifierTemplateExt(appConfig);
/** * Ajout dans le Scheduler d'un notification */ protected void addCron(Cron cron) throws Exception { CronTrigger cronTrigger = new CronTrigger(cron.getLabel(), Scheduler.DEFAULT_GROUP, cron.getLabel(), Scheduler.DEFAULT_GROUP, cron.getDateStart(), cron.getDateEnd(), cron.getExpression()); JobDetail jobDetail = new JobDetail(cron.getLabel(), Scheduler.DEFAULT_GROUP, NotifierJob.class); JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put("cronTopiaId", cron.getTopiaId()); jobDetail.setJobDataMap(jobDataMap); scheduler.scheduleJob(jobDetail, cronTrigger); log.info("Added cron : " + cron.getLabel()); }
"event", cron.getEvent(), "cron", cron, "date", cron.getTopiaCreateDate()); log.debug("NotifyCron " + cron.getTopiaId() + " in queue " + queues.size()); log.info("Nothing to do for cron " + cron.getTopiaId());
TaasUser author = userDAO.findByTopiaId(cron.getAuthor()); Collection<String> recipients = cron.getRecipients(); Set<String> to = new HashSet<String>(); if (log.isDebugEnabled()) { log.info("No recipient cron " + cron.getTopiaId());
/** * Ajout d'une notification */ public void add(Cron cron) { try { boolean enable = cron.getEnable(); String expression = cron.getExpression(); if (enable && expression != null && !"".equals(expression)) { addCron(cron); } } catch (Exception e) { log.error("Adding failed", e); } }
for (Cron cron : crons) { if (log.isDebugEnabled()) { log.debug("cron : " + cron.getTopiaId());
/** * Suppression d'une notification */ public void del(Cron cron) { try { boolean result = scheduler.deleteJob(cron.getLabel(), Scheduler.DEFAULT_GROUP); if (result) { log.info("Deleted cron : " + cron.getLabel()); } else { log.info("Failed delete cron : " + cron.getLabel()); } } catch (Exception e) { log.error("Deleting failed", e); } }
String topiaId = cron.getTopiaId(); String label = cron.getLabel(); if (topiaId == null || "".equals(topiaId)) { if (cronDAO.findByLabel(label) != null) { } else { newCron = cronDAO.findByTopiaId(topiaId); if (!newCron.getLabel().equals(label) && cronDAO.findByLabel(label) != null) { throw new LogicException("error.service.cron.already.exists"); newCron.setDateEnd(cron.getDateEnd()); newCron.setDateStart(cron.getDateStart()); newCron.setEnable(cron.getEnable()); newCron.setLabel(label); newCron.setTemplate(cron.getTemplate()); if (cron.getAuthor() != null && !cron.getAuthor().isEmpty()) { newCron.setAuthor(cron.getAuthor()); } else { newCron.setAuthor(SecurityHelper.getUser().getTopiaId()); Event event = eventDAO.findByTopiaId(cron.getEvent().getTopiaId()); newCron.setEvent(event); String expression = cron.getExpression(); if (expression != null && !"".equals(expression) && !CronExpression.isValidExpression(expression)) { throw new LogicException("error.service.cron.expression.invalid"); newCron.setExpression(expression);
for (Cron cron : crons) { if (log.isDebugEnabled()) { log.debug("cron : " + cron.getTopiaId());
@Override public void delete(E entity) throws TopiaException { { List<Queue> list = getContext().getHibernate().createSQLQuery( "SELECT main.topiaid " + "from queue main, cron_queue secondary " + "where main.topiaid=secondary.queue" + " and secondary.cron='" + entity.getTopiaId() + "'") .addEntity("main", com.cybelia.sandra.SandraDAOHelper.getImplementationClass(Queue.class)).list(); for (Queue item : list) { item.removeCron(entity); } } super.delete(entity); }