org.openoss.opennms.spring.dao
Class OssDaoOpenNMSImpl

java.lang.Object
  extended by org.openoss.opennms.spring.dao.OssDaoOpenNMSImpl
Direct Known Subclasses:
OssDaoOpenNMSImplSingleton

public class OssDaoOpenNMSImpl
extends java.lang.Object


Field Summary
protected static org.opennms.netmgt.dao.AlarmDao _alarmDao
          Used to search and update opennms alarm list
protected static org.opennms.netmgt.dao.AssetRecordDao _assetRecordDao
          Used to obtain opennms asset information for inclusion in alarms
protected static javax.sql.DataSource _dataSource
          Used to create new Lazy objects
protected static org.opennms.netmgt.dao.NodeDao _nodeDao
          Used to obtain opennms node information for inclusion in alarms
protected static 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
 org.opennms.netmgt.model.OnmsAlarm addCurrentAlarmForUniqueKey(org.opennms.netmgt.model.OnmsAlarm alarm)
          Adds Current alarm to OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm.
 java.lang.String alarmToString(org.opennms.netmgt.model.OnmsAlarm alarm)
          Debug method to print out opennms alarms
 java.lang.String alarmToStringBrief(org.opennms.netmgt.model.OnmsAlarm alarm)
          Debug method to print out opennms alarms (brief summary)
 org.opennms.netmgt.model.OnmsNode findNodeByID(java.lang.Integer nodeid)
          Returns the OnmsNode for the supplied node id
 org.opennms.netmgt.model.OnmsNode findNodeByInstanceAndType(java.lang.String managedObjectInstance, java.lang.String managedObjectType)
          This will return the first node with entry in Assets table having matching managedObjectInstance and managedObjectType.
 org.opennms.netmgt.model.OnmsNode findNodeByLabel(java.lang.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
 org.opennms.netmgt.model.OnmsAlarm[] getAlarmCache()
          Used By QoSD to retreive a copy of the current view of the alarm cache.
 org.opennms.netmgt.model.OnmsAlarm getCurrentAlarmForUniqueKey(java.lang.String applicationDN, java.lang.String ossPrimaryKey)
           
 void init()
          Initialises the Node and Alarm caches Must be called before any other methods to ensure that ossDao is initialised
 void setalarmDao(org.opennms.netmgt.dao.AlarmDao alarmDao)
          Used by Spring Application context to pass in alarmDao
 void setassetRecordDao(org.opennms.netmgt.dao.AssetRecordDao ar)
          Used by Spring Application context to pass in AssetRecordDao
 void setdataSource(javax.sql.DataSource dataSource)
           
 void setnodeDao(org.opennms.netmgt.dao.NodeDao nodedao)
          Used by Spring Application context to pass in NodeDaof
 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()
          Used to force an update to the local cache from latest alarm list in database
 void updateAlarmCacheAndSendAlarms()
          Used By QoSD to force an update to the local cache from latest alarm list in database Tries to call back to QoSD to send the latest alarm list.
 org.opennms.netmgt.model.OnmsAlarm updateCurrentAlarmForUniqueKey(org.opennms.netmgt.model.OnmsAlarm alarm)
          Updates Current alarm in OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm.
 void updateNodeCaches()
          Synchronized method to Update the node cache from the OpenNMS database May be called from Qosd on receipt of an asset register update event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dataSource

protected static javax.sql.DataSource _dataSource
Used to create new Lazy objects


_assetRecordDao

protected static org.opennms.netmgt.dao.AssetRecordDao _assetRecordDao
Used to obtain opennms asset information for inclusion in alarms

See Also:
AssetRecordDao

_nodeDao

protected static org.opennms.netmgt.dao.NodeDao _nodeDao
Used to obtain opennms node information for inclusion in alarms

See Also:
NodeDao

_alarmDao

protected static org.opennms.netmgt.dao.AlarmDao _alarmDao
Used to search and update opennms alarm list

See Also:
AlarmDao

transTemplate

protected static 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(javax.sql.DataSource dataSource)
Parameters:
source - the dataSource to set

setassetRecordDao

public void setassetRecordDao(org.opennms.netmgt.dao.AssetRecordDao ar)
Used by Spring Application context to pass in AssetRecordDao

Parameters:
ar -

setnodeDao

public void setnodeDao(org.opennms.netmgt.dao.NodeDao nodedao)
Used by Spring Application context to pass in NodeDaof

Parameters:
nodedao -

setalarmDao

public void setalarmDao(org.opennms.netmgt.dao.AlarmDao alarmDao)
Used by Spring Application context to pass in alarmDao

Parameters:
alarmDao -

setTransTemplate

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

Parameters:
transTemplate -

setQoSD

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

Parameters:
alarmDao -

init

public void init()
Initialises the Node and Alarm caches Must be called before any other methods to ensure that ossDao is initialised


addCurrentAlarmForUniqueKey

public org.opennms.netmgt.model.OnmsAlarm addCurrentAlarmForUniqueKey(org.opennms.netmgt.model.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).

Parameters:
alarm - - alarm to add.
Returns:
added alarm with new alarmID
Throws:
If - alarm AlarmID not null throws IllegalArgumentException. If ApplicationDN() and OssPrimaryKey() not unique in Current Alarm list throws IllegalArgumentException If alarm type not type 1 throws IllegalArgumentException. If ApplicationDN()==null or "" or OssPrimaryKey()==null or "", throws IllegalArgumentException. Note any new locally generated OpenNMS alarms will have ApplictionDN or OssPrimaryKey ==null or "" and so are ignored

updateCurrentAlarmForUniqueKey

public org.opennms.netmgt.model.OnmsAlarm updateCurrentAlarmForUniqueKey(org.opennms.netmgt.model.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).

Parameters:
alarm - - alarm to add.
Returns:
added alarm with new alarmID from OpenNMS Database
Throws:
If - alarm AlarmID not null throws IllegalArgumentException. If alarm type not type 1 throws IllegalArgumentException. If ApplicationDN()==null or "" or OssPrimaryKey()==null or "", throws IllegalArgumentException. Note any new locally generated OpenNMS alarms will have ApplictionDN or OssPrimaryKey ==null or "" and so are ignored

getCurrentAlarmForUniqueKey

public org.opennms.netmgt.model.OnmsAlarm getCurrentAlarmForUniqueKey(java.lang.String applicationDN,
                                                                      java.lang.String ossPrimaryKey)
Parameters:
applicationDN -
OssPrimaryKey -
Returns:
the first found alarm from current alarm list with matching paramaters. Returns Null if no such alarm.

updateAlarmCache

public void updateAlarmCache()
                      throws java.lang.IllegalStateException
Used to force an update to the local cache from latest alarm list in database

Throws:
java.lang.IllegalStateException

updateAlarmCacheAndSendAlarms

public void updateAlarmCacheAndSendAlarms()
                                   throws java.lang.IllegalStateException
Used By QoSD to force an update to the local cache from latest alarm list in database Tries to call back to QoSD to send the latest alarm list. The reason for this is to enforce synchronisation between QoSD and QoSDrx so that the current alarm list is always sent by QoSD If QoSD not running. Logs a debug message and returns

Throws:
java.lang.IllegalStateException

getAlarmCache

public org.opennms.netmgt.model.OnmsAlarm[] getAlarmCache()
Used By QoSD to retreive a copy of the current view of the alarm cache. Note NOT Synchronized - but OK if called by QoSD through QoSD.sendAlarms()


alarmToStringBrief

public java.lang.String alarmToStringBrief(org.opennms.netmgt.model.OnmsAlarm alarm)
Debug method to print out opennms alarms (brief summary)

Parameters:
alarm -
Returns:
string to print out

alarmToString

public java.lang.String alarmToString(org.opennms.netmgt.model.OnmsAlarm alarm)
Debug method to print out opennms alarms

Parameters:
alarm -
Returns:
string to print out

findNodeByLabel

public org.opennms.netmgt.model.OnmsNode findNodeByLabel(java.lang.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

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 org.opennms.netmgt.model.OnmsNode findNodeByInstanceAndType(java.lang.String managedObjectInstance,
                                                                   java.lang.String managedObjectType)
                                                            throws java.lang.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

Parameters:
managedObjectInstance -
managedObjectType -
Returns:
Throws:
java.lang.IllegalArgumentException - Note: Accesses the Node Cache

findNodeByID

public org.opennms.netmgt.model.OnmsNode findNodeByID(java.lang.Integer nodeid)
Returns the OnmsNode for the supplied node id

Parameters:
nodeid -
Returns:
Note: Accesses the Node Cache

updateNodeCaches

public void updateNodeCaches()
Synchronized method to Update the node cache from the OpenNMS database May be called from Qosd on receipt of an asset register update event



Copyright ? 2006-2008. All Rights Reserved.