JAL-715 - allow rest service attributes to be exported and imported as a | separated...
[jalview.git] / src / jalview / ws / rest / params / SeqGroupIndexVector.java
index 91b1fff..7df7d1c 100644 (file)
@@ -7,10 +7,12 @@ import jalview.ws.rest.AlignmentProcessor;
 import jalview.ws.rest.InputType;
 import jalview.ws.rest.NoValidInputDataException;
 import jalview.ws.rest.RestJob;
+import jalview.ws.rest.RestServiceDescription;
 import jalview.ws.rest.InputType.molType;
 
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Vector;
 
 import org.apache.http.entity.mime.content.ContentBody;
@@ -170,4 +172,64 @@ public class SeqGroupIndexVector extends InputType implements
         minsize=1;
       }
   }
-}
\ No newline at end of file
+  @Override
+  public List<String> getURLEncodedParameter()
+  {
+    ArrayList<String> prms = new ArrayList<String>();
+    super.addBaseParams(prms);
+    prms.add("minsize='"+ minsize+"'");
+    prms.add("sep='"+ sep+"'");
+    if (type!=null)
+    {
+      prms.add("type='"+type+"'");
+    }
+    return prms;
+  }
+
+  @Override
+  public String getURLtokenPrefix()
+  {
+    return "PARTITION";
+  }
+
+  @Override
+  public boolean configureProperty(String tok, String val,
+          StringBuffer warnings)
+  {
+
+    if (tok.startsWith("sep"))
+    {
+      sep=val;
+      return true;
+    }
+    if (tok.startsWith("minsize"))
+    {
+      try {
+        minsize=Integer.valueOf(val);
+        if (minsize>=0)
+        return true;
+      } catch (Exception x)
+      {
+        
+      }
+      warnings.append("Invalid minsize value '"+val+"'. Must be a positive integer.\n");
+    }
+    if (tok.startsWith("type"))
+    {
+      try {
+        type=molType.valueOf(val);
+        return true;
+      } catch (Exception x)
+      {
+        warnings.append("Invalid molecule type '"+val+"'. Must be one of (");
+        for (molType v:molType.values())
+        {
+          warnings.append(" "+v);
+        }
+        warnings.append(")\n");
+      }
+    }
+    return false;
+  }
+
+}