public void addTimers(TimerWorker timerWorker, UserKey userKey) { for (Widget widget : widgets) { if (widget instanceof DeviceTiles) { timerWorker.add(userKey, (DeviceTiles) widget, id); } else if (widget instanceof Timer) { timerWorker.add(userKey, (Timer) widget, id, -1L, -1L); } else if (widget instanceof Eventor) { timerWorker.add(userKey, (Eventor) widget, id); } } }
public int add(UserKey userKey, DeviceTiles deviceTiles, int dashId) { int counter = 0; for (TileTemplate template : deviceTiles.templates) { for (Widget widgetInTemplate : template.widgets) { if (widgetInTemplate instanceof Timer) { add(userKey, (Timer) widgetInTemplate, dashId, deviceTiles.id, template.id); counter++; } } } return counter; }
public void add(UserKey userKey, Eventor eventor, int dashId) { if (eventor.rules != null) { for (Rule rule : eventor.rules) { if (rule.isValidTimerRule()) { add(userKey, dashId, eventor.deviceId, eventor.id, rule.triggerTime.id, rule.triggerTime, rule.actions); } } } }
private void init(ConcurrentMap<UserKey, User> users) { int counter = 0; for (Map.Entry<UserKey, User> entry : users.entrySet()) { for (DashBoard dash : entry.getValue().profile.dashBoards) { int dashId = dash.id; for (Widget widget : dash.widgets) { if (widget instanceof DeviceTiles) { DeviceTiles deviceTiles = (DeviceTiles) widget; counter += add(entry.getKey(), deviceTiles, dashId); } else if (widget instanceof Timer) { Timer timer = (Timer) widget; add(entry.getKey(), timer, dashId, -1, -1); counter++; } else if (widget instanceof Eventor) { Eventor eventor = (Eventor) widget; add(entry.getKey(), eventor, dashId); counter++; } } } } log.info("Timers : {}", counter); }