org.openoss.opennms.spring.dao
Interface OssDao

All Known Implementing Classes:
OssDaoOpenNMSImpl

public interface OssDao

OssDao interface.

Version:
$Id: $
Author:
ranger

Method Summary
 OnmsAlarm addCurrentAlarmForUniqueKey(OnmsAlarm alarm)
          Adds Current alarm to OpenNMS database with a new alarmID as an AlarmType= 'raise' ( type 1 ) alarm.
 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()
          Used By QoSD to retreive a copy of the current view of the alarm cache.
 OnmsAlarm getCurrentAlarmForUniqueKey(String applicationDN, String ossPrimaryKey)
          getCurrentAlarmForUniqueKey
 void init()
          Initialises the Node and Alarm caches Must be called before any other methods to ensure that ossDao is initialised
 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()
          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.
 OnmsAlarm updateCurrentAlarmForUniqueKey(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
 

Method Detail

setDataSource

void setDataSource(DataSource dataSource)

setDataSource

Parameters:
dataSource - The dataSource to set

setAssetRecordDao

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

Parameters:
ar - a AssetRecordDao object.

setNodeDao

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

Parameters:
nodedao - a NodeDao object.

setAlarmDao

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

Parameters:
alarmDao - a AlarmDao object.

setTransTemplate

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

Parameters:
transTemplate - a TransactionTemplate object.

setQoSD

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

Parameters:
qoSD - a QoSD object.

init

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


addCurrentAlarmForUniqueKey

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).

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

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).

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

OnmsAlarm getCurrentAlarmForUniqueKey(String applicationDN,
                                      String ossPrimaryKey)

getCurrentAlarmForUniqueKey

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

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

Throws:
IllegalStateException - if any.

updateAlarmCacheAndSendAlarms

void updateAlarmCacheAndSendAlarms()
                                   throws 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:
IllegalStateException - if any.

getAlarmCache

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()

Returns:
an array of OnmsAlarm objects.

findNodeByLabel

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

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

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

Parameters:
managedObjectInstance - a String object.
managedObjectType - a String object.
Returns:
the node object
Throws:
IllegalArgumentException - Note: Accesses the Node Cache

findNodeByID

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

Parameters:
nodeid - a Integer object.
Returns:
a OnmsNode object.

updateNodeCaches

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 © 2011. All Rights Reserved.