Package org.opennms.netmgt.dao.support
Class DefaultResourceDao
- java.lang.Object
-
- org.opennms.netmgt.dao.support.DefaultResourceDao
-
- All Implemented Interfaces:
ResourceDao
,org.springframework.beans.factory.InitializingBean
public class DefaultResourceDao extends Object implements ResourceDao, org.springframework.beans.factory.InitializingBean
Retrieves and enumerates elements from the resource tree. This class is responsible for maintaining the list of resource types and coordinating amongst these. All resource type specific logic should be contained in the resource type implementations rather than this class.- Author:
- Jesse White, Seth Leger , Lawrence Karnowski , DJ Gregor
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAXIMUM_NODE_METRIC_RESOURCE_DEPTH
Largest depth at which we will find node related metrics: [0] will catch node-level resources [1] will catch interface-level resources [2] will catch generic index type resources
-
Constructor Summary
Constructors Constructor Description DefaultResourceDao()
Constructor for DefaultResourceDao.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
afterPropertiesSetstatic String
decode(String string)
Encapsulate the deprecated decode method to fix it in one place.boolean
deleteResource(OnmsResource resource, boolean recursive)
boolean
deleteResourceById(ResourceId resourceId)
Deletes the resource identified by the given resource ID.List<OnmsResource>
findTopLevelResources()
findTopLevelResourcesprotected OnmsResource
getChildResource(OnmsResource parentResource, String resourceType, String resource)
getChildResourceCollectdConfigFactory
getCollectdConfig()
getCollectdConfigIpInterfaceDao
getIpInterfaceDao()
NodeDao
getNodeDao()
getNodeDaoOnmsResource
getResourceById(ResourceId id)
Fetch a specific resource by string ID.OnmsResource
getResourceForNode(OnmsNode node)
Creates a resource for the given node using the most appropriate type.ResourceId
getResourceId(CollectionResource resource, long nodeId)
ResourceStorageDao
getResourceStorageDao()
Collection<OnmsResourceType>
getResourceTypes()
getResourceTypesResourceTypesDao
getResourceTypesDao()
protected boolean
hasAnyChildResources(OnmsResource resource)
Used to determine whether or not the given (parent) resource has any child resources.void
setCollectdConfig(CollectdConfigFactory collectdConfig)
setCollectdConfigvoid
setIpInterfaceDao(IpInterfaceDao ipInterfaceDao)
void
setNodeDao(NodeDao nodeDao)
setNodeDaovoid
setResourceStorageDao(ResourceStorageDao resourceStorageDao)
void
setResourceTypesDao(ResourceTypesDao resourceTypesDao)
-
-
-
Field Detail
-
MAXIMUM_NODE_METRIC_RESOURCE_DEPTH
public static final int MAXIMUM_NODE_METRIC_RESOURCE_DEPTH
Largest depth at which we will find node related metrics: [0] will catch node-level resources [1] will catch interface-level resources [2] will catch generic index type resources- See Also:
- Constant Field Values
-
-
Method Detail
-
getResourceTypesDao
public ResourceTypesDao getResourceTypesDao()
-
setResourceTypesDao
public void setResourceTypesDao(ResourceTypesDao resourceTypesDao)
-
setNodeDao
public void setNodeDao(NodeDao nodeDao)
setNodeDao
- Parameters:
nodeDao
- aNodeDao
object.
-
getCollectdConfig
public CollectdConfigFactory getCollectdConfig()
getCollectdConfig
- Returns:
- a
CollectdConfigFactory
object.
-
setCollectdConfig
public void setCollectdConfig(CollectdConfigFactory collectdConfig)
setCollectdConfig
- Parameters:
collectdConfig
- aCollectdConfigFactory
object.
-
getIpInterfaceDao
public IpInterfaceDao getIpInterfaceDao()
-
setIpInterfaceDao
public void setIpInterfaceDao(IpInterfaceDao ipInterfaceDao)
-
setResourceStorageDao
public void setResourceStorageDao(ResourceStorageDao resourceStorageDao)
-
getResourceStorageDao
public ResourceStorageDao getResourceStorageDao()
-
afterPropertiesSet
public void afterPropertiesSet()
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
getResourceTypes
public Collection<OnmsResourceType> getResourceTypes()
getResourceTypes
- Specified by:
getResourceTypes
in interfaceResourceDao
- Returns:
- a
Collection
object.
-
findTopLevelResources
@Transactional(readOnly=true) public List<OnmsResource> findTopLevelResources()
findTopLevelResources
- Specified by:
findTopLevelResources
in interfaceResourceDao
- Returns:
- a
List
object.
-
hasAnyChildResources
protected boolean hasAnyChildResources(OnmsResource resource)
Used to determine whether or not the given (parent) resource has any child resources.
-
getResourceById
@Transactional(readOnly=true) public OnmsResource getResourceById(ResourceId id)
Fetch a specific resource by string ID.- Specified by:
getResourceById
in interfaceResourceDao
- Parameters:
id
- aString
object.- Returns:
- Resource or null if resource cannot be found.
- Throws:
IllegalArgumentException
- When the resource ID string does not match the expected regex patternorg.springframework.orm.ObjectRetrievalFailureException
- If any exceptions are thrown while searching for the resource
-
getResourceForNode
public OnmsResource getResourceForNode(OnmsNode node)
Creates a resource for the given node using the most appropriate type.- Specified by:
getResourceForNode
in interfaceResourceDao
- Parameters:
node
- aOnmsNode
object.- Returns:
- a
OnmsResource
object.
-
deleteResourceById
public boolean deleteResourceById(ResourceId resourceId)
Description copied from interface:ResourceDao
Deletes the resource identified by the given resource ID.- Specified by:
deleteResourceById
in interfaceResourceDao
- Parameters:
resourceId
- the ID of the resource to delete- Returns:
true
iff, the resource was found and deleted
-
deleteResource
public boolean deleteResource(OnmsResource resource, boolean recursive)
-
getChildResource
protected OnmsResource getChildResource(OnmsResource parentResource, String resourceType, String resource)
getChildResource
- Parameters:
parentResource
- aOnmsResource
object.resourceType
- aString
object.resource
- aString
object.- Returns:
- a
OnmsResource
object.
-
decode
public static String decode(String string)
Encapsulate the deprecated decode method to fix it in one place.- Parameters:
string
- string to be decoded- Returns:
- decoded string
-
getResourceId
public ResourceId getResourceId(CollectionResource resource, long nodeId)
- Specified by:
getResourceId
in interfaceResourceDao
-
-