Skip to content
Snippets Groups Projects
Commit 13aecebc authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Shown job list in UI

parent b8b4a042
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package it.inaf.ia2.vospace.ui.client; ...@@ -3,6 +3,7 @@ package it.inaf.ia2.vospace.ui.client;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import it.inaf.ia2.aa.data.User; import it.inaf.ia2.aa.data.User;
import it.inaf.ia2.vospace.ui.VOSpaceUiApplication; import it.inaf.ia2.vospace.ui.VOSpaceUiApplication;
import it.inaf.ia2.vospace.ui.data.Job;
import it.inaf.ia2.vospace.ui.exception.VOSpaceException; import it.inaf.ia2.vospace.ui.exception.VOSpaceException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -14,15 +15,19 @@ import java.net.http.HttpClient; ...@@ -14,15 +15,19 @@ import java.net.http.HttpClient;
import java.net.http.HttpRequest; import java.net.http.HttpRequest;
import java.net.http.HttpResponse; import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers; import java.net.http.HttpResponse.BodyHandlers;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionException;
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import javax.xml.bind.JAXB; import javax.xml.bind.JAXB;
import net.ivoa.xml.uws.v1.JobSummary; import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.uws.v1.Jobs;
import net.ivoa.xml.uws.v1.ShortJobDescription;
import net.ivoa.xml.vospace.v2.Node; import net.ivoa.xml.vospace.v2.Node;
import net.ivoa.xml.vospace.v2.Protocol; import net.ivoa.xml.vospace.v2.Protocol;
import net.ivoa.xml.vospace.v2.Transfer; import net.ivoa.xml.vospace.v2.Transfer;
...@@ -111,6 +116,21 @@ public class VOSpaceClient { ...@@ -111,6 +116,21 @@ public class VOSpaceClient {
return call(request, BodyHandlers.ofInputStream(), 200, res -> unmarshal(res, Node.class)); return call(request, BodyHandlers.ofInputStream(), 200, res -> unmarshal(res, Node.class));
} }
public List<Job> getJobs() {
HttpRequest request = getRequest("/transfers?direction=pullToVoSpace")
.header("Accept", useJson ? "application/json" : "text/xml")
.header("Content-Type", useJson ? "application/json" : "text/xml")
.GET()
.build();
return call(request, BodyHandlers.ofInputStream(), 200, res -> {
return unmarshal(res, Jobs.class).getJobref().stream()
.map(jobDesc -> new Job(jobDesc))
.collect(Collectors.toList());
});
}
private <T, U> U call(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler, int expectedStatusCode, Function<T, U> responseHandler) { private <T, U> U call(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler, int expectedStatusCode, Function<T, U> responseHandler) {
try { try {
return httpClient.sendAsync(request, responseBodyHandler) return httpClient.sendAsync(request, responseBodyHandler)
......
...@@ -158,7 +158,6 @@ public class JobController extends BaseController { ...@@ -158,7 +158,6 @@ public class JobController extends BaseController {
@GetMapping(value = "/jobs", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "/jobs", produces = MediaType.APPLICATION_JSON_VALUE)
public List<Job> getJobs() { public List<Job> getJobs() {
// TODO return client.getJobs();
return new ArrayList<>();
} }
} }
package it.inaf.ia2.vospace.ui.data; package it.inaf.ia2.vospace.ui.data;
import java.text.SimpleDateFormat;
import javax.xml.datatype.XMLGregorianCalendar;
import net.ivoa.xml.uws.v1.ExecutionPhase; import net.ivoa.xml.uws.v1.ExecutionPhase;
import net.ivoa.xml.uws.v1.JobSummary; import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.uws.v1.ShortJobDescription;
public class Job { public class Job {
private String id; private String id;
private String creationTime;
private ExecutionPhase phase; private ExecutionPhase phase;
private boolean read; private boolean read;
...@@ -14,9 +18,21 @@ public class Job { ...@@ -14,9 +18,21 @@ public class Job {
public Job(JobSummary job) { public Job(JobSummary job) {
this.id = job.getJobId(); this.id = job.getJobId();
this.creationTime = formatCreationTime(job.getCreationTime());
this.phase = job.getPhase(); this.phase = job.getPhase();
} }
public Job(ShortJobDescription job) {
this.id = job.getId();
this.creationTime = formatCreationTime(job.getCreationTime());
this.phase = job.getPhase();
}
private String formatCreationTime(XMLGregorianCalendar calendar) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(calendar.toGregorianCalendar().getTime());
}
public String getId() { public String getId() {
return id; return id;
} }
...@@ -25,6 +41,14 @@ public class Job { ...@@ -25,6 +41,14 @@ public class Job {
this.id = id; this.id = id;
} }
public String getCreationTime() {
return creationTime;
}
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public ExecutionPhase getPhase() { public ExecutionPhase getPhase() {
return phase; return phase;
} }
......
<template> <template>
<div>
<h3>Async recall jobs</h3>
<table class="table b-table table-striped table-hover"> <table class="table b-table table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th>Creation time</th>
<th>Id</th> <th>Id</th>
<th>Status</th> <th>Phase</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="job in jobs" :key="job.id"> <tr v-for="job in jobs" :key="job.id">
<td>{{job.creationTime}}</td>
<td>{{job.id}}</td> <td>{{job.id}}</td>
<td>{{job.status}}</td> <td>{{job.phase}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
</template> </template>
<script> <script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment