From d1d2e0d38c08f6ac5ce95cfbf049c4ddcdc49e62 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Thu, 10 Feb 2011 13:50:10 +0000 Subject: [PATCH] Finally, the new web services are working git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3738 e3abac25-378b-4346-85de-24260fe3988d --- datamodel/compbio/data/sequence/Range.java | 6 ++ datamodel/compbio/data/sequence/Score.java | 21 +++--- datamodel/compbio/data/sequence/ScoreManager.java | 15 ++-- how_to_add_new_webservice.txt | 4 ++ .../compbio/data/sequence/SequenceUtilTester.java | 5 +- .../data/msa/jaxws/GetAnnotationResponse.java | 10 ++- .../data/msa/jaxws/JobSubmissionExceptionBean.java | 4 +- .../data/msa/jaxws/LimitExceededExceptionBean.java | 4 +- .../msa/jaxws/ResultNotAvailableExceptionBean.java | 4 +- .../msa/jaxws/UnsupportedRuntimeExceptionBean.java | 4 +- .../msa/jaxws/WrongParameterExceptionBean.java | 4 +- .../compbio/ws/server/resource/AAConWS.wsdl | 72 ++++++++++---------- .../compbio/ws/server/resource/AAConWS_schema1.xsd | 34 ++++++--- .../ws/server/resource/DisemblWS_schema1.xsd | 34 ++++++--- .../ws/server/resource/GlobPlotWS_schema1.xsd | 34 ++++++--- .../compbio/ws/server/resource/JronnWS_schema1.xsd | 34 ++++++--- wsbuild.xml | 6 +- 17 files changed, 182 insertions(+), 113 deletions(-) diff --git a/datamodel/compbio/data/sequence/Range.java b/datamodel/compbio/data/sequence/Range.java index 839ae28..1fabc07 100644 --- a/datamodel/compbio/data/sequence/Range.java +++ b/datamodel/compbio/data/sequence/Range.java @@ -5,6 +5,12 @@ public class Range implements Comparable { public final int from; public final int to; + private Range() { + // JAXB default constructor should not be used + from = 0; + to = from; + } + public Range(int from, int to) { this.from = from; this.to = to; diff --git a/datamodel/compbio/data/sequence/Score.java b/datamodel/compbio/data/sequence/Score.java index b61c74e..f28bd0d 100644 --- a/datamodel/compbio/data/sequence/Score.java +++ b/datamodel/compbio/data/sequence/Score.java @@ -12,8 +12,6 @@ import java.util.TreeSet; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlTransient; import compbio.util.annotation.Immutable; @@ -28,25 +26,22 @@ import compbio.util.annotation.Immutable; @Immutable public class Score { - @XmlTransient static final NumberFormat NUMBER_FORMAT = NumberFormat .getNumberInstance(Locale.UK); static { NUMBER_FORMAT.setGroupingUsed(false); NUMBER_FORMAT.setMaximumFractionDigits(3); } + // This should be Enum but JAXB cannot serialize it. + private final String method; - private Enum method; - // private String method; - - @XmlElement private TreeSet ranges = new TreeSet(); - @XmlElement private ArrayList scores = new ArrayList(0); private Score() { // JaXB default constructor + method = null; } /** @@ -60,7 +55,7 @@ public class Score { * alignment */ public Score(Enum method, ArrayList scores) { - this.method = method; + this.method = method.toString(); this.scores = new ArrayList(scores); } @@ -76,18 +71,18 @@ public class Score { * function, usually can be calculated based on scores */ public Score(Enum method, ArrayList scores, TreeSet ranges) { - this.method = method; + this.method = method.toString(); this.ranges = ranges; this.scores = scores; } public Score(Enum method, TreeSet ranges) { - this.method = method; + this.method = method.toString(); this.ranges = ranges; } public Score(Enum method, float[] scores) { - this.method = method; + this.method = method.toString(); this.scores = toList(scores); } @@ -103,7 +98,7 @@ public class Score { * * @return the ConservationMethod */ - public Enum getMethod() { + public String getMethod() { return method; } diff --git a/datamodel/compbio/data/sequence/ScoreManager.java b/datamodel/compbio/data/sequence/ScoreManager.java index f384308..7ddf894 100644 --- a/datamodel/compbio/data/sequence/ScoreManager.java +++ b/datamodel/compbio/data/sequence/ScoreManager.java @@ -13,10 +13,12 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlTransient; @XmlAccessorType(XmlAccessType.FIELD) public class ScoreManager { + @XmlTransient public static final String SINGLE_ENTRY_KEY = "Alignment"; private List seqScores; @@ -104,7 +106,6 @@ public class ScoreManager { } writer.flush(); } - @Override public int hashCode() { @@ -132,13 +133,11 @@ public class ScoreManager { return true; } - - @XmlAccessorType(XmlAccessType.FIELD) public static class ScoreHolder { public String id; - public Set scores; + public HashSet scores; private ScoreHolder() { // JAXB Default constructor should not be used otherwise @@ -146,7 +145,7 @@ public class ScoreManager { ScoreHolder(String id, Set scores) { this.id = id; - this.scores = scores; + this.scores = new HashSet(scores); } public void writeOut(OutputStream outStream) throws IOException { @@ -158,13 +157,12 @@ public class ScoreManager { public Score getScoreByMethod(Enum method) { for (Score sc : scores) { - if (method == sc.getMethod()) { + if (method.toString().equals(sc.getMethod())) { return sc; } } return null; } - public int getNumberOfScores() { return scores.size(); } @@ -200,7 +198,6 @@ public class ScoreManager { return false; return true; } - - + } } diff --git a/how_to_add_new_webservice.txt b/how_to_add_new_webservice.txt index cb11ba4..529aa42 100644 --- a/how_to_add_new_webservice.txt +++ b/how_to_add_new_webservice.txt @@ -38,6 +38,10 @@ Check that - you do not have interfaces to serialize. JAXB cannot serialize them. - you have a default no args constructor (can be private if you do not need it) - JAXB cannot serialize a Map, use custom data structure instead! + - Enum cannot be serialized as its abstract class (do not confuse with enum which is fine) + - Fields serialization leave a little more space for manuevre, so use it. If you do you then + can accept and return interfaces, e.g. List, Map; abstract classes etc, from your methods. + If you have the data on the server side, but nothing is coming through to the client, this is a JAXB serialization problem. They tend to be very silent and thus hard to debug. Check your data structure can be serialized! diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java index 682bcad..b6e74ae 100644 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ b/testsrc/compbio/data/sequence/SequenceUtilTester.java @@ -232,11 +232,12 @@ public class SequenceUtilTester { } for (Score score : scores) { - if (score.getMethod() == (Enum) GlobProtResult.Disorder) { + if (score.getMethod() + .equals(GlobProtResult.Disorder.toString())) { assertEquals(score.getRanges().size(), 7); assertTrue(score.getScores().isEmpty()); } - if (score.getMethod() == (Enum) GlobProtResult.Dydx) { + if (GlobProtResult.valueOf(score.getMethod()) == GlobProtResult.Dydx) { assertFalse(score.getScores().isEmpty()); assertTrue(score.getRanges().isEmpty()); } diff --git a/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java b/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java index d7adf3c..749551e 100644 --- a/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java +++ b/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java @@ -1,8 +1,6 @@ package compbio.data.msa.jaxws; -import java.util.HashMap; -import java.util.HashSet; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -15,14 +13,14 @@ import javax.xml.bind.annotation.XmlType; public class GetAnnotationResponse { @XmlElement(name = "return", namespace = "") - private HashMap> _return; + private compbio.data.sequence.ScoreManager _return; /** * * @return - * returns HashMap> + * returns ScoreManager */ - public HashMap> getReturn() { + public compbio.data.sequence.ScoreManager getReturn() { return this._return; } @@ -31,7 +29,7 @@ public class GetAnnotationResponse { * @param _return * the value for the _return property */ - public void setReturn(HashMap> _return) { + public void setReturn(compbio.data.sequence.ScoreManager _return) { this._return = _return; } diff --git a/webservices/compbio/data/msa/jaxws/JobSubmissionExceptionBean.java b/webservices/compbio/data/msa/jaxws/JobSubmissionExceptionBean.java index 30950b4..b2d62d6 100644 --- a/webservices/compbio/data/msa/jaxws/JobSubmissionExceptionBean.java +++ b/webservices/compbio/data/msa/jaxws/JobSubmissionExceptionBean.java @@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlType; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.1-hudson-28- - * Generated source version: 2.2.1 + * JAX-WS RI 2.1.6 in JDK 6 + * Generated source version: 2.1.6 * */ @XmlRootElement(name = "JobSubmissionException", namespace = "http://msa.data.compbio/01/12/2010/") diff --git a/webservices/compbio/data/msa/jaxws/LimitExceededExceptionBean.java b/webservices/compbio/data/msa/jaxws/LimitExceededExceptionBean.java index c9c3a4e..e1bf0bf 100644 --- a/webservices/compbio/data/msa/jaxws/LimitExceededExceptionBean.java +++ b/webservices/compbio/data/msa/jaxws/LimitExceededExceptionBean.java @@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlType; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.1-hudson-28- - * Generated source version: 2.2.1 + * JAX-WS RI 2.1.6 in JDK 6 + * Generated source version: 2.1.6 * */ @XmlRootElement(name = "LimitExceededException", namespace = "http://msa.data.compbio/01/12/2010/") diff --git a/webservices/compbio/data/msa/jaxws/ResultNotAvailableExceptionBean.java b/webservices/compbio/data/msa/jaxws/ResultNotAvailableExceptionBean.java index be8a26d..7016909 100644 --- a/webservices/compbio/data/msa/jaxws/ResultNotAvailableExceptionBean.java +++ b/webservices/compbio/data/msa/jaxws/ResultNotAvailableExceptionBean.java @@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlType; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.1-hudson-28- - * Generated source version: 2.2.1 + * JAX-WS RI 2.1.6 in JDK 6 + * Generated source version: 2.1.6 * */ @XmlRootElement(name = "ResultNotAvailableException", namespace = "http://msa.data.compbio/01/12/2010/") diff --git a/webservices/compbio/data/msa/jaxws/UnsupportedRuntimeExceptionBean.java b/webservices/compbio/data/msa/jaxws/UnsupportedRuntimeExceptionBean.java index 5e1268a..fa77aae 100644 --- a/webservices/compbio/data/msa/jaxws/UnsupportedRuntimeExceptionBean.java +++ b/webservices/compbio/data/msa/jaxws/UnsupportedRuntimeExceptionBean.java @@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlType; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.1-hudson-28- - * Generated source version: 2.2.1 + * JAX-WS RI 2.1.6 in JDK 6 + * Generated source version: 2.1.6 * */ @XmlRootElement(name = "UnsupportedRuntimeException", namespace = "http://msa.data.compbio/01/12/2010/") diff --git a/webservices/compbio/data/msa/jaxws/WrongParameterExceptionBean.java b/webservices/compbio/data/msa/jaxws/WrongParameterExceptionBean.java index 62be910..fc22bd0 100644 --- a/webservices/compbio/data/msa/jaxws/WrongParameterExceptionBean.java +++ b/webservices/compbio/data/msa/jaxws/WrongParameterExceptionBean.java @@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlType; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.1-hudson-28- - * Generated source version: 2.2.1 + * JAX-WS RI 2.1.6 in JDK 6 + * Generated source version: 2.1.6 * */ @XmlRootElement(name = "WrongParameterException", namespace = "http://msa.data.compbio/01/12/2010/") diff --git a/webservices/compbio/ws/server/resource/AAConWS.wsdl b/webservices/compbio/ws/server/resource/AAConWS.wsdl index dffcb48..c9c8412 100644 --- a/webservices/compbio/ws/server/resource/AAConWS.wsdl +++ b/webservices/compbio/ws/server/resource/AAConWS.wsdl @@ -1,6 +1,6 @@ - - + + @@ -89,60 +89,60 @@ - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/webservices/compbio/ws/server/resource/AAConWS_schema1.xsd b/webservices/compbio/ws/server/resource/AAConWS_schema1.xsd index 77fe8df..038af26 100644 --- a/webservices/compbio/ws/server/resource/AAConWS_schema1.xsd +++ b/webservices/compbio/ws/server/resource/AAConWS_schema1.xsd @@ -204,20 +204,36 @@ - + - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/webservices/compbio/ws/server/resource/DisemblWS_schema1.xsd b/webservices/compbio/ws/server/resource/DisemblWS_schema1.xsd index 6185886..97d6989 100644 --- a/webservices/compbio/ws/server/resource/DisemblWS_schema1.xsd +++ b/webservices/compbio/ws/server/resource/DisemblWS_schema1.xsd @@ -271,20 +271,36 @@ - + - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/webservices/compbio/ws/server/resource/GlobPlotWS_schema1.xsd b/webservices/compbio/ws/server/resource/GlobPlotWS_schema1.xsd index 109e3fb..858d2c2 100644 --- a/webservices/compbio/ws/server/resource/GlobPlotWS_schema1.xsd +++ b/webservices/compbio/ws/server/resource/GlobPlotWS_schema1.xsd @@ -69,20 +69,36 @@ - + - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/webservices/compbio/ws/server/resource/JronnWS_schema1.xsd b/webservices/compbio/ws/server/resource/JronnWS_schema1.xsd index 77fe8df..038af26 100644 --- a/webservices/compbio/ws/server/resource/JronnWS_schema1.xsd +++ b/webservices/compbio/ws/server/resource/JronnWS_schema1.xsd @@ -204,20 +204,36 @@ - + - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/wsbuild.xml b/wsbuild.xml index dad6d25..bf55aaa 100644 --- a/wsbuild.xml +++ b/wsbuild.xml @@ -26,8 +26,9 @@ + - + @@ -47,6 +48,7 @@ + + +