@Test public void testGetPrimaryInterface() { OnmsNode node = new OnmsNode(); OnmsIpInterface iface = new OnmsIpInterface(); PrimaryType primary1 = PrimaryType.PRIMARY; iface.setIsSnmpPrimary(primary1); node.addIpInterface(iface); OnmsIpInterface iface2 = new OnmsIpInterface(); PrimaryType not_eligible1 = PrimaryType.NOT_ELIGIBLE; iface2.setIsSnmpPrimary(not_eligible1); node.addIpInterface(iface2); Object o = node.getPrimaryInterface(); Assert.assertSame(o, iface); }
@Transient public OnmsIpInterface getPrimaryInterface() { for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { return iface; } } return null; }
OnmsNode extends OnmsEntity implements Serializable, Comparable<OnmsNode> { @Transient public OnmsIpInterface getPrimaryInterface() { for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { return iface; } } return null; } }
OnmsNode extends OnmsEntity implements Serializable, Comparable<OnmsNode> { @Transient public OnmsIpInterface getPrimaryInterface() { for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { return iface; } } return null; } OnmsNode();  OnmsNode(final OnmsDistPoller distPoller);  OnmsNode(final OnmsDistPoller distPoller, final String label); }
OnmsNode extends OnmsEntity implements Serializable, Comparable<OnmsNode> { @Transient public OnmsIpInterface getPrimaryInterface() { for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { return iface; } } return null; } OnmsNode();  OnmsNode(final OnmsDistPoller distPoller);  OnmsNode(final OnmsDistPoller distPoller, final String label); @Id @Column(name="nodeId", nullable=false) @SequenceGenerator(name="nodeSequence", sequenceName="nodeNxtId") @GeneratedValue(generator="nodeSequence") @XmlTransient Integer getId(); @XmlID @XmlAttribute(name="id", required=true) @Transient String getNodeId(); void setId(Integer nodeid); void setNodeId(String nodeid); @XmlElement(name="createTime") @Temporal(TemporalType.TIMESTAMP) @Column(name="nodeCreateTime", nullable=false) Date getCreateTime(); void setCreateTime(Date nodecreatetime); @XmlTransient @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="nodeParentID") OnmsNode getParent(); void setParent(OnmsNode parent); @XmlAttribute(name="type") @Column(name="nodeType", length=1) String getType(); void setType(String nodetype); @XmlElement(name="sysObjectId") @Column(name="nodeSysOID", length=256) String getSysObjectId(); void setSysObjectId(String nodesysoid); @XmlElement(name="sysName") @Column(name="nodeSysName", length=256) String getSysName(); void setSysName(String nodesysname); @XmlElement(name="sysDescription") @Column(name="nodeSysDescription", length=256) String getSysDescription(); void setSysDescription(String nodesysdescription); @XmlElement(name="sysLocation") @Column(name="nodeSysLocation", length=256) String getSysLocation(); void setSysLocation(String nodesyslocation); @XmlElement(name="sysContact") @Column(name="nodeSysContact", length=256) String getSysContact(); void setSysContact(String nodesyscontact); @XmlAttribute(name="label") @Column(name="nodeLabel", length=256, nullable=false) String getLabel(); void setLabel(String nodelabel); @XmlElement(name="labelSource") @Column(name="nodeLabelSource", length=1) String getLabelSource(); void setLabelSource(String nodelabelsource); @XmlElement(name="netBIOSName") @Column(name="nodeNetBIOSName", length=16) String getNetBiosName(); void setNetBiosName(String nodenetbiosname); @XmlElement(name="netBIOSDomainName") @Column(name="nodeDomainName", length=16) String getNetBiosDomain(); void setNetBiosDomain(String nodedomainname); @XmlElement(name="operatingSystem") @Column(name="operatingSystem", length=64) String getOperatingSystem(); void setOperatingSystem(String operatingsystem); @XmlElement(name="lastCapsdPoll") @Temporal(TemporalType.TIMESTAMP) @Column(name="lastCapsdPoll") Date getLastCapsdPoll(); void setLastCapsdPoll(Date lastcapsdpoll); @XmlAttribute(name="foreignId") @Column(name="foreignId") String getForeignId(); void setForeignId(String foreignId); @XmlAttribute(name="foreignSource") @Column(name="foreignSource") String getForeignSource(); void setForeignSource(String foreignSource); @XmlTransient @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="dpName") OnmsDistPoller getDistPoller(); void setDistPoller(org.opennms.netmgt.model.OnmsDistPoller distpoller); @OneToOne(mappedBy="node", cascade = CascadeType.ALL, fetch=FetchType.LAZY) OnmsAssetRecord getAssetRecord(); void setAssetRecord(OnmsAssetRecord asset); @XmlTransient @Embedded @AttributeOverrides({ @AttributeOverride(name="ipAddress", column=@Column(name="criticalPathIp", table="pathOutage")), @AttributeOverride(name="serviceName", column=@Column(name="criticalPathServiceName", table="pathOutage")) }) PathElement getPathElement(); void setPathElement(PathElement pathElement); @XmlTransient @OneToMany(mappedBy="node") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsIpInterface> getIpInterfaces(); void setIpInterfaces(Set<OnmsIpInterface> ipinterfaces); void addIpInterface(OnmsIpInterface iface); @XmlTransient @OneToMany(mappedBy="node") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsSnmpInterface> getSnmpInterfaces(); void setSnmpInterfaces(Set<OnmsSnmpInterface> snmpinterfaces); @XmlTransient @OneToMany(mappedBy="sourceNode") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsArpInterface> getArpInterfacesBySource(); void setArpInterfacesBySource(Set<OnmsArpInterface> arpInterfaces); void addArpInterfaceBySource(OnmsArpInterface iface); @XmlTransient @OneToMany(mappedBy="node") Set<OnmsArpInterface> getArpInterfaces(); void setArpInterfaces(Set<OnmsArpInterface> arpInterfaces); void addArpInterface(OnmsArpInterface iface); @XmlElement(name="categories") @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable( name="category_node", joinColumns={@JoinColumn(name="nodeId")}, inverseJoinColumns={@JoinColumn(name="categoryId")} ) Set<OnmsCategory> getCategories(); void setCategories(Set<OnmsCategory> categories); boolean addCategory(OnmsCategory category); boolean removeCategory(OnmsCategory category); boolean hasCategory(String categoryName); String toString(); void visit(EntityVisitor visitor); void addSnmpInterface(OnmsSnmpInterface snmpIface); @Transient boolean isDown(); @Transient OnmsSnmpInterface getSnmpInterfaceWithIfIndex(int ifIndex); OnmsIpInterface getIpInterfaceByIpAddress(String ipAddress); OnmsIpInterface getIpInterfaceByIpAddress(InetAddress ipAddress); int compareTo(OnmsNode o); @Transient OnmsIpInterface getPrimaryInterface(); @Transient OnmsIpInterface getInterfaceWithService(String svcName); @Transient OnmsIpInterface getCriticalInterface(); void mergeAgentAttributes(OnmsNode scannedNode); void mergeNodeAttributes(OnmsNode scannedNode, EventForwarder eventForwarder); void mergeAdditionalCategories(OnmsNode scannedNode); void mergeSnmpInterfaces(OnmsNode scannedNode, boolean deleteMissing); void mergeIpInterfaces(OnmsNode scannedNode, EventForwarder eventForwarder, boolean deleteMissing); void mergeCategorySet(OnmsNode scannedNode); void mergeAssets(OnmsNode scannedNode); void replaceCurrentAssetRecord(OnmsNode scannedNode); void mergeNode(OnmsNode scannedNode, EventForwarder eventForwarder, boolean deleteMissing); }
OnmsNode extends OnmsEntity implements Serializable, Comparable<OnmsNode> { @Transient public OnmsIpInterface getPrimaryInterface() { for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { return iface; } } return null; } OnmsNode();  OnmsNode(final OnmsDistPoller distPoller);  OnmsNode(final OnmsDistPoller distPoller, final String label); @Id @Column(name="nodeId", nullable=false) @SequenceGenerator(name="nodeSequence", sequenceName="nodeNxtId") @GeneratedValue(generator="nodeSequence") @XmlTransient Integer getId(); @XmlID @XmlAttribute(name="id", required=true) @Transient String getNodeId(); void setId(Integer nodeid); void setNodeId(String nodeid); @XmlElement(name="createTime") @Temporal(TemporalType.TIMESTAMP) @Column(name="nodeCreateTime", nullable=false) Date getCreateTime(); void setCreateTime(Date nodecreatetime); @XmlTransient @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="nodeParentID") OnmsNode getParent(); void setParent(OnmsNode parent); @XmlAttribute(name="type") @Column(name="nodeType", length=1) String getType(); void setType(String nodetype); @XmlElement(name="sysObjectId") @Column(name="nodeSysOID", length=256) String getSysObjectId(); void setSysObjectId(String nodesysoid); @XmlElement(name="sysName") @Column(name="nodeSysName", length=256) String getSysName(); void setSysName(String nodesysname); @XmlElement(name="sysDescription") @Column(name="nodeSysDescription", length=256) String getSysDescription(); void setSysDescription(String nodesysdescription); @XmlElement(name="sysLocation") @Column(name="nodeSysLocation", length=256) String getSysLocation(); void setSysLocation(String nodesyslocation); @XmlElement(name="sysContact") @Column(name="nodeSysContact", length=256) String getSysContact(); void setSysContact(String nodesyscontact); @XmlAttribute(name="label") @Column(name="nodeLabel", length=256, nullable=false) String getLabel(); void setLabel(String nodelabel); @XmlElement(name="labelSource") @Column(name="nodeLabelSource", length=1) String getLabelSource(); void setLabelSource(String nodelabelsource); @XmlElement(name="netBIOSName") @Column(name="nodeNetBIOSName", length=16) String getNetBiosName(); void setNetBiosName(String nodenetbiosname); @XmlElement(name="netBIOSDomainName") @Column(name="nodeDomainName", length=16) String getNetBiosDomain(); void setNetBiosDomain(String nodedomainname); @XmlElement(name="operatingSystem") @Column(name="operatingSystem", length=64) String getOperatingSystem(); void setOperatingSystem(String operatingsystem); @XmlElement(name="lastCapsdPoll") @Temporal(TemporalType.TIMESTAMP) @Column(name="lastCapsdPoll") Date getLastCapsdPoll(); void setLastCapsdPoll(Date lastcapsdpoll); @XmlAttribute(name="foreignId") @Column(name="foreignId") String getForeignId(); void setForeignId(String foreignId); @XmlAttribute(name="foreignSource") @Column(name="foreignSource") String getForeignSource(); void setForeignSource(String foreignSource); @XmlTransient @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="dpName") OnmsDistPoller getDistPoller(); void setDistPoller(org.opennms.netmgt.model.OnmsDistPoller distpoller); @OneToOne(mappedBy="node", cascade = CascadeType.ALL, fetch=FetchType.LAZY) OnmsAssetRecord getAssetRecord(); void setAssetRecord(OnmsAssetRecord asset); @XmlTransient @Embedded @AttributeOverrides({ @AttributeOverride(name="ipAddress", column=@Column(name="criticalPathIp", table="pathOutage")), @AttributeOverride(name="serviceName", column=@Column(name="criticalPathServiceName", table="pathOutage")) }) PathElement getPathElement(); void setPathElement(PathElement pathElement); @XmlTransient @OneToMany(mappedBy="node") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsIpInterface> getIpInterfaces(); void setIpInterfaces(Set<OnmsIpInterface> ipinterfaces); void addIpInterface(OnmsIpInterface iface); @XmlTransient @OneToMany(mappedBy="node") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsSnmpInterface> getSnmpInterfaces(); void setSnmpInterfaces(Set<OnmsSnmpInterface> snmpinterfaces); @XmlTransient @OneToMany(mappedBy="sourceNode") @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) Set<OnmsArpInterface> getArpInterfacesBySource(); void setArpInterfacesBySource(Set<OnmsArpInterface> arpInterfaces); void addArpInterfaceBySource(OnmsArpInterface iface); @XmlTransient @OneToMany(mappedBy="node") Set<OnmsArpInterface> getArpInterfaces(); void setArpInterfaces(Set<OnmsArpInterface> arpInterfaces); void addArpInterface(OnmsArpInterface iface); @XmlElement(name="categories") @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable( name="category_node", joinColumns={@JoinColumn(name="nodeId")}, inverseJoinColumns={@JoinColumn(name="categoryId")} ) Set<OnmsCategory> getCategories(); void setCategories(Set<OnmsCategory> categories); boolean addCategory(OnmsCategory category); boolean removeCategory(OnmsCategory category); boolean hasCategory(String categoryName); String toString(); void visit(EntityVisitor visitor); void addSnmpInterface(OnmsSnmpInterface snmpIface); @Transient boolean isDown(); @Transient OnmsSnmpInterface getSnmpInterfaceWithIfIndex(int ifIndex); OnmsIpInterface getIpInterfaceByIpAddress(String ipAddress); OnmsIpInterface getIpInterfaceByIpAddress(InetAddress ipAddress); int compareTo(OnmsNode o); @Transient OnmsIpInterface getPrimaryInterface(); @Transient OnmsIpInterface getInterfaceWithService(String svcName); @Transient OnmsIpInterface getCriticalInterface(); void mergeAgentAttributes(OnmsNode scannedNode); void mergeNodeAttributes(OnmsNode scannedNode, EventForwarder eventForwarder); void mergeAdditionalCategories(OnmsNode scannedNode); void mergeSnmpInterfaces(OnmsNode scannedNode, boolean deleteMissing); void mergeIpInterfaces(OnmsNode scannedNode, EventForwarder eventForwarder, boolean deleteMissing); void mergeCategorySet(OnmsNode scannedNode); void mergeAssets(OnmsNode scannedNode); void replaceCurrentAssetRecord(OnmsNode scannedNode); void mergeNode(OnmsNode scannedNode, EventForwarder eventForwarder, boolean deleteMissing);  }