From: Jim Procter Date: Fri, 20 Jul 2018 11:02:58 +0000 (+0100) Subject: JAL-3070 refactored base analysis action descriptor from RestClient for X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=42a9157ffcdeb7292b7b9fd0e13db94e99af0bef;p=jalview.git JAL-3070 refactored base analysis action descriptor from RestClient for use in all web service clients --- diff --git a/src/jalview/ws/api/UIinfo.java b/src/jalview/ws/api/UIinfo.java new file mode 100644 index 0000000..cd156f2 --- /dev/null +++ b/src/jalview/ws/api/UIinfo.java @@ -0,0 +1,70 @@ +package jalview.ws.api; + +/** + * Service UI Info { Action, Specific Name of Service, Brief Description } + */ + +public class UIinfo +{ + public UIinfo(String action, String name, String description) + { + this.Action = action == null ? "" : action; + this.description = description == null ? "" : description; + this.Name = name == null ? "" : name; + } + + 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; + } + + @Override + public boolean equals(Object object) + { + if (object == null || !(object instanceof UIinfo)) + { + return false; + } + UIinfo other = (UIinfo) object; + + return (Name == null && other.getName() == null || Name != null + && other.getName() != null && Name.equals(other.getName())) + && (Action == null && other.getAction() == null + || Action != null && other.getAction() != null + && Action.equals(other.getAction())) + && (description == null && other.getDescription() == null + || description != null && other.getDescription() != null + && description.equals(other.getDescription())); + } + + String Action; + + String Name; + + String description; +} \ No newline at end of file diff --git a/src/jalview/ws/rest/RestServiceDescription.java b/src/jalview/ws/rest/RestServiceDescription.java index 5533406..285b795 100644 --- a/src/jalview/ws/rest/RestServiceDescription.java +++ b/src/jalview/ws/rest/RestServiceDescription.java @@ -23,6 +23,7 @@ package jalview.ws.rest; import jalview.datamodel.SequenceI; import jalview.io.packed.DataProvider.JvDataType; import jalview.util.StringUtils; +import jalview.ws.api.UIinfo; import jalview.ws.rest.params.Alignment; import jalview.ws.rest.params.AnnotationFile; import jalview.ws.rest.params.SeqGroupIndexVector; @@ -66,10 +67,7 @@ public class RestServiceDescription boolean vseparable, char gapCharacter) { super(); - this.details = new UIinfo(); - details.Action = action == null ? "" : action; - details.description = description == null ? "" : description; - details.Name = name == null ? "" : name; + this.details = new UIinfo(action, name, description); this.postUrl = postUrl == null ? "" : postUrl; this.urlSuffix = urlSuffix == null ? "" : urlSuffix; if (inputParams != null) @@ -98,56 +96,11 @@ public class RestServiceDescription // 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); + diff |= !details.equals(other.details); return !diff; } - /** - * Service UI Info { Action, Specific Name of Service, Brief Description } - */ - - 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; - } - - public UIinfo details = new UIinfo(); + public UIinfo details; public String getAction() { @@ -238,7 +191,7 @@ public class RestServiceDescription /** * input info given as key/value pairs - mapped to post arguments */ - Map inputParams = new HashMap(); + Map inputParams = new HashMap<>(); /** * assigns the given inputType it to its corresponding input parameter token @@ -455,7 +408,7 @@ public class RestServiceDescription } StringTokenizer st = new StringTokenizer(outstring, ";"); String tok = ""; - resultData = new ArrayList(); + resultData = new ArrayList<>(); while (st.hasMoreTokens()) { try @@ -479,7 +432,7 @@ public class RestServiceDescription private String getServiceIOProperties() { - ArrayList vls = new ArrayList(); + ArrayList vls = new ArrayList<>(); if (isHseparable()) { vls.add("hseparable"); @@ -496,17 +449,18 @@ public class RestServiceDescription ","); } + @Override public String toString() { StringBuffer result = new StringBuffer(); result.append("|"); - result.append(details.Name); + result.append(details.getName()); result.append('|'); - result.append(details.Action); + result.append(details.getAction()); result.append('|'); - if (details.description != null) + if (details.getDescription() != null) { - result.append(details.description); + result.append(details.getDescription()); } ; // list job input flags @@ -567,9 +521,7 @@ public class RestServiceDescription { p++; } - details.Name = list[p]; - details.Action = list[p + 1]; - details.description = list[p + 2]; + details = new UIinfo(list[p + 1], list[p], list[p + 2]); invalid |= !configureFromServiceInputProperties(list[p + 3], warnings); if (list.length - p > 5 && list[p + 5] != null && list[p + 5].trim().length() > 5) @@ -667,7 +619,7 @@ public class RestServiceDescription int lastp = 0; String url = new String(); Matcher prms = PARAM_ENCODED_URL_PATTERN.matcher(ipurl); - Map iparams = new Hashtable(); + Map iparams = new Hashtable<>(); InputType jinput; while (prms.find()) { @@ -728,7 +680,7 @@ public class RestServiceDescription jinput = (InputType) (type.getConstructor().newInstance()); if (iprm.equalsIgnoreCase(jinput.getURLtokenPrefix())) { - ArrayList al = new ArrayList(); + ArrayList al = new ArrayList<>(); for (String prprm : StringUtils.separatorListToArray(iprmparams, ",")) { @@ -838,7 +790,7 @@ public class RestServiceDescription return jobId + urlSuffix; } - private List resultData = new ArrayList(); + private List resultData = new ArrayList<>(); /** * @@ -852,7 +804,7 @@ public class RestServiceDescription { if (resultData == null) { - resultData = new ArrayList(); + resultData = new ArrayList<>(); } resultData.add(dt); } @@ -883,7 +835,7 @@ public class RestServiceDescription String services) throws Exception { String[] list = StringUtils.separatorListToArray(services, "|"); - List svcparsed = new ArrayList(); + List svcparsed = new ArrayList<>(); int p = 0, lastp = 0; StringBuffer warnings = new StringBuffer(); do