RemoteFile featFile = null;
try
{
- var slivkaJob = client.getJob(jobId.getJobId());
- Collection<RemoteFile> files = slivkaJob.getResults();
+ Collection<RemoteFile> files = client.fetchFilesList(jobId.getJobId());
for (RemoteFile f : files)
{
if (f.getMediaType().equals("application/jalview-annotations"))
Collection<RemoteFile> files;
try
{
- var slivkaJob = client.getJob(jobId.getJobId());
- files = slivkaJob.getResults();
+ files = client.fetchFilesList(jobId.getJobId());
for (RemoteFile f : files)
{
if (f.getMediaType().equals("application/clustal"))
for (String url : getServiceUrls())
{
- SlivkaClient client = new SlivkaClient(url);
+ SlivkaClient client = SlivkaClient.newInstance(url);
List<SlivkaService> services;
try
{
try
{
- List<?> services = new SlivkaClient(url).getServices();
+ List<?> services = SlivkaClient.newInstance(url).getServices();
return services.isEmpty() ? STATUS_NO_SERVICES : STATUS_OK;
} catch (IOException | org.json.JSONException e)
{
import java.util.Collection;
import uk.ac.dundee.compbio.slivkaclient.Job;
-import uk.ac.dundee.compbio.slivkaclient.JobRequest;
+import uk.ac.dundee.compbio.slivkaclient.RequestValues;
import uk.ac.dundee.compbio.slivkaclient.Parameter;
import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
WsParamSetI preset, List<ArgumentI> args) throws Throwable
{
var parameters = service.getParameters();
- var request = new JobRequest();
+ var request = new RequestValues();
for (Parameter param : parameters)
{
if (param instanceof Parameter.FileParameter)
}
}
}
- var job = service.submitJob(request);
- return new JobId(service.getName(), service.getName(), job.getId());
+ var jobId = client.submitJob(service, request);
+ return new JobId(service.getName(), service.getName(), jobId);
}
@Override
{
try
{
- var slivkaJob = client.getJob(job.getJobId());
- job.setState(stateMap.get(slivkaJob.getStatus()));
+ job.setState(stateMap.get(client.fetchJobStatus(job.getJobId())));
} catch (IOException e)
{
throw new IOError(e);
@Override
public final boolean updateJobProgress(WsJob job) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
- Collection<RemoteFile> files = slivkaJob.getResults();
+ Collection<RemoteFile> files = client.fetchFilesList(job.getJobId());
RemoteFile logFile=null;
for (RemoteFile f : files)
{
if (logFile!=null)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
- logFile.writeTo(output);
+ client.writeFileTo(logFile, output);
if (output.size() > job.getNextChunk())
{
newContent = true;
if (errLogFile!=null)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
- errLogFile.writeTo(output);
+ client.writeFileTo(errLogFile, output);
if (output.size() > 0)
{
newContent = true;
final SlivkaClient client;
- SlivkaWSClient(SlivkaService service)
+ SlivkaWSClient(SlivkaClient client, SlivkaService service)
{
this.service = service;
- this.client = service.getClient();
+ this.client = client;
}
@Override
public WebServiceJobHandle submit(List<SequenceI> sequences,
List<ArgumentI> args, Credentials credentials) throws IOException
{
- var request = new uk.ac.dundee.compbio.slivkaclient.JobRequest();
+ var request = new uk.ac.dundee.compbio.slivkaclient.RequestValues();
for (Parameter param : service.getParameters())
{
// TODO: restrict input sequences parameter name to "sequences"
}
}
}
- var job = service.submitJob(request);
- return createJobHandle(job.getId());
+ var jobId = client.submitJob(service, request);
+ return createJobHandle(jobId);
}
protected WebServiceJobHandle createJobHandle(String jobId)
@Override
public JobStatus getStatus(WebServiceJobHandle job) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
- return statusMap.getOrDefault(slivkaJob.getStatus(), JobStatus.UNKNOWN);
+ return statusMap.getOrDefault(client.fetchJobStatus(job.getJobId()), JobStatus.UNKNOWN);
}
protected static final EnumMap<Job.Status, JobStatus> statusMap = new EnumMap<>(Job.Status.class);
@Override
public String getLog(WebServiceJobHandle job) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
- for (var f : slivkaJob.getResults())
+ for (var f : client.fetchFilesList(job.getJobId()))
{
if (f.getLabel().equals("log"))
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- f.writeTo(stream);
+ client.writeFileTo(f, stream);
return stream.toString("UTF-8");
}
}
@Override
public String getErrorLog(WebServiceJobHandle job) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
- for (var f : slivkaJob.getResults())
+ for (var f : client.fetchFilesList(job.getJobId()))
{
if (f.getLabel().equals("error-log"))
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- f.writeTo(stream);
+ client.writeFileTo(f, stream);
return stream.toString("UTF-8");
}
}
implements AlignmentWebServiceClientI
{
- SlivkaAlignmentWSClient(SlivkaService service)
+ SlivkaAlignmentWSClient(SlivkaClient client, SlivkaService service)
{
- super(service);
+ super(client, service);
}
@Override
public AlignmentI getAlignment(WebServiceJobHandle job) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
- for (var f : slivkaJob.getResults())
+ for (var f : client.fetchFilesList(job.getJobId()))
{
// TODO: restrict result file label to "alignment"
FileFormat format;
class SlivkaAnnotationWSClient extends SlivkaWSClient
implements AnnotationWebServiceClientI
{
- SlivkaAnnotationWSClient(SlivkaService service)
+ SlivkaAnnotationWSClient(SlivkaClient client, SlivkaService service)
{
- super(service);
+ super(client, service);
}
@Override
List<SequenceI> sequences, Map<String, FeatureColourI> colours,
Map<String, FeatureMatcherSetI> filters) throws IOException
{
- var slivkaJob = client.getJob(job.getJobId());
var aln = new Alignment(sequences.toArray(new SequenceI[sequences.size()]));
boolean featPresent = false, annotPresent = false;
- for (var f : slivkaJob.getResults())
+ for (var f : client.fetchFilesList(job.getJobId()))
{
// TODO: restrict file label to "annotations" or "features"
var match = mediaTypePattern.matcher(f.getMediaType());
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.Function;
import jalview.bin.Cache;
import jalview.bin.Console;
private static SlivkaWSDiscoverer instance = null;
private static ParamManager paramManager = null;
+
+ private final Function<URI, SlivkaClient> clientFactory;
- private SlivkaWSDiscoverer()
+ SlivkaWSDiscoverer(Function<URI, SlivkaClient> clientFactory)
{
+ this.clientFactory = clientFactory;
}
public static SlivkaWSDiscoverer getInstance()
{
if (instance == null)
- instance = new SlivkaWSDiscoverer();
+ instance = new SlivkaWSDiscoverer(SlivkaClient::newInstance);
return instance;
}
{
try
{
- List<?> services = new SlivkaClient(url.toString()).getServices();
+ List<?> services = clientFactory.apply(url.toURI()).getServices();
return services.isEmpty() ? STATUS_NO_SERVICES : STATUS_OK;
+ } catch (URISyntaxException e)
+ {
+ Console.error("invalid URL " + url, e);
+ return STATUS_INVALID;
} catch (IOException e)
{
Console.error("slivka could not retrieve services from " + url, e);
SlivkaClient slivkaClient;
try
{
- slivkaClient = new SlivkaClient(url.toURI());
+ slivkaClient = clientFactory.apply(url.toURI());
} catch (URISyntaxException e)
{
throw new MalformedURLException(e.getMessage());
if (serviceClass == SERVICE_CLASS_MSA)
{
var wsb = WebService.<AlignmentAction> newBuilder();
- initServiceBuilder(slivkaService, wsb);
+ initServiceBuilder(slivkaClient, slivkaService, wsb);
wsb.category("Alignment");
wsb.interactive(false);
wsb.actionClass(AlignmentAction.class);
var msaService = wsb.build();
boolean canRealign = msaService.getName().contains("lustal");
- var client = new SlivkaAlignmentWSClient(slivkaService);
+ var client = new SlivkaAlignmentWSClient(slivkaClient, slivkaService);
var actionBuilder = AlignmentAction.newBuilder(client);
actionBuilder.name("Alignment");
actionBuilder.webService(msaService);
else if (serviceClass == SERVICE_CLASS_PROT_SEQ_ANALYSIS)
{
var wsb = WebService.<AnnotationAction> newBuilder();
- initServiceBuilder(slivkaService, wsb);
+ initServiceBuilder(slivkaClient, slivkaService, wsb);
wsb.category("Protein Disorder");
wsb.interactive(false);
wsb.actionClass(AnnotationAction.class);
var psaService = wsb.build();
- var client = new SlivkaAnnotationWSClient(slivkaService);
+ var client = new SlivkaAnnotationWSClient(slivkaClient, slivkaService);
var actionBuilder = AnnotationAction.newBuilder(client);
actionBuilder.webService(psaService);
actionBuilder.name("Analysis");
else if (serviceClass == SERVICE_CLASS_CONSERVATION)
{
var wsb = WebService.<AnnotationAction> newBuilder();
- initServiceBuilder(slivkaService, wsb);
+ initServiceBuilder(slivkaClient, slivkaService, wsb);
wsb.category("Conservation");
wsb.interactive(true);
wsb.actionClass(AnnotationAction.class);
var conService = wsb.build();
- var client = new SlivkaAnnotationWSClient(slivkaService);
+ var client = new SlivkaAnnotationWSClient(slivkaClient, slivkaService);
var actionBuilder = AnnotationAction.newBuilder(client);
actionBuilder.webService(conService);
actionBuilder.name("");
else if (serviceClass == SERVICE_CLASS_RNA_SEC_STR_PRED)
{
var wsb = WebService.<AnnotationAction> newBuilder();
- initServiceBuilder(slivkaService, wsb);
+ initServiceBuilder(slivkaClient, slivkaService, wsb);
wsb.category("Secondary Structure Prediction");
wsb.interactive(true);
wsb.actionClass(AnnotationAction.class);
var predService = wsb.build();
- var client = new SlivkaAnnotationWSClient(slivkaService);
+ var client = new SlivkaAnnotationWSClient(slivkaClient, slivkaService);
var actionBuilder = AnnotationAction.newBuilder(client);
actionBuilder.webService(predService);
actionBuilder.name("Prediction");
return allServices;
}
- private void initServiceBuilder(SlivkaService service, WebService.Builder<?> wsBuilder)
+ private void initServiceBuilder(SlivkaClient client, SlivkaService service, WebService.Builder<?> wsBuilder)
{
try
{
- wsBuilder.url(service.getClient().getUrl().toURL());
+ wsBuilder.url(client.getUrl().toURL());
} catch (MalformedURLException e)
{
e.printStackTrace();