本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.setLabelSource方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.setLabelSource方法的具体用法?Java OnmsNode.setLabelSource怎么用?Java OnmsNode.setLabelSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.model.OnmsNode
的用法示例。
在下文中一共展示了OnmsNode.setLabelSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: AbstractSaveOrUpdateOperation
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>Constructor for AbstractSaveOrUpdateOperation.</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.
*/
public AbstractSaveOrUpdateOperation(final Integer nodeId, final String foreignSource, final String foreignId, final String nodeLabel, final String building, final String city) {
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);
}
示例3: testSaveCategoriesOnUpdateNodeAttributes
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test(timeout=300000)
@JUnitTemporaryDatabase // Relies on records created in @Before so we need a fresh database
@Transactional
public void testSaveCategoriesOnUpdateNodeAttributes() throws Exception {
final String TEST_CATEGORY = "TEST_CATEGORY";
final String OLD_LABEL = "apknd";
final String NEW_LABEL = "apknd-new";
importFromResource("classpath:/tec_dump.xml.smalltest", true);
final Collection<OnmsNode> nodes = m_nodeDao.findByLabel(OLD_LABEL);
assertNotNull(nodes);
assertEquals(1, nodes.size());
OnmsNode node = nodes.iterator().next();
assertNotNull(node);
OnmsNode nodeCopy = new OnmsNode();
nodeCopy.setId(node.getId());
nodeCopy.setLabel(OLD_LABEL);
// TODO: Replace with constant
nodeCopy.setLabelSource("U");
assertNotSame(node, nodeCopy);
assertEquals(OLD_LABEL, node.getLabel());
assertFalse(node.hasCategory(TEST_CATEGORY));
// Create a policy that will apply the category to the node
final NodeCategorySettingPolicy policy = new NodeCategorySettingPolicy();
policy.setCategory(TEST_CATEGORY);
policy.setLabel(OLD_LABEL);
// Apply the policy
nodeCopy = policy.apply(nodeCopy);
assertTrue(nodeCopy.hasCategory(TEST_CATEGORY));
// Change the label of the node so that we can trigger a NODE_LABEL_CHANGED_EVENT_UEI event
nodeCopy.setLabel(NEW_LABEL);
// TODO: Replace with constant
nodeCopy.setLabelSource("U");
assertFalse(node.getLabel().equals(nodeCopy.getLabel()));
m_provisionService.updateNodeAttributes(nodeCopy);
// Flush here to force a write so we are sure that the OnmsCategories are correctly created
m_nodeDao.flush();
// Query by the new node label
final OnmsNode node2 = m_nodeDao.findByLabel(NEW_LABEL).iterator().next();
assertTrue(node2.hasCategory(TEST_CATEGORY));
// Iterate over the events in the TransactionAwareEventForwarder to make
// sure that the NODE_LABEL_CHANGED_EVENT_UEI event was sent
boolean foundEvent = false;
for (Log eventLog : ((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).requestPendingEventsList()) {
for (Event event : eventLog.getEvents().getEventCollection()) {
if (EventConstants.NODE_LABEL_CHANGED_EVENT_UEI.equals(event.getUei())) {
foundEvent = true;
}
}
}
assertTrue(String.format("Did not find anticipated %s event", EventConstants.NODE_LABEL_CHANGED_EVENT_UEI), foundEvent);
}