use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DefaultGeolocationService method getLocations.
@Override
public List<GeolocationInfo> getLocations(GeolocationQuery query) {
if (query == null) {
return new ArrayList<>();
}
final List<OnmsNode> nodes = getNodes(query);
final List<GeolocationInfo> nodesWithCoordinates = nodes.stream().filter(n -> geoLocation(n) != null && geoLocation(n).getLongitude() != null && geoLocation(n).getLatitude() != null).filter(n -> geoLocation(n).getLatitude() != Float.NEGATIVE_INFINITY && geoLocation(n).getLongitude() != Float.NEGATIVE_INFINITY).map(node -> convert(node)).collect(Collectors.toList());
if (query.getStatusCalculationStrategy() != null) {
applyStatus(query, nodesWithCoordinates);
}
if (query.getSeverity() != null) {
OnmsSeverity severity = OnmsSeverity.get(query.getSeverity().getId());
return nodesWithCoordinates.stream().filter(n -> severity.getId() <= n.getSeverityInfo().getId()).collect(Collectors.toList());
}
return nodesWithCoordinates;
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class GenericInfoPanelItemProviderTest method setUp.
@Before
public void setUp() throws IllegalAccessException, InstantiationException {
m_nodeDao = EasyMock.createMock(NodeDao.class);
m_measurementsService = EasyMock.createMock(MeasurementsService.class);
m_genericInfoPanelItemProvider = new GenericInfoPanelItemProvider(m_nodeDao, m_measurementsService);
m_onmsNode = new OnmsNode();
m_onmsNode.setLabel("nodeLabel");
m_onmsNode.setId(10);
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class NodeInfoPanelItemProvider method createComponent.
private Component createComponent(AbstractVertex ref) {
Preconditions.checkState(ref.getNodeID() != null, "no Node ID defined.");
OnmsNode node = nodeDao.get(ref.getNodeID());
FormLayout formLayout = new FormLayout();
formLayout.setSpacing(false);
formLayout.setMargin(false);
formLayout.addComponent(createLabel("Node ID", "" + node.getId()));
final HorizontalLayout nodeButtonLayout = new HorizontalLayout();
Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(ref.getNodeID()).open());
nodeButton.setStyleName(BaseTheme.BUTTON_LINK);
nodeButtonLayout.addComponent(nodeButton);
nodeButtonLayout.setCaption("Node Label");
formLayout.addComponent(nodeButtonLayout);
if (!Strings.isNullOrEmpty(node.getSysObjectId())) {
formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId()));
}
return formLayout;
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class OpenlayersWidgetCompontentTest method testGeolocation.
@Test
@Ignore
public void testGeolocation() throws Exception {
final OnmsNode node = new OnmsNode();
final OnmsAssetRecord asset = new OnmsAssetRecord();
final OnmsGeolocation geo = new OnmsGeolocation();
node.setId(1);
node.setAssetRecord(asset);
asset.setGeolocation(geo);
geo.setAddress1("220 Chatham Business Dr.");
geo.setCity("Pittsboro");
geo.setState("NC");
geo.setZip("27312");
assertEquals("220 Chatham Business Dr., Pittsboro, NC 27312", geo.asAddressString());
EasyMock.expect(m_geocoder.getCoordinates(geo.asAddressString())).andReturn(new Coordinates(-1.0f, 1.0f)).times(1);
final PaintTarget target = EasyMock.createMock(PaintTarget.class);
m_assetDao.saveOrUpdate(EasyMock.isA(OnmsAssetRecord.class));
target.startTag(EasyMock.eq("1"));
target.addAttribute(EasyMock.eq("longitude"), EasyMock.eq("-1.0"));
target.addAttribute(EasyMock.eq("latitude"), EasyMock.eq("1.0"));
target.endTag(EasyMock.eq("1"));
EasyMock.replay(m_nodeDao, m_assetDao, m_geocoder, target);
// m_component.paintNode(target, node);
EasyMock.verify(m_nodeDao, m_assetDao, m_geocoder, target);
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class JmsNorthBounderTest method testAlarmMappingNoParams.
@Test
public void testAlarmMappingNoParams() throws Exception {
String xml = generateMappingConfigXml();
Resource resource = new ByteArrayResource(xml.getBytes());
JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
dao.setConfigResource(resource);
dao.afterPropertiesSet();
JmsNorthbounderConfig config = dao.getConfig();
List<JmsDestination> destinations = config.getDestinations();
List<JmsNorthbounder> nbis = new LinkedList<JmsNorthbounder>();
for (JmsDestination jmsDestination : destinations) {
JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
nbi.afterPropertiesSet();
nbis.add(nbi);
}
List<NorthboundAlarm> alarms = new LinkedList<NorthboundAlarm>();
OnmsNode node = new OnmsNode(null, NODE_LABEL);
node.setForeignSource("TestGroup");
node.setForeignId("2");
node.setId(m_nodeDao.getNextNodeId());
OnmsIpInterface ip = new OnmsIpInterface("127.0.0.1", node);
InetAddress ia = null;
try {
ia = InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException e) {
}
m_nodeDao.save(node);
m_nodeDao.flush();
// TX via NBIs
for (JmsNorthbounder nbi : nbis) {
OnmsEvent event = new OnmsEvent(5, "uei.uei.org/uei", new Date(), "eventhost", "eventsource", ia, null, "eventssnmphost", null, "eventsnmp", null, new Date(), "eventdescr", "eventloggroup", "eventlogmsg", 4, null, null, 0, "operinstruct", null, null, null, null, "tticketid", 1, null, null, null, null, null, null, null, node, null, null, null);
OnmsAlarm alarm = new OnmsAlarm(9, event.getEventUei(), null, 1, 4, new Date(), event);
alarm.setNode(node);
alarm.setDescription(event.getEventDescr());
alarm.setApplicationDN("applicationDN");
alarm.setLogMsg(event.getEventLogMsg());
alarm.setManagedObjectInstance("managedObjectInstance");
alarm.setManagedObjectType("managedObjectType");
alarm.setOssPrimaryKey("ossPrimaryKey");
alarm.setQosAlarmState("qosAlarmState");
alarm.setTTicketId("tticketId");
alarm.setReductionKey("reductionKey");
alarm.setClearKey("clearKey");
alarm.setOperInstruct("operInstruct");
alarm.setAlarmType(1);
alarm.setFirstEventTime(new Date(0));
alarm.setIpAddr(ia);
alarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(1).name());
alarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(1).getId());
NorthboundAlarm a = new NorthboundAlarm(alarm);
alarms.add(a);
nbi.forwardAlarms(alarms);
}
Thread.sleep(100);
// Let's become a consumer and receive the message
Message m = m_template.receive("MappingTestQueue");
String escapedResponse = "ackUser: appDn: applicationDN logMsg: eventlogmsg objectInstance: managedObjectInstance objectType: managedObjectType ossKey: ossPrimaryKey\n" + " ossState: qosAlarmState ticketId: tticketId alarmUei: uei.uei.org/uei alarmKey: reductionKey clearKey: clearKey description: eventdescr operInstruct: operInstruct ackTime: \n" + " alarmType: PROBLEM count: 1 alarmId: 9 ipAddr: 127.0.0.1 lastOccurrence: nodeId: 1\n" + " nodeLabel: schlazor distPoller: 00000000-0000-0000-0000-000000000000 ifService: severity: WARNING ticketState: x733AlarmType: other\n" + " x733ProbableCause: other firstOccurrence: " + StringUtils.iso8601LocalOffsetString(new Date(0)) + " lastOccurrence eventParmsXml: <eventParms/>";
String response = ((TextMessage) m).getText();
Assert.assertEquals("Contents of message\n'" + response + "'\n not equals\n'" + escapedResponse + "'.", response, escapedResponse);
}
Aggregations