X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Frest%2FRestServiceDescription.java;h=7ae922c18c4d43914ae81352419c663a893a0260;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=6794a8d2420a03d689f063e66eb180233fc24ea9;hpb=c762d9525db36ffd5d3fca49fb5e7d506d13401a;p=jalview.git diff --git a/src/jalview/ws/rest/RestServiceDescription.java b/src/jalview/ws/rest/RestServiceDescription.java index 6794a8d..7ae922c 100644 --- a/src/jalview/ws/rest/RestServiceDescription.java +++ b/src/jalview/ws/rest/RestServiceDescription.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -17,22 +17,45 @@ */ package jalview.ws.rest; - import jalview.datamodel.SequenceI; +import jalview.io.packed.DataProvider; +import jalview.io.packed.SimpleDataProvider; +import jalview.io.packed.DataProvider.JvDataType; 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 { /** + * create a new rest service description ready to be configured + */ + public RestServiceDescription() + { + + } + /** * @param details * @param postUrl * @param urlSuffix @@ -41,794 +64,897 @@ 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.description = description; - details.Name = name; - this.postUrl = postUrl; - this.urlSuffix = urlSuffix; - this.inputParams = inputParams; + details.Action = action == null ? "" : action; + details.description = description == null ? "" : description; + details.Name = name == null ? "" : name; + this.postUrl = postUrl == null ? "" : postUrl; + this.urlSuffix = urlSuffix == null ? "" : urlSuffix; + if (inputParams != null) + { + this.inputParams = inputParams; + } this.hseparable = hseparable; 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 + { + public String getAction() + { + return Action; + } + + public void setAction(String action) + { + Action = action; + } + + public String getName() + { + return Name; + } + + public void setName(String name) + { + Name = name; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + String Action; + String Name; + String description; } - UIinfo details = new UIinfo(); - - /** Service base URL + + public UIinfo details = new UIinfo(); + + public String getAction() + { + return details.getAction(); + } + + public void setAction(String action) + { + details.setAction(action); + } + + public String getName() + { + return details.getName(); + } + + public void setName(String name) + { + details.setName(name); + } + + public String getDescription() + { + return details.getDescription(); + } + + public void setDescription(String description) + { + details.setDescription(description); + } + + /** + * Service base URL */ String postUrl; + + public String getPostUrl() + { + return postUrl; + } + + public void setPostUrl(String postUrl) + { + this.postUrl = postUrl; + } + + public String getUrlSuffix() + { + return urlSuffix; + } + + public void setUrlSuffix(String urlSuffix) + { + this.urlSuffix = urlSuffix; + } + + public Map getInputParams() + { + return inputParams; + } + + public void setInputParams(Map inputParams) + { + this.inputParams = inputParams; + } + + public void setHseparable(boolean hseparable) + { + this.hseparable = hseparable; + } + + public void setVseparable(boolean vseparable) + { + this.vseparable = vseparable; + } + + public void setGapCharacter(char gapCharacter) + { + this.gapCharacter = gapCharacter; + } + /** - * 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; - - /*** - * modelling the io: - * validation of input - * { formatter for type, parser for type } - * + + /** + * 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 */ - /** input info given as key/value pairs - mapped to post arguments - */ - Map inputParams=new HashMap(); + 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