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.Desktop;
24 import jalview.util.MessageManager;
25 import jalview.ws.api.JalviewServiceEndpointProviderI;
26 import jalview.ws.api.ServiceWithParameters;
27 import jalview.ws.jws2.JabaParamStore;
28 import jalview.ws.params.ParamDatastoreI;
29 import jalview.ws.params.ParamManager;
31 import java.io.Closeable;
34 import compbio.data.msa.JABAService;
35 import compbio.data.msa.MsaWS;
36 import compbio.data.msa.SequenceAnnotation;
37 import compbio.metadata.PresetManager;
38 import compbio.metadata.RunnerConfig;
40 public class Jws2Instance extends ServiceWithParameters
41 implements AutoCloseable
44 public JABAService service;
51 * Category for this service's analysis
53 * text describing their action that service performs (eg 'aligning',
56 * Description from JABAWS registry
58 * JABAWS registry ID for service
60 public Jws2Instance(String hosturl, String serviceType, String action,
61 String description, JABAService service)
63 super(action, action, serviceType, description, hosturl);
64 this.service = service;
65 if (service instanceof MsaWS<?>)
67 style = ServiceClient.MSAWSCLIENT;
69 else if (service instanceof SequenceAnnotation<?>)
71 style = ServiceClient.SEQUENCEANNOTATIONWSCLIENT;
74 int p = description.indexOf("MORE INFORMATION:");
77 String docUrl = description.substring(description.indexOf("http", p))
79 if (docUrl.indexOf('\n') > -1)
81 docUrl = docUrl.substring(0, docUrl.indexOf("\n")).trim();
83 if (docUrl.length() > 0)
87 URL url = new URL(docUrl);
90 setDocumentationUrl(docUrl);
101 PresetManager presets = null;
103 public JabaParamStore paramStore = null;
106 * non thread safe - gets the presets for this service (blocks whilst it calls
107 * the service to get the preset set)
109 * @return service presets or null if exceptions were raised.
111 public PresetManager getPresets()
117 if (service instanceof MsaWS<?>)
119 presets = ((MsaWS) service).getPresets();
122 if (service instanceof SequenceAnnotation<?>)
124 presets = ((SequenceAnnotation) service).getPresets();
126 } catch (Exception ex)
128 System.err.println("Exception when retrieving presets for service "
129 + getServiceType() + " at " + getHostURL());
136 * non-thread safe - blocks whilst accessing service to get complete set of
137 * available options and parameters
141 public RunnerConfig getRunnerConfig()
143 if (service instanceof MsaWS<?>)
145 return ((MsaWS) service).getRunnerOptions();
147 if (service instanceof SequenceAnnotation<?>)
149 return ((SequenceAnnotation) service).getRunnerOptions();
151 throw new Error(MessageManager.formatMessage(
152 "error.implementation_error_runner_config_not_available",
154 { getServiceType(), service.getClass().toString() }));
164 ((Closeable) service).close();
165 } catch (Throwable t)
174 public ParamDatastoreI getParamStore()
176 if (paramStore == null)
180 paramStore = new JabaParamStore(this,
181 (Desktop.getInstance() != null ? Desktop.getUserParameterStore()
183 } catch (Exception ex)
185 System.err.println("Unexpected exception creating JabaParamStore.");
186 ex.printStackTrace();
193 private boolean hasParams = false, lookedForParams = false;
196 public boolean hasParameters()
198 if (!lookedForParams)
200 lookedForParams = true;
203 hasParams = (getRunnerConfig().getArguments().size() > 0);
204 } catch (Exception e)
213 * initialise a parameter store for this service
215 * @param userParameterStore
216 * - the user ParamManager (e.g. Desktop.getUserParameterStore() )
219 public void initParamStore(ParamManager userParameterStore)
221 if (paramStore == null)
223 paramStore = new JabaParamStore(this, userParameterStore);
228 * an object that implements one or more interfaces in jalview.ws.api
233 public Object getEndpoint()
235 if (service instanceof MsaWS<?>)
240 "JABAWS MsaWS based instant calculation not implemented.");
245 return new JabawsMsaInstance(this);
250 if (service instanceof compbio.data.msa.SequenceAnnotation)
256 // probably a factory would be nicer but..
257 return aaui.getClient().getConstructor(getClass())
259 } catch (Throwable t)
261 throw new Error("Implementation Error in web service framework",
265 return new AADisorderClient(this);