use of org.opennms.netmgt.model.AggregateStatusView in project opennms by OpenNMS.
the class SiteStatusViewController method handleRequestInternal.
/**
* {@inheritDoc}
*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) throws Exception {
ModelAndView mav = new ModelAndView("siteStatus");
String statusView = req.getParameter("statusView");
String statusSite = req.getParameter("statusSite");
String nodeId = req.getParameter("nodeid");
AggregateStatusView view = null;
try {
view = m_service.createAggregateStatusView(statusView);
} catch (ObjectRetrievalFailureException e) {
SiteStatusViewError viewError = createSiteStatusViewError((String) e.getIdentifier(), e.getMessage());
return new ModelAndView("siteStatusError", "error", viewError);
}
Collection<AggregateStatus> aggrStati;
if (nodeId != null && WebSecurityUtils.safeParseInt(nodeId) > 0) {
aggrStati = m_service.createAggregateStatusesUsingNodeId(WebSecurityUtils.safeParseInt(nodeId), statusView);
} else if (statusSite == null) {
aggrStati = m_service.createAggregateStatuses(view);
} else {
aggrStati = m_service.createAggregateStatuses(view, statusSite);
// Don't persist this, convenience for display only.
view.setColumnValue(statusSite);
}
mav.addObject("view", view);
mav.addObject("stati", aggrStati);
return mav;
}
use of org.opennms.netmgt.model.AggregateStatusView in project opennms by OpenNMS.
the class DefaultSiteStatusViewService method createAggregateStatusView.
/**
* {@inheritDoc}
*
* This creator looks up a configured status view by name and calls the creator that
* accepts the AggregateStatusView model object.
* @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusView(java.lang.String)
*/
@Override
public AggregateStatusView createAggregateStatusView(String statusViewName) {
AggregateStatusView statusView = new AggregateStatusView();
statusViewName = (statusViewName == null ? m_siteStatusViewConfigDao.getDefaultView().getName() : statusViewName);
View view = m_siteStatusViewConfigDao.getView(statusViewName);
statusView.setName(statusViewName);
statusView.setColumnName(view.getColumnName());
statusView.setColumnValue(view.getColumnValue().orElse(null));
statusView.setTableName(view.getTableName());
Set<AggregateStatusDefinition> statusDefs = getAggregateStatusDefinitionsForView(view);
statusView.setStatusDefinitions(statusDefs);
return statusView;
}
use of org.opennms.netmgt.model.AggregateStatusView in project opennms by OpenNMS.
the class DefaultSiteStatusViewService method getAggregateStatus.
/**
* {@inheritDoc}
*/
@Override
public AggregateStatus getAggregateStatus(String statusViewName, String statusSite, String rowLabel) {
AggregateStatusView statusView = createAggregateStatusView(statusViewName);
Collection<AggregateStatus> stati = createAggregateStatuses(statusView, statusSite);
for (AggregateStatus status : stati) {
if (status.getLabel().equals(rowLabel)) {
return status;
}
}
throw new DataRetrievalFailureException("Unable to locate row: " + rowLabel + " for status view: " + statusViewName);
}
use of org.opennms.netmgt.model.AggregateStatusView in project opennms by OpenNMS.
the class DefaultSiteStatusServiceIT method testCreateAggregateStatusView.
@Test
@Transactional
public void testCreateAggregateStatusView() {
m_databasePopulator.populateDatabase();
AggregateStatusView view = m_aggregateService.createAggregateStatusView(null);
assertNotNull(view);
assertFalse(view.getStatusDefinitions().isEmpty());
m_databasePopulator.resetDatabase();
}
use of org.opennms.netmgt.model.AggregateStatusView in project opennms by OpenNMS.
the class DefaultSiteStatusServiceIT method testCreateAggregateStatusUsingBuilding.
@Test
@Transactional
public void testCreateAggregateStatusUsingBuilding() {
m_databasePopulator.populateDatabase();
createOutageForNodeInCategory("Routers");
createOutageForNodeInCategory("Servers");
Set<AggregateStatusDefinition> defs = new LinkedHashSet<>();
AggregateStatusDefinition definition;
definition = new AggregateStatusDefinition("Routers", Collections.singleton(new OnmsCategory("Routers")));
defs.add(definition);
definition = new AggregateStatusDefinition("Switches", Collections.singleton(new OnmsCategory("Switches")));
defs.add(definition);
definition = new AggregateStatusDefinition("Servers", Collections.singleton(new OnmsCategory("Servers")));
defs.add(definition);
// AggregateStatusDefinition definition;
// definition = new AggregateStatusDefinition("LB/Router", new HashSet<OnmsCategory>(Arrays.asList(new OnmsCategory[]{ new OnmsCategory("DEV_ROUTER"), new OnmsCategory("DEV_LOADBAL") })));
// defs.add(definition);
// definition = new AggregateStatusDefinition("Access Controller", Collections.singleton(new OnmsCategory("DEV_AC")));
// defs.add(definition);
// definition = new AggregateStatusDefinition("Switches", Collections.singleton(new OnmsCategory("DEV_SWITCH")));
// defs.add(definition);
// definition = new AggregateStatusDefinition("Access Points", Collections.singleton(new OnmsCategory("DEV_AP")));
// defs.add(definition);
// definition = new AggregateStatusDefinition("BCPC", Collections.singleton(new OnmsCategory("DEV_BCPC")));
// defs.add(definition);
AggregateStatusView view = new AggregateStatusView();
view.setName("building");
view.setColumnName("building");
view.setColumnValue("HQ");
view.setStatusDefinitions(defs);
List<AggregateStatus> aggrStati = new ArrayList<AggregateStatus>(m_aggregateService.createAggregateStatuses(view));
AggregateStatus status;
status = aggrStati.get(0);
assertEquals("Routers", status.getLabel());
assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
status = aggrStati.get(1);
assertEquals("Switches", status.getLabel());
assertEquals(AggregateStatus.ALL_NODES_UP, status.getStatus());
status = aggrStati.get(2);
assertEquals("Servers", status.getLabel());
assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
// status = aggrStati.get(3);
// assertEquals(AggregateStatus.NODES_ARE_DOWN, status.getStatus());
// assertEquals(new Integer(6), status.getDownEntityCount());
//
// status = aggrStati.get(4);
// assertEquals(AggregateStatus.ALL_NODES_UP, status.getStatus());
m_databasePopulator.resetDatabase();
}
Aggregations