当前位置: 首页>>代码示例>>Java>>正文


Java OnmsNode.setLabel方法代码示例

本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.setLabel方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.setLabel方法的具体用法?Java OnmsNode.setLabel怎么用?Java OnmsNode.setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opennms.netmgt.model.OnmsNode的用法示例。


在下文中一共展示了OnmsNode.setLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddUserName

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
   @Transactional
public void testAddUserName() {
       OnmsNode onmsNode = new OnmsNode(m_distPollerDao.load("localhost"));
       onmsNode.setLabel("myNode");
       m_nodeDao.save(onmsNode);
       OnmsAssetRecord assetRecord = onmsNode.getAssetRecord();
       assetRecord.setAssetNumber("imported-id: 7");
       assetRecord.setUsername("antonio");
       assetRecord.setPassword("password");
       assetRecord.setEnable("cisco");
       assetRecord.setConnection(OnmsAssetRecord.TELNET_CONNECTION);
       m_assetRecordDao.update(assetRecord);
       m_assetRecordDao.flush();

       //Test findAll method
       int id = assetRecord.getId();
       OnmsAssetRecord assetRecordFromDb = m_assetRecordDao.get(id);
       assertEquals(assetRecord.getUsername(), assetRecordFromDb.getUsername());
       assertEquals(assetRecord.getPassword(), assetRecordFromDb.getPassword());
       assertEquals(assetRecord.getEnable(), assetRecordFromDb.getEnable());
       assertEquals(assetRecord.getConnection(), assetRecordFromDb.getConnection());

   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:AssetRecordDaoTest.java

示例2: testCreateAndGets

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
public void testCreateAndGets() {
	OnmsNode onmsNode = new OnmsNode(m_distPollerDao.load("localhost"));
	onmsNode.setLabel("myNode");
	m_nodeDao.save(onmsNode);
	OnmsAssetRecord assetRecord = onmsNode.getAssetRecord();
	assetRecord.setAssetNumber("imported-id: 7");
	m_assetRecordDao.update(assetRecord);
	m_assetRecordDao.flush();

	// Test findAll method
	Collection<OnmsAssetRecord> assetRecords = m_assetRecordDao.findAll();
	assertEquals(7, assetRecords.size());

	// Test countAll method
	assertEquals(7, m_assetRecordDao.countAll());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:AssetServiceImplTest.java

示例3: get

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Override
public OnmsNode get(Integer id) {
	OnmsNode node = new OnmsNode();
	node.setId(777);
	node.setLabel("p-brane");
	return node;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:8,代码来源:TestNodeDao.java

示例4: testSaveWithPathElement

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
public void testSaveWithPathElement() {
    OnmsDistPoller distPoller = getDistPollerDao().get("localhost");
    OnmsNode node = new OnmsNode(distPoller);
    node.setLabel("MyFirstNode");
    PathElement p = new PathElement("192.168.7.7", "ICMP");
    node.setPathElement(p);
    getNodeDao().save(node);
    
    getNodeDao().flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:NodeDaoTest.java

示例5: testCreate

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
public void testCreate() throws InterruptedException {
    OnmsDistPoller distPoller = getDistPoller();
    
    OnmsNode node = new OnmsNode(distPoller);
    node.setLabel("MyFirstNode");
    node.getAssetRecord().setDisplayCategory("MyCategory");
    PathElement p = new PathElement("192.168.7.7", "ICMP");
    node.setPathElement(p);
    
    getNodeDao().save(node);
    
    
    System.out.println("BEFORE GET");
    OnmsDistPoller dp = getDistPoller();
    assertSame(distPoller, dp);
    System.out.println("AFTER GET");
    Collection<OnmsNode> nodes = getNodeDao().findNodes(dp);
    assertEquals(7, nodes.size());
    System.out.println("AFTER GETNODES");
    for (OnmsNode retrieved : nodes) {
        System.out.println("category for "+retrieved.getId()+" = "+retrieved.getAssetRecord().getDisplayCategory());
        if (node.getId().intValue() == 5) {
            assertEquals("MyFirstNode", retrieved.getLabel());
            assertEquals("MyCategory", retrieved.getAssetRecord().getDisplayCategory());
            assertEquals("192.168.7.7", retrieved.getPathElement().getIpAddress());
            
        }
    }
    System.out.println("AFTER Loop");
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:34,代码来源:NodeDaoTest.java

示例6: testFilteredResourceAttributeFilteringWithMatch

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testFilteredResourceAttributeFilteringWithMatch() throws Exception {
    OnmsAttribute rrdAttribute = new RrdGraphAttribute("IfInOctets", "something", "something else");
    ExternalValueAttribute externalValueAttribute = new ExternalValueAttribute("ifSpeed", "100000000");

    Set<OnmsAttribute> attributes = new HashSet<OnmsAttribute>();
    attributes.add(rrdAttribute);
    attributes.add(externalValueAttribute);

    final OnmsNode node = new OnmsNode();
    node.setId(1);
    node.setLabel("Node One");
    EasyMock.expect(m_nodeDao.load(1)).andReturn(node);
    
    MockResourceType resourceType = new MockResourceType();
    resourceType.setName("interfaceSnmp");
    OnmsResource resource = new OnmsResource(node.getId().toString(), node.getLabel(), resourceType, attributes);

    ReportDefinition def = createReportDefinition();
    def.getReport().getPackage().setFilter("");
    def.setResourceAttributeKey(externalValueAttribute.getName());
    def.setResourceAttributeValueMatch(externalValueAttribute.getValue());
    ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_rrdDao, m_filterDao);

    SortedMap<Integer,String> sortedNodeMap = new TreeMap<Integer, String>();
    sortedNodeMap.put(node.getId(), node.getLabel());
    EasyMock.expect(m_filterDao.getNodeMap("")).andReturn(sortedNodeMap);

    EasyMock.expect(m_resourceDao.getResourceForNode(node)).andReturn(resource);

    EasyMock.expect(m_rrdDao.getPrintValue(rrdAttribute, def.getConsolidationFunction(), report.getStartTime(), report.getEndTime())).andReturn(1.0);

    m_mocks.replayAll();
    
    report.walk();
    
    assertEquals("results size", 1, report.getResults().size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:ReportDefinitionTest.java

示例7: createNodeList

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
public NodeListModel createNodeList(NodeListCommand command, boolean sanitizeLabels) {
    Collection<OnmsNode> onmsNodes = null;
    
    /*
     * All search queries can be done solely with
     * criteria, so we build a common criteria object with common
     * restrictions and sort options.  Each specific search query
     * adds its own crtieria restrictions (if any).
     * 
     * A set of booleans is maintained for aliases that might be
     * added in muliple places to ensure we don't add the same alias
     * multiple times.
     */
    OnmsCriteria criteria = new OnmsCriteria(OnmsNode.class, "node");
    criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
    criteria.add(Restrictions.ne("node.type", "D"));

    // Add additional criteria based on the command object
    addCriteriaForCommand(criteria, command);
        
    criteria.addOrder(Order.asc("node.label"));
    onmsNodes = m_nodeDao.findMatching(criteria);

    if (command.getNodesWithDownAggregateStatus()) {
        AggregateStatus as = new AggregateStatus(onmsNodes);
        onmsNodes = as.getDownNodes();
    }
    
    if (sanitizeLabels) {
        for (OnmsNode node : onmsNodes) {
            node.setLabel(WebSecurityUtils.sanitizeString(node.getLabel()));
        }
    }
    
    return createModelForNodes(command, onmsNodes);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:DefaultNodeListService.java

示例8: testSave

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
    @Transactional
    public void testSave() {
        OnmsNode node = new OnmsNode(getLocalHostDistPoller());
        node.setLabel("localhost");
        m_nodeDao.save(node);

        OnmsIpInterface ipInterface = new OnmsIpInterface("172.16.1.1", node);

        OnmsServiceType serviceType = m_serviceTypeDao.findByName("ICMP");
        assertNotNull(serviceType);

        OnmsMonitoredService monitoredService = new OnmsMonitoredService(ipInterface, serviceType);

        OnmsEvent event = new OnmsEvent();

        OnmsOutage outage = new OnmsOutage();
        outage.setServiceLostEvent(event);
        outage.setIfLostService(new Date());
        outage.setMonitoredService(monitoredService);
        m_outageDao.save(outage);

        //it works we're so smart! hehe
        outage = m_outageDao.load(outage.getId());
        assertEquals("ICMP", outage.getMonitoredService().getServiceType().getName());
//        outage.setEventBySvcRegainedEvent();
        
    }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:OutageDaoTest.java

示例9: SaveOrUpdateOperation

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>Constructor for SaveOrUpdateOperation.</p>
 *
 * @param nodeId a {@link java.lang.Integer} object.
 * @param foreignSource a {@link java.lang.String} object.
 * @param foreignId a {@link java.lang.String} object.
 * @param nodeLabel a {@link java.lang.String} object.
 * @param building a {@link java.lang.String} object.
 * @param city a {@link java.lang.String} object.
 * @param provisionService a {@link org.opennms.netmgt.provision.service.ProvisionService} object.
        * @param rescanExisting a {@link java.lang.Boolean} object
 */
public SaveOrUpdateOperation(Integer nodeId, String foreignSource, String foreignId, String nodeLabel, String building, String city, ProvisionService provisionService, boolean rescanExisting) {
    super(provisionService);
    
       m_node = new OnmsNode();
       m_node.setId(nodeId);
	m_node.setLabel(nodeLabel);
	m_node.setLabelSource("U");
	m_node.setType("A");
       m_node.setForeignSource(foreignSource);
       m_node.setForeignId(foreignId);
       m_node.getAssetRecord().setBuilding(building);
       m_node.getAssetRecord().setCity(city);
       m_rescanExisting = rescanExisting;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:SaveOrUpdateOperation.java

示例10: createNode

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private OnmsNode createNode() {
    OnmsNode node = new OnmsNode();
    //node.setId(nodeId);
    node.setLastCapsdPoll(new Date());
    node.setForeignSource("imported:");
    node.setLabel("default");
    
    m_nodeDao.save(node);
    m_nodeDao.flush();
    return node;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:12,代码来源:ProvisionerTest.java

示例11: createSnmpIfData

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private static SnmpIfData createSnmpIfData(String ipAddress, String ifName, Long ifSpeed, Integer ifIndex, boolean collectionEnabled) {
    OnmsNode node = new OnmsNode();
    node.setId(1);
    node.setLabel("testNode");
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, ifIndex);
    snmpIface.setIfDescr(ifName);
    snmpIface.setIfName(ifName);
    snmpIface.setIfAlias(ifName);
    snmpIface.setIfSpeed(ifSpeed);
    // If the SNMP interface doesn't have collection enable, threshold processing will be ignored for the interface
    snmpIface.setCollectionEnabled(collectionEnabled);
    return new SnmpIfData(snmpIface);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:ThresholdingVisitorTest.java

示例12: findAll

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Override
public List<OnmsNode> findAll() {
	
	List<OnmsNode> nodeList = new LinkedList<OnmsNode>();
	
	OnmsNode node = new OnmsNode();
	node.setId(777);
	node.setLabel("p-brane");
	
	nodeList.add(node);
	return nodeList;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:TestNodeDao.java

示例13: load

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Override
public OnmsNode load(Integer id) {
	OnmsNode node = new OnmsNode();
	node.setId(777);
	node.setLabel("p-brane");
	return node;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:8,代码来源:TestNodeDao.java

示例14: testInterfaceResource

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
public void testInterfaceResource() throws Exception {
    // Set Defaults
    String ipAddress = "10.0.0.1";
    String ifName = "eth0";
    int ifIndex = 2;
    
    // Initialize Database
    MockNetwork network = new MockNetwork();
    network.setCriticalService("ICMP");
    network.addNode(1, "testNode");
    network.addInterface(ipAddress);
    network.setIfAlias(ifName);
    network.addService("ICMP");
    network.addService("SNMP");
    network.addService("HTTP");
    MockDatabase db = new MockDatabase();
    db.populate(network);
    db.update("update snmpinterface set snmpifindex=?, snmpifname=?, snmpifdescr=? where id=?", ifIndex, ifName, ifName, 1);
    DataSourceFactory.setInstance(db);
    Vault.setDataSource(db);

    // Create Mock Collection Agent
    CollectionAgent agent = createCollectionAgent();

    // Create SnmpIfData
    OnmsNode node = new OnmsNode();
    node.setId(agent.getNodeId());
    node.setLabel("testNode");
    node.setForeignSource(agent.getForeignSource());
    node.setForeignId(agent.getForeignId());
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, ifIndex);
    snmpIface.setIfDescr(ifName);
    snmpIface.setIfName(ifName);
    snmpIface.setIfAlias(ifName);
    snmpIface.setIfSpeed(10000000l);
    snmpIface.setPhysAddr("001122334455");
    SnmpIfData ifData = new SnmpIfData(snmpIface);

    // Creating IfResourceType
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();        
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig);
    IfResourceType resourceType = new IfResourceType(agent, collection);

    // Creating Resource
    SnmpCollectionResource resource = new IfInfo(resourceType, agent, ifData);
    SnmpAttribute attribute = addAttributeToCollectionResource(resource, "ifInOctets", "counter", "ifIndex", "5000");
    Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>();
    attributes.put(attribute.getName(), attribute);
    
    // Create Wrapper
    CollectionResourceWrapper wrapper = createWrapper(resource, attributes);

    // Validations
    Assert.assertEquals(node.getId().intValue(), wrapper.getNodeId());
    Assert.assertEquals("127.0.0.1", wrapper.getHostAddress()); // Should be the address of the SNMP Agent (Bug 3808)
    Assert.assertEquals("eth0-001122334455", wrapper.getIfLabel());
    Assert.assertEquals("if", wrapper.getResourceTypeName());
    Assert.assertEquals("SNMP", wrapper.getServiceName());
    Assert.assertEquals(true, wrapper.isAnInterfaceResource());
    Assert.assertEquals(Integer.toString(ifIndex), wrapper.getInstance());
    Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex());
    Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex()); // IfLabel is called only once
    Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex()); // IfLabel is called only once
    Assert.assertEquals("eth0", wrapper.getIfInfoValue("snmpifname"));  // IfLabel is called only once
    Assert.assertEquals("eth0-001122334455", wrapper.getInstanceLabel());
    Assert.assertEquals("nodeSource[JUnit%3AT001].interfaceSnmp[eth0-001122334455]", wrapper.getResourceId());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:69,代码来源:CollectionResourceWrapperTest.java

示例15: doPersist

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>doPersist</p>
 *
 * @return a {@link java.util.List} object.
 */
public List<Event> doPersist() {
	OnmsNode imported = getNode();
	OnmsNode db = getNodeDao().getHierarchy(imported.getId());

	List<Event> events = new LinkedList<Event>();

	// verify that the node label is still the same
	if (!db.getLabel().equals(imported.getLabel())) {
		db.setLabel(imported.getLabel());
		// TODO: nodeLabelChanged event
	}

       if (!nullSafeEquals(db.getForeignSource(), imported.getForeignSource())) {
           db.setForeignSource(imported.getForeignSource());
       }

       if (!nullSafeEquals(db.getForeignId(), imported.getForeignId())) {
           db.setForeignId(imported.getForeignId());
       }

       if (isSnmpDataForNodeUpToDate()) {

		if (!nullSafeEquals(db.getSysContact(), imported.getSysContact())) {
			db.setSysContact(imported.getSysContact());
		}

		if (!nullSafeEquals(db.getSysDescription(), imported.getSysDescription())) {
			db.setSysDescription(imported.getSysDescription());
		}

		if (!nullSafeEquals(db.getSysLocation(), imported.getSysLocation())) {
			db.setSysLocation(imported.getSysLocation());
		}

		if (!nullSafeEquals(db.getSysName(), imported.getSysName())) {
			db.setSysName(imported.getSysName());
		}

		if (!nullSafeEquals(db.getSysObjectId(), imported.getSysObjectId())) {
			db.setSysObjectId(imported.getSysObjectId());
		}
		
	}

       if (isSnmpDataForInterfacesUpToDate())
           updateSnmpInterfaces(db, imported);

       updateInterfaces(db, imported, events);
	updateCategories(db, imported);

	getNodeDao().update(db);
       
	return events;

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:61,代码来源:UpdateOperation.java


注:本文中的org.opennms.netmgt.model.OnmsNode.setLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。