From: Sasha Sherstnev Date: Fri, 31 Jan 2014 16:36:14 +0000 (+0000) Subject: Add new operation to the ProteoCache WS X-Git-Url: http://source.jalview.org/gitweb/?p=proteocache.git;a=commitdiff_plain;h=e42ffa7fff3b1bcc7b85451ab0914422d36d8324 Add new operation to the ProteoCache WS --- diff --git a/server/compbio/ws/jpred/Jpred.java b/server/compbio/ws/jpred/Jpred.java index cebac29..4b4a965 100644 --- a/server/compbio/ws/jpred/Jpred.java +++ b/server/compbio/ws/jpred/Jpred.java @@ -6,7 +6,15 @@ import javax.jws.WebService; @WebService(targetNamespace = "http://server.proteocache.ws") public interface Jpred { + @WebMethod public String findSequence(@WebParam(name = "sequence") String sequence, @WebParam(name = "program") String program, @WebParam(name = "version") String version); + + @WebMethod + public String findJobForSequence(@WebParam(name = "sequence") String sequence, @WebParam(name = "program") String program, + @WebParam(name = "version") String version); + + @WebMethod + public String getArchive(@WebParam(name = "job") String jobid); } diff --git a/server/compbio/ws/jpred/JpredWS.java b/server/compbio/ws/jpred/JpredWS.java index 16e100f..9978cc4 100644 --- a/server/compbio/ws/jpred/JpredWS.java +++ b/server/compbio/ws/jpred/JpredWS.java @@ -1,27 +1,85 @@ package compbio.ws.jpred; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import javax.jws.WebService; import org.apache.log4j.Logger; +import compbio.beans.ProteinBean; import compbio.cassandra.CassandraNativeConnector; import compbio.cassandra.readers.SequenceReader; +import compbio.engine.archive.ArchivedJob; @WebService(endpointInterface = "compbio.ws.jpred.Jpred", targetNamespace = "http://server.proteocache.ws", serviceName = "ProteoCacheWS", portName = "ProteoCacheWSPort") public class JpredWS implements Jpred { private static Logger log = Logger.getLogger(CassandraNativeConnector.class); + String jobid; - @Override - public String findSequence(String sequence, String program, String version) { + private List findJobs(String sequence, String program, String version) { CassandraNativeConnector dbconnector = new CassandraNativeConnector(); SequenceReader reader = new SequenceReader(); reader.setSession(dbconnector.getSession()); - log.debug("ProteoCacheWS is connected:\n search for sequence: " + sequence + "\ncalculated wih " + program + " (version; " + log.debug("ProteoCacheWS is connected:\n search for sequence: " + sequence + "\ncalculated with " + program + " (version: " + version + ")"); - if (null != reader.readProteins(sequence, "whole")) { - return "The sequence " + sequence + " found. Calculated with " + program + "(" + version + ")"; + List jobs = new ArrayList(); + List result = reader.readProteins(sequence, "whole"); + if (null != result) { + for (ProteinBean protein : result) { + List thejobs = protein.getJobid(); + jobid = thejobs.get(0); + for (String job : thejobs) { + jobs.add(job); + } + } + } + return jobs; + } + + @Override + public String findSequence(String sequence, String program, String version) { + List jobs = findJobs(sequence, program, version); + if (null != jobs) { + return jobs.size() + " jobs found"; + } + return "no jobs found"; + } + + @Override + public String findJobForSequence(String sequence, String program, String version) { + List jobs = findJobs(sequence, program, version); + if (null != jobs) { + for (String job : jobs) { + String link = null; + ArchivedJob aj = new ArchivedJob(job); + try { + link = aj.prepareJobArchiveToWeb(); + } catch (IOException e) { + log.error("JpredWS.findSequence: IO exception with job archive file"); + log.error(e.getLocalizedMessage(), e.getCause()); + } + if (null != link) { + return job; + } + } + return ""; + } + return ""; + } + + @Override + public String getArchive(String jobid) { + String link = "undefined"; + ArchivedJob aj = new ArchivedJob(jobid); + try { + link = aj.prepareJobArchiveToWeb(); + } catch (IOException e) { + log.error("JpredWS.findSequence: IO exception with job archive file"); + log.error(e.getLocalizedMessage(), e.getCause()); } - return "The sequence " + sequence + " not found"; + return link; } } diff --git a/server/compbio/ws/jpred/jaxws/FindSequence.java b/server/compbio/ws/jpred/jaxws/FindSequence.java index d1b23d2..76195e8 100644 --- a/server/compbio/ws/jpred/jaxws/FindSequence.java +++ b/server/compbio/ws/jpred/jaxws/FindSequence.java @@ -1,3 +1,4 @@ + package compbio.ws.jpred.jaxws; import javax.xml.bind.annotation.XmlAccessType; @@ -8,71 +9,72 @@ import javax.xml.bind.annotation.XmlType; @XmlRootElement(name = "findSequence", namespace = "http://server.proteocache.ws") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "findSequence", namespace = "http://server.proteocache.ws", propOrder = { "sequence", "program", "version" }) +@XmlType(name = "findSequence", namespace = "http://server.proteocache.ws", propOrder = { + "sequence", + "program", + "version" +}) public class FindSequence { - @XmlElement(name = "sequence", namespace = "") - private String sequence; - @XmlElement(name = "program", namespace = "") - private String program; - @XmlElement(name = "version", namespace = "") - private String version; + @XmlElement(name = "sequence", namespace = "") + private String sequence; + @XmlElement(name = "program", namespace = "") + private String program; + @XmlElement(name = "version", namespace = "") + private String version; - /** - * - * @return returns String - */ - public String getSequence() { - System.out.println("FindSequence.setSequence: output sequence " + this.sequence); - return this.sequence; - } + /** + * + * @return + * returns String + */ + public String getSequence() { + return this.sequence; + } - /** - * - * @param sequence - * the value for the sequence property - */ - public void setSequence(String sequence) { - System.out.println("FindSequence.setSequence: input sequence " + sequence); - this.sequence = sequence; - } + /** + * + * @param sequence + * the value for the sequence property + */ + public void setSequence(String sequence) { + this.sequence = sequence; + } - /** - * - * @return returns String - */ - public String getProgram() { - System.out.println("FindSequence.setProgram: output program " + this.program); - return this.program; - } + /** + * + * @return + * returns String + */ + public String getProgram() { + return this.program; + } - /** - * - * @param program - * the value for the program property - */ - public void setProgram(String program) { - System.out.println("FindSequence.setProgram: input program " + program); - this.program = program; - } + /** + * + * @param program + * the value for the program property + */ + public void setProgram(String program) { + this.program = program; + } - /** - * - * @return returns String - */ - public String getVersion() { - System.out.println("FindSequence.setVersion: output version " + this.version); - return this.version; - } + /** + * + * @return + * returns String + */ + public String getVersion() { + return this.version; + } - /** - * - * @param version - * the value for the version property - */ - public void setVersion(String version) { - System.out.println("FindSequence.setVersion: input version " + version); - this.version = version; - } + /** + * + * @param version + * the value for the version property + */ + public void setVersion(String version) { + this.version = version; + } } diff --git a/server/compbio/ws/resources/ProteoCacheWS.wsdl b/server/compbio/ws/resources/ProteoCacheWS.wsdl index c456e47..dd3aa90 100644 --- a/server/compbio/ws/resources/ProteoCacheWS.wsdl +++ b/server/compbio/ws/resources/ProteoCacheWS.wsdl @@ -6,6 +6,18 @@ + + + + + + + + + + + + @@ -13,6 +25,14 @@ + + + + + + + + @@ -20,6 +40,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd b/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd index d9ee154..cf80b4c 100644 --- a/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd +++ b/server/compbio/ws/resources/ProteoCacheWS_schema1.xsd @@ -1,10 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -18,5 +40,17 @@ + + + + + + + + + + + +