private void deleteTimers(UserKey userKey, int dashId, DeviceTiles deviceTiles) { for (TileTemplate template : deviceTiles.templates) { for (Widget widgetInTemplate : template.widgets) { if (widgetInTemplate instanceof Timer) { delete(userKey, (Timer) widgetInTemplate, dashId, deviceTiles.id, template.id); } } } } }
public void deleteTimers(UserKey userKey, DashBoard dash) { for (Widget widget : dash.widgets) { if (widget instanceof DeviceTiles) { DeviceTiles deviceTiles = (DeviceTiles) widget; deleteTimers(userKey, dash.id, deviceTiles); } else if (widget instanceof Timer) { delete(userKey, (Timer) widget, dash.id, -1L, -1L); } else if (widget instanceof Eventor) { delete(userKey, (Eventor) widget, dash.id); } } }
public void delete(UserKey userKey, Eventor eventor, int dashId) { if (eventor.rules != null) { for (Rule rule : eventor.rules) { if (rule.isValidTimerRule()) { delete(userKey, dashId, eventor.deviceId, eventor.id, rule.triggerTime.id, -1L, -1L, rule.triggerTime); } } } }
/** * Removes all widgets with tabId greater than lastTabIndex */ static Widget[] deleteTabs(TimerWorker timerWorker, User user, UserKey userKey, int dashId, long deviceTilesId, long templateId, Widget[] widgets, int lastTabIndex) { ArrayList<Widget> zeroTabWidgets = new ArrayList<>(); int removedWidgetPrice = 0; for (Widget widgetToDelete : widgets) { if (widgetToDelete.tabId > lastTabIndex) { removedWidgetPrice += widgetToDelete.getPrice(); if (widgetToDelete instanceof Timer) { timerWorker.delete(userKey, (Timer) widgetToDelete, dashId, deviceTilesId, templateId); } else if (widgetToDelete instanceof Eventor) { timerWorker.delete(userKey, (Eventor) widgetToDelete, dashId); } } else { zeroTabWidgets.add(widgetToDelete); } } user.addEnergy(removedWidgetPrice); return zeroTabWidgets.toArray(new Widget[0]); }
public void delete(UserKey userKey, Timer timer, int dashId, long deviceTilesId, long templateId) { if (timer.isValidStart()) { delete(userKey, dashId, timer.deviceId, timer.id, 0, deviceTilesId, templateId, new TimerTime(timer.startTime)); } if (timer.isValidStop()) { delete(userKey, dashId, timer.deviceId, timer.id, 1, deviceTilesId, templateId, new TimerTime(timer.stopTime)); } }