From: jprocter Date: Tue, 23 Aug 2011 12:30:22 +0000 (+0100) Subject: JAL-715 - simple tests and functions for IO of service as '|' string X-Git-Tag: Release_2_7~89 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=9c80addd4e2e5e137e171744be2be1add9f9b483 JAL-715 - simple tests and functions for IO of service as '|' string --- diff --git a/src/jalview/ws/rest/RestServiceDescription.java b/src/jalview/ws/rest/RestServiceDescription.java index 17d7a6e..dea7fc9 100644 --- a/src/jalview/ws/rest/RestServiceDescription.java +++ b/src/jalview/ws/rest/RestServiceDescription.java @@ -17,7 +17,6 @@ */ package jalview.ws.rest; - import jalview.datamodel.SequenceI; import jalview.io.packed.DataProvider; import jalview.io.packed.SimpleDataProvider; @@ -26,14 +25,26 @@ import jalview.util.GroupUrlLink.UrlStringTooLongException; import jalview.util.Platform; import jalview.ws.rest.params.Alignment; import jalview.ws.rest.params.AnnotationFile; +import jalview.ws.rest.params.JobConstant; import jalview.ws.rest.params.SeqGroupIndexVector; +import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JViewport; +import com.stevesoft.pat.Regex; +import com.sun.org.apache.xml.internal.serialize.OutputFormat.DTD; +import com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output; public class RestServiceDescription { @@ -46,13 +57,14 @@ public class RestServiceDescription * @param vseparable * @param gapCharacter */ - public RestServiceDescription(String action,String description,String name, String postUrl, - String urlSuffix, Map inputParams, - boolean hseparable, boolean vseparable, char gapCharacter) + public RestServiceDescription(String action, String description, + String name, String postUrl, String urlSuffix, + Map inputParams, boolean hseparable, + boolean vseparable, char gapCharacter) { super(); this.details = new UIinfo(); - details.Action= action; + details.Action = action; details.description = description; details.Name = name; this.postUrl = postUrl; @@ -62,788 +74,678 @@ public class RestServiceDescription this.vseparable = vseparable; this.gapCharacter = gapCharacter; } + + public boolean equals(Object o) + { + if (o == null || !(o instanceof RestServiceDescription)) + { + return false; + } + RestServiceDescription other = (RestServiceDescription) o; + boolean diff = (gapCharacter != other.gapCharacter); + diff |= vseparable != other.vseparable; + diff |= hseparable != other.hseparable; + diff |= !(urlSuffix.equals(other.urlSuffix)); + // TODO - robust diff that includes constants and reordering of URL + // diff |= !(postUrl.equals(other.postUrl)); + // diff |= !inputParams.equals(other.inputParams); + diff |= !details.Name.equals(other.details.Name); + diff |= !details.Action.equals(other.details.Action); + diff |= !details.description.equals(other.details.description); + return !diff; + } + /** * Service UI Info { Action, Specific Name of Service, Brief Description } */ - - public class UIinfo { + + public class UIinfo + { String Action; + String Name; + String description; } + public UIinfo details = new UIinfo(); - - /** Service base URL + + /** + * Service base URL */ String postUrl; + /** - * suffix that should be added to any url used if it does not already end in the suffix. + * suffix that should be added to any url used if it does not already end in + * the suffix. */ String urlSuffix; - - /** input info given as key/value pairs - mapped to post arguments - */ - Map inputParams=new HashMap(); + /** - * assigns the given inputType it to its corresponding input parameter token it.token + * input info given as key/value pairs - mapped to post arguments + */ + Map inputParams = new HashMap(); + + /** + * assigns the given inputType it to its corresponding input parameter token + * it.token + * * @param it */ public void setInputParam(InputType it) { inputParams.put(it.token, it); } + /** * remove the given input type it from the set of service input parameters. + * * @param it */ public void removeInputParam(InputType it) { inputParams.remove(it.token); } + /** * service requests alignment data */ boolean aligndata; + /** - * service requests alignment and/or seuqence annotationo data + * service requests alignment and/or seuqence annotationo data */ boolean annotdata; + /** * service requests partitions defined over input (alignment) data */ boolean partitiondata; - + /** - * process ths input data and set the appropriate shorthand flags describing the input the service wants + * process ths input data and set the appropriate shorthand flags describing + * the input the service wants */ - public void setInvolvesFlags() { + public void setInvolvesFlags() + { aligndata = inputInvolves(Alignment.class); annotdata = inputInvolves(AnnotationFile.class); partitiondata = inputInvolves(SeqGroupIndexVector.class); } - /** Service return info { alignment, annotation file (loaded back on to alignment), tree (loaded back on to alignment), sequence annotation - loaded back on to alignment), text report, pdb structures with sequence mapping ) - * - */ - - /** Start with bare minimum: input is alignment + groups on alignment - * - * @author JimP - * - */ - /** - * Helper class based on the UrlLink class which enables URLs to be - * constructed from sequences or IDs associated with a group of sequences. URL - * definitions consist of a pipe separated string containing a