Search in sources :

Example 6 with InterfaceLevelResource

use of org.opennms.netmgt.collection.support.builder.InterfaceLevelResource in project opennms by OpenNMS.

the class XmpCollector method getResource.

protected Resource getResource(NodeLevelResource nodeLevelResource, String nodeTypeName, String resourceType, String instance) throws CollectionException {
    if (CollectionResource.RESOURCE_TYPE_NODE.equalsIgnoreCase(nodeTypeName)) {
        return nodeLevelResource;
    }
    final String effectiveResourceType;
    if ((resourceType == null) || (resourceType.length() == 0)) {
        effectiveResourceType = null;
    } else {
        effectiveResourceType = resourceType;
    }
    final String effectiveInstance;
    if (instance != null) {
        effectiveInstance = XmpCollector.sanitizeInstance(instance);
    } else {
        effectiveInstance = null;
    }
    if (effectiveResourceType != null) {
        final ResourceType resourceTypeDef = m_resourceTypesDao.getResourceTypeByName(effectiveResourceType);
        if (resourceType == null) {
            throw new CollectionException("No resource type found with name '" + effectiveResourceType + "'.");
        }
        return new GenericTypeResource(nodeLevelResource, resourceTypeDef, effectiveInstance);
    } else {
        return new InterfaceLevelResource(nodeLevelResource, effectiveInstance);
    }
}
Also used : GenericTypeResource(org.opennms.netmgt.collection.support.builder.GenericTypeResource) CollectionException(org.opennms.netmgt.collection.api.CollectionException) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) InterfaceLevelResource(org.opennms.netmgt.collection.support.builder.InterfaceLevelResource)

Aggregations

InterfaceLevelResource (org.opennms.netmgt.collection.support.builder.InterfaceLevelResource)6 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)4 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)3 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)3 Test (org.junit.Test)2 MockCollectionAgent (org.opennms.core.collection.test.MockCollectionAgent)2 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)2 GenericTypeResource (org.opennms.netmgt.collection.support.builder.GenericTypeResource)2 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Callable (java.util.concurrent.Callable)1 Parameters (org.junit.runners.Parameterized.Parameters)1 CollectionException (org.opennms.netmgt.collection.api.CollectionException)1 Persister (org.opennms.netmgt.collection.api.Persister)1 ResourceType (org.opennms.netmgt.collection.api.ResourceType)1 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)1 DeferredGenericTypeResource (org.opennms.netmgt.collection.support.builder.DeferredGenericTypeResource)1 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)1 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)1