JAL-3807 JPred can now successfully submit and track the job.
[jalview.git] / src / jalview / ws / api / ServiceWithParameters.java
1 package jalview.ws.api;
2
3 import jalview.bin.Cache;
4 import jalview.gui.AlignFrame;
5 import jalview.ws.JPredClient;
6 import jalview.ws.jws2.MsaWSClient;
7 import jalview.ws.jws2.SequenceAnnotationWSClient;
8 import jalview.ws.params.ParamManager;
9
10 import javax.swing.JMenu;
11
12 public abstract class ServiceWithParameters extends UIinfo
13     implements JalviewServiceEndpointProviderI
14 {
15
16   protected jalview.ws.uimodel.AlignAnalysisUIText aaui;
17
18   public ServiceWithParameters(String serviceType, String action,
19           String name, String description, String hosturl)
20   {
21     super(serviceType, action, name, description, hosturl);
22   }
23
24   public abstract void initParamStore(ParamManager userParameterStore);
25
26   public jalview.ws.uimodel.AlignAnalysisUIText getAlignAnalysisUI()
27   {
28     return aaui;
29   }
30
31   public void setAlignAnalysisUI(
32           jalview.ws.uimodel.AlignAnalysisUIText aaui)
33   {
34     this.aaui = aaui;
35   }
36
37   public boolean isInteractiveUpdate()
38   {
39     return aaui != null && aaui.isAA();
40   }
41   // config flags for SeqAnnotationServiceCalcWorker
42
43   public boolean isProteinService()
44   {
45     return aaui == null ? true : aaui.isPr();
46   }
47
48   public boolean isNucleotideService()
49   {
50     return aaui == null ? false : aaui.isNa();
51   }
52
53   public boolean isNeedsAlignedSequences()
54   {
55     return aaui == null ? false : aaui.isNeedsAlignedSeqs();
56   }
57
58   public boolean isAlignmentAnalysis()
59   {
60     return aaui == null ? false : aaui.isAA();
61   }
62
63   public boolean isFilterSymbols()
64   {
65     return aaui != null ? aaui.isFilterSymbols() : true;
66   }
67
68   public int getMinimumInputSequences()
69   {
70     return aaui != null ? aaui.getMinimumSequences() : 1;
71   }
72
73   public String getNameURI()
74   {
75     return "java:" + getName();
76   }
77
78   public String getUri()
79   {
80     // TODO verify that service parameter sets in projects are consistent with
81     // Jalview 2.10.4
82     // this is only valid for Jaba 1.0 - this formula might have to change!
83     return getHostURL()
84             + (getHostURL().lastIndexOf("/") == (getHostURL().length() - 1)
85                     ? ""
86                     : "/")
87             + getName();
88   }
89
90   protected enum ServiceClient
91   {
92     MSAWSCLIENT, SEQUENCEANNOTATIONWSCLIENT, JPREDWSCLIENT;
93   };
94
95   protected ServiceClient style = null;
96
97   public void attachWSMenuEntry(JMenu atpoint, AlignFrame alignFrame)
98   {
99     switch (style)
100     {
101     case MSAWSCLIENT:
102         new MsaWSClient().attachWSMenuEntry(atpoint, this, alignFrame);
103       break;
104     case JPREDWSCLIENT:
105         JPredClient.getMenuEntryProvider(this).attachWSMenuEntry(atpoint, alignFrame);
106         break;
107     case SEQUENCEANNOTATIONWSCLIENT:
108         new SequenceAnnotationWSClient().attachWSMenuEntry(atpoint, this,
109                 alignFrame);
110       break;
111     default:
112       Cache.log.warn("Implementation error ? Service " + getName()
113               + " has Unknown service style " + style);
114     }
115   }
116 }