+ CompletableFuture<WSDiscovererI> task = CompletableFuture
+ .supplyAsync(() -> {
+ reloadServices();
+ return SlivkaWSDiscoverer.this;
+ }, executor);
+ discoveryTasks.add(task);
+ return task;
+ }
+
+ private List<ServiceWithParameters> reloadServices()
+ {
+ Console.info("Reloading Slivka services");
+ notifyServiceListeners(Collections.emptyList());
+ ArrayList<ServiceWithParameters> instances = new ArrayList<>();
+
+ for (String url : getServiceUrls())
+ {
+ SlivkaClient client = SlivkaClient.newInstance(url);
+
+ List<SlivkaService> services;
+ try
+ {
+ services = client.getServices();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ continue;
+ }
+ for (SlivkaService service : services)
+ {
+ SlivkaWSInstance newInstance = null;
+ for (String classifier : service.classifiers)
+ {
+ String[] path = classifier.split("\\s*::\\s*");
+ if (path.length >= 3 && path[0].toLowerCase().equals("operation")
+ && path[1].toLowerCase().equals("analysis"))
+ {
+ switch (path[path.length - 1].toLowerCase())
+ {
+ case "rna secondary structure prediction":
+ newInstance = new RNAalifoldServiceInstance(client,
+ service, "Secondary Structure Prediction");
+ break;
+ case "sequence alignment analysis (conservation)":
+ newInstance = new SlivkaAnnotationServiceInstance(client,
+ service, Category.CATEGORY_CONSERVATION);
+ break;
+ case "protein sequence analysis":
+ newInstance = new SlivkaAnnotationServiceInstance(client,
+ service, Category.CATEGORY_DISORDER);
+ break;
+ case "protein secondary structure prediction":
+ newInstance = new SlivkaAnnotationServiceInstance(client,
+ service, "Secondary Structure Prediction");
+ break;
+ case "multiple sequence alignment":
+ newInstance = new SlivkaMsaServiceInstance(client, service,
+ Category.CATEGORY_ALIGNMENT);
+ break;
+ }
+ }
+ if (newInstance != null)
+ break;
+ }
+ if (newInstance != null)
+ instances.add(newInstance);
+ }
+ }
+
+ services = instances;
+ Console.info("Slivka services reloading finished");
+ notifyServiceListeners(instances);
+ return instances;
+ }
+
+ @Override
+ public List<ServiceWithParameters> getServices()
+ {
+ return services;
+ }
+
+ @Override
+ public boolean hasServices()
+ {
+ return !isRunning() && services.size() > 0;