org.openoss.opennms.spring.dao
Class OssDaoOpenNMSImpl

java.lang.Object
  extended by org.openoss.opennms.spring.dao.OssDaoOpenNMSImpl
All Implemented Interfaces:
OssDao

public class OssDaoOpenNMSImpl
extends Object
implements OssDao

OssDaoOpenNMSImpl class.

Version:
$Id: $
Author:
ranger

Field Summary
protected  AlarmDao _alarmDao
          Used to search and update opennms alarm list
protected  AssetRecordDao _assetRecordDao
          Used to obtain opennms asset information for inclusion in alarms
protected  DataSource _dataSource
          Used to create new Lazy objects
protected  NodeDao _nodeDao
          Used to obtain opennms node information for inclusion in alarms
protected  org.springframework.transaction.support.TransactionTemplate transTemplate
          Used to ensure that objects retreived from OpenNMS through Hibernate contain all of their internal objects populated with values
 
Constructor Summary
OssDaoOpenNMSImpl()
           
 
Method Summary
 OnmsAlarm addCurrentAlarmForUniqueKey(OnmsAlarm alarm)
          Adds Current alarm to OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm.
static String alarmToString(OnmsAlarm alarm)
          Debug method to print out opennms alarms
 OnmsNode findNodeByID(Integer nodeid)
          Returns the OnmsNode for the supplied node id
 OnmsNode findNodeByInstanceAndType(String managedObjectInstance, String managedObjectType)
          This will return the first node with entry in Assets table having matching managedObjectInstance and managedObjectType.
 OnmsNode findNodeByLabel(String label)
          This will return the first node in nodes table with nodeLable entry matching label Note for this to work, the configuration of OpenNMS must ensure that the node label is unique otherwise only the first instance will be returned
 OnmsAlarm[] getAlarmCache()
          getAlarmCache
 OnmsAlarm getCurrentAlarmForUniqueKey(String applicationDN, String ossPrimaryKey)
          getCurrentAlarmForUniqueKey
 void init()
          init
 void setAlarmDao(AlarmDao alarmDao)
          Used by Spring Application context to pass in AlarmDao.
 void setAssetRecordDao(AssetRecordDao ar)
          Used by Spring Application context to pass in AssetRecordDao.
 void setDataSource(DataSource dataSource)
          setDataSource
 void setNodeDao(NodeDao nodedao)
          Used by Spring Application context to pass in NodeDao.
 void setQoSD(QoSD _qoSD)
          Used by running QoSD to set up OssDao to call back alarm list updates
 void setTransTemplate(org.springframework.transaction.support.TransactionTemplate _transTemplate)
          Used by Spring Application context to pass in a Spring transaction manager
 void updateAlarmCache()
          updateAlarmCache
 void updateAlarmCacheAndSendAlarms()
          updateAlarmCacheAndSendAlarms
 OnmsAlarm updateCurrentAlarmForUniqueKey(OnmsAlarm alarm)
          Updates Current alarm in OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm.
 void updateNodeCaches()
          updateNodeCaches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dataSource

protected DataSource _dataSource
Used to create new Lazy objects


_assetRecordDao

protected AssetRecordDao _assetRecordDao
Used to obtain opennms asset information for inclusion in alarms

See Also:
AssetRecordDao

_nodeDao

protected NodeDao _nodeDao
Used to obtain opennms node information for inclusion in alarms

See Also:
NodeDao

_alarmDao

protected AlarmDao _alarmDao
Used to search and update opennms alarm list

See Also:
AlarmDao

transTemplate

protected org.springframework.transaction.support.TransactionTemplate transTemplate
Used to ensure that objects retreived from OpenNMS through Hibernate contain all of their internal objects populated with values

Constructor Detail

OssDaoOpenNMSImpl

public OssDaoOpenNMSImpl()
Method Detail

setDataSource

public void setDataSource(DataSource dataSource)

setDataSource

Specified by:
setDataSource in interface OssDao
Parameters:
dataSource - The dataSource to set

setAssetRecordDao

public void setAssetRecordDao(AssetRecordDao ar)
Used by Spring Application context to pass in AssetRecordDao.

Specified by:
setAssetRecordDao in interface OssDao
Parameters:
ar - a AssetRecordDao object.

setNodeDao

public void setNodeDao(NodeDao nodedao)
Used by Spring Application context to pass in NodeDao.

Specified by:
setNodeDao in interface OssDao
Parameters:
nodedao - a NodeDao object.

setAlarmDao

public void setAlarmDao(AlarmDao alarmDao)
Used by Spring Application context to pass in AlarmDao.

