X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/52a3016af3ff21b8fb5402bf70d0aab07f5ee486..daa50b3dc4488c705d2445fcadd2d35968787a68:/sdk/java/ArvadosSDKJavaExample.java diff --git a/sdk/java/ArvadosSDKJavaExample.java b/sdk/java/ArvadosSDKJavaExample.java index 3c47f668b7..ded6ce99dd 100644 --- a/sdk/java/ArvadosSDKJavaExample.java +++ b/sdk/java/ArvadosSDKJavaExample.java @@ -1,16 +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. - * Please also see arvadso * @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: @@ -36,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"); @@ -49,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."); @@ -57,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()); + } + } } }