diff --git a/src/main/java/org/gcube/data/analysis/wps/GetCapabilitiesBuilder.java b/src/main/java/org/gcube/data/analysis/wps/GetCapabilitiesBuilder.java
index 5c6ee40..f7c3f56 100644
--- a/src/main/java/org/gcube/data/analysis/wps/GetCapabilitiesBuilder.java
+++ b/src/main/java/org/gcube/data/analysis/wps/GetCapabilitiesBuilder.java
@@ -1,7 +1,6 @@
package org.gcube.data.analysis.wps;
import java.io.InputStream;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -11,7 +10,7 @@ import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.wps.repository.GcubeAlgorithmRepository;
-import org.gcube.dataanalysis.ecoengine.processing.factories.ProcessorsFactory;
+import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.algorithms.AlgorithmClassification;
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.infrastructure.InfrastructureDialoguer;
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.ConfigurationManager;
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.TokenManager;
@@ -21,43 +20,14 @@ import org.slf4j.LoggerFactory;
public class GetCapabilitiesBuilder {
- public static String processString = "\n\t#CLASS#\n\t#TITLE#\n";
-
+ public static final String processString = "\n\t#CLASS#\n\t#TITLE#\n";
+
private static final Logger LOGGER= LoggerFactory.getLogger(GetCapabilitiesBuilder.class);
-
- public String getClassification(String algorithmName, ConfigurationManager configManager) throws Exception{
- //get algorithms classification:
- LOGGER.debug("Searching for a classification of "+algorithmName);
- HashMap> algorithmsClassification = ProcessorsFactory.getAllFeaturesUser(configManager.getConfig());
- String rightClassification = "Others";
- for (String classification:algorithmsClassification.keySet()){
- List algorithms = algorithmsClassification.get(classification);
- if (algorithms.contains(algorithmName)){
- LOGGER.debug("Found classification"+classification);
- return classification;
- }
- }
- LOGGER.debug("No classification found for "+algorithmName);
- return rightClassification;
- }
-
+
+
public String buildGetCapabilities(Map parameters) throws Exception {
LinkedHashMap basicInputs = new LinkedHashMap();
- //DONE get scope and username from SmartGears to build the get capabilities
- /* OLD CODE
- if (parameters != null) {
- if (parameters.get(ConfigurationManager.scopeParameter) != null)
- basicInputs.put(ConfigurationManager.scopeParameter, parameters.get(ConfigurationManager.scopeParameter)[0]);
- if (parameters.get(ConfigurationManager.usernameParameter) != null)
- basicInputs.put(ConfigurationManager.usernameParameter, parameters.get(ConfigurationManager.usernameParameter)[0]);
- } else {// case for testing purposes only
- if (AbstractEcologicalEngineMapper.simulationMode){
- basicInputs.put(ConfigurationManager.scopeParameter, ConfigurationManager.defaultScope);
- basicInputs.put(ConfigurationManager.usernameParameter, ConfigurationManager.defaultUsername);
- }
- }
- */
ConfigurationManager configManager = new ConfigurationManager();
TokenManager tokenm = new TokenManager();
tokenm.getCredentials();
@@ -67,63 +37,50 @@ public class GetCapabilitiesBuilder {
basicInputs.put(ConfigurationManager.scopeParameter, scope);
basicInputs.put(ConfigurationManager.usernameParameter, username);
basicInputs.put(ConfigurationManager.tokenParameter, token);
-
+
configManager.configAlgorithmEnvironment(basicInputs);
LOGGER.debug("Initializing Capabilities Skeleton in scope " + configManager.getScope() + " with user " + configManager.getUsername());
InputStream is = this.getClass().getClassLoader().getResourceAsStream("templates/wpsCapabilitiesSkeleton.xml");
String stringTemplate = IOUtils.toString(is, "UTF-8");
-
+
//TODO: GET HOSTNAME AND PORT from container
String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
stringTemplate = stringTemplate.replace("#HOST#", host).replace("#PORT#", port);
LOGGER.debug("Host: " + host + " Port: " + port);
-
- LinkedHashMap allalgorithms = new LinkedHashMap();
- /*
- String packageS = "org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses";
- List> classes = null;
- try{
- LOGGER.debug("Taking classes from /classes");
- classes = GetCapabilitiesChecker.find(packageS);
- }catch(Exception e){
- LOGGER.debug("Taking classes from the Jar");
- classes=GetCapabilitiesChecker.getClassesInSamePackageFromJar(packageS);
- }*/
-
- LOGGER.info("using classloader class {} ",Thread.currentThread().getContextClassLoader().getClass().getSimpleName());
-
-
- Set> algorithmsClass = GcubeAlgorithmRepository.getAllAlgorithms();
-
- LOGGER.info("class found with annotation Algorithm are {}",algorithmsClass.size());
-
- for (Class> classfind : algorithmsClass) {
- org.n52.wps.algorithm.annotation.Algorithm algorithmInfo = classfind.getAnnotation(org.n52.wps.algorithm.annotation.Algorithm.class);
- if (algorithmInfo != null) {
- LOGGER.debug("Retrieving local declared Algorithm: " + algorithmInfo.title());
- allalgorithms.put(algorithmInfo.title(), classfind.getName());
- }
- }
LOGGER.debug("Getting algorithms from the infrastructure");
InfrastructureDialoguer dialoguer = new InfrastructureDialoguer(configManager.getScope());
List algorithmsInScope = dialoguer.getAlgorithmsInScope();
LOGGER.debug("Found {} algorithms in scope {} ",algorithmsInScope.size() ,ScopeProvider.instance.get());
StringBuffer capabilities = new StringBuffer();
-
+
//TO eliminate duplicate coming from IS
Set algorithmsSet = new HashSet(algorithmsInScope);
-
- for (String algorithmInScope : algorithmsSet ) {
- String classAlgorithm = allalgorithms.get(algorithmInScope);
- if (classAlgorithm != null) {
- LOGGER.debug("Approving " + classAlgorithm + " to capabilities ");
- String algorithmTitle = getClassification(algorithmInScope, configManager)+":"+algorithmInScope;
-// String algorithmTitle = algorithmInScope;
- capabilities.append(processString.replace("#TITLE#", algorithmTitle).replace("#CLASS#", classAlgorithm));
+
+
+ LOGGER.info("using classloader class {} ",Thread.currentThread().getContextClassLoader().getClass().getSimpleName());
+
+ Set> algorithmsClass = GcubeAlgorithmRepository.getAllAlgorithms();
+
+ LOGGER.info("class found with annotation Algorithm are {}",algorithmsClass.size());
+
+ for (Class> classfound : algorithmsClass) {
+ org.n52.wps.algorithm.annotation.Algorithm algorithmInfo = classfound.getAnnotation(org.n52.wps.algorithm.annotation.Algorithm.class);
+ if (algorithmInfo != null) {
+ LOGGER.debug("Retrieving local declared Algorithm: " + algorithmInfo.title());
+ String classification = "Others";
+ if (classfound.isAnnotationPresent(AlgorithmClassification.class))
+ classification = classfound.getAnnotation(AlgorithmClassification.class).value();
+
+ if (algorithmsSet.contains(algorithmInfo.title())){
+ String algorithmTitle = String.format("%s:%s", classification, algorithmInfo.title());
+ capabilities.append(processString.replace("#TITLE#", algorithmTitle).replace("#CLASS#", classfound.getName()));
+ }
}
+
+
}
stringTemplate = stringTemplate.replace("#PROCESSES#", capabilities.toString());
@@ -131,6 +88,4 @@ public class GetCapabilitiesBuilder {
return stringTemplate;
}
-
-
}
diff --git a/src/main/webapp/WEB-INF/README b/src/main/webapp/WEB-INF/README
index 89e12de..77c91ca 100644
--- a/src/main/webapp/WEB-INF/README
+++ b/src/main/webapp/WEB-INF/README
@@ -25,7 +25,7 @@ no. 654119), SoBigData (grant no. 654024);
Version
--------------------------------------------------
-1.1.0-SNAPSHOT (2017-10-11)
+1.1.0-SNAPSHOT (${maven.build.timestamp})
Please see the file named "changelog.xml" in this directory for the release notes.