use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSComponentServiceImpl method deleteComponent.
@Override
@Transactional
public void deleteComponent(final String type, final String foreignSource, final String foreignId, final boolean deleteOrphans) {
LOG.debug("deleteSubcomponent({}, {}, {}, {})", type, foreignSource, foreignId, Boolean.valueOf(deleteOrphans));
final NCSComponent component = getComponent(type, foreignSource, foreignId);
final ComponentIdentifier id = getIdentifier(component);
final ComponentEventQueue ceq = new ComponentEventQueue();
deleteComponent(id, ceq, deleteOrphans);
try {
ceq.sendAll(m_eventProxy);
} catch (final EventProxyException e) {
LOG.warn("Component {} deleted, but an error occured while sending delete/update events.", id, e);
}
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSComponentServiceImpl method addSubcomponent.
@Override
@Transactional
public NCSComponent addSubcomponent(final String type, final String foreignSource, final String foreignId, final NCSComponent subComponent, final boolean deleteOrphans) {
final ComponentIdentifier subComponentId = getIdentifier(subComponent);
LOG.debug("addSubcomponent({}, {}, {}, {}, {})", type, foreignSource, foreignId, subComponentId, Boolean.valueOf(deleteOrphans));
final NCSComponent component = getComponent(type, foreignSource, foreignId);
final ComponentIdentifier id = getIdentifier(component);
final ComponentEventQueue ceq = new ComponentEventQueue();
if (component == null) {
throw new ObjectRetrievalFailureException(NCSComponent.class, "Unable to locate component with type=" + type + ", foreignSource=" + foreignSource + ", foreignId=" + foreignId);
}
final NCSComponent updatedSubComponent = addOrUpdateComponents(subComponentId, subComponent, ceq, deleteOrphans);
component.addSubcomponent(updatedSubComponent);
m_componentDao.update(component);
ceq.componentUpdated(id);
try {
ceq.sendAll(m_eventProxy);
} catch (final EventProxyException e) {
LOG.warn("Component {} added to {}, but an error occured while sending add/delete/update events.", subComponentId, id, e);
}
return getComponent(id);
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSListFormattingTest method getComponentHTML.
private String getComponentHTML(NCSComponent component) {
StringBuffer buffer = new StringBuffer();
buffer.append("<li>");
buffer.append(component.getName());
Set<NCSComponent> subcomponents = component.getSubcomponents();
if (subcomponents.size() > 0) {
buffer.append("<ul>\n");
for (NCSComponent c : subcomponents) {
buffer.append(getComponentHTML(c));
}
buffer.append("</ul>");
}
buffer.append("</li>\n");
return buffer.toString();
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSListFormattingTest method testMarshallComponent.
@Test
public void testMarshallComponent() throws JAXBException, UnsupportedEncodingException, TransformerConfigurationException {
NCSComponent svc = new NCSBuilder("Service", "NA-Service", "123").setName("CokeP2P").pushComponent("ServiceElement", "NA-ServiceElement", "8765").setName("PE1:SE1").setNodeIdentity("space", "1111-PE1").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765:jnxVpnIf").setName("jnxVpnIf").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfDown").setAttribute("jnxVpnIfVpnType", "5").setAttribute("jnxVpnIfVpnName", "ge-1/0/2.50").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765:link").setName("link").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/linkUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/linkDown").setAttribute("linkName", "ge-1/0/2").popComponent().popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765:jnxVpnPw-vcid(50)").setName("jnxVpnPw-vcid(50)").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwDown").setAttribute("jnxVpnPwVpnType", "5").setAttribute("jnxVpnPwVpnName", "ge-1/0/2.50").setDependenciesRequired(DependencyRequirements.ANY).pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765:lspA-PE1-PE2").setName("lspA-PE1-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspA-PE1-PE2").popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765:lspB-PE1-PE2").setName("lspB-PE1-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspB-PE1-PE2").popComponent().popComponent().popComponent().pushComponent("ServiceElement", "NA-ServiceElement", "9876").setName("PE2:SE1").setNodeIdentity("space", "2222-PE2").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876:jnxVpnIf").setName("jnxVpnIf").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfDown").setAttribute("jnxVpnIfVpnType", "5").setAttribute("jnxVpnIfVpnName", "ge-3/1/4.50").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876:link").setName("link").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/linkUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/linkDown").setAttribute("linkName", "ge-3/1/4").popComponent().popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876:jnxVpnPw-vcid(50)").setName("jnxVpnPw-vcid(50)").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwDown").setAttribute("jnxVpnPwVpnType", "5").setAttribute("jnxVpnPwVpnName", "ge-3/1/4.50").setDependenciesRequired(DependencyRequirements.ANY).pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876:lspA-PE2-PE1").setName("lspA-PE2-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspA-PE2-PE1").popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876:lspB-PE2-PE1").setName("lspB-PE2-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspB-PE2-PE1").popComponent().popComponent().popComponent().get();
String result = "<ul>\n" + getComponentHTML(svc) + "</ul>";
assertEquals(getExpectedList(), result);
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class DefaultNCSCorrelationService method findComponentsByNodeIdAndEventParameters.
@Override
public List<NCSComponent> findComponentsByNodeIdAndEventParameters(Event e, String... parameterNames) {
assert e.getNodeid() != null;
assert e.getNodeid() != 0;
List<NCSComponent> components = m_componentRepo.findComponentsByNodeId(e.getNodeid().intValue());
List<NCSComponent> matching = new LinkedList<NCSComponent>();
for (NCSComponent component : components) {
if (matches(component, e, parameterNames)) {
matching.add(component);
}
}
return matching;
}
Aggregations