use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.
the class DefaultDistributedStatusService method createStatusTable.
/**
* {@inheritDoc}
*/
@Override
public SimpleWebTable createStatusTable(DistributedStatusDetailsCommand command, Errors errors) {
SimpleWebTable table = new SimpleWebTable();
table.setErrors(errors);
// Already had some validation errors, so don't bother doing anything
if (table.getErrors().hasErrors()) {
return table;
}
table.setTitle("Distributed status view for " + command.getApplication() + " from " + command.getLocation() + " location");
List<OnmsLocationSpecificStatus> status = findLocationSpecificStatus(command, table.getErrors());
// No data was found, and an error was probably added, so just return
if (status == null) {
return table;
}
table.addColumn("Node", "");
table.addColumn("Monitor", "");
table.addColumn("Service", "");
table.addColumn("Status", "");
table.addColumn("Response", "");
table.addColumn("Last Status Change", "");
table.addColumn("Last Update", "");
SortedSet<OnmsLocationSpecificStatus> sortedStatus = new TreeSet<OnmsLocationSpecificStatus>(LOCATION_STATUS_COMPARATOR);
sortedStatus.addAll(status);
for (OnmsLocationSpecificStatus s : sortedStatus) {
table.newRow();
table.addCell(s.getMonitoredService().getIpInterface().getNode().getLabel(), getStyleForPollResult(s.getPollResult()), "element/node.jsp?node=" + s.getMonitoredService().getIpInterface().getNode().getId());
table.addCell(s.getLocationMonitor().getLocation() + "-" + s.getLocationMonitor().getId(), "", "distributed/locationMonitorDetails.htm?monitorId=" + s.getLocationMonitor().getId());
table.addCell(s.getMonitoredService().getServiceName(), "", "element/service.jsp?ifserviceid=" + s.getMonitoredService().getId());
table.addCell(s.getPollResult().getStatusName(), "bright");
table.addCell(getResponseText(s.getPollResult()), "");
table.addCell(reDateify(s.getPollResult().getTimestamp()), "");
table.addCell(reDateify(s.getLocationMonitor().getLastUpdated()), "");
}
return table;
}
use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.
the class DefaultDistributedStatusService method createFacilityStatusTable.
/**
* {@inheritDoc}
*/
@Override
public SimpleWebTable createFacilityStatusTable(Date start, Date end) {
Assert.notNull(start, "argument start cannot be null");
Assert.notNull(end, "argument end cannot be null");
if (!start.before(end)) {
throw new IllegalArgumentException("start date (" + start + ") must be older than end date (" + end + ")");
}
SimpleWebTable table = new SimpleWebTable();
List<OnmsMonitoringLocation> locationDefinitions = m_monitoringLocationDao.findAll();
Collection<OnmsApplication> applications = m_applicationDao.findAll();
if (applications.size() == 0) {
throw new IllegalArgumentException("there are no applications");
}
List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(applications);
Collections.sort(sortedApplications);
Collection<OnmsLocationSpecificStatus> mostRecentStatuses = m_locationMonitorDao.getAllMostRecentStatusChanges();
Collection<OnmsLocationSpecificStatus> statusesPeriod = new HashSet<>();
statusesPeriod.addAll(m_locationMonitorDao.getAllStatusChangesAt(start));
statusesPeriod.addAll(m_locationMonitorDao.getStatusChangesBetween(start, end));
table.setTitle("Distributed Status Summary");
table.addColumn("Area", "");
table.addColumn("Location", "");
for (OnmsApplication application : sortedApplications) {
table.addColumn(application.getName(), "");
}
for (OnmsMonitoringLocation locationDefinition : locationDefinitions) {
Collection<OnmsLocationMonitor> monitors = m_locationMonitorDao.findByLocationDefinition(locationDefinition);
table.newRow();
table.addCell(locationDefinition.getMonitoringArea(), "");
table.addCell(locationDefinition.getLocationName(), "");
for (OnmsApplication application : sortedApplications) {
Collection<OnmsMonitoredService> memberServices = m_monitoredServiceDao.findByApplication(application);
Severity status = calculateCurrentStatus(monitors, memberServices, mostRecentStatuses);
Set<OnmsLocationSpecificStatus> selectedStatuses = filterStatus(statusesPeriod, monitors, memberServices);
if (selectedStatuses.size() > 0) {
String percentage = calculatePercentageUptime(memberServices, selectedStatuses, start, end);
table.addCell(percentage, status.getStyle(), createHistoryPageUrl(locationDefinition, application));
} else {
table.addCell("No data", status.getStyle());
}
}
}
if (isLayoutApplicationsVertically()) {
SimpleWebTable newTable = new SimpleWebTable();
newTable.setErrors(table.getErrors());
newTable.setTitle(table.getTitle());
newTable.addColumn("Application");
for (List<Cell> row : table.getRows()) {
// The location is in the second row
newTable.addColumn(row.get(1).getContent(), row.get(1).getStyleClass());
}
for (Cell columnHeader : table.getColumnHeaders().subList(2, table.getColumnHeaders().size())) {
// This is the index into collumn list of the old table to get the data for the current application
int rowColumnIndex = newTable.getRows().size() + 2;
newTable.newRow();
newTable.addCell(columnHeader.getContent(), columnHeader.getStyleClass());
for (List<Cell> row : table.getRows()) {
newTable.addCell(row.get(rowColumnIndex).getContent(), row.get(rowColumnIndex).getStyleClass(), row.get(rowColumnIndex).getLink());
}
}
return newTable;
}
return table;
}
use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.
the class DefaultSurveillanceService method createSurveillanceTable.
/**
* {@inheritDoc}
*
* Creates a custom table object containing intersected rows and
* columns and categories.
*/
@Override
public SimpleWebTable createSurveillanceTable(final String surveillanceViewName, final ProgressMonitor progressMonitor) {
CellStatusStrategy strategy = getCellStatusStrategy();
final String name = (surveillanceViewName == null ? m_surveillanceConfigDao.getDefaultView().getName() : surveillanceViewName);
final View view = m_surveillanceConfigDao.getView(name);
final SurveillanceView sView = new SurveillanceView(name, m_surveillanceConfigDao, m_categoryDao);
progressMonitor.setPhaseCount(strategy.getPhaseCount(sView) + 1);
/*
* Initialize a status table
*/
final SimpleWebTable webTable = new SimpleWebTable();
webTable.setTitle(view.getName());
webTable.addColumn("Nodes Down", "simpleWebTableHeader");
// set up the column headings
for (int colIndex = 0; colIndex < sView.getColumnCount(); colIndex++) {
webTable.addColumn(sView.getColumnLabel(colIndex), "simpleWebTableHeader").setLink(computeReportCategoryLink(sView.getColumnReportCategory(colIndex).orElse(null)));
}
// build the set of nodes for each cell
final SurveillanceStatus[][] cellStatus = strategy.calculateCellStatus(sView, progressMonitor);
progressMonitor.beginNextPhase("Calculating Status Values");
for (int rowIndex = 0; rowIndex < sView.getRowCount(); rowIndex++) {
webTable.newRow();
webTable.addCell(sView.getRowLabel(rowIndex), "simpleWebTableRowLabel").setLink(computeReportCategoryLink(sView.getRowReportCategory(rowIndex).orElse(null)));
for (int colIndex = 0; colIndex < sView.getColumnCount(); colIndex++) {
final SurveillanceStatus survStatus = cellStatus[rowIndex][colIndex];
final String text = survStatus.getDownEntityCount() + " of " + survStatus.getTotalEntityCount();
LOG.debug("Text: {}, Style {}", text, survStatus.getStatus());
final SimpleWebTable.Cell cell = webTable.addCell(text, survStatus.getStatus());
if (survStatus.getDownEntityCount() > 0) {
cell.setLink(createNodePageUrl(sView, colIndex, rowIndex));
}
}
}
progressMonitor.finished(webTable);
return webTable;
}
use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.
the class DefaultDistributedStatusServiceTest method runTestCreateStatus.
public void runTestCreateStatus() {
DistributedStatusDetailsCommand command = new DistributedStatusDetailsCommand();
Errors errors = new BindException(command, "command");
command.setLocation(m_locationDefinition1.getLocationName());
command.setApplication(m_application1.getName());
expectEverything();
expect(m_monitoredServiceDao.findByApplication(m_application1)).andReturn(m_applicationServices1);
m_easyMockUtils.replayAll();
SimpleWebTable table = m_service.createStatusTable(command, errors);
m_easyMockUtils.verifyAll();
SimpleWebTable expectedTable = new SimpleWebTable();
expectedTable.setTitle("Distributed status view for Application 1 from Raleigh location");
expectedTable.addColumn("Node", "");
expectedTable.addColumn("Monitor", "");
expectedTable.addColumn("Service", "");
expectedTable.addColumn("Status", "");
expectedTable.addColumn("Response", "");
expectedTable.addColumn("Last Status Change", "");
expectedTable.addColumn("Last Update", "");
expectedTable.newRow();
expectedTable.addCell("Node 1", "Normal", "element/node.jsp?node=1");
expectedTable.addCell("Raleigh-" + LOCATION_MONITOR_ID_A, "", "distributed/locationMonitorDetails.htm?monitorId=" + LOCATION_MONITOR_ID_A);
expectedTable.addCell("HTTP", "", "element/service.jsp?ifserviceid=null");
expectedTable.addCell("Up", "bright");
expectedTable.addCell("", "");
expectedTable.addCell(IGNORE_MATCH, "");
expectedTable.addCell(IGNORE_MATCH, "");
expectedTable.newRow();
expectedTable.addCell("Node 1", "Indeterminate", "element/node.jsp?node=1");
expectedTable.addCell("Raleigh-" + LOCATION_MONITOR_ID_A, "", "distributed/locationMonitorDetails.htm?monitorId=" + LOCATION_MONITOR_ID_A);
expectedTable.addCell("HTTPS", "", "element/service.jsp?ifserviceid=null");
expectedTable.addCell("Unknown", "bright");
expectedTable.addCell("No status recorded for this service from this location", "");
expectedTable.addCell(IGNORE_MATCH, "");
expectedTable.addCell(IGNORE_MATCH, "");
assertTableEquals(expectedTable, table);
}
use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.
the class DistributedStatusSummaryController method handleRequestInternal.
/**
* {@inheritDoc}
*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
// Calculate a date that equals midnight of the current day (00:00:00 AM)
GregorianCalendar calendar = new GregorianCalendar();
Date endDate = new Date(calendar.getTimeInMillis());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date startDate = new Date(calendar.getTimeInMillis());
if (m_distributedStatusService.getApplicationCount() <= 0) {
return new ModelAndView("distributedStatusSummaryError", "error", createError("No Applications Defined", "No applications have been defined for this system so a summary of application status is impossible to display."));
}
SimpleWebTable table = m_distributedStatusService.createFacilityStatusTable(startDate, endDate);
return new ModelAndView("distributedStatusSummary", "webTable", table);
}
Aggregations