Class DeviceConfigDaoImpl
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- org.springframework.orm.hibernate3.support.HibernateDaoSupport
-
- org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate<DeviceConfig,Long>
-
- org.opennms.features.deviceconfig.persistence.impl.DeviceConfigDaoImpl
-
- All Implemented Interfaces:
DeviceConfigDao
,OnmsDao<DeviceConfig,Long>
,org.springframework.beans.factory.InitializingBean
public class DeviceConfigDaoImpl extends AbstractDaoHibernate<DeviceConfig,Long> implements DeviceConfigDao
-
-
Field Summary
-
Fields inherited from class org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate
m_criteriaConverter
-
-
Constructor Summary
Constructors Constructor Description DeviceConfigDaoImpl()
-
Method Summary
-
Methods inherited from class org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate
buildHibernateCallback, bulkDelete, clear, countAll, countMatching, countMatching, delete, delete, deleteAll, find, find, findAll, findMatching, findMatching, findObjects, findUnique, flush, get, initDao, initialize, load, lock, merge, queryInt, queryInt, save, saveOrUpdate, update
-
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.netmgt.dao.api.OnmsDao
clear, countAll, countMatching, delete, delete, findAll, findMatching, flush, get, initialize, load, lock, save, saveOrUpdate, update
-
-
-
-
Method Detail
-
findConfigsForInterfaceSortedByDate
public List<DeviceConfig> findConfigsForInterfaceSortedByDate(OnmsIpInterface ipInterface, String serviceName)
- Specified by:
findConfigsForInterfaceSortedByDate
in interfaceDeviceConfigDao
-
findStaleConfigs
public List<DeviceConfig> findStaleConfigs(OnmsIpInterface ipInterface, String serviceName, Date staleDate, Optional<Long> excludedId)
Find device configs for the given interface and service, excluding the given 'excludedId' if present, that are older than the 'staleDate'. Used to find state device configs - records that are not the latest good config and are older than the staleDate.- Specified by:
findStaleConfigs
in interfaceDeviceConfigDao
- Parameters:
ipInterface
- TheOnmsIpInterface
to filter onserviceName
- The name of the service to usestaleDate
- Records returned will be older than this dateexcludedId
- If supplied, an id of aDeviceConfig
record to exclude
-
getLatestConfigForInterface
public Optional<DeviceConfig> getLatestConfigForInterface(OnmsIpInterface ipInterface, String serviceName)
- Specified by:
getLatestConfigForInterface
in interfaceDeviceConfigDao
-
getLatestConfigForEachInterface
public List<DeviceConfigQueryResult> getLatestConfigForEachInterface(Integer limit, Integer offset, String orderBy, String sortOrder, String searchTerm, Set<DeviceConfigStatus> statuses)
Get latest device configuration for each interface. Returns a single record per device/config type combination.- Specified by:
getLatestConfigForEachInterface
in interfaceDeviceConfigDao
- Parameters:
limit
- Limit of number of records to return; defaults to 20offset
- Zero-based offset of records to return, used for pagination; defaults to 0.orderBy
- Property to order by, see implementation for exact options. Default is "lastUpdated".sortOrder
- Sort order for the sort type specified in 'orderBy'. Options are "desc" and "asc", defaults to "desc"searchTerm
- Search term to filter by, Currently searches device name and ip address.statuses
- If provided, a list ofDeviceConfigStatus
to filter on. If null or empty, does not do any filtering.- Returns:
- A list of
DeviceConfigQueryResult
objects
-
getLatestConfigCountForEachInterface
public int getLatestConfigCountForEachInterface(String searchTerm, Set<DeviceConfigStatus> statuses)
Get the total device count forgetLatestConfigForEachInterface(java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.util.Set<org.opennms.features.deviceconfig.persistence.api.DeviceConfigStatus>)
if no limit/offset were applied. Query is simplified as we do not need to do any sorting, grouping or windowing functions.- Specified by:
getLatestConfigCountForEachInterface
in interfaceDeviceConfigDao
- Parameters:
searchTerm
- Optional search termstatuses
- See explanation inDeviceConfigDao.getLatestConfigForEachInterface(java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.util.Set<org.opennms.features.deviceconfig.persistence.api.DeviceConfigStatus>)
-
getAllDeviceConfigsWithAnInterfaceId
public List<DeviceConfig> getAllDeviceConfigsWithAnInterfaceId(Integer ipInterfaceId)
- Specified by:
getAllDeviceConfigsWithAnInterfaceId
in interfaceDeviceConfigDao
-
updateDeviceConfigContent
public Optional<Long> updateDeviceConfigContent(OnmsIpInterface ipInterface, String serviceName, String configType, String encoding, byte[] deviceConfigBytes, String fileName)
Description copied from interface:DeviceConfigDao
Update the content of the specific device config.- Specified by:
updateDeviceConfigContent
in interfaceDeviceConfigDao
- Returns:
- An
Optional
containing the id of theDeviceConfig
record that was updated.
-
updateDeviceConfigFailure
public void updateDeviceConfigFailure(OnmsIpInterface ipInterface, String serviceName, String configType, String encoding, String reason)
- Specified by:
updateDeviceConfigFailure
in interfaceDeviceConfigDao
-
createEmptyDeviceConfig
public void createEmptyDeviceConfig(OnmsIpInterface ipInterface, String serviceName, String configType)
- Specified by:
createEmptyDeviceConfig
in interfaceDeviceConfigDao
-
-