JAL-975 - bespoke AACons settings object to save current service settings for the...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 19 Jun 2012 16:26:57 +0000 (17:26 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 19 Jun 2012 16:26:57 +0000 (17:26 +0100)
src/jalview/gui/AlignViewport.java
src/jalview/ws/jws2/dm/AAConsSettings.java [new file with mode: 0644]

index 7294bae..a731796 100644 (file)
@@ -67,8 +67,6 @@ import jalview.workers.StrucConsensusThread;
  */
 public class AlignViewport extends AlignmentViewport implements SelectionSource, VamsasSource, AlignViewportI
 {
-  private static final int RIGHT_JUSTIFY = 1;
-
   int startRes;
 
   int endRes;
@@ -995,6 +993,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
    */
   public long[] getUndoRedoHash()
   {
+    // TODO: JAL-1126
     if (historyList == null || redoList == null)
       return new long[]
       { -1, -1 };
@@ -1291,4 +1290,15 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
   {
     return validCharWidth;
   }
+  private jalview.ws.jws2.dm.AAConsSettings preferredAAConsSettings; 
+
+  public jalview.ws.jws2.dm.AAConsSettings getPreferredAAConsSettings()
+  {
+    return preferredAAConsSettings;
+  }
+  public void setPreferredAAConsSettings(jalview.ws.jws2.dm.AAConsSettings aaConsSettings)
+  {
+    preferredAAConsSettings=aaConsSettings;
+  }
+  
 }
diff --git a/src/jalview/ws/jws2/dm/AAConsSettings.java b/src/jalview/ws/jws2/dm/AAConsSettings.java
new file mode 100644 (file)
index 0000000..f2d7126
--- /dev/null
@@ -0,0 +1,118 @@
+package jalview.ws.jws2.dm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import compbio.metadata.Argument;
+import compbio.metadata.Preset;
+
+import jalview.ws.jws2.JabaPreset;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.WsParamSetI;
+
+/**
+ * preferences for running AACons service
+ * 
+ * @author jprocter TODO: refactor to a generic 'last job and service run'
+ *         container ?
+ */
+public class AAConsSettings
+{
+  boolean autoUpdate;
+
+  Jws2Instance service;
+
+  WsParamSetI preset;
+
+  List<Argument> jobArgset;
+
+  public AAConsSettings(boolean autoUpdate, Jws2Instance service,
+          WsParamSetI preset, List<Argument> jobArgset)
+  {
+    super();
+    this.autoUpdate = autoUpdate;
+    this.service = service;
+    this.preset = preset;
+    this.jobArgset = jobArgset;
+  }
+
+  public boolean isAutoUpdate()
+  {
+    return autoUpdate;
+  }
+
+  public void setAutoUpdate(boolean autoUpdate)
+  {
+    this.autoUpdate = autoUpdate;
+  }
+
+  public Jws2Instance getService()
+  {
+    return service;
+  }
+
+  public void setService(Jws2Instance service)
+  {
+    this.service = service;
+    if (preset != null)
+    {
+      // migrate preset to new service
+      for (String url : preset.getApplicableUrls())
+      {
+        if (url.equals(service.getUri()))
+        {
+          return;
+        }
+      }
+      WsParamSetI pr = service.getParamStore().getPreset(preset.getName());
+      if (pr instanceof JabaPreset && preset instanceof JabaPreset)
+      {
+        // easy - Presets are identical (we assume)
+        preset = pr;
+        return;
+      }
+      List<ArgumentI> oldargs = new ArrayList<ArgumentI>(), newargs = new ArrayList<ArgumentI>();
+      oldargs.addAll(preset.getArguments());
+      // need to compare parameters
+      for (ArgumentI newparg : pr.getArguments())
+      {
+        if (!oldargs.remove(newparg))
+        {
+          newargs.add(newparg);
+        }
+      }
+      if (oldargs.size() == 0 && newargs.size() == 0)
+      {
+        // exact match.
+        preset = pr;
+        return;
+      }
+      // Try even harder to migrate arguments.
+      throw new Error("Parameter migration not implemented yet");
+    }
+  }
+
+  public WsParamSetI getPreset()
+  {
+    return preset;
+  }
+
+  public void setPreset(WsParamSetI preset)
+  {
+    // TODO: test if service URL is in presets
+    this.preset = preset;
+  }
+
+  public List<Argument> getJobArgset()
+  {
+    return jobArgset;
+  }
+
+  public void setJobArgset(List<Argument> jobArgset)
+  {
+    // TODO: test if parameters valid for service
+    this.jobArgset = jobArgset;
+  }
+
+}