/**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    if (STATISTICS_FULL_RECALCULATION_TRIGGER_BUTTON.equals(event.getCommand())) {
      StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {

        String title = getTranslator().translate("statistics.fullrecalculation.really.title");
        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())) {
      StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {
        statisticUpdateManager.updateStatistics(false, getUpdateFinishedCallback());
        refreshUIState();
        getInitialComponent().setDirty(true);
      }
    }
  }
 private void updateStatisticUpdateOngoingFlag() {
   StatisticUpdateManager 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");
      Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
      if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) {
        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 (SchedulerException e) {
          log_.warn(
              "refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state",
              e);
        }
      }
      CronTriggerBean triggerBean =
          (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger");
      JobDetail jobDetail = triggerBean.getJobDetail();
      enabled &= jobDetail.getName().equals("org.olat.statistics.job.enabled");
      log_.info("refreshUIState: org.olat.statistics.job.enabled check, enabled now: " + enabled);
      cronExpression = triggerBean.getCronExpression();
      StatisticUpdateManager 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();
  }
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == dialogCtr_) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
       if (statisticUpdateManager == null) {
         log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
       } else {
         statisticUpdateManager.updateStatistics(true, getUpdateFinishedCallback());
         refreshUIState();
         getInitialComponent().setDirty(true);
       }
     }
   }
 }