JAL-3878 Separate gui elements from operations.
[jalview.git] / src / jalview / ws2 / slivka / SlivkaWebService.java
index aee6b73..9f04290 100644 (file)
@@ -12,7 +12,10 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.SequenceI;
 import jalview.io.AnnotationFile;
@@ -43,12 +46,8 @@ public class SlivkaWebService implements WebServiceI
   protected final SlivkaClient client;
 
   protected final SlivkaService service;
-
-  protected SlivkaDatastore store = null;
-
-  protected final ArrayList<Operation> operations = new ArrayList<>();
-
-  protected int typeFlags = 0;
+  
+  protected ParamDatastoreI store;
 
   protected static final EnumMap<Job.Status, WSJobStatus> statusMap = new EnumMap<>(
           Job.Status.class);
@@ -97,22 +96,6 @@ public class SlivkaWebService implements WebServiceI
   }
 
   @Override
-  public List<Operation> getOperations()
-  {
-    return operations;
-  }
-
-  void addOperation(Operation operation)
-  {
-    operations.add(operation);
-  }
-
-  void removeOperation(Operation operation)
-  {
-    operations.remove(operation);
-  }
-
-  @Override
   public boolean hasParameters()
   {
     return getParamStore().getServiceParameters().size() > 0;
@@ -213,6 +196,7 @@ public class SlivkaWebService implements WebServiceI
   @Override
   public void cancel(WSJob job) throws IOException
   {
+    job.setStatus(WSJobStatus.CANCELLED);
     Cache.log.warn("Slivka does not support job cancellation yet.");
   }
 
@@ -234,7 +218,8 @@ public class SlivkaWebService implements WebServiceI
     return false;
   }
 
-  public AlignmentI getAlignment(WSJob job) throws IOException
+  public AlignmentI getAlignment(WSJob job, List<SequenceI> dataset,
+      AlignViewportI viewport) throws IOException
   {
     Collection<RemoteFile> files;
     var slivkaJob = client.getJob(job.getJobId());
@@ -255,7 +240,8 @@ public class SlivkaWebService implements WebServiceI
     return null;
   }
 
-  public FeaturesFile getFeaturesFile(WSJob job) throws IOException
+  public FeaturesFile getFeaturesFile(WSJob job,
+      List<SequenceI> dataset, AlignViewportI viewport) throws IOException
   {
     var slivkaJob = client.getJob(job.getJobId());
     Collection<RemoteFile> files = slivkaJob.getResults();
@@ -269,7 +255,8 @@ public class SlivkaWebService implements WebServiceI
     return null;
   }
 
-  public AnnotationFile getAnnotationFile(WSJob job) throws IOException
+  public List<AlignmentAnnotation> getAnnotations(WSJob job,
+      List<SequenceI> dataset, AlignViewportI viewport) throws IOException
   {
     var slivkaJob = client.getJob(job.getJobId());
     Collection<RemoteFile> files = slivkaJob.getResults();
@@ -277,7 +264,19 @@ public class SlivkaWebService implements WebServiceI
     {
       if (f.getMediaType().equals("application/jalview-annotations"))
       {
-        // return new AnnorationFile(...);
+        Alignment aln = new Alignment(dataset.toArray(new SequenceI[0]));
+        AnnotationFile af = new AnnotationFile();
+        boolean valid = af.readAnnotationFileWithCalcId(aln, service.getId(),
+            f.getContentUrl().toString(), DataSourceType.URL);
+        if (valid)
+        {
+          return Arrays.asList(aln.getAlignmentAnnotation());
+        }
+        else
+        {
+          throw new IOException("Unable to read annotations from file " +
+              f.getContentUrl().toString());
+        }
       }
     }
     return null;