X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d70ff3d064c9a6da8b8678b249abf7f4b93b6370..9c4c0fd4015865e8f2f9f9c9867c7d847cd34aeb:/sdk/java/ArvadosSDKJavaExample.java diff --git a/sdk/java/ArvadosSDKJavaExample.java b/sdk/java/ArvadosSDKJavaExample.java index 050eaa69f0..7c9c0138ea 100644 --- a/sdk/java/ArvadosSDKJavaExample.java +++ b/sdk/java/ArvadosSDKJavaExample.java @@ -10,6 +10,8 @@ import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; public class ArvadosSDKJavaExample { /** Make sure the following environment variables are set before using Arvados: @@ -35,8 +37,9 @@ public class ArvadosSDKJavaExample { Map params = new HashMap(); Map response = arv.call("users", "list", params); - System.out.println("Arvados users.list:\n" + response); - + System.out.println("Arvados users.list:\n"); + printResponse(response); + // get uuid of the first user from the response List items = (List)response.get("items"); @@ -48,7 +51,8 @@ public class ArvadosSDKJavaExample { params = new HashMap(); params.put("uuid", userUuid); response = arv.call("users", "get", params); - System.out.println("Arvados users.get:\n" + response); + System.out.println("Arvados users.get:\n"); + printResponse(response); // Make a pipeline_templates list call System.out.println("\n\n\nMaking a pipeline_templates.list call."); @@ -56,6 +60,21 @@ public class ArvadosSDKJavaExample { params = new HashMap(); response = arv.call("pipeline_templates", "list", params); - System.out.println("Arvados pipelinetempates.list:\n" + response); + System.out.println("Arvados pipelinetempates.list:\n"); + printResponse(response); + } + + private static void printResponse(Map response){ + Set> entrySet = (Set>)response.entrySet(); + for (Map.Entry entry : entrySet) { + if ("items".equals(entry.getKey())) { + List items = (List)entry.getValue(); + for (Object item : items) { + System.out.println(" " + item); + } + } else { + System.out.println(entry.getKey() + " = " + entry.getValue()); + } + } } -} +} \ No newline at end of file