/** * Get a list of all the defined jobs on the server (at the summary level) * * @return list of defined jobs (summary level, for details @see Job#details * @throws IOException */ public Map<String, Job> getJobs() throws IOException { List<Job> jobs = client.get("/", MainView.class).getJobs(); return Maps.uniqueIndex(jobs, new Function<Job, String>() { @Override public String apply(Job job) { job.setClient(client); return job.getName().toLowerCase(); } }); }
/** * Get a list of all the defined views on the server (at the summary level * and in the given folder) * * @param folder {@link FolderJob} * @return list of defined views * @throws IOException in case of an error. */ public Map<String, View> getViews(FolderJob folder) throws IOException { // This is much better than using &depth=2 // http://localhost:8080/api/json?pretty&tree=views[name,url,jobs[name,url]] List<View> views = client.get(UrlUtils.toBaseUrl(folder) + "?tree=views[name,url,jobs[name,url]]", MainView.class).getViews(); return Maps.uniqueIndex(views, new Function<View, String>() { @Override public String apply(View view) { view.setClient(client); // TODO: Think about the following? Does there exists a // simpler/more elegant method? for (Job job : view.getJobs()) { job.setClient(client); } for (View item : view.getViews()) { item.setClient(client); } return view.getName(); } }); }
/** * Get a list of all the defined jobs on the server (at the specified view * level and in the specified folder) * * @param folder {@link FolderJob} * @param view The view to use. * @return list of defined jobs (view level, for details @see Job#details * @throws IOException in case of an error. */ public Map<String, Job> getJobs(FolderJob folder, String view) throws IOException { String path = UrlUtils.toBaseUrl(folder); Class<? extends MainView> viewClass = MainView.class; if (view != null) { path = path + "view/" + EncodingUtils.encode(view) + "/"; viewClass = View.class; } List<Job> jobs = client.get(path, viewClass).getJobs(); return Maps.uniqueIndex(jobs, new Function<Job, String>() { @Override public String apply(Job job) { job.setClient(client); return job.getName(); } }); }