use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class EnLinkdElementFactory method convertFromModel.
@Transactional
@SuppressWarnings("deprecation")
private IsisLinkNode convertFromModel(int nodeid, IsIsLink link) {
IsisLinkNode linknode = new IsisLinkNode();
linknode.setIsisCircIfIndex(link.getIsisCircIfIndex());
linknode.setIsisCircAdminState(IsisAdminState.getTypeString(link.getIsisCircAdminState().getValue()));
IsIsElement isiselement = m_isisElementDao.findByIsIsSysId(link.getIsisISAdjNeighSysID());
if (isiselement != null) {
linknode.setIsisISAdjNeighSysID(getAdjSysIDString(link.getIsisISAdjNeighSysID(), isiselement.getNode().getLabel()));
linknode.setIsisISAdjUrl(getNodeUrl(isiselement.getNode().getId()));
} else {
linknode.setIsisISAdjNeighSysID(link.getIsisISAdjNeighSysID());
}
linknode.setIsisISAdjNeighSysType(IsisISAdjNeighSysType.getTypeString(link.getIsisISAdjNeighSysType().getValue()));
linknode.setIsisISAdjNeighSNPAAddress(link.getIsisISAdjNeighSNPAAddress());
linknode.setIsisISAdjState(IsisISAdjState.get(link.getIsisISAdjState().getValue()).toString());
linknode.setIsisISAdjNbrExtendedCircID(link.getIsisISAdjNbrExtendedCircID());
OnmsSnmpInterface remiface = null;
if (isiselement != null) {
IsIsLink adjLink = m_isisLinkDao.get(isiselement.getNode().getId(), link.getIsisISAdjIndex(), link.getIsisCircIndex());
if (adjLink != null) {
remiface = m_snmpInterfaceDao.findByNodeIdAndIfIndex(isiselement.getNode().getId(), adjLink.getIsisCircIfIndex());
}
}
if (remiface == null) {
remiface = getFromPhysAddress(link.getIsisISAdjNeighSNPAAddress());
}
if (remiface != null) {
linknode.setIsisISAdjNeighPort(getPortString(remiface.getIfIndex(), remiface.getIfName(), remiface.getIfAlias()));
linknode.setIsisISAdjUrl(getSnmpInterfaceUrl(remiface.getNode().getId(), remiface.getIfIndex()));
} else {
linknode.setIsisISAdjNeighPort("(Isis IS Adj Index: " + link.getIsisISAdjIndex() + ")");
}
linknode.setIsisLinkCreateTime(Util.formatDateToUIString(link.getIsisLinkCreateTime()));
linknode.setIsisLinkLastPollTime(Util.formatDateToUIString(link.getIsisLinkLastPollTime()));
return linknode;
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class EnLinkdElementFactory method convertFromModel.
@Transactional
@SuppressWarnings("deprecation")
private LldpLinkNode convertFromModel(int nodeid, LldpLink link) {
LldpLinkNode linknode = new LldpLinkNode();
linknode.setLldpPortString(getPortString(link.getLldpPortId(), link.getLldpPortIdSubType()));
linknode.setLldpPortDescr(link.getLldpPortDescr());
linknode.setLldpPortUrl(getSnmpInterfaceUrl(Integer.valueOf(nodeid), link.getLldpPortIfindex()));
linknode.setLldpRemSysName(link.getLldpRemSysname());
linknode.setLldpRemPortString(getPortString(link.getLldpRemPortId(), link.getLldpRemPortIdSubType()));
linknode.setLldpRemPortDescr(link.getLldpRemPortDescr());
linknode.setLldpCreateTime(Util.formatDateToUIString(link.getLldpLinkCreateTime()));
linknode.setLldpLastPollTime(Util.formatDateToUIString(link.getLldpLinkLastPollTime()));
OnmsNode remNode = null;
List<LldpElement> lldpremelements = m_lldpElementDao.findByChassisId(link.getLldpRemChassisId(), link.getLldpRemChassisIdSubType());
if (lldpremelements.size() == 1) {
remNode = lldpremelements.get(0).getNode();
} else if (lldpremelements.size() > 1) {
linknode.setLldpRemChassisIdString(getChassisIdString("Found " + lldpremelements.size() + " nodes for", link.getLldpRemChassisId(), link.getLldpRemChassisIdSubType()));
return linknode;
} else {
final Criteria criteria = new Criteria(OnmsNode.class).addRestriction(new EqRestriction("sysName", link.getLldpRemSysname()));
List<OnmsNode> nodes = m_nodeDao.findMatching(criteria);
if (nodes.size() == 1)
remNode = nodes.get(0);
}
if (remNode != null) {
linknode.setLldpRemChassisIdString(getChassisIdString(remNode.getLabel(), link.getLldpRemChassisId(), link.getLldpRemChassisIdSubType()));
linknode.setLldpRemChassisIdUrl(getNodeUrl(remNode.getId()));
if (link.getLldpRemPortIdSubType() == LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL) {
try {
Integer remIfIndex = Integer.getInteger(link.getLldpRemPortId());
linknode.setLldpRemPortUrl(getSnmpInterfaceUrl(Integer.valueOf(remNode.getId()), remIfIndex));
} catch (Exception e) {
}
}
} else {
linknode.setLldpRemChassisIdString(getChassisIdString(link.getLldpRemChassisId(), link.getLldpRemChassisIdSubType()));
}
return linknode;
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class DefaultSurveillanceServiceIntegrationIT method testCreateSurveillanceServiceTableUsingViewName.
@Test
@Transactional
public void testCreateSurveillanceServiceTableUsingViewName() {
String viewName = "default";
SimpleWebTable table = m_surveillanceService.createSurveillanceTable(viewName, new ProgressMonitor() {
@Override
public void beginNextPhase(String string) {
System.err.println("PHASE: " + string);
}
@Override
public void setPhaseCount(int i) {
}
});
assertEquals("default", table.getTitle());
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class AlarmRestServiceIT method testAlarmUpdates.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testAlarmUpdates() throws Exception {
createAlarm(OnmsSeverity.MAJOR);
OnmsAlarm alarm = getLastAlarm();
alarm.setAlarmAckTime(null);
alarm.setAlarmAckUser(null);
getAlarmDao().saveOrUpdate(alarm);
final Integer alarmId = alarm.getId();
sendPut("/alarms", "ack=true&alarmId=" + alarmId, 204);
String xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("ackUser>admin<"));
sendPut("/alarms/" + alarmId, "clear=true", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("severity=\"CLEARED\""));
sendPut("/alarms/" + alarmId, "escalate=true", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("severity=\"NORMAL\""));
sendPut("/alarms/" + alarmId, "ticketId=12345", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("<troubleTicket>12345</troubleTicket>"));
sendPut("/alarms/" + alarmId, "ticketState=UPDATE_PENDING", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
sendPut("/alarms/" + alarmId, "ticketState=UPDATE_PENDING", 204);
alarm = getLastAlarm();
alarm.setSeverity(OnmsSeverity.MAJOR);
alarm.setAlarmAckTime(null);
alarm.setAlarmAckUser(null);
getAlarmDao().saveOrUpdate(alarm);
// Log in as a normal REST user and attempt to resolve an alarm as a different user.
// This should fail with a 403 forbidden.
setUser("foo", new String[] { "ROLE_REST" });
sendPut("/alarms/" + alarmId, "ack=true&ackUser=bar", 403);
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class AlarmRepositoryIT method testCountMatchingBySeverity.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testCountMatchingBySeverity() {
int[] matchingAlarmCount = m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new SeverityFilter(OnmsSeverity.NORMAL))));
assertEquals(8, matchingAlarmCount.length);
}
Aggregations