Search in sources :

Example 6 with NCSComponent

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);
    }
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) EventProxyException(org.opennms.netmgt.events.api.EventProxyException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with NCSComponent

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);
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) EventProxyException(org.opennms.netmgt.events.api.EventProxyException) ObjectRetrievalFailureException(org.springframework.orm.ObjectRetrievalFailureException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with NCSComponent

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();
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent)

Example 9 with NCSComponent

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);
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) NCSBuilder(org.opennms.netmgt.model.ncs.NCSBuilder) Test(org.junit.Test)

Example 10 with NCSComponent

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;
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) LinkedList(java.util.LinkedList)

Aggregations

NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)30 NCSBuilder (org.opennms.netmgt.model.ncs.NCSBuilder)6 Test (org.junit.Test)5 Before (org.junit.Before)4 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 EventProxyException (org.opennms.netmgt.events.api.EventProxyException)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LinkedList (java.util.LinkedList)2 Criteria (org.opennms.features.topology.api.topo.Criteria)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 NodeIdentification (org.opennms.netmgt.model.ncs.NCSComponent.NodeIdentification)2 NCSComponentRepository (org.opennms.netmgt.model.ncs.NCSComponentRepository)2 Item (com.vaadin.data.Item)1 Validator (com.vaadin.data.Validator)1 PropertysetItem (com.vaadin.data.util.PropertysetItem)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1