X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d70ff3d064c9a6da8b8678b249abf7f4b93b6370..5aa4fc745af335240a3782146dc0f6fcd93346ba:/sdk/java/ArvadosSDKJavaExample.java diff --git a/sdk/java/ArvadosSDKJavaExample.java b/sdk/java/ArvadosSDKJavaExample.java index 050eaa69f0..ded6ce99dd 100644 --- a/sdk/java/ArvadosSDKJavaExample.java +++ b/sdk/java/ArvadosSDKJavaExample.java @@ -1,15 +1,21 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 + /** * This Sample test program is useful in getting started with working with Arvados Java SDK. * @author radhika * */ -import org.arvados.sdk.java.Arvados; +import org.arvados.sdk.Arvados; 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 +41,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 +55,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 +64,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()); + } + } } }