diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/ExecutorServiceConfig.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/ExecutorServiceConfig.java deleted file mode 100644 index 78da24f79..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/ExecutorServiceConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package eu.eudat.configurations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Created by ikalyvas on 9/26/2018. - */ -@Configuration -public class ExecutorServiceConfig { - - @Bean - public Executor asyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(2); - executor.setMaxPoolSize(2); - executor.setQueueCapacity(500); - executor.setThreadNamePrefix("Rules-"); - executor.initialize(); - return executor; - } -} \ No newline at end of file diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfiguration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfiguration.java deleted file mode 100644 index 4a7f08672..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.eudat.configurations.dynamicfunder; - -import eu.eudat.configurations.dynamicfunder.entities.Configuration; -import eu.eudat.models.data.dynamicfields.DynamicField; - -import java.util.List; - -public interface DynamicFunderConfiguration { - Configuration getConfiguration(); - - List getFields(); -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationDevelImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationDevelImpl.java deleted file mode 100644 index eca3ab522..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationDevelImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package eu.eudat.configurations.dynamicfunder; - -import eu.eudat.configurations.dynamicfunder.entities.Configuration; -import eu.eudat.configurations.dynamicfunder.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; - -@Service("dynamicFunderConfiguration") -@Profile("devel") -public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfiguration { - private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationDevelImpl.class); - - private Configuration configuration; - private List fields; - private Environment environment; - - public DynamicFunderConfigurationDevelImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL("file:///"+ current + "/web/src/main/resources/FunderConfiguration.xml").openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationProdImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationProdImpl.java deleted file mode 100644 index 30f2124a5..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/DynamicFunderConfigurationProdImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package eu.eudat.configurations.dynamicfunder; - -import eu.eudat.configurations.dynamicfunder.entities.Configuration; -import eu.eudat.configurations.dynamicfunder.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Paths; -import java.util.LinkedList; -import java.util.List; - -@Service("dynamicFunderConfiguration") -@Profile({ "production", "staging", "docker" }) -public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration { - private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationProdImpl.class); - - private Configuration configuration; - private List fields; - private Environment environment; - - public DynamicFunderConfigurationProdImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Configuration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Configuration.java deleted file mode 100644 index 3a65659c1..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Configuration.java +++ /dev/null @@ -1,31 +0,0 @@ -package eu.eudat.configurations.dynamicfunder.entities; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import jakarta.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement -public class Configuration { - private List configurationProperties; - private MainProperty mainExternalField; - - public MainProperty getMainExternalField() { - return mainExternalField; - } - - @XmlElement(name = "mainExternalField") - public void setMainExternalField(MainProperty mainExternalField) { - this.mainExternalField = mainExternalField; - } - - public List getConfigurationProperties() { - return configurationProperties; - } - - @XmlElementWrapper - @XmlElement(name = "property") - public void setConfigurationProperties(List configurationProperties) { - this.configurationProperties = configurationProperties; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Dependency.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Dependency.java deleted file mode 100644 index 0d7288ec9..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Dependency.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.eudat.configurations.dynamicfunder.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -public class Dependency { - private String id; - private String queryProperty; - - public String getId() { - return id; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Language.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Language.java deleted file mode 100644 index 1dfd36c00..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Language.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.eudat.configurations.dynamicfunder.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -public class Language { - private String key; - private String languageKey; - - public String getKey() { - return key; - } - - @XmlElement(name = "key") - public void setKey(String key) { - this.key = key; - } - - public String getLanguageKey() { - return languageKey; - } - - @XmlElement(name = "languageKey") - public void setLanguageKey(String languageKey) { - this.languageKey = languageKey; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/MainProperty.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/MainProperty.java deleted file mode 100644 index 285a3fb37..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/MainProperty.java +++ /dev/null @@ -1,103 +0,0 @@ -package eu.eudat.configurations.dynamicfunder.entities; - -import eu.eudat.service.remotefetcher.config.UrlConfiguration; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -public class MainProperty { - private String id; - private String name; - private String queryProperty; - private String externalFieldId; - private List urlConfig; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - private List language; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } - - public List getUrlConfig() { - return urlConfig; - } - - @XmlElement(name = "urlConfig") - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; - } - - public List getLanguage() { - return language; - } - - @XmlElementWrapper - @XmlElement(name = "languageProperty") - public void setLanguage(List language) { - this.language = language; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Property.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Property.java deleted file mode 100644 index 2f5172f0e..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicfunder/entities/Property.java +++ /dev/null @@ -1,91 +0,0 @@ -package eu.eudat.configurations.dynamicfunder.entities; - - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -public class Property { - private String id; - private String name; - private String sourceUrl; - private String queryProperty; - private String externalFieldId; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getSourceUrl() { - return sourceUrl; - } - - @XmlElement(name = "sourceUrl") - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfiguration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfiguration.java deleted file mode 100644 index efe07f403..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.eudat.configurations.dynamicgrant; - -import eu.eudat.configurations.dynamicgrant.entities.Configuration; -import eu.eudat.models.data.dynamicfields.DynamicField; - -import java.util.List; - -/** - * Created by ikalyvas on 3/23/2018. - */ -public interface DynamicGrantConfiguration { - Configuration getConfiguration(); - - List getFields(); -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationDevelImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationDevelImpl.java deleted file mode 100644 index eb4fc308c..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationDevelImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package eu.eudat.configurations.dynamicgrant; - -import eu.eudat.configurations.dynamicgrant.entities.Configuration; -import eu.eudat.configurations.dynamicgrant.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; - -/** - * Created by ikalyvas on 5/4/2018. - */ - -@Service("dynamicGrantConfiguration") -@Profile("devel") -public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfiguration { - private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationDevelImpl.class); - - private Configuration configuration; - - private List fields; - - private Environment environment; - - @Autowired - public DynamicGrantConfigurationDevelImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL("file:///"+ current + "/web/src/main/resources/GrantConfiguration.xml").openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationProdImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationProdImpl.java deleted file mode 100644 index e23dd1240..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/DynamicGrantConfigurationProdImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package eu.eudat.configurations.dynamicgrant; - -import eu.eudat.configurations.dynamicgrant.entities.Configuration; -import eu.eudat.configurations.dynamicgrant.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Paths; -import java.util.LinkedList; -import java.util.List; - -/** - * Created by ikalyvas on 3/23/2018. - */ -@Service("dynamicGrantConfiguration") -@Profile({ "production", "staging", "docker" }) -public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration { - private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class); - - private Configuration configuration; - - private List fields; - - private Environment environment; - - @Autowired - public DynamicGrantConfigurationProdImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Configuration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Configuration.java deleted file mode 100644 index 1fede94fa..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Configuration.java +++ /dev/null @@ -1,34 +0,0 @@ -package eu.eudat.configurations.dynamicgrant.entities; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import jakarta.xml.bind.annotation.XmlRootElement; -import java.util.List; - -/** - * Created by ikalyvas on 3/23/2018. - */ -@XmlRootElement -public class Configuration { - private List configurationProperties; - private MainProperty mainExternalField; - - public MainProperty getMainExternalField() { - return mainExternalField; - } - - @XmlElement(name = "mainExternalField") - public void setMainExternalField(MainProperty mainExternalField) { - this.mainExternalField = mainExternalField; - } - - public List getConfigurationProperties() { - return configurationProperties; - } - - @XmlElementWrapper - @XmlElement(name = "property") - public void setConfigurationProperties(List configurationProperties) { - this.configurationProperties = configurationProperties; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Dependency.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Dependency.java deleted file mode 100644 index 8eb96a9b1..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Dependency.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.eudat.configurations.dynamicgrant.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -/** - * Created by ikalyvas on 3/23/2018. - */ -public class Dependency { - private String id; - private String queryProperty; - - public String getId() { - return id; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Language.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Language.java deleted file mode 100644 index 47c024643..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Language.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.eudat.configurations.dynamicgrant.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -/** - * Created by ikalyvas on 3/28/2018. - */ -public class Language { - private String key; - private String languageKey; - - public String getKey() { - return key; - } - - @XmlElement(name = "key") - public void setKey(String key) { - this.key = key; - } - - public String getLanguageKey() { - return languageKey; - } - - @XmlElement(name = "languageKey") - public void setLanguageKey(String languageKey) { - this.languageKey = languageKey; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/MainProperty.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/MainProperty.java deleted file mode 100644 index b73219a82..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/MainProperty.java +++ /dev/null @@ -1,106 +0,0 @@ -package eu.eudat.configurations.dynamicgrant.entities; - -import eu.eudat.service.remotefetcher.config.UrlConfiguration; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -/** - * Created by ikalyvas on 3/28/2018. - */ -public class MainProperty { - private String id; - private String name; - private String queryProperty; - private String externalFieldId; - private List urlConfig; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - private List language; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } - - public List getUrlConfig() { - return urlConfig; - } - - @XmlElement(name = "urlConfig") - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; - } - - public List getLanguage() { - return language; - } - - @XmlElementWrapper - @XmlElement(name = "languageProperty") - public void setLanguage(List language) { - this.language = language; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Property.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Property.java deleted file mode 100644 index ec31ce285..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicgrant/entities/Property.java +++ /dev/null @@ -1,93 +0,0 @@ -package eu.eudat.configurations.dynamicgrant.entities; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -/** - * Created by ikalyvas on 3/23/2018. - */ -public class Property { - private String id; - private String name; - private String sourceUrl; - private String queryProperty; - private String externalFieldId; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getSourceUrl() { - return sourceUrl; - } - - @XmlElement(name = "sourceUrl") - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfiguration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfiguration.java deleted file mode 100644 index 825a00c9f..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.eudat.configurations.dynamicproject; - -import eu.eudat.configurations.dynamicproject.entities.Configuration; -import eu.eudat.models.data.dynamicfields.DynamicField; - -import java.util.List; - -public interface DynamicProjectConfiguration { - Configuration getConfiguration(); - - List getFields(); -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationDevelImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationDevelImpl.java deleted file mode 100644 index f385580bf..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationDevelImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package eu.eudat.configurations.dynamicproject; - -import eu.eudat.configurations.dynamicproject.entities.Configuration; -import eu.eudat.configurations.dynamicproject.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; - -@Service("dynamicProjectConfiguration") -@Profile("devel") -public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfiguration{ - private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationDevelImpl.class); - - private Configuration configuration; - private List fields; - private Environment environment; - - @Autowired - public DynamicProjectConfigurationDevelImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL("file:///"+ current + "/web/src/main/resources/ProjectConfiguration.xml").openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationProdImpl.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationProdImpl.java deleted file mode 100644 index 0d0aeb607..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/DynamicProjectConfigurationProdImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package eu.eudat.configurations.dynamicproject; - -import eu.eudat.configurations.dynamicproject.entities.Configuration; -import eu.eudat.configurations.dynamicproject.entities.Property; -import eu.eudat.models.data.dynamicfields.Dependency; -import eu.eudat.models.data.dynamicfields.DynamicField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.Unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Paths; -import java.util.LinkedList; -import java.util.List; - -@Service("dynamicProjectConfiguration") -@Profile({ "production", "staging", "docker" }) -public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{ - private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class); - - private Configuration configuration; - - private List fields; - - private Environment environment; - - @Autowired - public DynamicProjectConfigurationProdImpl(Environment environment) { - this.environment = environment; - } - - @Override - public Configuration getConfiguration() { - if (this.configuration != null) return this.configuration; - String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl"); - logger.info("Loaded also config file: " + fileUrl); - String current = null; - InputStream is = null; - try { - current = new java.io.File(".").getCanonicalPath(); - - JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); - this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); - } catch (Exception ex) { - logger.error("Cannot find in folder" + current, ex); - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e); - } - } - return this.configuration; - } - - @Override - public List getFields() { - if (this.fields != null) return this.fields; - Configuration configuration = this.getConfiguration(); - List fields = new LinkedList<>(); - List properties = configuration.getConfigurationProperties(); - properties.stream().forEach(item -> { - DynamicField dynamicField = new DynamicField(); - dynamicField.setId(item.getId()); - dynamicField.setName(item.getName()); - dynamicField.setQueryProperty(item.getQueryProperty()); - dynamicField.setRequired(item.getRequired()); - List dependencies = new LinkedList<>(); - item.getDependencies().stream().forEach(dependency -> { - Dependency modelDependency = new Dependency(); - modelDependency.setId(dependency.getId()); - modelDependency.setQueryProperty(dependency.getQueryProperty()); - dependencies.add(modelDependency); - }); - dynamicField.setDependencies(dependencies); - fields.add(dynamicField); - }); - this.fields = fields; - return fields; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Configuration.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Configuration.java deleted file mode 100644 index f207844c6..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Configuration.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.eudat.configurations.dynamicproject.entities; - - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import jakarta.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement -public class Configuration { - private List configurationProperties; - private MainProperty mainExternalField; - - public MainProperty getMainExternalField() { - return mainExternalField; - } - - @XmlElement(name = "mainExternalField") - public void setMainExternalField(MainProperty mainExternalField) { - this.mainExternalField = mainExternalField; - } - - public List getConfigurationProperties() { - return configurationProperties; - } - - @XmlElementWrapper - @XmlElement(name = "property") - public void setConfigurationProperties(List configurationProperties) { - this.configurationProperties = configurationProperties; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Dependency.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Dependency.java deleted file mode 100644 index 889444402..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Dependency.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.eudat.configurations.dynamicproject.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -public class Dependency { - private String id; - private String queryProperty; - - public String getId() { - return id; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Language.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Language.java deleted file mode 100644 index 89fed26d6..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Language.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.eudat.configurations.dynamicproject.entities; - -import jakarta.xml.bind.annotation.XmlElement; - -public class Language { - private String key; - private String languageKey; - - public String getKey() { - return key; - } - - @XmlElement(name = "key") - public void setKey(String key) { - this.key = key; - } - - public String getLanguageKey() { - return languageKey; - } - - @XmlElement(name = "languageKey") - public void setLanguageKey(String languageKey) { - this.languageKey = languageKey; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/MainProperty.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/MainProperty.java deleted file mode 100644 index 96df8f202..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/MainProperty.java +++ /dev/null @@ -1,103 +0,0 @@ -package eu.eudat.configurations.dynamicproject.entities; - -import eu.eudat.service.remotefetcher.config.UrlConfiguration; - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -public class MainProperty { - private String id; - private String name; - private String queryProperty; - private String externalFieldId; - private List urlConfig; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - private List language; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } - - public List getUrlConfig() { - return urlConfig; - } - - @XmlElement(name = "urlConfig") - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; - } - - public List getLanguage() { - return language; - } - - @XmlElementWrapper - @XmlElement(name = "languageProperty") - public void setLanguage(List language) { - this.language = language; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Property.java b/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Property.java deleted file mode 100644 index 40b919a8a..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/configurations/dynamicproject/entities/Property.java +++ /dev/null @@ -1,91 +0,0 @@ -package eu.eudat.configurations.dynamicproject.entities; - - -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; - -public class Property { - private String id; - private String name; - private String sourceUrl; - private String queryProperty; - private String externalFieldId; - private String externalFieldLabel; - private List dependencies; - private Boolean required; - - - public String getId() { - return id; - } - - @XmlElement(name = "id") - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @XmlElement(name = "name") - public void setName(String name) { - this.name = name; - } - - public String getSourceUrl() { - return sourceUrl; - } - - @XmlElement(name = "sourceUrl") - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - public String getExternalFieldId() { - return externalFieldId; - } - - @XmlElement(name = "externalFieldId") - public void setExternalFieldId(String externalFieldId) { - this.externalFieldId = externalFieldId; - } - - public String getExternalFieldLabel() { - return externalFieldLabel; - } - - @XmlElement(name = "externalFieldLabel") - public void setExternalFieldLabel(String externalFieldLabel) { - this.externalFieldLabel = externalFieldLabel; - } - - public List getDependencies() { - return dependencies; - } - - @XmlElementWrapper - @XmlElement(name = "dependency") - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public Boolean getRequired() { - return required; - } - - @XmlElement(name = "required") - public void setRequired(Boolean required) { - this.required = required; - } - - public String getQueryProperty() { - return queryProperty; - } - - @XmlElement(name = "queryProperty") - public void setQueryProperty(String queryProperty) { - this.queryProperty = queryProperty; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index 428b8b971..eec034d9f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -2,7 +2,6 @@ package eu.eudat.controllers; import eu.eudat.authorization.Permission; -import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.criteria.DMPCriteria; import eu.eudat.data.DmpEntity; import eu.eudat.data.dao.criteria.DynamicFieldsCriteria; @@ -65,17 +64,15 @@ import static org.springframework.http.MediaType.*; public class DMPs extends BaseController { private static final Logger logger = LoggerFactory.getLogger(DMPs.class); - private DynamicGrantConfiguration dynamicGrantConfiguration; private Environment environment; private DataManagementPlanManager dataManagementPlanManager; private ConfigLoader configLoader; private final AuthorizationService authorizationService; @Autowired - public DMPs(ApiContext apiContext, DynamicGrantConfiguration dynamicGrantConfiguration, Environment environment, + public DMPs(ApiContext apiContext, Environment environment, DataManagementPlanManager dataManagementPlanManager, ConfigLoader configLoader, AuthorizationService authorizationService) { super(apiContext); - this.dynamicGrantConfiguration = dynamicGrantConfiguration; this.environment = environment; this.dataManagementPlanManager = dataManagementPlanManager; this.configLoader = configLoader; @@ -168,14 +165,14 @@ public class DMPs extends BaseController { // } } - @RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity>>> getWithCriteria(@RequestBody RequestItem criteriaRequestItem) throws InstantiationException, IllegalAccessException { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - List> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria()); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); - } +// @RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json") +// public @ResponseBody +// ResponseEntity>>> getWithCriteria(@RequestBody RequestItem criteriaRequestItem) throws InstantiationException, IllegalAccessException { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// +// List> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria()); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); +// } @RequestMapping(method = RequestMethod.GET, value = {"/versions/{id}"}, consumes = "application/json", produces = "application/json") public @ResponseBody diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index f49727fe2..7071a0afa 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -6,8 +6,6 @@ import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.*; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.dmpblueprint.*; -import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; -import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.data.*; import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.entities.*; @@ -366,48 +364,48 @@ public class DataManagementPlanManager { return datamanagementPlan; } - public List> getDynamicFields(String id, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicFieldsCriteria criteria) throws IllegalAccessException, InstantiationException { - List> result = new LinkedList<>(); - RestTemplate restTemplate = new RestTemplate(); - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity<>("parameters", headers); - - Property property = dynamicGrantConfiguration.getConfiguration().getConfigurationProperties().stream() - .filter(item -> item.getId().equals(id)).findFirst().orElse(null); - StringBuilder stringBuilder = new StringBuilder(); - if (criteria.getLike() != null) stringBuilder.append("?search=" + criteria.getLike()); - if (property.getDependencies() != null && !property.getDependencies().isEmpty() && criteria.getDynamicFields() != null && !criteria.getDynamicFields().isEmpty()) { - property.getDependencies().stream().forEach(item -> { - DynamicFieldsCriteria.DynamicFieldDependencyCriteria dependencyCriteria = criteria.getDynamicFields().stream().filter(dfield -> dfield.getProperty().equals(item.getId())) - .findFirst().orElse(null); - if (dependencyCriteria != null) { - if (criteria.getLike() != null || property.getDependencies().indexOf(item) > 0) - stringBuilder.append("&"); - stringBuilder.append(item.getQueryProperty() + "=" + dependencyCriteria.getValue()); - } - }); - - ResponseEntity response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class); - response.getBody().forEach(item -> { - Tuple tuple = new Tuple<>(); - tuple.setId((String) (((Map) item).get(property.getExternalFieldId()))); - tuple.setLabel((String) (((Map) item).get(property.getExternalFieldLabel()))); - result.add(tuple); - }); - - } else { - ResponseEntity response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class); - response.getBody().forEach(item -> { - Tuple tuple = new Tuple<>(); - tuple.setId((String) (((Map) item).get(property.getExternalFieldId()))); - tuple.setLabel((String) (((Map) item).get(property.getExternalFieldLabel()))); - result.add(tuple); - }); - } - return result; - } +// public List> getDynamicFields(String id, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicFieldsCriteria criteria) throws IllegalAccessException, InstantiationException { +// List> result = new LinkedList<>(); +// RestTemplate restTemplate = new RestTemplate(); +// HttpHeaders headers = new HttpHeaders(); +// headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); +// headers.setContentType(MediaType.APPLICATION_JSON); +// HttpEntity entity = new HttpEntity<>("parameters", headers); +// +// Property property = dynamicGrantConfiguration.getConfiguration().getConfigurationProperties().stream() +// .filter(item -> item.getId().equals(id)).findFirst().orElse(null); +// StringBuilder stringBuilder = new StringBuilder(); +// if (criteria.getLike() != null) stringBuilder.append("?search=" + criteria.getLike()); +// if (property.getDependencies() != null && !property.getDependencies().isEmpty() && criteria.getDynamicFields() != null && !criteria.getDynamicFields().isEmpty()) { +// property.getDependencies().stream().forEach(item -> { +// DynamicFieldsCriteria.DynamicFieldDependencyCriteria dependencyCriteria = criteria.getDynamicFields().stream().filter(dfield -> dfield.getProperty().equals(item.getId())) +// .findFirst().orElse(null); +// if (dependencyCriteria != null) { +// if (criteria.getLike() != null || property.getDependencies().indexOf(item) > 0) +// stringBuilder.append("&"); +// stringBuilder.append(item.getQueryProperty() + "=" + dependencyCriteria.getValue()); +// } +// }); +// +// ResponseEntity response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class); +// response.getBody().forEach(item -> { +// Tuple tuple = new Tuple<>(); +// tuple.setId((String) (((Map) item).get(property.getExternalFieldId()))); +// tuple.setLabel((String) (((Map) item).get(property.getExternalFieldLabel()))); +// result.add(tuple); +// }); +// +// } else { +// ResponseEntity response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class); +// response.getBody().forEach(item -> { +// Tuple tuple = new Tuple<>(); +// tuple.setId((String) (((Map) item).get(property.getExternalFieldId()))); +// tuple.setLabel((String) (((Map) item).get(property.getExternalFieldLabel()))); +// result.add(tuple); +// }); +// } +// return result; +// } public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue());