package jalview.ws.rest;
import jalview.bin.Cache;
-import jalview.bin.ApplicationSingletonProvider;
-import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.datamodel.AlignmentView;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
*
*/
public class RestClient extends WSClient
- implements WSClientI, WSMenuEntryProviderI, ApplicationSingletonI
+ implements WSClientI, WSMenuEntryProviderI
{
- public static final String RSBS_SERVICES = "RSBS_SERVICES";
-
RestServiceDescription service;
+ public RestClient(RestServiceDescription rsd)
+ {
+ service = rsd;
+ }
+
/**
* parent alignframe for this job
*/
*/
AlignViewport av;
- boolean headless = false;
-
- protected Vector<String> services = null;
-
- private static RestClient getInstance()
- {
- return (RestClient) ApplicationSingletonProvider.getInstance(RestClient.class);
- }
-
- public static RestClient makeShmmrRestClient()
- {
- String action = "Analysis",
- description = "Sequence Harmony and Multi-Relief (Brandt et al. 2010)",
- name = MessageManager.getString("label.multiharmony");
- Hashtable<String, InputType> iparams = new Hashtable<>();
- // jalview.ws.rest.params.JobConstant toolp;
- // toolp = new jalview.ws.rest.JobConstant("tool","jalview");
- // iparams.put(toolp.token, toolp);
- // toolp = new jalview.ws.rest.params.JobConstant("mbjob[method]","shmr");
- // iparams.put(toolp.token, toolp);
- // toolp = new
- // jalview.ws.rest.params.JobConstant("mbjob[description]","step 1");
- // iparams.put(toolp.token, toolp);
- // toolp = new jalview.ws.rest.params.JobConstant("start_search","1");
- // iparams.put(toolp.token, toolp);
- // toolp = new jalview.ws.rest.params.JobConstant("blast","0");
- // iparams.put(toolp.token, toolp);
-
- jalview.ws.rest.params.Alignment aliinput = new jalview.ws.rest.params.Alignment();
- // SHMR server has a 65K limit for content pasted into the 'ali' parameter,
- // so we always upload our files.
- aliinput.token = "ali_file";
- aliinput.writeAsFile = true;
- iparams.put(aliinput.token, aliinput);
- jalview.ws.rest.params.SeqGroupIndexVector sgroups = new jalview.ws.rest.params.SeqGroupIndexVector();
- sgroups.setMinsize(2);
- sgroups.min = 2;// need at least two group defined to make a partition
- iparams.put("groups", sgroups);
- sgroups.token = "groups";
- sgroups.sep = " ";
- RestServiceDescription shmrService = new RestServiceDescription(action,
- description, name,
- "http://zeus.few.vu.nl/programs/shmrwww/index.php?tool=jalview", // ?tool=jalview&mbjob[method]=shmr&mbjob[description]=step1",
- "?tool=jalview", iparams, true, false, '-');
- // a priori knowledge of the data returned from the service
- shmrService.addResultDatatype(JvDataType.ANNOTATION);
- return new RestClient(shmrService);
- }
-
- public static RestClient[] getRestClients()
- {
- RestClient c = getInstance();
-
- if (c.services == null)
- {
- c.services = new Vector<>();
- try
- {
- for (RestServiceDescription descr : RestServiceDescription
- .parseDescriptions(
- jalview.bin.Cache.getDefault(RSBS_SERVICES,
- makeShmmrRestClient().service.toString())))
- {
- c.services.add(descr.toString());
- }
- } catch (Exception ex)
- {
- System.err.println(
- "Serious - RSBS descriptions in user preferences are corrupt!");
- ex.printStackTrace();
- }
-
- }
- RestClient[] lst = new RestClient[c.services.size()];
- int i = 0;
- for (String svc : c.services)
- {
- lst[i++] = new RestClient(new RestServiceDescription(svc));
- }
- return lst;
- }
-
- public static Vector<String> getRsbsDescriptions()
- {
- Vector<String> rsbsDescrs = new Vector<>();
- for (RestClient rsbs : getRestClients())
- {
- rsbsDescrs.add(rsbs.getRestDescription().toString());
- }
- return rsbsDescrs;
- }
-
- public static void setRsbsServices(Vector<String> rsbsUrls)
- {
- if (rsbsUrls != null)
- {
- // TODO: consider validating services ?
- RestClient c = getInstance();
- c.services = new Vector<>(rsbsUrls);
- StringBuffer sprop = new StringBuffer();
- for (String s : c.services)
- {
- sprop.append(s);
- }
- Cache.setProperty(RSBS_SERVICES, sprop.toString());
- }
- else
- {
- Cache.removeProperty(RSBS_SERVICES);
- }
- }
-
/**
* get the alignFrame for the associated input data if it exists.
*
return jalview.gui.Desktop.getAlignFrameFor(av);
}
- private RestClient()
- {
-
- }
-
- public RestClient(RestServiceDescription rsd)
- {
- service = rsd;
- }
-
public RestClient(RestServiceDescription service2, AlignFrame alignFrame)
{
this(service2, alignFrame, false);
}
+ boolean headless = false;
+
public RestClient(RestServiceDescription service2, AlignFrame alignFrame,
boolean nogui)
{
else
{
// TODO: try to tell the user why the job couldn't be started.
- JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
+ JvOptionPane.showMessageDialog(Desktop.desktop,
(jobsthread.hasWarnings() ? jobsthread.getWarnings()
: MessageManager.getString(
"label.job_couldnt_be_started_check_input")),
}
}
+ public static RestClient makeShmmrRestClient()
+ {
+ String action = "Analysis",
+ description = "Sequence Harmony and Multi-Relief (Brandt et al. 2010)",
+ name = MessageManager.getString("label.multiharmony");
+ Hashtable<String, InputType> iparams = new Hashtable<String, InputType>();
+ jalview.ws.rest.params.JobConstant toolp;
+ // toolp = new jalview.ws.rest.JobConstant("tool","jalview");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("mbjob[method]","shmr");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new
+ // jalview.ws.rest.params.JobConstant("mbjob[description]","step 1");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("start_search","1");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("blast","0");
+ // iparams.put(toolp.token, toolp);
+
+ jalview.ws.rest.params.Alignment aliinput = new jalview.ws.rest.params.Alignment();
+ // SHMR server has a 65K limit for content pasted into the 'ali' parameter,
+ // so we always upload our files.
+ aliinput.token = "ali_file";
+ aliinput.writeAsFile = true;
+ iparams.put(aliinput.token, aliinput);
+ jalview.ws.rest.params.SeqGroupIndexVector sgroups = new jalview.ws.rest.params.SeqGroupIndexVector();
+ sgroups.setMinsize(2);
+ sgroups.min = 2;// need at least two group defined to make a partition
+ iparams.put("groups", sgroups);
+ sgroups.token = "groups";
+ sgroups.sep = " ";
+ RestServiceDescription shmrService = new RestServiceDescription(action,
+ description, name,
+ "http://zeus.few.vu.nl/programs/shmrwww/index.php?tool=jalview", // ?tool=jalview&mbjob[method]=shmr&mbjob[description]=step1",
+ "?tool=jalview", iparams, true, false, '-');
+ // a priori knowledge of the data returned from the service
+ shmrService.addResultDatatype(JvDataType.ANNOTATION);
+ return new RestClient(shmrService);
+ }
+
public AlignmentPanel recoverAlignPanelForView()
{
AlignmentPanel[] aps = Desktop
return true;
}
+ protected static Vector<String> services = null;
+
+ public static final String RSBS_SERVICES = "RSBS_SERVICES";
+
+ public static RestClient[] getRestClients()
+ {
+ if (services == null)
+ {
+ services = new Vector<String>();
+ try
+ {
+ for (RestServiceDescription descr : RestServiceDescription
+ .parseDescriptions(
+ jalview.bin.Cache.getDefault(RSBS_SERVICES,
+ makeShmmrRestClient().service.toString())))
+ {
+ services.add(descr.toString());
+ }
+ } catch (Exception ex)
+ {
+ System.err.println(
+ "Serious - RSBS descriptions in user preferences are corrupt!");
+ ex.printStackTrace();
+ }
+
+ }
+ RestClient[] lst = new RestClient[services.size()];
+ int i = 0;
+ for (String svc : services)
+ {
+ lst[i++] = new RestClient(new RestServiceDescription(svc));
+ }
+ return lst;
+ }
+
public String getAction()
{
return service.details.Action;
return service;
}
+ public static Vector<String> getRsbsDescriptions()
+ {
+ Vector<String> rsbsDescrs = new Vector<String>();
+ for (RestClient rsbs : getRestClients())
+ {
+ rsbsDescrs.add(rsbs.getRestDescription().toString());
+ }
+ return rsbsDescrs;
+ }
+
+ public static void setRsbsServices(Vector<String> rsbsUrls)
+ {
+ if (rsbsUrls != null)
+ {
+ // TODO: consider validating services ?
+ services = new Vector<String>(rsbsUrls);
+ StringBuffer sprop = new StringBuffer();
+ for (String s : services)
+ {
+ sprop.append(s);
+ }
+ Cache.setProperty(RSBS_SERVICES, sprop.toString());
+ }
+ else
+ {
+ Cache.removeProperty(RSBS_SERVICES);
+ }
+ }
+
}