Search in sources :

Example 1 with StatsEvent

use of org.bedework.sysevents.events.StatsEvent in project bw-calendar-engine by Bedework.

the class DataValues method update.

/**
 * @param ev
 */
public void update(final SysEvent ev) {
    SysCode sc = ev.getSysCode();
    if (ev instanceof TimedEvent) {
        TimedEvent te = (TimedEvent) ev;
        String lbl = te.getLabel();
        DataAvg dv = timedValuesMap.get(lbl);
        if (dv == null) {
            dv = new DataAvg(lbl, ev.getSysCode());
            timedValuesMap.put(lbl, dv);
        }
        dv.inc(te.getMillis());
        return;
    }
    if (ev instanceof MillisecsEvent) {
        DataAvg dv = dvMap.get(sc);
        if (dv != null) {
            dv.inc(((MillisecsEvent) ev).getMillis());
        }
        return;
    }
    if (sc == SysCode.STATS) {
        StatsEvent se = (StatsEvent) ev;
        String sname = se.getName();
        DataAvg da = statMap.get(sname);
        if (da == null) {
            da = new DataAvg(sname, sc);
            statMap.put(sname, da);
        }
        StatType st = StatsEvent.getStatType(sname);
        if (st != StatType.lnum) {
            da.inc(1);
        } else if (se.getLongValue() != null) {
            da.inc(se.getLongValue());
        }
        return;
    }
}
Also used : MillisecsEvent(org.bedework.sysevents.events.MillisecsEvent) TimedEvent(org.bedework.sysevents.events.TimedEvent) StatType(org.bedework.sysevents.events.StatsEvent.StatType) StatsEvent(org.bedework.sysevents.events.StatsEvent) SysCode(org.bedework.sysevents.events.SysEventBase.SysCode)

Aggregations

MillisecsEvent (org.bedework.sysevents.events.MillisecsEvent)1 StatsEvent (org.bedework.sysevents.events.StatsEvent)1 StatType (org.bedework.sysevents.events.StatsEvent.StatType)1 SysCode (org.bedework.sysevents.events.SysEventBase.SysCode)1 TimedEvent (org.bedework.sysevents.events.TimedEvent)1