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; }
/** * 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; }
/** * 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; } }
public static ResourceDTO fromResource(final OnmsResource resource, final int depth) { final ResourceDTO dto = new ResourceDTO(); dto.setId(resource.getId().toString()); dto.setLabel(resource.getLabel()); dto.setName(resource.getName()); dto.setLink(resource.getLink()); dto.setTypeLabel(resource.getResourceType().getLabel()); dto.setParentId(resource.getParent() == null ? null : resource.getParent().getId().toString()); dto.setStringPropertyAttributes(resource.getStringPropertyAttributes()); dto.setExternalValueAttributes(resource.getExternalValueAttributes()); dto.setRrdGraphAttributes(resource.getRrdGraphAttributes()); dto.setResource(resource); if (depth == 0) { dto.setChildren(null); } else { List<ResourceDTO> children = new LinkedList<>(); for (final OnmsResource child : resource.getChildResources()) { children.add(ResourceDTO.fromResource(child, depth - 1)); } dto.setChildren(new ResourceDTOCollection(children)); } return dto; } }