use of org.opennms.netmgt.model.resource.ResourceDTO in project opennms by OpenNMS.
the class GraphRestService method getGraphResourcesForNode.
@GET
@Path("fornode/{nodeCriteria}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Transactional(readOnly = true)
public GraphResourceDTO getGraphResourcesForNode(@PathParam("nodeCriteria") final String nodeCriteria, @DefaultValue("-1") @QueryParam("depth") final int depth) {
OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null) {
throw getException(Status.NOT_FOUND, "No node found with criteria '{}'.", nodeCriteria);
}
OnmsResource resource = m_resourceDao.getResourceForNode(node);
if (resource == null) {
throw getException(Status.NOT_FOUND, "No resource found for node with id {}.", "" + node.getId());
}
final ResourceVisitor visitor = new ResourceVisitor(this);
final ResourceDTO resourceDTO = ResourceDTO.fromResource(resource, depth);
visitor.visit(resourceDTO);
return new GraphResourceDTO(resourceDTO, visitor.getGraphs());
}
use of org.opennms.netmgt.model.resource.ResourceDTO in project opennms by OpenNMS.
the class ShowCommand method execute.
@Override
public void execute(final ResourceCli resourceCli) throws Exception {
// Request and print the data
final ResourceDTO resource = connect(resourceCli, this.resource).header("Accept", "application/xml").get(ResourceDTO.class);
System.out.println("ID: " + resource.getId());
System.out.println("Name: " + resource.getName());
System.out.println("Label: " + resource.getLabel());
System.out.println("Type: " + resource.getTypeLabel());
System.out.println("Link: " + resource.getLink());
System.out.println("Parent ID: " + resource.getParentId());
System.out.println("Children:");
if (resource.getChildren() != null) {
for (final ResourceDTO childResource : resource.getChildren().getObjects()) {
System.out.println(" " + childResource.getId());
}
}
System.out.println("Attributes:");
System.out.println(" External:");
for (final Map.Entry<String, String> e : resource.getExternalValueAttributes().entrySet()) {
System.out.println(" " + e.getKey() + " = '" + e.getValue() + "'");
}
System.out.println(" Metrics:");
for (final Map.Entry<String, RrdGraphAttribute> e : resource.getRrdGraphAttributes().entrySet()) {
System.out.println(" " + e.getKey() + " = '" + e.getValue().getRrdFile() + "'");
}
System.out.println(" Strings:");
for (final Map.Entry<String, String> e : resource.getStringPropertyAttributes().entrySet()) {
System.out.println(" " + e.getKey() + " = '" + e.getValue() + "'");
}
}
Aggregations