2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.jws2.jabaws2;
23 import jalview.gui.AlignFrame;
24 import jalview.gui.Desktop;
25 import jalview.util.MessageManager;
26 import jalview.ws.api.JalviewServiceEndpointProviderI;
27 import jalview.ws.api.ServiceWithParameters;
28 import jalview.ws.jws2.JabaParamStore;
29 import jalview.ws.jws2.MsaWSClient;
30 import jalview.ws.jws2.SequenceAnnotationWSClient;
31 import jalview.ws.params.ParamDatastoreI;
32 import jalview.ws.params.ParamManager;
34 import java.io.Closeable;
36 import javax.swing.JMenu;
38 import compbio.data.msa.JABAService;
39 import compbio.data.msa.MsaWS;
40 import compbio.data.msa.SequenceAnnotation;
41 import compbio.metadata.PresetManager;
42 import compbio.metadata.RunnerConfig;
44 public class Jws2Instance extends ServiceWithParameters
45 implements JalviewServiceEndpointProviderI
48 public JABAService service;
57 * Category for this service's analysis
59 * text describing their action that service performs (eg 'aligning',
62 * Description from JABAWS registry
64 * JABAWS registry ID for service
66 public Jws2Instance(String hosturl, String serviceType, String action,
67 String description, JABAService service)
69 super(action, action, serviceType, description, hosturl);
70 this.service = service;
71 int p = description.indexOf("MORE INFORMATION:");
74 docUrl = description.substring(description.indexOf("http", p)).trim();
75 if (docUrl.indexOf('\n') > -1)
77 docUrl = docUrl.substring(0, docUrl.indexOf("\n")).trim();
83 PresetManager presets = null;
85 public JabaParamStore paramStore = null;
88 * non thread safe - gets the presets for this service (blocks whilst it calls
89 * the service to get the preset set)
91 * @return service presets or null if exceptions were raised.
93 public PresetManager getPresets()
99 if (service instanceof MsaWS<?>)
101 presets = ((MsaWS) service).getPresets();
104 if (service instanceof SequenceAnnotation<?>)
106 presets = ((SequenceAnnotation) service).getPresets();
108 } catch (Exception ex)
110 System.err.println("Exception when retrieving presets for service "
111 + getServiceType() + " at " + getHostURL());
118 * non-thread safe - blocks whilst accessing service to get complete set of
119 * available options and parameters
123 public RunnerConfig getRunnerConfig()
125 if (service instanceof MsaWS<?>)
127 return ((MsaWS) service).getRunnerOptions();
129 if (service instanceof SequenceAnnotation<?>)
131 return ((SequenceAnnotation) service).getRunnerOptions();
133 throw new Error(MessageManager.formatMessage(
134 "error.implementation_error_runner_config_not_available",
136 { getServiceType(), service.getClass().toString() }));
140 protected void finalize() throws Throwable
146 ((Closeable) service).close();
147 } catch (Throwable t)
156 public ParamDatastoreI getParamStore()
158 if (paramStore == null)
162 paramStore = new JabaParamStore(this,
163 (Desktop.instance != null ? Desktop.getUserParameterStore()
165 } catch (Exception ex)
167 System.err.println("Unexpected exception creating JabaParamStore.");
168 ex.printStackTrace();
175 public String getUri()
177 // TODO verify that service parameter sets in projects are consistent with
179 // this is only valid for Jaba 1.0 - this formula might have to change!
181 + (getHostURL().lastIndexOf("/") == (getHostURL().length() - 1)
187 private boolean hasParams = false, lookedForParams = false;
190 public boolean hasParameters()
192 if (!lookedForParams)
194 lookedForParams = true;
197 hasParams = (getRunnerConfig().getArguments().size() > 0);
198 } catch (Exception e)
206 public void attachWSMenuEntry(JMenu atpoint, AlignFrame alignFrame)
208 if (service instanceof MsaWS<?>)
210 new MsaWSClient().attachWSMenuEntry(atpoint, this, alignFrame);
212 else if (service instanceof SequenceAnnotation<?>)
214 new SequenceAnnotationWSClient().attachWSMenuEntry(atpoint, this,
219 public String getNameURI()
221 return "java:" + getName();
224 jalview.ws.uimodel.AlignAnalysisUIText aaui;
226 public jalview.ws.uimodel.AlignAnalysisUIText getAlignAnalysisUI()
232 * initialise a parameter store for this service
234 * @param userParameterStore
235 * - the user ParamManager (e.g. Desktop.getUserParameterStore() )
238 public void initParamStore(ParamManager userParameterStore)
240 if (paramStore == null)
242 paramStore = new JabaParamStore(this, userParameterStore);
247 * an object that implements one or more interfaces in jalview.ws.api
252 public Object getEndpoint()
258 if (service instanceof MsaWS<?>)
260 return new JabawsMsaInstance(this);
263 // service is for sequence analysis