public void validateId(int id) { Report report = getReportById(id); if (report != null) { throw new IllegalCommandException("Report with passed id already exists."); } }
public Widget getWidgetWithLoggedPin(DashBoard dash, int deviceId, short pin, PinType pinType) { for (Widget widget : dash.widgets) { if (widget instanceof Superchart) { Superchart graph = (Superchart) widget; if (isWithinGraph(dash, graph, pin, pinType, deviceId)) { return graph; } } if (widget instanceof DeviceTiles) { DeviceTiles deviceTiles = (DeviceTiles) widget; for (TileTemplate tileTemplate : deviceTiles.templates) { for (Widget tilesWidget : tileTemplate.widgets) { if (tilesWidget instanceof Superchart) { Superchart graph = (Superchart) tilesWidget; if (isWithinGraph(dash, graph, pin, pinType, deviceId, tileTemplate.deviceIds)) { return graph; } } } } } if (widget instanceof ReportingWidget) { ReportingWidget reportingWidget = (ReportingWidget) widget; if (reportingWidget.hasPin(pin, pinType)) { return reportingWidget; } } } return null; }
int existingReportIndex = reportingWidget.getReportIndexById(reportId); if (existingReportIndex == -1) { throw new IllegalCommandException("Cannot find report with provided id.");
reportingWidget.validateId(report.id);
int existingReportIndex = reportingWidget.getReportIndexById(report.id); if (existingReportIndex == -1) { throw new IllegalCommandException("Cannot find report with provided id.");
Report report = reportingWidget.getReportById(reportId); if (report == null) { throw new IllegalCommandException("Cannot find report with passed id.");