private OnmsResource createResource(final String location, final OnmsIpInterface ipInterface, final String ipAddr, final ResourcePath path) { final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, path); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); final OnmsResource resource = new OnmsResource(ipAddr, ipAddr, this, set, path); resource.setEntity(ipInterface); return resource; }
private OnmsResource getResourceByParentPathAndInterface(ResourcePath parent, String intf, String label, OnmsSnmpInterface snmpInterface) throws DataAccessException { final ResourcePath path = ResourcePath.get(parent, intf); final AttributeLoader loader = new AttributeLoader(m_resourceStorageDao, path, snmpInterface); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); return new OnmsResource(intf, label, this, set, path); }
private OnmsResource getResourceByParentPathAndInterface(ResourcePath parent, String intf) { final ResourcePath path = ResourcePath.get(parent, intf); final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, path); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); return new OnmsResource(intf, intf, this, set, path); }
private OnmsResource createResource(String definitionName, String locationMonitorId, String ipAddress) { String monitor = definitionName + "-" + locationMonitorId; String label = ipAddress + " from " + monitor; final ResourcePath path = getRelativeInterfacePath(locationMonitorId, ipAddress); final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, path); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); return new OnmsResource(getResourceName(locationMonitorId, ipAddress), label, this, set, path); }
private OnmsResource getResourceForNode(OnmsResource node) { final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, node.getPath()); final Set<OnmsAttribute> attributes = new LazySet<OnmsAttribute>(loader); final OnmsResource resource = new OnmsResource("", "Node-level Performance Data", this, attributes, node.getPath()); resource.setParent(node); return resource; }
private OnmsResource createResourceForDomain(String domain) { final ResourcePath path = new ResourcePath(ResourceTypeUtils.SNMP_DIRECTORY, domain); final LazyChildResourceLoader loader = new LazyChildResourceLoader(m_resourceDao); final OnmsResource resource = new OnmsResource(domain, domain, this, s_emptyAttributeSet, new LazyList<OnmsResource>(loader), path); loader.setParent(resource); return resource; }
protected OnmsResource createResourceForNode(OnmsNode node) { final ResourcePath path = getResourcePathForNode(node); final LazyChildResourceLoader loader = new LazyChildResourceLoader(m_resourceDao); final String resourceName = node.getForeignSource() != null && node.getForeignId() != null ? String.format("%s:%s", node.getForeignSource(), node.getForeignId()) : Integer.toString(node.getId()); final OnmsResource resource = new OnmsResource(resourceName, node.getLabel(), this, s_emptyAttributeSet, new LazyList<OnmsResource>(loader), path); resource.setEntity(node); loader.setParent(resource); return resource; }
public void testUnfilteredResourceAttributeFilteringWithNoMatch() throws Exception { MockResourceType resourceType = new MockResourceType(); resourceType.setName("interfaceSnmp"); OnmsAttribute attribute = new RrdGraphAttribute("IfInOctets", "something", "something else"); OnmsResource resource = new OnmsResource("1", "Node One", resourceType, Collections.singleton(attribute), ResourcePath.get("foo")); EasyMock.expect(m_resourceDao.findTopLevelResources()).andReturn(Collections.singletonList(resource)); ReportDefinition def = createReportDefinition(); def.setResourceAttributeKey("ifSpeed"); def.setResourceAttributeValueMatch("100000000"); ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_fetchStrategy, m_filterDao); m_mocks.replayAll(); report.walk(); assertEquals("results size", 0, report.getResults().size()); }
private static OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; }
private static OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; }
/** * Checks a resource label for quotes. * * @param childResource the child resource to check * @return the resource */ private OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; }
public void testFilteredResourceAttributeFilteringWithNoMatch() throws Exception { final OnmsNode node = new OnmsNode(); node.setId(1); node.setLabel("Node One"); EasyMock.expect(m_nodeDao.load(1)).andReturn(node); MockResourceType resourceType = new MockResourceType(); resourceType.setName("interfaceSnmp"); OnmsAttribute attribute = new RrdGraphAttribute("IfInOctets", "something", "something else"); OnmsResource resource = new OnmsResource(node.getId().toString(), node.getLabel(), resourceType, Collections.singleton(attribute), ResourcePath.get("foo")); ReportDefinition def = createReportDefinition(); def.getReport().getPackage().setFilter(""); def.setResourceAttributeKey("ifSpeed"); def.setResourceAttributeValueMatch("100000000"); ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_fetchStrategy, m_filterDao); SortedMap<Integer,String> sortedNodeMap = new TreeMap<Integer, String>(); sortedNodeMap.put(node.getId(), node.getLabel()); EasyMock.expect(m_filterDao.getNodeMap("")).andReturn(sortedNodeMap); EasyMock.expect(m_resourceDao.getResourceForNode(node)).andReturn(resource); m_mocks.replayAll(); report.walk(); assertEquals("results size", 0, report.getResults().size()); }
/** * Checks a label for quotes and returns a safe resource instance. * * @param childResource the resource to check * @return a new constructed resource instance */ private static OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; } }
/** * Checks a resource label for quotes. * * @param childResource the child resource to check * @return the resource */ private OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; }
final OnmsResource resource = new OnmsResource(index, label, this, set, path); resource.setParent(parent); return resource;
/** * Checks a label for quotes and returns a safe resource instance. * * @param childResource the resource to check * @return a new constructed resource instance */ private static OnmsResource checkLabelForQuotes(OnmsResource childResource) { String lbl = Util.convertToJsSafeString(childResource.getLabel()); OnmsResource resource = new OnmsResource(childResource.getName(), lbl, childResource.getResourceType(), childResource.getAttributes(), childResource.getPath()); resource.setParent(childResource.getParent()); resource.setEntity(childResource.getEntity()); resource.setLink(childResource.getLink()); return resource; } }
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, attributes, ResourcePath.get("foo")); ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_fetchStrategy, m_filterDao); rrdAttribute.setResource(new OnmsResource("1", "Node One", resourceType, Collections.singleton(rrdAttribute), ResourcePath.get("foo"))); Source source = new Source(); source.setLabel("result");
OnmsResource resource = new OnmsResource(node.getId().toString(), node.getLabel(), resourceType, attributes, ResourcePath.get("foo"));