Add new method to ProteoCacheWS web service
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 4 Feb 2014 16:20:29 +0000 (16:20 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 4 Feb 2014 16:20:29 +0000 (16:20 +0000)
server/compbio/ws/jpred/Jpred.java
server/compbio/ws/jpred/JpredWS.java
server/compbio/ws/jpred/jaxws/FindSequenceResponse.java
server/compbio/ws/jpred/jaxws/JobExists.java [new file with mode: 0644]
server/compbio/ws/jpred/jaxws/JobExistsResponse.java [new file with mode: 0644]
server/compbio/ws/resources/ProteoCacheWS.wsdl
server/compbio/ws/resources/ProteoCacheWS_schema1.xsd

index 72b1a9e..13b11b3 100644 (file)
@@ -29,7 +29,7 @@ public interface Jpred {
         * @return a number of jobs executed for the protein
         */
        @WebMethod
-       public String findSequence(@WebParam(name = "sequence") String sequence, @WebParam(name = "program") String program,
+       public int findSequence(@WebParam(name = "sequence") String sequence, @WebParam(name = "program") String program,
                        @WebParam(name = "version") String version);
 
        /**
@@ -58,4 +58,14 @@ public interface Jpred {
         */
        @WebMethod
        public String getArchive(@WebParam(name = "job") String jobid);
+
+       /**
+        * Checks whether a job with a given Job ID is kept in ProteoCache
+        * 
+        * @param jobid
+        *            the job ID
+        * @return 1 if the job exists, 0 - otherwise
+        */
+       @WebMethod
+       public int jobExists(@WebParam(name = "job") String jobid);
 }
index 5249280..3688fb6 100644 (file)
@@ -10,6 +10,7 @@ import org.apache.log4j.Logger;
 
 import compbio.beans.ProteinBean;
 import compbio.cassandra.CassandraNativeConnector;
+import compbio.cassandra.readers.JobReader;
 import compbio.cassandra.readers.SequenceReader;
 import compbio.engine.archive.ArchivedJob;
 
@@ -48,12 +49,12 @@ public class JpredWS implements Jpred {
        }
 
        @Override
-       public String findSequence(String sequence, String program, String version) {
+       public int findSequence(String sequence, String program, String version) {
                List<String> jobs = findJobs(sequence, program, version);
                if (null != jobs) {
-                       return jobs.size() + " jobs found";
+                       return jobs.size();
                }
-               return "no jobs found";
+               return 0;
        }
 
        @Override
@@ -92,4 +93,15 @@ public class JpredWS implements Jpred {
                return link;
        }
 
+       @Override
+       public int jobExists(String jobid) {
+               CassandraNativeConnector dbconnector = new CassandraNativeConnector();
+               JobReader reader = new JobReader();
+               reader.setSession(dbconnector.getSession());
+               if (null != reader.readJobLog(jobid)) {
+                       return 1;
+               }
+               return 0;
+       }
+
 }
index 7889071..a2b881b 100644 (file)
@@ -13,14 +13,14 @@ import javax.xml.bind.annotation.XmlType;
 public class FindSequenceResponse {
 
     @XmlElement(name = "return", namespace = "")
-    private String _return;
+    private int _return;
 
     /**
      * 
      * @return
-     *     returns String
+     *     returns int
      */
-    public String getReturn() {
+    public int getReturn() {
         return this._return;
     }
 
@@ -29,7 +29,7 @@ public class FindSequenceResponse {
      * @param _return
      *     the value for the _return property
      */
-    public void setReturn(String _return) {
+    public void setReturn(int _return) {
         this._return = _return;
     }
 
diff --git a/server/compbio/ws/jpred/jaxws/JobExists.java b/server/compbio/ws/jpred/jaxws/JobExists.java
new file mode 100644 (file)
index 0000000..00a4a77
--- /dev/null
@@ -0,0 +1,36 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "jobExists", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "jobExists", namespace = "http://server.proteocache.ws")
+public class JobExists {
+
+    @XmlElement(name = "job", namespace = "")
+    private String job;
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getJob() {
+        return this.job;
+    }
+
+    /**
+     * 
+     * @param job
+     *     the value for the job property
+     */
+    public void setJob(String job) {
+        this.job = job;
+    }
+
+}
diff --git a/server/compbio/ws/jpred/jaxws/JobExistsResponse.java b/server/compbio/ws/jpred/jaxws/JobExistsResponse.java
new file mode 100644 (file)
index 0000000..8ac68b1
--- /dev/null
@@ -0,0 +1,36 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "jobExistsResponse", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "jobExistsResponse", namespace = "http://server.proteocache.ws")
+public class JobExistsResponse {
+
+    @XmlElement(name = "return", namespace = "")
+    private int _return;
+
+    /**
+     * 
+     * @return
+     *     returns int
+     */
+    public int getReturn() {
+        return this._return;
+    }
+
+    /**
+     * 
+     * @param _return
+     *     the value for the _return property
+     */
+    public void setReturn(int _return) {
+        this._return = _return;
+    }
+
+}
index b96d008..b4fefd8 100644 (file)
   <message name="getArchiveResponse">
     <part name="parameters" element="tns:getArchiveResponse"/>
   </message>
+  <message name="jobExists">
+    <part name="parameters" element="tns:jobExists"/>
+  </message>
+  <message name="jobExistsResponse">
+    <part name="parameters" element="tns:jobExistsResponse"/>
+  </message>
   <portType name="Jpred">
     <operation name="findSequence">
       <input wsam:Action="http://server.proteocache.ws/Jpred/findSequenceRequest" message="tns:findSequence"/>
       <input wsam:Action="http://server.proteocache.ws/Jpred/getArchiveRequest" message="tns:getArchive"/>
       <output wsam:Action="http://server.proteocache.ws/Jpred/getArchiveResponse" message="tns:getArchiveResponse"/>
     </operation>
+    <operation name="jobExists">
+      <input wsam:Action="http://server.proteocache.ws/Jpred/jobExistsRequest" message="tns:jobExists"/>
+      <output wsam:Action="http://server.proteocache.ws/Jpred/jobExistsResponse" message="tns:jobExistsResponse"/>
+    </operation>
   </portType>
   <binding name="ProteoCacheWSPortBinding" type="tns:Jpred">
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
         <soap:body use="literal"/>
       </output>
     </operation>
+    <operation name="jobExists">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
   </binding>
   <service name="ProteoCacheWS">
     <port name="ProteoCacheWSPort" binding="tns:ProteoCacheWSPortBinding">
index cf80b4c..514f9bf 100644 (file)
 
   <xs:element name="getArchiveResponse" type="tns:getArchiveResponse"/>
 
+  <xs:element name="jobExists" type="tns:jobExists"/>
+
+  <xs:element name="jobExistsResponse" type="tns:jobExistsResponse"/>
+
   <xs:complexType name="findJobForSequence">
     <xs:sequence>
       <xs:element name="sequence" type="xs:string" minOccurs="0"/>
     </xs:sequence>
   </xs:complexType>
 
+  <xs:complexType name="jobExists">
+    <xs:sequence>
+      <xs:element name="job" type="xs:string" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="jobExistsResponse">
+    <xs:sequence>
+      <xs:element name="return" type="xs:int"/>
+    </xs:sequence>
+  </xs:complexType>
+
   <xs:complexType name="findSequence">
     <xs:sequence>
       <xs:element name="sequence" type="xs:string" minOccurs="0"/>
@@ -37,7 +53,7 @@
 
   <xs:complexType name="findSequenceResponse">
     <xs:sequence>
-      <xs:element name="return" type="xs:string" minOccurs="0"/>
+      <xs:element name="return" type="xs:int"/>
     </xs:sequence>
   </xs:complexType>