javadoc for webservice client tutorial
[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 for this client and job.
71    */
72   protected WebserviceInfo setWebService(ServiceHandle sh)
73   {
74     WebServiceName = sh.getName();
75     if (ServiceActions.containsKey(sh.getAbstractName()))
76     {
77       WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification properly
78       // add this for short names. +(String) ServiceActions.get(sh.getAbstractName());
79     }
80     else
81     {
82       WebServiceJobTitle = sh.getAbstractName() + " using " + sh.getName();
83
84     }
85     WebServiceReference = sh.getDescription();
86     WsURL = sh.getEndpointURL();
87     WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
88                                                WebServiceReference);
89
90     return wsInfo;
91   }
92 }