Search in sources :

Example 1 with SurveillanceStatus

use of org.opennms.netmgt.model.SurveillanceStatus 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;
}
Also used : SurveillanceStatus(org.opennms.netmgt.model.SurveillanceStatus) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) View(org.opennms.netmgt.config.surveillanceViews.View)

Aggregations

View (org.opennms.netmgt.config.surveillanceViews.View)1 SurveillanceStatus (org.opennms.netmgt.model.SurveillanceStatus)1 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)1