JAL-3878 Code reformatting.
[jalview.git] / src / jalview / ws2 / slivka / SlivkaWebService.java
index e7800ad..2cd9385 100644 (file)
@@ -38,13 +38,19 @@ import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
 public class SlivkaWebService implements WebServiceI
 {
   protected final SlivkaClient client;
+
   protected final SlivkaService service;
+
   protected SlivkaDatastore store = null;
+
   protected final String operation;
+
   protected final ArrayList<Operation> operations = new ArrayList<>();
+
   protected int typeFlags = 0;
 
-  protected static final EnumMap<Job.Status, WsJob.JobState> stateMap = new EnumMap<>(Job.Status.class);
+  protected static final EnumMap<Job.Status, WsJob.JobState> stateMap = new EnumMap<>(
+          Job.Status.class);
   {
     stateMap.put(Job.Status.PENDING, WsJob.JobState.QUEUED);
     stateMap.put(Job.Status.REJECTED, WsJob.JobState.INVALID);
@@ -58,68 +64,96 @@ public class SlivkaWebService implements WebServiceI
     stateMap.put(Job.Status.ERROR, WsJob.JobState.SERVERERROR);
     stateMap.put(Job.Status.UNKNOWN, WsJob.JobState.UNKNOWN);
   }
-  protected final Set<WsJob.JobState> failedStates = new HashSet<>(Arrays.asList(
-      WsJob.JobState.INVALID, WsJob.JobState.BROKEN, WsJob.JobState.FAILED,
-      WsJob.JobState.SERVERERROR, WsJob.JobState.CANCELLED
-  ));
 
-  public SlivkaWebService(SlivkaClient client, SlivkaService service, String operation) {
+  protected final Set<WsJob.JobState> failedStates = new HashSet<>(
+          Arrays.asList(WsJob.JobState.INVALID, WsJob.JobState.BROKEN,
+                  WsJob.JobState.FAILED, WsJob.JobState.SERVERERROR,
+                  WsJob.JobState.CANCELLED));
+
+  public SlivkaWebService(SlivkaClient client, SlivkaService service,
+          String operation)
+  {
     this.client = client;
     this.service = service;
     this.operation = operation;
   }
 
   @Override
-  public String getHostName() { return client.getUrl().toString(); }
+  public String getHostName()
+  {
+    return client.getUrl().toString();
+  }
 
   @Override
-  public String getProviderName() { return "slivka"; }
+  public String getProviderName()
+  {
+    return "slivka";
+  }
 
   @Override
-  public String getName() { return service.getName(); }
+  public String getName()
+  {
+    return service.getName();
+  }
 
   @Override
-  public String getDescription() { return service.getDescription(); }
+  public String getDescription()
+  {
+    return service.getDescription();
+  }
 
   @Override
-  public String getOperationType() { return operation; }
+  public String getOperationType()
+  {
+    return operation;
+  }
 
   @Override
-  public List<Operation> getOperations() {
+  public List<Operation> getOperations()
+  {
     return operations;
   }
 
-  void addOperation(Operation operation) {
+  void addOperation(Operation operation)
+  {
     operations.add(operation);
   }
 
-  void removeOperation(Operation operation) {
+  void removeOperation(Operation operation)
+  {
     operations.remove(operation);
   }
 
   @Override
-  public boolean hasParameters() {
+  public boolean hasParameters()
+  {
     return getParamStore().getServiceParameters().size() > 0;
   }
 
   @Override
-  public ParamDatastoreI getParamStore() {
-    if (store == null) {
+  public ParamDatastoreI getParamStore()
+  {
+    if (store == null)
+    {
       store = new SlivkaDatastore(service);
     }
     return store;
   }
 
   @Override
-  public String submit(List<SequenceI> sequences, List<ArgumentI> args) throws IOException
+  public String submit(List<SequenceI> sequences, List<ArgumentI> args)
+          throws IOException
   {
     var request = new uk.ac.dundee.compbio.slivkaclient.JobRequest();
-    for (Parameter param : service.getParameters()) {
-      if (param instanceof Parameter.FileParameter) {
+    for (Parameter param : service.getParameters())
+    {
+      if (param instanceof Parameter.FileParameter)
+      {
         // if finds a file input, gives it sequences stream
         Parameter.FileParameter fileParam = (Parameter.FileParameter) param;
         FileFormat format;
-        switch (fileParam.getMediaType()) {
+        switch (fileParam.getMediaType())
+        {
         case "application/pfam":
           format = FileFormat.Pfam;
           break;
@@ -134,20 +168,22 @@ public class SlivkaWebService implements WebServiceI
           format = FileFormat.Fasta;
           break;
         }
-        InputStream stream = new ByteArrayInputStream(
-                format.getWriter(null)
+        InputStream stream = new ByteArrayInputStream(format.getWriter(null)
                 .print(sequences.toArray(new SequenceI[0]), false)
                 .getBytes());
         request.addFile(param.getId(), stream);
       }
     }
-    if (args != null) {
-      for (ArgumentI arg : args) {
+    if (args != null)
+    {
+      for (ArgumentI arg : args)
+      {
         // multiple choice field names are name$number to avoid duplications
         // the number is stripped here
         String paramId = arg.getName().split("\\$", 2)[0];
         Parameter param = service.getParameter(paramId);
-        if (param instanceof Parameter.FlagParameter) {
+        if (param instanceof Parameter.FlagParameter)
+        {
           if (arg.getValue() != null && !arg.getValue().isBlank())
             request.addData(paramId, true);
           else
@@ -164,8 +200,7 @@ public class SlivkaWebService implements WebServiceI
   }
 
   @Override
-  public void updateProgress(WSJob job)
-          throws IOException
+  public void updateProgress(WSJob job) throws IOException
   {
     // TODO Auto-generated method stub
 
@@ -180,7 +215,8 @@ public class SlivkaWebService implements WebServiceI
   @Override
   public boolean handleSubmissionError(WSJob job, Exception ex)
   {
-    if (ex instanceof ClientProtocolException) {
+    if (ex instanceof ClientProtocolException)
+    {
       Cache.log.error("Job submission failed due to exception.", ex);
       return true;
     }
@@ -194,25 +230,30 @@ public class SlivkaWebService implements WebServiceI
     return false;
   }
 
-  public AlignmentI getAlignment(WSJob job) throws IOException {
+  public AlignmentI getAlignment(WSJob job) throws IOException
+  {
     Collection<RemoteFile> files;
     var slivkaJob = client.getJob(job.getJobId());
     files = slivkaJob.getResults();
-    for (RemoteFile f : files) {
-      if (f.getMediaType().equals("application/clustal")) {
-        return new FormatAdapter().readFile(
-                f.getContentUrl().toString(), DataSourceType.URL, FileFormat.Clustal);
+    for (RemoteFile f : files)
+    {
+      if (f.getMediaType().equals("application/clustal"))
+      {
+        return new FormatAdapter().readFile(f.getContentUrl().toString(),
+                DataSourceType.URL, FileFormat.Clustal);
       }
-      else if (f.getMediaType().equals("application/fasta")) {
-        return new FormatAdapter().readFile(
-                f.getContentUrl().toString(), DataSourceType.URL, FileFormat.Fasta);
+      else if (f.getMediaType().equals("application/fasta"))
+      {
+        return new FormatAdapter().readFile(f.getContentUrl().toString(),
+                DataSourceType.URL, FileFormat.Fasta);
       }
     }
     return null;
   }
 
   @Override
-  public String toString() {
+  public String toString()
+  {
     return String.format("SlivkaWebService[%s]", getName());
   }
 }