JAL-3878 Initial preparation.
[jalview.git] / src / jalview / ws2 / JalviewWebServiceI.java
1 package jalview.ws2;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import jalview.datamodel.SequenceI;
7 import jalview.ws.params.ArgumentI;
8 import jalview.ws.params.ParamDatastoreI;
9 import jalview.ws.params.WsParamSetI;
10
11 /**
12  * Provides information about the web service and sub-routines
13  * to submit and track the jobs running on the server as well as
14  * retrieve the results.
15  * The instances should not depend on any other jalview components, especially
16  * must be oblivious to the existence of any UI.
17  * They are used by other classes such as WebServiceWorkers rather than
18  * manipulate data themselves.
19  *
20  * @author mmwarowny
21  *
22  * @param <R>
23  */
24 public interface JalviewWebServiceI<R>
25 {
26   public static final int PROTEIN_SERVICE = 0x01;
27   public static final int NUCLEOTIDE_SERVICE = 0x02;
28   public static final int ALIGNMENT_ANALYSIS = 0x04;
29   
30   public String getHostName();
31   public String getName();
32   public String getDescription();
33   public String getOperationType();
34   public int getTypeFlags();
35   public boolean canSubmitGaps();
36   public int getMinSequences();
37   public int getMaxSequences();
38   public boolean hasParameters();
39   public ParamDatastoreI getParamStore();
40   
41   public default boolean isProteinService() {
42     return (getTypeFlags() & PROTEIN_SERVICE) > 0;
43   }
44   public default boolean isNucleotideService() {
45     return (getTypeFlags() & NUCLEOTIDE_SERVICE) > 0;
46   }
47   public default boolean isAlignmentAnalysis() {
48     return (getTypeFlags() & ALIGNMENT_ANALYSIS) > 0;
49   }
50   
51   public WSJobID submit(List<SequenceI> sequences, WsParamSetI preset,
52       List<ArgumentI> parameters) throws IOException;
53   
54   public void updateProgress(WSJobID id, WSJobTrackerI tracker)
55       throws IOException;
56   
57   public R getResult(WSJobID id) throws IOException;
58   
59   public void cancel(WSJobID id) throws IOException;
60   
61   public boolean handleSubmissionError(WSJobID id, Throwable th,
62       WSJobTrackerI tracker);
63   
64   public boolean handleCollectionError(WSJobID id, Throwable th,
65       WSJobTrackerI tracker);
66   
67 }