From: Mateusz Warowny Date: Sat, 20 May 2023 21:57:52 +0000 (+0200) Subject: JAL-3954 create primitive gui handler for search service X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2cf151fe62bf1d49a36fa3afd4d964ee869764a5;p=jalview.git JAL-3954 create primitive gui handler for search service --- diff --git a/j11lib/hmmer-client-1.0-SNAPSHOT.jar b/j11lib/hmmer-client-1.0-SNAPSHOT.jar index 879f5b3..1efea10 100644 Binary files a/j11lib/hmmer-client-1.0-SNAPSHOT.jar and b/j11lib/hmmer-client-1.0-SNAPSHOT.jar differ diff --git a/src/jalview/ws2/actions/BaseJob.java b/src/jalview/ws2/actions/BaseJob.java index 945c7b0..6a4a600 100644 --- a/src/jalview/ws2/actions/BaseJob.java +++ b/src/jalview/ws2/actions/BaseJob.java @@ -25,6 +25,7 @@ import jalview.ws2.api.WebServiceJobHandle; * * @author mmwarowny */ +// TODO: make class non-abstract by removing isInputValid() public abstract class BaseJob implements JobI { protected final long internalId = MathUtils.getUID(); @@ -70,6 +71,7 @@ public abstract class BaseJob implements JobI * * @return {@code true} if the input is valid. */ + // FIXME: method not necessary, may incorporate into task#prepare() public abstract boolean isInputValid(); /** diff --git a/src/jalview/ws2/client/ebi/PhmmerWSClient.java b/src/jalview/ws2/client/ebi/PhmmerWSClient.java index 5a51fcc..9c79644 100644 --- a/src/jalview/ws2/client/ebi/PhmmerWSClient.java +++ b/src/jalview/ws2/client/ebi/PhmmerWSClient.java @@ -2,10 +2,14 @@ package jalview.ws2.client.ebi; import java.io.IOException; import java.io.StringReader; +import java.net.URI; import java.util.List; +import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; +import jalview.io.DataSourceType; import jalview.io.FileFormat; +import jalview.io.FormatAdapter; import jalview.ws.params.ArgumentI; import jalview.ws.params.simple.BooleanOption; import jalview.ws.params.simple.DoubleParameter; @@ -13,13 +17,14 @@ import jalview.ws.params.simple.IntegerParameter; import jalview.ws2.api.Credentials; import jalview.ws2.api.JobStatus; import jalview.ws2.api.WebServiceJobHandle; +import jalview.ws2.client.api.AlignmentWebServiceClientI; import jalview.ws2.client.api.WebServiceClientI; import uk.ac.dundee.compbio.hmmerclient.PhmmerClient; import uk.ac.dundee.compbio.hmmerclient.PhmmerRequest; import uk.ac.dundee.compbio.hmmerclient.PhmmerRequest.SequenceDatabase; import uk.ac.dundee.compbio.hmmerclient.PhmmerRequest.SubstitutionMatrix; -public class PhmmerWSClient implements WebServiceClientI +public class PhmmerWSClient implements AlignmentWebServiceClientI { final PhmmerClient client; @@ -229,4 +234,13 @@ public class PhmmerWSClient implements WebServiceClientI "ebi job dispatcher does not support job cancellation"); } + /** + * FIXME: Temporary hack + */ + @Override + public AlignmentI getAlignment(WebServiceJobHandle job) throws IOException + { + URI url = client.getResultURL(job.getJobId(), "sto"); + return new FormatAdapter().readFile(url.toString(), DataSourceType.URL, FileFormat.Stockholm); + } } diff --git a/src/jalview/ws2/gui/SearchServiceGuiHandler.java b/src/jalview/ws2/gui/SearchServiceGuiHandler.java new file mode 100644 index 0000000..b3ae5c1 --- /dev/null +++ b/src/jalview/ws2/gui/SearchServiceGuiHandler.java @@ -0,0 +1,95 @@ +package jalview.ws2.gui; + +import java.util.List; + +import jalview.bin.Console; +import jalview.datamodel.AlignmentI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.ws2.actions.api.JobI; +import jalview.ws2.actions.api.TaskEventListener; +import jalview.ws2.actions.api.TaskI; +import jalview.ws2.api.JobStatus; + +public class SearchServiceGuiHandler implements TaskEventListener +{ + private final AlignFrame parentFrame; + + public SearchServiceGuiHandler(AlignFrame parentFrame) + { + this.parentFrame = parentFrame; + } + + @Override + public void taskStarted(TaskI source, + List subJobs) + { + Console.info("task started with " + subJobs.size() + " jobs"); + // TODO Auto-generated method stub + + } + + @Override + public void taskStatusChanged(TaskI source, JobStatus status) + { + Console.info("task status " + status); + // TODO Auto-generated method stub + + } + + @Override + public void taskCompleted(TaskI source, AlignmentI result) + { + Console.info("task completed"); + displayResultsNewFrame(result); + } + + @Override + public void taskException(TaskI source, Exception e) + { + Console.info("task failed", e); + // TODO Auto-generated method stub + + } + + @Override + public void taskRestarted(TaskI source) + { + Console.info("task restarted"); + // TODO Auto-generated method stub + + } + + @Override + public void subJobStatusChanged(TaskI source, JobI job, + JobStatus status) + { + Console.info("sub-job " + job.getInternalId() + " status " + status); + // TODO Auto-generated method stub + + } + + @Override + public void subJobLogChanged(TaskI source, JobI job, + String log) + { + // TODO Auto-generated method stub + + } + + @Override + public void subJobErrorLogChanged(TaskI source, JobI job, + String log) + { + // TODO Auto-generated method stub + + } + + private void displayResultsNewFrame(AlignmentI aln) + { + AlignFrame frame = new AlignFrame(aln, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + frame.getFeatureRenderer().transferSettings( + parentFrame.getFeatureRenderer().getSettings()); + Desktop.addInternalFrame(frame, "title", AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + } +} diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index 8f48690..8e2dcee 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -39,6 +39,7 @@ import jalview.ws2.actions.annotation.AnnotationAction; import jalview.ws2.actions.api.ActionI; import jalview.ws2.actions.api.TaskEventListener; import jalview.ws2.actions.api.TaskI; +import jalview.ws2.actions.hmmer.PhmmerAction; import jalview.ws2.api.Credentials; import jalview.ws2.api.WebService; import jalview.ws2.client.api.WebServiceProviderI; @@ -470,6 +471,12 @@ public class WebServicesMenuManager var handler = new AnnotationServiceGuiHandler(_action, frame); return _action.perform(viewport, args, credentials, handler); } + if (action instanceof PhmmerAction) + { + var _action = (PhmmerAction) action; + var handler = new SearchServiceGuiHandler(frame); + return _action.perform(viewport, args, credentials, handler); + } Console.warn(String.format( "No known handler for action type %s. All output will be discarded.", action.getClass().getName()));