Search in sources :

Example 1 with StatisticUpdateManager

use of org.olat.course.statistic.StatisticUpdateManager in project openolat by klemens.

the class StatisticsAdminController method refreshUIState.

private void refreshUIState() {
    log_.info("refreshUIState: schedulerFactoryBean found");
    boolean enabled = false;
    String cronExpression = "";
    Trigger.TriggerState triggerState;
    try {
        TriggerKey triggerKey = new TriggerKey("updateStatisticsTrigger", null);
        triggerState = scheduler.getTriggerState(triggerKey);
        enabled = triggerState != Trigger.TriggerState.NONE && triggerState != Trigger.TriggerState.ERROR;
        Trigger trigger = scheduler.getTrigger(triggerKey);
        if (trigger == null) {
            enabled &= false;
        } else {
            enabled &= trigger.getJobKey().getName().equals("org.olat.statistics.job.enabled");
            if (trigger instanceof CronTrigger) {
                log_.info("refreshUIState: org.olat.statistics.job.enabled check, enabled now: " + enabled);
                cronExpression = ((CronTrigger) trigger).getCronExpression();
            }
        }
        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);
    }
    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);
    }
    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();
}
Also used : TriggerKey(org.quartz.TriggerKey) CronTrigger(org.quartz.CronTrigger) Trigger(org.quartz.Trigger) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) StatisticUpdateManager(org.olat.course.statistic.StatisticUpdateManager)

Example 2 with StatisticUpdateManager

use of org.olat.course.statistic.StatisticUpdateManager in project openolat by klemens.

the class StatisticsAdminController method updateStatisticUpdateOngoingFlag.

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());
    }
}
Also used : StatisticUpdateManager(org.olat.course.statistic.StatisticUpdateManager)

Example 3 with StatisticUpdateManager

use of org.olat.course.statistic.StatisticUpdateManager in project openolat by klemens.

the class StatisticsAdminController method 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);
        }
    }
}
Also used : StatisticUpdateManager(org.olat.course.statistic.StatisticUpdateManager)

Example 4 with StatisticUpdateManager

use of org.olat.course.statistic.StatisticUpdateManager in project OpenOLAT by OpenOLAT.

the class StatisticsAdminController method 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);
        }
    }
}
Also used : StatisticUpdateManager(org.olat.course.statistic.StatisticUpdateManager)

Example 5 with StatisticUpdateManager

use of org.olat.course.statistic.StatisticUpdateManager in project OpenOLAT by OpenOLAT.

the class StatisticsAdminController method event.

@Override
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);
            }
        }
    }
}
Also used : StatisticUpdateManager(org.olat.course.statistic.StatisticUpdateManager)

Aggregations

StatisticUpdateManager (org.olat.course.statistic.StatisticUpdateManager)8 CronTrigger (org.quartz.CronTrigger)2 SchedulerException (org.quartz.SchedulerException)2 Trigger (org.quartz.Trigger)2 TriggerKey (org.quartz.TriggerKey)2