Specified by:
setAlarmDao in interface OssDao
Parameters:
alarmDao - a AlarmDao object.

setTransTemplate

public void setTransTemplate(org.springframework.transaction.support.TransactionTemplate _transTemplate)
Used by Spring Application context to pass in a Spring transaction manager

Specified by:
setTransTemplate in interface OssDao
Parameters:
_transTemplate - a TransactionTemplate object.

setQoSD

public void setQoSD(QoSD _qoSD)
Used by running QoSD to set up OssDao to call back alarm list updates

Specified by:
setQoSD in interface OssDao
Parameters:
_qoSD - a QoSD object.

init

public void init()

init

Specified by:
init in interface OssDao

addCurrentAlarmForUniqueKey

public OnmsAlarm addCurrentAlarmForUniqueKey(OnmsAlarm alarm)
Adds Current alarm to OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm. Adds the alarm to the local Current Alarm Alarm list alarmCacheByID with the new alarmID only if the alarm is NOT (Acknowledged AND Cleared).

Specified by:
addCurrentAlarmForUniqueKey in interface OssDao
Parameters:
alarm - - alarm to add.
Returns:
added alarm with new alarmID

updateCurrentAlarmForUniqueKey

public OnmsAlarm updateCurrentAlarmForUniqueKey(OnmsAlarm alarm)
Updates Current alarm in OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm. Adds the alarm to the local Current Alarm Alarm list alarmCacheByID with the new alarmID only if the alarm is NOT (Acknowledged AND Cleared).

Specified by:
updateCurrentAlarmForUniqueKey in interface OssDao
Parameters:
alarm - - alarm to add.
Returns:
added alarm with new alarmID from OpenNMS Database

getCurrentAlarmForUniqueKey

public OnmsAlarm getCurrentAlarmForUniqueKey(String applicationDN,
                                             String ossPrimaryKey)

getCurrentAlarmForUniqueKey

Specified by:
getCurrentAlarmForUniqueKey in interface OssDao
Parameters:
applicationDN - a String object.
ossPrimaryKey - a String object.
Returns:
the first found alarm from current alarm list with matching parameters. Returns Null if no such alarm.

updateAlarmCache

public void updateAlarmCache()
                      throws IllegalStateException

updateAlarmCache

Specified by:
updateAlarmCache in interface OssDao
Throws:
IllegalStateException - if any.

updateAlarmCacheAndSendAlarms

public void updateAlarmCacheAndSendAlarms()
                                   throws IllegalStateException

updateAlarmCacheAndSendAlarms

Specified by:
updateAlarmCacheAndSendAlarms in interface OssDao
Throws:
IllegalStateException - if any.

getAlarmCache

public OnmsAlarm[] getAlarmCache()

getAlarmCache

Specified by:
getAlarmCache in interface OssDao
Returns:
an array of OnmsAlarm objects.

alarmToString

public static String alarmToString(OnmsAlarm alarm)
Debug method to print out opennms alarms

Parameters:
alarm - a OnmsAlarm object.
Returns:
string to print out

findNodeByLabel

public OnmsNode findNodeByLabel(String label)
This will return the first node in nodes table with nodeLable entry matching label Note for this to work, the configuration of OpenNMS must ensure that the node label is unique otherwise only the first instance will be returned

Specified by:
findNodeByLabel in interface OssDao
Parameters:
label - NodeLabel of node to look for
Returns:
will look for first match of node label. null if not found Note: Accesses the Node Cache

findNodeByInstanceAndType

public OnmsNode findNodeByInstanceAndType(String managedObjectInstance,
                                          String managedObjectType)
                                   throws IllegalArgumentException
This will return the first node with entry in Assets table having matching managedObjectInstance and managedObjectType. Note for this to work, the configuration of OpenNMS must ensure that the concatenation of these fields is unique in the system otherwise only the first instance will be returned

Specified by:
findNodeByInstanceAndType in interface OssDao
Parameters:
managedObjectInstance - a String object.
managedObjectType - a String object.
Returns:
the node object
Throws:
IllegalArgumentException - Note: Accesses the Node Cache

findNodeByID

public OnmsNode findNodeByID(Integer nodeid)
Returns the OnmsNode for the supplied node id

Specified by:
findNodeByID in interface OssDao
Parameters:
nodeid - a Integer object.
Returns:
a OnmsNode object.

updateNodeCaches

public void updateNodeCaches()

updateNodeCaches

Specified by:
updateNodeCaches in interface OssDao


Copyright © 2011. All Rights Reserved.