JAL-715 - allow rest service attributes to be exported and imported as a | separated...
[jalview.git] / src / jalview / ws / rest / params / AnnotationFile.java
index 84dcfb9..5abf0fc 100644 (file)
@@ -4,9 +4,12 @@ import jalview.datamodel.AlignmentI;
 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 org.apache.http.entity.mime.content.ContentBody;
 import org.apache.http.entity.mime.content.StringBody;
@@ -49,4 +52,42 @@ public class AnnotationFile extends InputType {
         return new StringBody(new jalview.io.AnnotationFile().printCSVAnnotations(al.getAlignmentAnnotation()));
       }
   }
-}
\ No newline at end of file
+  @Override
+  public List<String> getURLEncodedParameter()
+  {
+    ArrayList<String> prms = new ArrayList<String>();
+    super.addBaseParams(prms);
+    prms.add("format='"+format+"'");
+    return prms;     
+  }
+  @Override
+  public String getURLtokenPrefix()
+  {
+    return "ALANNOTATION";
+  }
+  @Override
+  public boolean configureProperty(String tok, String val,
+          StringBuffer warnings)
+  {
+
+    if (tok.startsWith("format"))
+    {
+      for (String fmt : new String[] { CSVANNOT, JVANNOT})
+      {
+        if (val.equalsIgnoreCase(fmt))
+        {
+          format = fmt;
+          return true;
+        }
+      }
+      warnings.append("Invalid annotation file format '" + val
+              + "'. Must be one of (");
+      for (String fmt : new String[] { CSVANNOT, JVANNOT})
+      {
+        warnings.append(" " + fmt);
+      }
+      warnings.append(")\n");
+    }
+    return false;
+  }
+}