29a8b9244cc1240ca3adde2aa5851df1595a06b6
[jalview.git] / src / jalview / ws / WSClient.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.ws;
20
21 import ext.vamsas.*;
22 import jalview.gui.*;
23
24 public class WSClient
25 {
26   /**
27    * WSClient holds the basic attributes that are displayed to the user
28    * for all jalview web service clients
29    */
30   /**
31    * displayed name for this web service
32    */
33   protected String WebServiceName;
34   /**
35    * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment from Cut and Paste input')
36    */
37   protected String WebServiceJobTitle;
38   /**
39    * String giving additional information such as method citations for this service 
40    */
41   protected String WebServiceReference;
42   /**
43    * Service endpoint
44    */
45   protected String WsURL;
46   /**
47    * Web service information used to initialise the WSClient attributes
48    */
49   protected WebserviceInfo wsInfo;
50   /**
51    * total number of jobs managed by this web service client instance. 
52    */
53   int jobsRunning = 0;
54   /**
55    * TODO: this is really service metadata, and should be moved elsewhere.
56    * mappings between abstract interface names and menu entries
57    */
58   protected java.util.Hashtable ServiceActions;
59   {
60     ServiceActions = new java.util.Hashtable();
61     ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
62     ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
63   };
64   public WSClient()
65   {
66   }
67   /**
68    * initialise WSClient service information attributes from the service handle
69    * @param sh
70    * @return the service instance information GUI for this client and job.
71    */
72   protected WebserviceInfo setWebService(ServiceHandle sh)
73   {
74     return setWebService(sh, false);
75   }
76     /**
77      * initialise WSClient service information attributes from the service handle
78      * @param sh
79      * @param headless true implies no GUI objects will be created.
80      * @return the service instance information GUI for this client and job.
81      */
82   protected WebserviceInfo setWebService(ServiceHandle sh, boolean headless)
83   {
84     WebServiceName = sh.getName();
85     if (ServiceActions.containsKey(sh.getAbstractName()))
86     {
87       WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification properly
88       // add this for short names. +(String) ServiceActions.get(sh.getAbstractName());
89     }
90     else
91     {
92       WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName();
93
94     }
95     WebServiceReference = sh.getDescription();
96     WsURL = sh.getEndpointURL();
97     WebserviceInfo wsInfo = null;
98     if (!headless)
99     {
100       wsInfo = new WebserviceInfo(WebServiceJobTitle,
101                                                WebServiceReference);
102     }
103     return wsInfo;
104   }
105 }