@Override @SuppressWarnings("unused") protected void event(final UserRequest ureq, final Component source, final Event event) { if (STATISTICS_FULL_RECALCULATION_TRIGGER_BUTTON.equals(event.getCommand())) { final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager(); if (statisticUpdateManager == null) { log.info("event: UpdateStatisticsJob configured, but no StatisticManager available"); } else { final String title = getTranslator().translate("statistics.fullrecalculation.really.title"); final String text = getTranslator().translate("statistics.fullrecalculation.really.text"); dialogCtr_ = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), title, text); listenTo(dialogCtr_); dialogCtr_.activate(); } } else if (STATISTICS_UPDATE_TRIGGER_BUTTON.equals(event.getCommand())) { final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager(); if (statisticUpdateManager == null) { log.info("event: UpdateStatisticsJob configured, but no StatisticManager available"); } else { statisticUpdateManager.updateStatistics(false, getUpdateFinishedCallback()); refreshUIState(); content.put( "updatecontrol", new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000)); getInitialComponent().setDirty(true); } } }
private void updateStatisticUpdateOngoingFlag() { final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager(); if (statisticUpdateManager == null) { log.info("event: UpdateStatisticsJob configured, but no StatisticManager available"); content.contextPut("statisticUpdateOngoing", Boolean.TRUE); } else { content.contextPut("statisticUpdateOngoing", statisticUpdateManager.updateOngoing()); } }
private void refreshUIState() { boolean enabled = false; String cronExpression = ""; if (CoreSpringFactory.containsBean("schedulerFactoryBean")) { log.info("refreshUIState: schedulerFactoryBean found"); final Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean"); if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) { final Scheduler schedulerBean = (Scheduler) schedulerFactoryBean; int triggerState; try { triggerState = schedulerBean.getTriggerState("updateStatisticsTrigger", null /* trigger group */); enabled = (triggerState != Trigger.STATE_NONE) && (triggerState != Trigger.STATE_ERROR); log.info( "refreshUIState: updateStatisticsTrigger state was " + triggerState + ", enabled now: " + enabled); } catch (final SchedulerException e) { log.warn( "refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state", e); } } final CronTriggerBean triggerBean = (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger"); final JobDetail jobDetail = triggerBean.getJobDetail(); enabled &= jobDetail.getName().equals("statistics.job.enabled"); log.info("refreshUIState: statistics.job.enabled check, enabled now: " + enabled); cronExpression = triggerBean.getCronExpression(); final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager(); if (statisticUpdateManager == null) { log.info("refreshUIState: statisticUpdateManager not configured"); enabled = false; } else { enabled &= statisticUpdateManager.isEnabled(); log.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled); } } else { log.info("refreshUIState: schedulerFactoryBean not found"); } if (enabled) { content.contextPut( "status", getTranslator().translate("statistics.status.enabled", new String[] {cronExpression})); } else { content.contextPut("status", getTranslator().translate("statistics.status.disabled")); } content.contextPut("statisticEnabled", enabled); recalcLastUpdated(); updateStatisticUpdateOngoingFlag(); }
@Override protected void event(final UserRequest ureq, final Controller source, final Event event) { if (source == dialogCtr_) { if (DialogBoxUIFactory.isYesEvent(event)) { final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager(); if (statisticUpdateManager == null) { log.info("event: UpdateStatisticsJob configured, but no StatisticManager available"); } else { statisticUpdateManager.updateStatistics(true, getUpdateFinishedCallback()); refreshUIState(); content.put( "updatecontrol", new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000)); getInitialComponent().setDirty(true); } } } }