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.UIinfo;
27 import jalview.ws.jws2.JabaParamStore;
28 import jalview.ws.jws2.MsaWSClient;
29 import jalview.ws.jws2.SequenceAnnotationWSClient;
30 import jalview.ws.params.ParamDatastoreI;
32 import java.io.Closeable;
34 import javax.swing.JMenu;
36 import compbio.data.msa.JABAService;
37 import compbio.data.msa.MsaWS;
38 import compbio.data.msa.SequenceAnnotation;
39 import compbio.metadata.PresetManager;
40 import compbio.metadata.RunnerConfig;
42 public class Jws2Instance extends UIinfo
45 public JABAService service;
54 * Category for this service's analysis
56 * text describing their action that service performs (eg 'aligning',
59 * Description from JABAWS registry
61 * JABAWS registry ID for service
63 public Jws2Instance(String hosturl, String serviceType, String action,
64 String description, JABAService service)
66 super(action, action, serviceType, description, hosturl);
67 this.service = service;
68 int p = description.indexOf("MORE INFORMATION:");
71 docUrl = description.substring(description.indexOf("http", p)).trim();
72 if (docUrl.indexOf('\n') > -1)
74 docUrl = docUrl.substring(0, docUrl.indexOf("\n")).trim();
80 PresetManager presets = null;
82 public JabaParamStore paramStore = null;
85 * non thread safe - gets the presets for this service (blocks whilst it calls
86 * the service to get the preset set)
88 * @return service presets or null if exceptions were raised.
90 public PresetManager getPresets()
96 if (service instanceof MsaWS<?>)
98 presets = ((MsaWS) service).getPresets();
101 if (service instanceof SequenceAnnotation<?>)
103 presets = ((SequenceAnnotation) service).getPresets();
105 } catch (Exception ex)
107 System.err.println("Exception when retrieving presets for service "
108 + getServiceType() + " at " + getHostURL());
115 * non-thread safe - blocks whilst accessing service to get complete set of
116 * available options and parameters
120 public RunnerConfig getRunnerConfig()
122 if (service instanceof MsaWS<?>)
124 return ((MsaWS) service).getRunnerOptions();
126 if (service instanceof SequenceAnnotation<?>)
128 return ((SequenceAnnotation) service).getRunnerOptions();
130 throw new Error(MessageManager.formatMessage(
131 "error.implementation_error_runner_config_not_available",
133 { getServiceType(), service.getClass().toString() }));
137 protected void finalize() throws Throwable
143 ((Closeable) service).close();
144 } catch (Throwable t)
152 public ParamDatastoreI getParamStore()
154 if (paramStore == null)
158 paramStore = new JabaParamStore(this,
159 (Desktop.instance != null ? Desktop.getUserParameterStore()
161 } catch (Exception ex)
163 System.err.println("Unexpected exception creating JabaParamStore.");
164 ex.printStackTrace();
171 public String getUri()
173 // TODO verify that service parameter sets in projects are consistent with
175 // this is only valid for Jaba 1.0 - this formula might have to change!
177 + (getHostURL().lastIndexOf("/") == (getHostURL().length() - 1)
183 private boolean hasParams = false, lookedForParams = false;
185 public boolean hasParameters()
187 if (!lookedForParams)
189 lookedForParams = true;
192 hasParams = (getRunnerConfig().getArguments().size() > 0);
193 } catch (Exception e)
201 public void attachWSMenuEntry(JMenu atpoint, AlignFrame alignFrame)
203 if (service instanceof MsaWS<?>)
205 new MsaWSClient().attachWSMenuEntry(atpoint, this, alignFrame);
207 else if (service instanceof SequenceAnnotation<?>)
209 new SequenceAnnotationWSClient().attachWSMenuEntry(atpoint, this,
214 public String getNameURI()
216 return "java:" + getName();
219 jalview.ws.uimodel.AlignAnalysisUIText aaui;
221 public jalview.ws.uimodel.AlignAnalysisUIText getAlignAnalysisUI()