本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.getAssetRecord方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.getAssetRecord方法的具体用法?Java OnmsNode.getAssetRecord怎么用?Java OnmsNode.getAssetRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.model.OnmsNode
的用法示例。
在下文中一共展示了OnmsNode.getAssetRecord方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateAndGets
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
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());
}
示例2: 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());
}
示例3: testAddAutoenable
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
public void testAddAutoenable() {
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.setAutoenable(OnmsAssetRecord.AUTOENABLED);
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.getAutoenable(), assetRecordFromDb.getAutoenable());
assertEquals(assetRecord.getConnection(), assetRecordFromDb.getConnection());
}
示例4: parseString
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* Parses the string.
*
* <p>Valid placeholders are:</p>
* <ul>
* <li><b>ipaddr</b>, The Node IP Address</li>
* <li><b>step</b>, The Collection Step in seconds</li>
* <li><b>nodeId</b>, The Node ID</li>
* <li><b>nodeLabel</b>, The Node Label</li>
* <li><b>foreignId</b>, The Node Foreign ID</li>
* <li><b>foreignSource</b>, The Node Foreign Source</li>
* <li>Any asset property defined on the node.</li>
* </ul>
*
* @param reference the reference
* @param unformattedString the unformatted string
* @param node the node
* @param ipAddress the IP address
* @return the string
* @throws IllegalArgumentException the illegal argument exception
*/
protected String parseString(final String reference, final String unformattedString, final OnmsNode node, final String ipAddress) throws IllegalArgumentException {
if (unformattedString == null)
return null;
String formattedString = unformattedString.replaceAll("[{](?i)(ipAddr|ipAddress)[}]", ipAddress);
formattedString = formattedString.replaceAll("[{](?i)nodeId[}]", node.getNodeId());
if (node.getLabel() != null)
formattedString = formattedString.replaceAll("[{](?i)nodeLabel[}]", node.getLabel());
if (node.getForeignId() != null)
formattedString = formattedString.replaceAll("[{](?i)foreignId[}]", node.getForeignId());
if (node.getForeignSource() != null)
formattedString = formattedString.replaceAll("[{](?i)foreignSource[}]", node.getForeignSource());
if (node.getAssetRecord() != null) {
BeanWrapper wrapper = new BeanWrapperImpl(node.getAssetRecord());
for (PropertyDescriptor p : wrapper.getPropertyDescriptors()) {
Object obj = wrapper.getPropertyValue(p.getName());
if (obj != null)
formattedString = formattedString.replaceAll("[{](?i)" + p.getName() + "[}]", obj.toString());
}
}
if (formattedString.matches(".*[{].+[}].*"))
throw new IllegalArgumentException("The " + reference + " " + formattedString + " contains unknown placeholders.");
return formattedString;
}
示例5: 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());
}
示例6: testFindByNodeId
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
public void testFindByNodeId() {
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 findByNodeId method
OnmsAssetRecord a = m_assetRecordDao.findByNodeId(onmsNode.getId());
assertTrue(a.equals(assetRecord));
}
示例7: testGeolocation
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
@Transactional
public void testGeolocation() {
OnmsNode onmsNode = new OnmsNode(m_distPollerDao.load("localhost"));
onmsNode.setLabel("myNode");
m_nodeDao.save(onmsNode);
OnmsAssetRecord assetRecord = onmsNode.getAssetRecord();
OnmsGeolocation geo = assetRecord.getGeolocation();
if (geo == null) {
geo = new OnmsGeolocation();
assetRecord.setGeolocation(geo);
}
geo.setAddress1("220 Chatham Business Drive");
geo.setCity("Pittsboro");
geo.setState("NC");
geo.setZip("27312");
geo.setCountry("US");
m_assetRecordDao.update(assetRecord);
m_assetRecordDao.flush();
//Test findAll method
int id = assetRecord.getId();
OnmsAssetRecord assetRecordFromDb = m_assetRecordDao.get(id);
assertNotNull(assetRecordFromDb.getGeolocation());
assertEquals(geo.getAddress1(), assetRecordFromDb.getGeolocation().getAddress1());
assertEquals(geo.getCity(), assetRecordFromDb.getGeolocation().getCity());
assertEquals(geo.getState(), assetRecordFromDb.getGeolocation().getState());
assertEquals(geo.getZip(), assetRecordFromDb.getGeolocation().getZip());
assertEquals(geo.getCountry(), assetRecordFromDb.getGeolocation().getCountry());
}
示例8: getSuitableRancidNodeAuthentication
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private RancidNodeAuthentication getSuitableRancidNodeAuthentication(OnmsNode node) {
// RancidAuthentication
RancidNodeAuthentication r_auth_node = new RancidNodeAuthentication();
r_auth_node.setDeviceName(node.getLabel());
OnmsAssetRecord asset_node = node.getAssetRecord();
// Seth 2011-09-12: Is this possible? I added this as defensive code against issue NMS-4475
//
// http://issues.opennms.org/browse/NMS-4475
//
if (asset_node == null) {
return r_auth_node;
}
if (asset_node.getUsername() != null) {
r_auth_node.setUser(asset_node.getUsername());
}
if (asset_node.getPassword() != null) {
r_auth_node.setPassword(asset_node.getPassword());
}
if (asset_node.getEnable() != null) {
r_auth_node.setEnablePass(asset_node.getEnable());
}
if (asset_node.getAutoenable() != null) {
r_auth_node.setAutoEnable(asset_node.getAutoenable().equals(OnmsAssetRecord.AUTOENABLED));
}
if (asset_node.getConnection() != null) {
r_auth_node.setConnectionMethod(asset_node.getConnection());
} else {
r_auth_node.setConnectionMethod("telnet");
}
return r_auth_node;
}
示例9: NodeEntry
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public NodeEntry(final OnmsNode node) {
final OnmsAssetRecord assetRecord = node.getAssetRecord();
if (assetRecord != null && assetRecord.getGeolocation() != null) {
final OnmsGeolocation geolocation = assetRecord.getGeolocation();
m_longitude = geolocation.getLongitude();
m_latitude = geolocation.getLatitude();
}
m_nodeId = node.getId();
m_nodeLabel = node.getLabel();
m_foreignSource = node.getForeignSource();
m_foreignId = node.getForeignId();
if (assetRecord != null) {
m_maintcontract = assetRecord.getMaintcontract();
m_description = assetRecord.getDescription();
}
if (node.getPrimaryInterface() != null) {
m_ipAddress = InetAddressUtils.str(node.getPrimaryInterface().getIpAddress());
}
if (node.getCategories() != null && node.getCategories().size() > 0) {
for (final OnmsCategory category : node.getCategories()) {
m_categories.add(category.getName());
}
}
}
示例10: evaluate
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Override public DisplayStatus evaluate(final HttpServletRequest request, final Object target) {
if (target instanceof OnmsNode) {
final OnmsNode node = (OnmsNode)target;
if (node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) {
final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation();
if (geolocation.getLongitude() != null && geolocation.getLatitude() != null) {
return DisplayStatus.DISPLAY_LINK;
}
}
}
return DisplayStatus.NO_DISPLAY;
}
示例11: testSaveOrUpdate
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
public void testSaveOrUpdate() {
OnmsNode onmsNode = new OnmsNode(m_distPollerDao.load("localhost"));
onmsNode.setLabel("myNode");
m_nodeDao.save(onmsNode);
OnmsAssetRecord assetRecord = onmsNode.getAssetRecord();
assetRecord.setAssetNumber("imported-id: " + onmsNode.getId());
assetRecord.setAdmin("supermario");
assetRecord.setLastModifiedDate(new Date());
assetRecord.getGeolocation().setAddress1("220 Chatham Business Drive");
assetRecord.getGeolocation().setCity("Pittsboro");
assetRecord.getGeolocation().setState("NC");
assetRecord.getGeolocation().setZip("27312");
assetRecord.getGeolocation().setCountry("US");
assetRecord.getGeolocation().setLatitude(35.717582f);
assetRecord.getGeolocation().setLongitude(-79.161800f);
m_assetRecordDao.update(assetRecord);
m_assetRecordDao.flush();
AssetCommand assetCommand = new AssetCommand();
BeanUtils.copyProperties(assetRecord, assetCommand);
System.out.println("AssetCommand (Source): " + assetCommand);
System.out.println("Asset to Save (Target): " + assetRecord);
AssetServiceImpl assetServiceImpl = new AssetServiceImpl();
assetServiceImpl.setNodeDao(m_nodeDao);
assetServiceImpl.setAssetRecordDao(m_assetRecordDao);
System.out.println();
assertTrue(assetServiceImpl.saveOrUpdateAssetByNodeId(onmsNode.getId(), assetCommand));
OnmsAssetRecord updated = m_assetRecordDao.get(assetRecord.getId());
assertEquals(assetRecord.getGeolocation().getAddress1(), updated.getGeolocation().getAddress1());
assertEquals(assetRecord.getGeolocation().getState(), updated.getGeolocation().getState());
assertEquals(assetRecord.getGeolocation().getCity(), updated.getGeolocation().getCity());
assertEquals(assetRecord.getGeolocation().getZip(), updated.getGeolocation().getZip());
assertEquals(assetRecord.getGeolocation().getCountry(), updated.getGeolocation().getCountry());
assertEquals(assetRecord.getGeolocation().getLongitude(), updated.getGeolocation().getLongitude());
assertEquals(assetRecord.getGeolocation().getLatitude(), updated.getGeolocation().getLatitude());
}
示例12: getAssetRecord
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private OnmsAssetRecord getAssetRecord(OnmsNode node) {
return node.getAssetRecord();
}
示例13: declareBeans
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private void declareBeans(BSFManager bsfManager) throws BSFException {
NodeDao nodeDao = Notifd.getInstance().getNodeDao();
Integer nodeId;
try {
nodeId = Integer.valueOf(m_notifParams.get(NotificationManager.PARAM_NODE));
} catch (NumberFormatException nfe) {
nodeId = null;
}
OnmsNode node = null;
OnmsAssetRecord assets = null;
List<String> categories = new ArrayList<String>();
String nodeLabel = null;
String foreignSource = null;
String foreignId = null;
if (nodeId != null) {
node = nodeDao.get(nodeId);
nodeLabel = node.getLabel();
assets = node.getAssetRecord();
for (OnmsCategory cat : node.getCategories()) {
categories.add(cat.getName());
}
foreignSource = node.getForeignSource();
foreignId = node.getForeignId();
}
bsfManager.declareBean("bsf_notif_strategy", this, BSFNotificationStrategy.class);
retrieveParams();
bsfManager.declareBean("notif_params", m_notifParams, Map.class);
bsfManager.declareBean("node_label", nodeLabel, String.class);
bsfManager.declareBean("foreign_source", foreignSource, String.class);
bsfManager.declareBean("foreign_id", foreignId, String.class);
bsfManager.declareBean("node_assets", assets, OnmsAssetRecord.class);
bsfManager.declareBean("node_categories", categories, List.class);
bsfManager.declareBean("node", node, OnmsNode.class);
for (Argument arg : m_arguments) {
if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) bsfManager.declareBean("text_message", arg.getValue(), String.class);
if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) bsfManager.declareBean("numeric_message", arg.getValue(), String.class);
if (NotificationManager.PARAM_NODE.equals(arg.getSwitch())) bsfManager.declareBean("node_id", arg.getValue(), String.class);
if (NotificationManager.PARAM_INTERFACE.equals(arg.getSwitch())) bsfManager.declareBean("ip_addr", arg.getValue(), String.class);
if (NotificationManager.PARAM_SERVICE.equals(arg.getSwitch())) bsfManager.declareBean("svc_name", arg.getValue(), String.class);
if (NotificationManager.PARAM_SUBJECT.equals(arg.getSwitch())) bsfManager.declareBean("subject", arg.getValue(), String.class);
if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) bsfManager.declareBean("email", arg.getValue(), String.class);
if (NotificationManager.PARAM_PAGER_EMAIL.equals(arg.getSwitch())) bsfManager.declareBean("pager_email", arg.getValue(), String.class);
if (NotificationManager.PARAM_XMPP_ADDRESS.equals(arg.getSwitch())) bsfManager.declareBean("xmpp_address", arg.getValue(), String.class);
if (NotificationManager.PARAM_TEXT_PAGER_PIN.equals(arg.getSwitch())) bsfManager.declareBean("text_pin", arg.getValue(), String.class);
if (NotificationManager.PARAM_NUM_PAGER_PIN.equals(arg.getSwitch())) bsfManager.declareBean("numeric_pin", arg.getValue(), String.class);
if (NotificationManager.PARAM_WORK_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("work_phone", arg.getValue(), String.class);
if (NotificationManager.PARAM_HOME_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("home_phone", arg.getValue(), String.class);
if (NotificationManager.PARAM_MOBILE_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("mobile_phone", arg.getValue(), String.class);
if (NotificationManager.PARAM_TUI_PIN.equals(arg.getSwitch())) bsfManager.declareBean("phone_pin", arg.getValue(), String.class);
if (NotificationManager.PARAM_MICROBLOG_USERNAME.equals(arg.getSwitch())) bsfManager.declareBean("microblog_username", arg.getValue(), String.class);
}
}