JAL-715 - allow rest service attributes to be exported and imported as a | separated...
[jalview.git] / src / jalview / ws / rest / params / SeqIdVector.java
index 9bdaed1..5f7c551 100644 (file)
@@ -5,9 +5,14 @@ import jalview.datamodel.SequenceI;
 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.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.http.entity.mime.content.ContentBody;
 import org.apache.http.entity.mime.content.StringBody;
@@ -17,7 +22,7 @@ import org.apache.http.entity.mime.content.StringBody;
  * @author JimP
  *
  */
-class SeqIdVector extends InputType {
+public class SeqIdVector extends InputType {
   public SeqIdVector()
   {
     super(new Class[] { AlignmentI.class} );
@@ -42,5 +47,44 @@ class SeqIdVector extends InputType {
       idvector.append(seq.getName());
     }
     return new StringBody(idvector.toString());
+  }  
+  @Override
+  public List<String> getURLEncodedParameter()
+  {
+    ArrayList<String> prms = new ArrayList<String>();
+    super.addBaseParams(prms);
+    prms.add("sep='"+ sep+"'");
+    prms.add("type='"+type+"'");
+    return prms;
+  }
+  @Override
+  public String getURLtokenPrefix()
+  {
+    return "SEQIDS";
+  }
+  @Override
+  public boolean configureProperty(String tok, String val, StringBuffer warnings)
+  {
+    if (tok.startsWith("sep"))
+    {
+      sep=val;
+      return true;
+    }
+    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;
   }
-}
\ No newline at end of file
+}