Compare commits
56 Commits
master
...
update-con
Author | SHA1 | Date |
---|---|---|
George Kalampokis | c84b0ab593 | |
George Kalampokis | 1f2084578d | |
George Kalampokis | 6b6d63c128 | |
George Kalampokis | b012f415a7 | |
George Kalampokis | 85b37dd16d | |
George Kalampokis | 1d1226dc5f | |
George Kalampokis | 93deb96f99 | |
George Kalampokis | 2c94cfa130 | |
George Kalampokis | 6542841c6c | |
George Kalampokis | 5916226a6f | |
George Kalampokis | af91a009db | |
George Kalampokis | 4434699f93 | |
George Kalampokis | a3da159564 | |
George Kalampokis | dea57b1cf8 | |
George Kalampokis | 4373d6db61 | |
George Kalampokis | 53d38088cd | |
George Kalampokis | d7653f374c | |
George Kalampokis | 198acac6b2 | |
George Kalampokis | f63d6b33ed | |
George Kalampokis | f5873ab9b0 | |
George Kalampokis | a9d6ab89f5 | |
George Kalampokis | 39cd57e4a9 | |
George Kalampokis | 9eec5daea1 | |
George Kalampokis | 65575048fe | |
George Kalampokis | df061051a3 | |
George Kalampokis | ee356c047d | |
George Kalampokis | 8a8993b235 | |
George Kalampokis | 734dc94f26 | |
George Kalampokis | 7741a82b28 | |
George Kalampokis | 1dd971c4aa | |
George Kalampokis | 4317feacd7 | |
George Kalampokis | 88568f6dcf | |
George Kalampokis | c6fea04fb4 | |
George Kalampokis | 41e8b40c40 | |
George Kalampokis | f9027c8cc3 | |
George Kalampokis | 1c275c4d2b | |
George Kalampokis | c0aac45f39 | |
George Kalampokis | a51aa3aeb5 | |
George Kalampokis | 2c00dab450 | |
George Kalampokis | 2666568fab | |
George Kalampokis | cf1b2489a3 | |
George Kalampokis | 5938e4d6f3 | |
George Kalampokis | 3fff5e1d2e | |
George Kalampokis | 9c9919fd85 | |
George Kalampokis | 063491ef21 | |
George Kalampokis | 57420c1403 | |
George Kalampokis | ed7cd0f852 | |
George Kalampokis | 4941a9fa95 | |
George Kalampokis | 765ddf752a | |
George Kalampokis | 6ddf8103f2 | |
George Kalampokis | 54173dc5b9 | |
George Kalampokis | f20cacc312 | |
George Kalampokis | ac4886b477 | |
George Kalampokis | 6e8794af1d | |
George Kalampokis | 4c651c6200 | |
George Kalampokis | 674cbbf384 |
|
@ -16,5 +16,5 @@ FROM docker.elastic.co/logstash/logstash:${ELK_VERSION}
|
||||||
|
|
||||||
# Add your logstash plugins setup here
|
# Add your logstash plugins setup here
|
||||||
# Example: RUN logstash-plugin install logstash-filter-json
|
# Example: RUN logstash-plugin install logstash-filter-json
|
||||||
RUN logstash-plugin update logstash-input-beats
|
#RUN logstash-plugin update logstash-input-beats
|
||||||
RUN logstash-plugin update logstash-filter-grok
|
#RUN logstash-plugin update logstash-filter-grok
|
||||||
|
|
|
@ -2,18 +2,11 @@ input {
|
||||||
pipeline { address => open_dmp_send_to_elastic }
|
pipeline { address => open_dmp_send_to_elastic }
|
||||||
}
|
}
|
||||||
|
|
||||||
filter {
|
|
||||||
}
|
|
||||||
|
|
||||||
output {
|
output {
|
||||||
elasticsearch {
|
elasticsearch {
|
||||||
hosts => "elasticsearch:9200"
|
hosts => "elasticsearch:9200"
|
||||||
|
index => "opendmp.logs"
|
||||||
user => elastic
|
user => elastic
|
||||||
password =>
|
password => ""
|
||||||
index =>"opendmp.logs"
|
}
|
||||||
#manage_template => true
|
}
|
||||||
#template => "/usr/share/logstash/templates/audit/openDMP.json"
|
|
||||||
#template_name => "cite.elas.openDMP-audit*"
|
|
||||||
#template_overwrite => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
import eu.eudat.types.grant.GrantStateType;
|
import eu.eudat.types.grant.GrantStateType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -25,6 +27,7 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("datasetDao")
|
@Component("datasetDao")
|
||||||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DatasetDaoImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
||||||
|
@ -99,6 +102,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset createOrUpdate(Dataset item) {
|
public Dataset createOrUpdate(Dataset item) {
|
||||||
|
logger.info("I'm Here " + item.getLabel());
|
||||||
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import eu.eudat.types.grant.GrantStateType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import schemasMicrosoftComOfficeOffice.LeftDocument;
|
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public abstract class ElasticRepository<T extends ElasticEntity,C extends Criteria> implements Repository<T,C> {
|
public abstract class ElasticRepository<T extends ElasticEntity,C extends Criteria> implements Repository<T,C> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ElasticRepository.class);
|
private static final Logger logger = LoggerFactory.getLogger(ElasticRepository.class);
|
||||||
|
private final ObjectMapper mapper;
|
||||||
private RestHighLevelClient client;
|
private RestHighLevelClient client;
|
||||||
|
|
||||||
public RestHighLevelClient getClient() {
|
public RestHighLevelClient getClient() {
|
||||||
|
@ -32,10 +33,10 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
|
||||||
logger.warn("Unable to connect to Elastic Services");
|
logger.warn("Unable to connect to Elastic Services");
|
||||||
this.client = null;
|
this.client = null;
|
||||||
}
|
}
|
||||||
|
this.mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T transformFromString(String value, Class<T> tClass) {
|
public <T> T transformFromString(String value, Class<T> tClass) {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
T item = null;
|
T item = null;
|
||||||
try {
|
try {
|
||||||
item = mapper.readValue(value, tClass);
|
item = mapper.readValue(value, tClass);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>2.6.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@ -27,166 +27,168 @@
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|
||||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||||
<org.springframework.version>5.3.8</org.springframework.version>
|
<!--<org.springframework.version>5.3.8</org.springframework.version>-->
|
||||||
<!-- <org.springframeweu.eudat.logic.securityrity.version>3.2.10.RELEASE</org.springframeweu.eudat.logic.securityrity.version> -->
|
<!-- <org.springframeweu.eudat.logic.securityrity.version>3.2.10.RELEASE</org.springframeweu.eudat.logic.securityrity.version> -->
|
||||||
<org.springframework.security.version>5.3.10.RELEASE</org.springframework.security.version>
|
<!-- <org.springframework.security.version>5.3.10.RELEASE</org.springframework.security.version>-->
|
||||||
<!--<com.sun.jersey.version>1.19.1</com.sun.jersey.version>-->
|
<!--<com.sun.jersey.version>1.19.1</com.sun.jersey.version>-->
|
||||||
<!--
|
<!--
|
||||||
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
||||||
-->
|
-->
|
||||||
<!--<com.fasterxml.jackson>2.9.0</com.fasterxml.jackson>-->
|
<!--<com.fasterxml.jackson>2.9.0</com.fasterxml.jackson>-->
|
||||||
|
|
||||||
<hibernate.version>5.5.3.Final</hibernate.version>
|
<!-- <hibernate.version>5.5.3.Final</hibernate.version>-->
|
||||||
|
|
||||||
<commons-codec.version>1.9</commons-codec.version>
|
<!-- <commons-codec.version>1.9</commons-codec.version>-->
|
||||||
<org.junit.version>4.11</org.junit.version>
|
<!-- <org.junit.version>4.11</org.junit.version>-->
|
||||||
<log4j.version>1.2.17</log4j.version>
|
<!-- <log4j.version>1.2.17</log4j.version>-->
|
||||||
<log4j2.version>2.15.0</log4j2.version>
|
<log4j2.version>2.15.0</log4j2.version>
|
||||||
<slf4j.version>1.7.12</slf4j.version>
|
<!-- <slf4j.version>1.7.12</slf4j.version>-->
|
||||||
<!--<jetty.version>11.0.5
|
<!--<jetty.version>11.0.5
|
||||||
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
||||||
<logback.version>1.2.3</logback.version>
|
<!-- <logback.version>1.2.3</logback.version>-->
|
||||||
<!-- <javax.inject.version>1</javax.inject.version>-->
|
<!-- <javax.inject.version>1</javax.inject.version>-->
|
||||||
<!--<javax.servlet.servlet-api.version>3.0.1</javax.servlet.servlet-api.version>-->
|
<!--<javax.servlet.servlet-api.version>3.0.1</javax.servlet.servlet-api.version>-->
|
||||||
|
<apache.poi.version>5.2.2</apache.poi.version>
|
||||||
|
<jackson.version>2.12.3</jackson.version>
|
||||||
|
<elasticsearch.version>7.6.2</elasticsearch.version>
|
||||||
|
<jaxb.version>2.3.0</jaxb.version>
|
||||||
|
<caffeine.version>2.9.0</caffeine.version>
|
||||||
|
<google.api.version>1.33.4</google.api.version>
|
||||||
|
<json.path.version>2.4.0</json.path.version>
|
||||||
|
<postgresql.version>42.2.22</postgresql.version>
|
||||||
|
<social.facebook.version>2.0.3.RELEASE</social.facebook.version>
|
||||||
|
<social.linkedin.version>1.0.2.RELEASE</social.linkedin.version>
|
||||||
|
<social.twitter.version>1.1.2.RELEASE</social.twitter.version>
|
||||||
|
<apache.commons.lang3.version>3.12.0</apache.commons.lang3.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Core Spring Boot Dependencies -->
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20160810</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.elasticsearch</groupId>
|
|
||||||
<artifactId>elasticsearch</artifactId>
|
|
||||||
<version>7.7.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore-nio</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
<version>4.5.12</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore-nio</artifactId>
|
|
||||||
<version>4.4.13</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore</artifactId>
|
|
||||||
<version>4.4.13</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
|
||||||
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
|
||||||
<version>7.6.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-core</artifactId>
|
|
||||||
<version>${hibernate.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-c3p0</artifactId>
|
<artifactId>hibernate-c3p0</artifactId>
|
||||||
<version>${hibernate.version}</version>
|
<version>${hibernate.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- jdbc Driver -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>${postgresql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Elasticsearch -->
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch</groupId>
|
||||||
|
<artifactId>elasticsearch</artifactId>
|
||||||
|
<version>${elasticsearch.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||||
|
<version>${elasticsearch.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Autocomplete cache -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
<artifactId>caffeine</artifactId>
|
||||||
|
<version>${caffeine.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Used for Google login ONLY -->
|
||||||
<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
|
<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.api-client</groupId>
|
<groupId>com.google.api-client</groupId>
|
||||||
<artifactId>google-api-client</artifactId>
|
<artifactId>google-api-client</artifactId>
|
||||||
<version>1.23.0</version>
|
<version>${google.api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- facebook Login -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.social</groupId>
|
||||||
|
<artifactId>spring-social-facebook</artifactId>
|
||||||
|
<version>${social.facebook.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- linkedin Login -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.social</groupId>
|
||||||
|
<artifactId>spring-social-linkedin</artifactId>
|
||||||
|
<version>${social.linkedin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- twitter login-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.social</groupId>
|
||||||
|
<artifactId>spring-social-twitter</artifactId>
|
||||||
|
<version>${social.twitter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Used for Remote Fetcher -->
|
||||||
<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
|
<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>${json.path.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
|
||||||
<version>2.12.3</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackeu.eudat.corecore -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackeu.eudat.corecore -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- g/a spring -->
|
<dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Various libs -->
|
<!-- Various libs -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.5</version>
|
<version>${apache.commons.lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Docx export -->
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>${apache.poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>${apache.poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
|
<!-- Used for the HTML to DocX export -->
|
||||||
|
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.convereu.eudat.corecore -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlgraphics</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
<artifactId>fop</artifactId>
|
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
|
||||||
<version>2.3</version>
|
<version>1.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -194,77 +196,38 @@
|
||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>1.14.3</version>
|
<version>1.14.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.pdf -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
|
||||||
<artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
|
|
||||||
<version>1.0.6</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.convereu.eudat.corecore -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
|
||||||
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
|
|
||||||
<version>1.0.6</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
|
||||||
<artifactId>fr.opensagres.xdocreport.itext.extension</artifactId>
|
|
||||||
<version>2.0.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>2.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
|
||||||
<artifactId>transport</artifactId>
|
|
||||||
<version>7.6.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-to-slf4j</artifactId>
|
|
||||||
<version>2.8.2</version>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
|
<!-- XML Binding for (mainly) the templates -->
|
||||||
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
|
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>${jaxb.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-core -->
|
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-core -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jaxb</groupId>
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>${jaxb.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
|
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jaxb</groupId>
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
<artifactId>jaxb-runtime</artifactId>
|
<artifactId>jaxb-runtime</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>${jaxb.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
|
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>javax.annotation</groupId>
|
<groupId>javax.annotation</groupId>
|
||||||
<artifactId>javax.annotation-api</artifactId>
|
<artifactId>javax.annotation-api</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.1</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
|
<!-- Model Validation -->
|
||||||
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
|
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
|
@ -272,37 +235,11 @@
|
||||||
<version>2.0.1.Final</version>
|
<version>2.0.1.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Prometheus Analytics -->
|
||||||
<!-- The client -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.prometheus</groupId>
|
|
||||||
<artifactId>simpleclient</artifactId>
|
|
||||||
<version>0.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Hotspot JVM metrics-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.prometheus</groupId>
|
|
||||||
<artifactId>simpleclient_hotspot</artifactId>
|
|
||||||
<version>0.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Exposition HTTPServer-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.prometheus</groupId>
|
|
||||||
<artifactId>simpleclient_httpserver</artifactId>
|
|
||||||
<version>0.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Pushgateway exposition-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.prometheus</groupId>
|
|
||||||
<artifactId>simpleclient_pushgateway</artifactId>
|
|
||||||
<version>0.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus -->
|
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.micrometer</groupId>
|
<groupId>io.micrometer</groupId>
|
||||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||||
<version>1.7.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.eudat.queryable.collector;
|
package eu.eudat.queryable.collector;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import javax.persistence.Tuple;
|
import javax.persistence.Tuple;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -68,7 +66,8 @@ public class ProjectionField {
|
||||||
list.add(current.parent.key);
|
list.add(current.parent.key);
|
||||||
current = current.parent;
|
current = current.parent;
|
||||||
}
|
}
|
||||||
return String.join(".", Lists.reverse(list));
|
Collections.reverse(list);
|
||||||
|
return String.join(".", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object createObject(List<Tuple> tuples, String field) {
|
private Object createObject(List<Tuple> tuples, String field) {
|
||||||
|
|
|
@ -42,9 +42,12 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
private String hint;
|
private String hint;
|
||||||
private Map<String, Join> joinsMap = new HashMap<>();
|
private Map<String, Join> joinsMap = new HashMap<>();
|
||||||
|
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
public QueryableHibernateList(EntityManager manager, Class<T> tClass) {
|
public QueryableHibernateList(EntityManager manager, Class<T> tClass) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.tClass = tClass;
|
this.tClass = tClass;
|
||||||
|
this.mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableHibernateList<T> setManager(EntityManager manager) {
|
public QueryableHibernateList<T> setManager(EntityManager manager) {
|
||||||
|
@ -246,7 +249,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
if (!this.fields.isEmpty()) this.selectFields();
|
if (!this.fields.isEmpty()) this.selectFields();
|
||||||
if (distinct) this.query.distinct(true);
|
if (distinct) this.query.distinct(true);
|
||||||
//if (!this.fields.isEmpty()) this.query.multiselect(this.parseFields(this.fields));
|
//if (!this.fields.isEmpty()) this.query.multiselect(this.parseFields(this.fields));
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
if (!this.fields.isEmpty()) return this.toListWithFields().stream().map(m -> mapper.convertValue(m, this.tClass)).collect(Collectors.toList());
|
if (!this.fields.isEmpty()) return this.toListWithFields().stream().map(m -> mapper.convertValue(m, this.tClass)).collect(Collectors.toList());
|
||||||
return this.toListWithOutFields();
|
return this.toListWithOutFields();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.12.3</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
||||||
|
@ -71,55 +70,45 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
<artifactId>caffeine</artifactId>
|
<artifactId>caffeine</artifactId>
|
||||||
<version>2.9.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.7.2</version>
|
<version>5.7.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
<version>42.2.22</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
<!-- facebook Login -->
|
<!-- facebook Login -->
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.springframework.social</groupId>
|
<groupId>org.springframework.social</groupId>
|
||||||
<artifactId>spring-social-facebook</artifactId>
|
<artifactId>spring-social-facebook</artifactId>
|
||||||
<version>2.0.3.RELEASE</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- linkedin Login -->
|
<!– linkedin Login –>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.social</groupId>
|
<groupId>org.springframework.social</groupId>
|
||||||
<artifactId>spring-social-linkedin</artifactId>
|
<artifactId>spring-social-linkedin</artifactId>
|
||||||
<version>1.0.2.RELEASE</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- tweeter login-->
|
<!– tweeter login–>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.social</groupId>
|
<groupId>org.springframework.social</groupId>
|
||||||
<artifactId>spring-social-twitter</artifactId>
|
<artifactId>spring-social-twitter</artifactId>
|
||||||
<version>1.1.2.RELEASE</version>
|
</dependency>-->
|
||||||
</dependency>
|
<!--<dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package eu.eudat.configurations;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.Module;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
||||||
import eu.eudat.criteria.entities.Criteria;
|
|
||||||
import eu.eudat.criteria.serialzier.CriteriaSerializer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class JacksonConfiguration {
|
|
||||||
@Bean
|
|
||||||
public ObjectMapper buildObjectMapper() {
|
|
||||||
|
|
||||||
ArrayList<Module> modules = new ArrayList<>();
|
|
||||||
SimpleModule criteriaSerializerModule = new SimpleModule();
|
|
||||||
criteriaSerializerModule.addDeserializer(Criteria.class, new CriteriaSerializer());
|
|
||||||
modules.add(criteriaSerializerModule);
|
|
||||||
|
|
||||||
return new ObjectMapper()
|
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
|
||||||
.registerModules(modules);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +1,43 @@
|
||||||
package eu.eudat.configurations;
|
package eu.eudat.configurations;
|
||||||
|
|
||||||
import eu.eudat.controllers.interceptors.RequestInterceptor;
|
|
||||||
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
public class WebMVCConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
|
|
||||||
private AuthenticationService verifiedUserAuthenticationService;
|
private final AuthenticationService verifiedUserAuthenticationService;
|
||||||
private AuthenticationService nonVerifiedUserAuthenticationService;
|
private final AuthenticationService nonVerifiedUserAuthenticationService;
|
||||||
|
|
||||||
@Autowired
|
private final Environment environment;
|
||||||
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService) {
|
|
||||||
|
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService, Environment environment) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
|
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
|
||||||
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/api/**").allowedOrigins(this.environment.getProperty("dmp.domain"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Override
|
@Override
|
||||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||||
argumentResolvers.add(new PrincipalArgumentResolver(verifiedUserAuthenticationService, nonVerifiedUserAuthenticationService));
|
argumentResolvers.add(new PrincipalArgumentResolver(verifiedUserAuthenticationService, nonVerifiedUserAuthenticationService));
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.eudat.configurations.file;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({TmpProperties.class, PermProperties.class})
|
||||||
|
public class FileTimeConfiguration {
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.configurations.file;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "perm")
|
||||||
|
public class PermProperties {
|
||||||
|
|
||||||
|
private TimeProperties time;
|
||||||
|
|
||||||
|
public TimeProperties getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTime(TimeProperties time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package eu.eudat.configurations.file;
|
||||||
|
|
||||||
|
public class StartTimeProperties {
|
||||||
|
private Integer month;
|
||||||
|
private String dayOfWeekName;
|
||||||
|
private Integer dayOfWeek;
|
||||||
|
|
||||||
|
private Integer dayOfMonth;
|
||||||
|
private Integer hour;
|
||||||
|
private Integer minute;
|
||||||
|
|
||||||
|
public Integer getMonth() {
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonth(Integer month) {
|
||||||
|
this.month = month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDayOfWeekName() {
|
||||||
|
return dayOfWeekName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfWeekName(String dayOfWeekName) {
|
||||||
|
this.dayOfWeekName = dayOfWeekName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDayOfWeek() {
|
||||||
|
return dayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfWeek(Integer dayOfWeek) {
|
||||||
|
this.dayOfWeek = dayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDayOfMonth() {
|
||||||
|
return dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfMonth(Integer dayOfMonth) {
|
||||||
|
this.dayOfMonth = dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHour() {
|
||||||
|
return hour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHour(Integer hour) {
|
||||||
|
this.hour = hour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMinute() {
|
||||||
|
return minute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinute(Integer minute) {
|
||||||
|
this.minute = minute;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package eu.eudat.configurations.file;
|
||||||
|
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
|
public class TimeProperties {
|
||||||
|
private Integer interval;
|
||||||
|
private ChronoUnit timeUnit;
|
||||||
|
private StartTimeProperties startTime;
|
||||||
|
|
||||||
|
public Integer getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterval(Integer interval) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChronoUnit getTimeUnit() {
|
||||||
|
return timeUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeUnit(ChronoUnit timeUnit) {
|
||||||
|
this.timeUnit = timeUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StartTimeProperties getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(StartTimeProperties startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.configurations.file;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "tmp")
|
||||||
|
public class TmpProperties {
|
||||||
|
|
||||||
|
private TimeProperties time;
|
||||||
|
|
||||||
|
public TimeProperties getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTime(TimeProperties time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,7 +38,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
||||||
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/admin/"})
|
@RequestMapping(value = {"/api/admin/"})
|
||||||
public class Admin extends BaseController {
|
public class Admin extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||||
* Created by ikalyvas on 3/28/2018.
|
* Created by ikalyvas on 3/28/2018.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/common"})
|
@RequestMapping(value = {"/api/common"})
|
||||||
public class CommonController {
|
public class CommonController {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/contactEmail")
|
@RequestMapping(value = "api/contactEmail")
|
||||||
public class ContactEmail {
|
public class ContactEmail {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContactEmail.class);
|
private static final Logger logger = LoggerFactory.getLogger(ContactEmail.class);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/currency")
|
@RequestMapping(value = "api/currency")
|
||||||
public class CurrencyController {
|
public class CurrencyController {
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* Created by ikalyvas on 3/21/2018.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/dmpprofile"})
|
@RequestMapping(value = {"/api/dmpprofile"})
|
||||||
public class DMPProfileController extends BaseController {
|
public class DMPProfileController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ import static org.springframework.http.MediaType.*;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/dmps/"})
|
@RequestMapping(value = {"/api/dmps/"})
|
||||||
public class DMPs extends BaseController {
|
public class DMPs extends BaseController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
|
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
|
||||||
|
|
|
@ -22,11 +22,10 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class DashBoardController extends BaseController {
|
public class DashBoardController extends BaseController {
|
||||||
|
|
||||||
private DashBoardManager dashBoardManager;
|
private final DashBoardManager dashBoardManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DashBoardController(ApiContext apiContext, DashBoardManager dashBoardManager) {
|
public DashBoardController(ApiContext apiContext, DashBoardManager dashBoardManager) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/datarepos"})
|
@RequestMapping(value = {"/api/external/datarepos"})
|
||||||
public class DataRepositories extends BaseController {
|
public class DataRepositories extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,7 @@ import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.properties.PropertiesModel;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -19,15 +17,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class DatasetProfileController extends BaseController {
|
public class DatasetProfileController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class DatasetProfiles extends BaseController {
|
public class DatasetProfiles extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/datasets/"})
|
@RequestMapping(value = {"/api/datasets/"})
|
||||||
public class Datasets extends BaseController {
|
public class Datasets extends BaseController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Datasets.class);
|
private static final Logger logger = LoggerFactory.getLogger(Datasets.class);
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/emailConfirmation")
|
@RequestMapping(value = "api/emailConfirmation")
|
||||||
public class EmailConfirmation {
|
public class EmailConfirmation {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/emailMergeConfirmation")
|
@RequestMapping(value = "api/emailMergeConfirmation")
|
||||||
public class EmailMergeConfirmation {
|
public class EmailMergeConfirmation {
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class ExternalDatasets extends BaseController {
|
public class ExternalDatasets extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.FileUpload;
|
import eu.eudat.data.entities.FileUpload;
|
||||||
|
@ -12,14 +12,15 @@ import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.json.JsonSearcher;
|
import eu.eudat.logic.utilities.json.JsonSearcher;
|
||||||
import eu.eudat.models.HintedModelFactory;
|
import eu.eudat.models.HintedModelFactory;
|
||||||
|
import eu.eudat.models.data.components.commons.datafield.UploadData;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.json.JSONArray;
|
import org.slf4j.Logger;
|
||||||
import org.json.JSONObject;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
@ -32,25 +33,28 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/file/"})
|
@RequestMapping(value = {"/api/file/"})
|
||||||
public class FileController {
|
public class FileController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FileController.class);
|
||||||
|
|
||||||
private DatasetProfileManager datasetProfileManager;
|
private DatasetProfileManager datasetProfileManager;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
private DatabaseRepository databaseRepository;
|
private DatabaseRepository databaseRepository;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FileController(DatasetProfileManager datasetProfileManager, Environment environment, ApiContext apiContext) {
|
public FileController(DatasetProfileManager datasetProfileManager, Environment environment, ApiContext apiContext) {
|
||||||
this.datasetProfileManager = datasetProfileManager;
|
this.datasetProfileManager = datasetProfileManager;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
|
this.objectMapper = apiContext.getUtilitiesService().getGenericObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
|
@ -62,57 +66,48 @@ public class FileController {
|
||||||
|
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(datasetProfileId);
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(datasetProfileId);
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
String json = objectMapper.writeValueAsString(datasetprofile.getSections());
|
||||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
JsonNode propertiesJson = objectMapper.readTree(json);
|
||||||
String json = mapper.writeValueAsString(datasetprofile.getSections());;
|
|
||||||
JsonNode propertiesJson = mapper.readTree(json);
|
|
||||||
Set<JsonNode> fieldNodes = new HashSet<>();
|
Set<JsonNode> fieldNodes = new HashSet<>();
|
||||||
fieldNodes.addAll(JsonSearcher.findNodes(propertiesJson, "id", fieldId, false));
|
fieldNodes.addAll(JsonSearcher.findNodes(propertiesJson, "id", fieldId, false));
|
||||||
|
|
||||||
// AtomicReference<String> exceptionMessage = null;
|
// AtomicReference<String> exceptionMessage = null;
|
||||||
AtomicBoolean acceptedFile = new AtomicBoolean(false);
|
Boolean acceptedFile = false;
|
||||||
fieldNodes.forEach(node -> {
|
for (JsonNode node : fieldNodes) {
|
||||||
JsonNode data = node.get("data");
|
JsonNode data = node.get("data");
|
||||||
if (data != null && !data.toString().equals("\"\"") && !data.toString().equals("null")) {
|
try {
|
||||||
String stringValue = data.toString().replaceAll("=", ":");
|
UploadData uploadData = objectMapper.treeToValue(data, UploadData.class);
|
||||||
JSONObject dataObj = new JSONObject(stringValue);
|
if (uploadData != null) {
|
||||||
Map<String, Object> dataMap = ((JSONObject) dataObj).toMap();
|
if (uploadData.getMaxFileSizeInMB() != null) {
|
||||||
if(dataMap.get("maxFileSizeInMB") != null && !dataMap.get("maxFileSizeInMB").toString().equals("\"\"") && !dataMap.get("maxFileSizeInMB").toString().equals("null")) {
|
if (file.getSize() <= (uploadData.getMaxFileSizeInMB() * Math.pow(1024, 2))) {
|
||||||
if (file.getSize() <= Integer.parseInt(dataMap.get("maxFileSizeInMB").toString())*1048576) {
|
acceptedFile = true;
|
||||||
acceptedFile.set(true);
|
}
|
||||||
}
|
}
|
||||||
// else {
|
if (acceptedFile && uploadData.getTypes() != null && !uploadData.getTypes().isEmpty()) {
|
||||||
// exceptionMessage.set("The file is too large. Max file upload is " + dataMap.get("maxFileSizeInMB").toString() + " MB.");
|
acceptedFile = false;
|
||||||
// }
|
for (UploadData.Option option : uploadData.getTypes()) {
|
||||||
}
|
if (option.getValue() != null) {
|
||||||
|
if (file.getContentType().equals(option.getValue())) {
|
||||||
if(acceptedFile.get() && data.get("types") != null && !data.get("types").toString().equals("\"\"") && !data.get("types").toString().equals("null")) {
|
acceptedFile = true;
|
||||||
acceptedFile.set(false);
|
}
|
||||||
|
|
||||||
JSONArray types = new JSONArray(data.get("types").toString());
|
|
||||||
|
|
||||||
types.iterator().forEachRemaining(element -> {
|
|
||||||
Map<String, Object> typesMap = ((JSONObject) element).toMap();
|
|
||||||
if(typesMap.get("value") != null && !typesMap.get("value").toString().equals("\"\"") && !typesMap.get("value").toString().equals("null")) {
|
|
||||||
if(file.getContentType().equals(typesMap.get("value").toString())) {
|
|
||||||
acceptedFile.set(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
// if(!acceptedFile.get()) {
|
// if(!acceptedFile.get()) {
|
||||||
// exceptionMessage.set("The file type is not accepted.");
|
// exceptionMessage.set("The file type is not accepted.");
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!acceptedFile.get()) {
|
if (!acceptedFile) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("The uploaded file is too large or has an unaccepted type"));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("The uploaded file is too large or has an unaccepted type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File convFile = new File(this.environment.getProperty("temp.temp") + uuid);
|
File convFile = new File(this.environment.getProperty("temp.temp") + uuid);
|
||||||
convFile.createNewFile();
|
|
||||||
FileOutputStream fos = new FileOutputStream(convFile);
|
FileOutputStream fos = new FileOutputStream(convFile);
|
||||||
fos.write(file.getBytes());
|
fos.write(file.getBytes());
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/funders/"})
|
@RequestMapping(value = {"/api/funders/"})
|
||||||
public class Funders extends BaseController {
|
public class Funders extends BaseController {
|
||||||
private FunderManager funderManager;
|
private FunderManager funderManager;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/grants/"})
|
@RequestMapping(value = {"/api/grants/"})
|
||||||
public class Grants extends BaseController {
|
public class Grants extends BaseController {
|
||||||
private GrantManager grantManager;
|
private GrantManager grantManager;
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/journals"})
|
@RequestMapping(value = {"/api/external/journals"})
|
||||||
public class JournalsController extends BaseController {
|
public class JournalsController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.io.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/language/"})
|
@RequestMapping(value = {"/api/language/"})
|
||||||
public class LanguageController {
|
public class LanguageController {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/licenses"})
|
@RequestMapping(value = {"/api/external/licenses"})
|
||||||
public class Licenses extends BaseController {
|
public class Licenses extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/lock/"})
|
@RequestMapping(value = {"/api/lock/"})
|
||||||
public class LockController {
|
public class LockController {
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/auth")
|
@RequestMapping(value = "api/auth")
|
||||||
public class Login {
|
public class Login {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Login.class);
|
private static final Logger logger = LoggerFactory.getLogger(Login.class);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class Organisations extends BaseController {
|
public class Organisations extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class Prefillings {
|
public class Prefillings {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/projects/"})
|
@RequestMapping(value = {"/api/projects/"})
|
||||||
public class Projects extends BaseController {
|
public class Projects extends BaseController {
|
||||||
private ProjectManager projectManager;
|
private ProjectManager projectManager;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/pubrepos"})
|
@RequestMapping(value = {"/api/external/pubrepos"})
|
||||||
public class PubRepositoriesController extends BaseController {
|
public class PubRepositoriesController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/publications"})
|
@RequestMapping(value = {"/api/external/publications"})
|
||||||
public class PublicationsController extends BaseController {
|
public class PublicationsController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import javax.validation.Valid;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/quick-wizard/"})
|
@RequestMapping(value = {"/api/quick-wizard/"})
|
||||||
public class QuickWizardController extends BaseController {
|
public class QuickWizardController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class Registries extends BaseController {
|
public class Registries extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/researchers"})
|
@RequestMapping(value = {"/api/researchers"})
|
||||||
|
|
||||||
public class Researchers extends BaseController {
|
public class Researchers extends BaseController {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class Services extends BaseController {
|
public class Services extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.stream.Collectors;
|
||||||
* Created by ikalyvas on 7/5/2018.
|
* Created by ikalyvas on 7/5/2018.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class TagController extends BaseController {
|
public class TagController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/taxonomies"})
|
@RequestMapping(value = {"/api/external/taxonomies"})
|
||||||
public class TaxonomiesController extends BaseController {
|
public class TaxonomiesController extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.stream.Stream;
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/userguide/"})
|
@RequestMapping(value = {"/api/userguide/"})
|
||||||
public class UserGuideController {
|
public class UserGuideController {
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
@RequestMapping("api/invite/")
|
@RequestMapping("api/invite/")
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
public class UserInvitationController extends BaseController {
|
public class UserInvitationController extends BaseController {
|
||||||
|
|
||||||
private InvitationsManager invitationsManager;
|
private InvitationsManager invitationsManager;
|
||||||
|
|
|
@ -31,7 +31,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = "api/user")
|
@RequestMapping(value = "api/user")
|
||||||
public class Users extends BaseController {
|
public class Users extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
@RequestMapping(value = {"/api"})
|
||||||
public class Validation extends BaseController {
|
public class Validation extends BaseController {
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
@ -18,7 +19,7 @@ import javax.annotation.Priority;
|
||||||
* Created by ikalyvas on 6/12/2018.
|
* Created by ikalyvas on 6/12/2018.
|
||||||
*/
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
@Priority(5)
|
@Order(5)
|
||||||
public class ControllerErrorHandler {
|
public class ControllerErrorHandler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
|
private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
@ -16,7 +17,7 @@ import javax.annotation.Priority;
|
||||||
* Created by ikalyvas on 6/12/2018.
|
* Created by ikalyvas on 6/12/2018.
|
||||||
*/
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
@Priority(4)
|
@Order(4)
|
||||||
public class ControllerUnauthorisedHandler {
|
public class ControllerUnauthorisedHandler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ControllerUnauthorisedHandler.class);
|
private static final Logger logger = LoggerFactory.getLogger(ControllerUnauthorisedHandler.class);
|
||||||
|
|
||||||
|
|
|
@ -47,17 +47,17 @@ import java.util.stream.Stream;
|
||||||
public class DashBoardManager {
|
public class DashBoardManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DashBoardManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(DashBoardManager.class);
|
||||||
|
|
||||||
private final Map<String, Comparator<RecentActivityModel>> comparators = Stream.of(new Object[][] {
|
private final Map<String, Comparator<RecentActivityModel>> comparators = Stream.of(new Object[][]{
|
||||||
{ "modified", Comparator.comparing(o -> ((RecentActivityModel)o).getModified()).reversed()},
|
{"modified", Comparator.comparing(o -> ((RecentActivityModel) o).getModified()).reversed()},
|
||||||
{ "created", Comparator.comparing(o -> ((RecentActivityModel)o).getCreated()).reversed()},
|
{"created", Comparator.comparing(o -> ((RecentActivityModel) o).getCreated()).reversed()},
|
||||||
{ "label", Comparator.comparing(o -> ((RecentActivityModel)o).getTitle())},
|
{"label", Comparator.comparing(o -> ((RecentActivityModel) o).getTitle())},
|
||||||
{ "status", Comparator.comparing(o -> ((RecentActivityModel)o).getStatus()).reversed()},
|
{"status", Comparator.comparing(o -> ((RecentActivityModel) o).getStatus()).reversed()},
|
||||||
{ "finalizedAt", Comparator.comparing(o -> ((RecentActivityModel)o).getFinalizedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()},
|
{"finalizedAt", Comparator.comparing(o -> ((RecentActivityModel) o).getFinalizedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()},
|
||||||
{ "publishedAt", Comparator.comparing(o -> ((RecentActivityModel)o).getPublishedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()}
|
{"publishedAt", Comparator.comparing(o -> ((RecentActivityModel) o).getPublishedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()}
|
||||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Comparator<RecentActivityModel>)data[1]));
|
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Comparator<RecentActivityModel>) data[1]));
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private final DataManagementPlanManager dataManagementPlanManager;
|
private final DataManagementPlanManager dataManagementPlanManager;
|
||||||
private final DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
|
|
||||||
|
@ -152,21 +152,14 @@ public class DashBoardManager {
|
||||||
|
|
||||||
List<Integer> roles = new LinkedList<>();
|
List<Integer> roles = new LinkedList<>();
|
||||||
if ((dmps == null || dmps == 0L) && (datasets == null || datasets == 0L)) {
|
if ((dmps == null || dmps == 0L) && (datasets == null || datasets == 0L)) {
|
||||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).distinct().countAsync()
|
statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).distinct().count());
|
||||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
statistics.setTotalDataSetCount(datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct().count());
|
||||||
CompletableFuture datasetFuture = datasetRepository.getAuthenticated( datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct().countAsync()
|
|
||||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
|
||||||
CompletableFuture.allOf(dmpFuture, datasetFuture).join();
|
|
||||||
} else {
|
} else {
|
||||||
statistics.setTotalDataManagementPlanCount(dmps);
|
statistics.setTotalDataManagementPlanCount(dmps);
|
||||||
statistics.setTotalDataSetCount(datasets);
|
statistics.setTotalDataSetCount(datasets);
|
||||||
}
|
}
|
||||||
CompletableFuture grantFuture = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).countAsync()
|
statistics.setTotalGrantCount(grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).count());
|
||||||
.whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats));
|
statistics.setTotalOrganisationCount(organisationRepository.getAuthenticated(organisationRepository.getWithCriteria(organisationCriteria).withHint("organisationRecentActivity"), user).count());
|
||||||
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.getWithCriteria(organisationCriteria).withHint("organisationRecentActivity"), user).countAsync()
|
|
||||||
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
|
|
||||||
|
|
||||||
CompletableFuture.allOf( grantFuture, orgnanisationFuture).join();
|
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ import eu.eudat.types.MetricNames;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -97,21 +96,20 @@ import java.util.stream.Stream;
|
||||||
@Component
|
@Component
|
||||||
public class DataManagementPlanManager {
|
public class DataManagementPlanManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class);
|
||||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] {
|
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][]{
|
||||||
{NotificationType.DMP_MODIFIED, "/plans/edit"},
|
{NotificationType.DMP_MODIFIED, "/plans/edit"},
|
||||||
{NotificationType.DMP_PUBLISH, "/plans/publicEdit"},
|
{NotificationType.DMP_PUBLISH, "/plans/publicEdit"},
|
||||||
{NotificationType.DMP_FINALISED, "/plans/edit"},
|
{NotificationType.DMP_FINALISED, "/plans/edit"},
|
||||||
{NotificationType.DMP_MODIFIED_FINALISED, "/plans/edit"}
|
{NotificationType.DMP_MODIFIED_FINALISED, "/plans/edit"}
|
||||||
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
|
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
private DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private Environment environment;
|
private final Environment environment;
|
||||||
private RDAManager rdaManager;
|
private final RDAManager rdaManager;
|
||||||
private UserManager userManager;
|
private final UserManager userManager;
|
||||||
private final MetricsManager metricsManager;
|
private final MetricsManager metricsManager;
|
||||||
private final ConfigLoader configLoader;
|
private final ConfigLoader configLoader;
|
||||||
|
|
||||||
|
@ -125,6 +123,7 @@ public class DataManagementPlanManager {
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.metricsManager = metricsManager;
|
this.metricsManager = metricsManager;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -318,7 +317,7 @@ public class DataManagementPlanManager {
|
||||||
} else {
|
} else {
|
||||||
dataManagementPlan.fromDataModelNoDatasets(dataManagementPlanEntity);
|
dataManagementPlan.fromDataModelNoDatasets(dataManagementPlanEntity);
|
||||||
}
|
}
|
||||||
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null;
|
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? apiContext.getUtilitiesService().getGenericObjectMapper().readValue(dataManagementPlanEntity.getDmpProperties(), LinkedHashMap.class) : null;
|
||||||
|
|
||||||
if (dmpProperties != null && dataManagementPlan.getDynamicFields() != null)
|
if (dmpProperties != null && dataManagementPlan.getDynamicFields() != null)
|
||||||
dataManagementPlan.getDynamicFields().forEach(item -> {
|
dataManagementPlan.getDynamicFields().forEach(item -> {
|
||||||
|
@ -1474,8 +1473,8 @@ public class DataManagementPlanManager {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (dataset.getProperties() != null) {
|
if (dataset.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(dataset.getProperties());
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(dataset.getProperties(), LinkedHashMap.class);
|
||||||
properties = jobject.toMap();
|
;
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset);
|
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
|
@ -1763,9 +1762,9 @@ public class DataManagementPlanManager {
|
||||||
UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
dmp.setModified(new Date());
|
dmp.setModified(new Date());
|
||||||
dmp.setCreator(me);
|
dmp.setCreator(me);
|
||||||
Map<String, String> extraProperties = objectMapper.readValue(dmp.getExtraProperties(), HashMap.class);
|
Map<String, String> extraProperties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(dmp.getExtraProperties(), HashMap.class);
|
||||||
extraProperties.put("contact", me.getId().toString());
|
extraProperties.put("contact", me.getId().toString());
|
||||||
dmp.setExtraProperties(objectMapper.writeValueAsString(extraProperties));
|
dmp.setExtraProperties(apiContext.getUtilitiesService().getGenericObjectMapper().writeValueAsString(extraProperties));
|
||||||
dmp.setVersion(0);
|
dmp.setVersion(0);
|
||||||
dmp.setStatus((short)0);
|
dmp.setStatus((short)0);
|
||||||
dmp.setGroupId(UUID.randomUUID());
|
dmp.setGroupId(UUID.randomUUID());
|
||||||
|
@ -2043,7 +2042,7 @@ public class DataManagementPlanManager {
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
ZenodoDeposit deposit = DMPToZenodoMapper.fromDMP(dmp, environment, configLoader);
|
ZenodoDeposit deposit = DMPToZenodoMapper.fromDMP(dmp, environment, configLoader);
|
||||||
//if (Objects.requireNonNull(environment.getProperty("spring.profiles.active")).contains("devel")) {
|
//if (Objects.requireNonNull(environment.getProperty("spring.profiles.active")).contains("devel")) {
|
||||||
String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deposit);
|
String json = apiContext.getUtilitiesService().getGenericObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(deposit);
|
||||||
logger.info(json);
|
logger.info(json);
|
||||||
//}
|
//}
|
||||||
HttpEntity<ZenodoDeposit> request = new HttpEntity<>(deposit, headers);
|
HttpEntity<ZenodoDeposit> request = new HttpEntity<>(deposit, headers);
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||||
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
|
@ -56,8 +58,6 @@ import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -98,18 +98,18 @@ import java.util.stream.Stream;
|
||||||
public class DatasetManager {
|
public class DatasetManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class);
|
||||||
|
|
||||||
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] {
|
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][]{
|
||||||
{NotificationType.DATASET_MODIFIED, "/datasets/edit"},
|
{NotificationType.DATASET_MODIFIED, "/datasets/edit"},
|
||||||
{NotificationType.DATASET_MODIFIED_FINALISED, "/datasets/edit"}
|
{NotificationType.DATASET_MODIFIED_FINALISED, "/datasets/edit"}
|
||||||
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
|
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private DatasetRepository datasetRepository;
|
private final DatasetRepository datasetRepository;
|
||||||
private BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private UserManager userManager;
|
private final UserManager userManager;
|
||||||
private ConfigLoader configLoader;
|
private final ConfigLoader configLoader;
|
||||||
private Environment environment;
|
private final Environment environment;
|
||||||
private final MetricsManager metricsManager;
|
private final MetricsManager metricsManager;
|
||||||
private final FileManager fileManager;
|
private final FileManager fileManager;
|
||||||
|
|
||||||
|
@ -168,20 +168,14 @@ public class DatasetManager {
|
||||||
datasets = null;
|
datasets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfo userInfo = builderFactory.getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
|
||||||
// QueryableList<eu.eudat.data.entities.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
// QueryableList<eu.eudat.data.entities.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||||
QueryableList<eu.eudat.data.entities.Dataset> items;
|
QueryableList<eu.eudat.data.entities.Dataset> items;
|
||||||
if (datasets != null) {
|
if (datasets != null && !datasets.isEmpty()) {
|
||||||
|
//items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||||
if (!datasets.isEmpty()) {
|
final List<UUID> datasetIds = datasets.stream().map(datasetE -> UUID.fromString(datasetE.getId())).distinct().collect(Collectors.toList());
|
||||||
//items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
items = databaseRepository.getDatasetDao().filterFromElastic(datasetTableRequest.getCriteria(), datasetIds).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
||||||
final List<UUID> datasetIds = datasets.stream().map(datasetE -> UUID.fromString(datasetE.getId())).distinct().collect(Collectors.toList());
|
//items.where((builder, root) -> root.get("id").in(datasetIds));
|
||||||
items = databaseRepository.getDatasetDao().filterFromElastic(datasetTableRequest.getCriteria(), datasetIds).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
|
||||||
//items.where((builder, root) -> root.get("id").in(datasetIds));
|
|
||||||
} else {
|
|
||||||
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
|
||||||
//items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
||||||
}
|
}
|
||||||
|
@ -192,11 +186,11 @@ public class DatasetManager {
|
||||||
if (principal.getId() == null) {
|
if (principal.getId() == null) {
|
||||||
throw new UnauthorisedException("You are not allowed to access those datasets");
|
throw new UnauthorisedException("You are not allowed to access those datasets");
|
||||||
}
|
}
|
||||||
|
UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());//builderFactory.getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||||
if (datasetTableRequest.getCriteria().getRole() != null) {
|
if (datasetTableRequest.getCriteria().getRole() != null) {
|
||||||
roles.add(datasetTableRequest.getCriteria().getRole());
|
roles.add(datasetTableRequest.getCriteria().getRole());
|
||||||
}
|
}
|
||||||
authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles).distinct();
|
authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles).distinct();
|
||||||
pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
|
||||||
} else {
|
} else {
|
||||||
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
|
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
|
||||||
items.where((builder, root) -> {
|
items.where((builder, root) -> {
|
||||||
|
@ -204,12 +198,12 @@ public class DatasetManager {
|
||||||
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal.getId()), builder.equal(userJoin.get("role"), datasetTableRequest.getCriteria().getRole()));
|
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal.getId()), builder.equal(userJoin.get("role"), datasetTableRequest.getCriteria().getRole()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
String[] strings = new String[1];
|
//String[] strings = new String[1];
|
||||||
//strings[0] = "-dmp:publishedAt|join|";
|
//strings[0] = "-dmp:publishedAt|join|";
|
||||||
//datasetTableRequest.getOrderings().setFields(strings);
|
//datasetTableRequest.getOrderings().setFields(strings);
|
||||||
authItems = items;
|
authItems = items;
|
||||||
pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
|
||||||
}
|
}
|
||||||
|
pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
||||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
|
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,8 +381,12 @@ public class DatasetManager {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||||
datasetprofile.setStatus(dataset.getStatus());
|
datasetprofile.setStatus(dataset.getStatus());
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
Map<String, Object> properties = null;
|
||||||
Map<String, Object> properties = jObject.toMap();
|
try {
|
||||||
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(datasetEntity.getProperties(), LinkedHashMap.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
datasetprofile.fromJsonObject(properties);
|
datasetprofile.fromJsonObject(properties);
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
|
@ -456,8 +454,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(datasetEntity.getProperties(), LinkedHashMap.class);
|
||||||
properties = jObject.toMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||||
|
@ -489,8 +486,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (dataset.getDatasetProfileDefinition() != null) {
|
if (dataset.getDatasetProfileDefinition() != null) {
|
||||||
JSONObject jObject = new JSONObject(propertiesModelToString(dataset.getDatasetProfileDefinition()));
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(propertiesModelToString(dataset.getDatasetProfileDefinition()), LinkedHashMap.class);
|
||||||
properties = jObject.toMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||||
|
@ -547,8 +543,7 @@ public class DatasetManager {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(datasetEntity.getProperties(), LinkedHashMap.class);
|
||||||
properties = jobject.toMap();
|
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
|
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
|
@ -609,6 +604,7 @@ public class DatasetManager {
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = dataset1.getDmp().getId();
|
UUID dmpId = dataset1.getDmp().getId();
|
||||||
dataset1.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
dataset1.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
|
this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo);
|
||||||
updateTags(dataset1, datasetWizardModel.getTags());
|
updateTags(dataset1, datasetWizardModel.getTags());
|
||||||
if (sendNotification) {
|
if (sendNotification) {
|
||||||
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
|
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
|
||||||
|
@ -618,9 +614,6 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo);
|
|
||||||
|
|
||||||
|
|
||||||
return dataset1;
|
return dataset1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +624,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
String json = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());;
|
String json = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
||||||
JsonNode propertiesJson = mapper.readTree(json);
|
JsonNode propertiesJson = mapper.readTree(json);
|
||||||
|
|
||||||
Set<JsonNode> uploadNodes = new HashSet<>();
|
Set<JsonNode> uploadNodes = new HashSet<>();
|
||||||
|
@ -641,11 +634,15 @@ public class DatasetManager {
|
||||||
JsonNode value = node.get("value");
|
JsonNode value = node.get("value");
|
||||||
if (value != null && !value.toString().equals("\"\"") && !value.toString().equals("null")) {
|
if (value != null && !value.toString().equals("\"\"") && !value.toString().equals("null")) {
|
||||||
String stringValue = value.toString().replaceAll("=", ":");
|
String stringValue = value.toString().replaceAll("=", ":");
|
||||||
JSONObject values = new JSONObject(stringValue);
|
Map<String, Object> data = null;
|
||||||
Map<String, Object> data = ((JSONObject) values).toMap();
|
try {
|
||||||
|
data = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(stringValue, LinkedHashMap.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
int index = fileUploadIds.indexOf(data.get("id").toString());
|
int index = fileUploadIds.indexOf(data.get("id").toString());
|
||||||
if(index != -1) {
|
if (index != -1) {
|
||||||
// file in DB is the same as file in the Dataset
|
// file in DB is the same as file in the Dataset
|
||||||
fileUploadIds.remove(index);
|
fileUploadIds.remove(index);
|
||||||
fileUploads.remove(index);
|
fileUploads.remove(index);
|
||||||
|
@ -657,9 +654,7 @@ public class DatasetManager {
|
||||||
});
|
});
|
||||||
|
|
||||||
// old files in DB that are not contained anymore in the Dataset -> mark them as Deleted
|
// old files in DB that are not contained anymore in the Dataset -> mark them as Deleted
|
||||||
fileUploads.forEach(fileUpload -> {
|
fileUploads.forEach(fileManager::markOldFileAsDeleted);
|
||||||
fileManager.markOldFileAsDeleted(fileUpload);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(Dataset dataset, DMP dmp, UserInfo user, NotificationType notificationType) {
|
private void sendNotification(Dataset dataset, DMP dmp, UserInfo user, NotificationType notificationType) {
|
||||||
|
@ -707,9 +702,9 @@ public class DatasetManager {
|
||||||
nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
|
nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
|
||||||
|
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(dataset.getProperties());
|
Map<String, Object> obj = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(dataset.getProperties(), LinkedHashMap.class);
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
visibilityRuleService.setProperties(obj.toMap());
|
visibilityRuleService.setProperties(obj);
|
||||||
|
|
||||||
dataset.setProfile(profile);
|
dataset.setProfile(profile);
|
||||||
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), dataset);
|
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), dataset);
|
||||||
|
@ -719,7 +714,7 @@ public class DatasetManager {
|
||||||
String failedField = null;
|
String failedField = null;
|
||||||
|
|
||||||
for (String validator : datasetProfileValidators) {
|
for (String validator : datasetProfileValidators) {
|
||||||
if (obj.has(validator) && isNullOrEmpty(obj.getString(validator)) && isElementVisible(nodeList, validator, visibilityRuleService)) {
|
if (obj.containsKey(validator) && isNullOrEmpty(obj.get(validator).toString()) && isElementVisible(nodeList, validator, visibilityRuleService)) {
|
||||||
//throw new Exception("Field value of " + validator + " must be filled.");
|
//throw new Exception("Field value of " + validator + " must be filled.");
|
||||||
failedField = validator;
|
failedField = validator;
|
||||||
break;
|
break;
|
||||||
|
@ -759,8 +754,12 @@ public class DatasetManager {
|
||||||
private String propertiesModelToString(PagedDatasetProfile pagedDatasetProfile) {
|
private String propertiesModelToString(PagedDatasetProfile pagedDatasetProfile) {
|
||||||
Map<String, Object> values = new LinkedHashMap<>();
|
Map<String, Object> values = new LinkedHashMap<>();
|
||||||
pagedDatasetProfile.toMap(values);
|
pagedDatasetProfile.toMap(values);
|
||||||
JSONObject jobject = new JSONObject(values);
|
try {
|
||||||
return jobject.toString();
|
return apiContext.getUtilitiesService().getGenericObjectMapper().writeValueAsString(values);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception {
|
public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception {
|
||||||
|
@ -969,12 +968,9 @@ public class DatasetManager {
|
||||||
)))))
|
)))))
|
||||||
.collect(Collectors.toMap(DatasetImportField::getId, DatasetImportField::getValue));
|
.collect(Collectors.toMap(DatasetImportField::getId, DatasetImportField::getValue));
|
||||||
|
|
||||||
// Transforms map into json file.
|
|
||||||
JSONObject jsonDatasetProperties = new JSONObject(importMap);
|
|
||||||
|
|
||||||
// Creates the entity data set to save.
|
// Creates the entity data set to save.
|
||||||
eu.eudat.data.entities.Dataset entity = new Dataset();
|
eu.eudat.data.entities.Dataset entity = new Dataset();
|
||||||
entity.setProperties(jsonDatasetProperties.toString());
|
entity.setProperties(apiContext.getUtilitiesService().getGenericObjectMapper().writeValueAsString(importMap));
|
||||||
entity.setLabel(importFile.getOriginalFilename());
|
entity.setLabel(importFile.getOriginalFilename());
|
||||||
DMP dmp = new DMP();
|
DMP dmp = new DMP();
|
||||||
dmp.setId(UUID.fromString(dmpId));
|
dmp.setId(UUID.fromString(dmpId));
|
||||||
|
@ -1047,8 +1043,12 @@ public class DatasetManager {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||||
datasetprofile.setStatus(datasetEntity.getStatus());
|
datasetprofile.setStatus(datasetEntity.getStatus());
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
Map<String, Object> properties = null;
|
||||||
Map<String, Object> properties = jobject.toMap();
|
try {
|
||||||
|
properties = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(datasetEntity.getProperties(), LinkedHashMap.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
datasetprofile.fromJsonObject(properties);
|
datasetprofile.fromJsonObject(properties);
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
|
@ -1117,11 +1117,15 @@ public class DatasetManager {
|
||||||
JsonNode value = node.get("value");
|
JsonNode value = node.get("value");
|
||||||
if (!value.toString().equals("\"\"") && !value.toString().equals("null") && value.toString().startsWith("[")) {
|
if (!value.toString().equals("\"\"") && !value.toString().equals("null") && value.toString().startsWith("[")) {
|
||||||
String stringValue = value.toString().replaceAll("=", ":");
|
String stringValue = value.toString().replaceAll("=", ":");
|
||||||
JSONArray values = new JSONArray(stringValue);
|
List<Tag> values = null;
|
||||||
values.iterator().forEachRemaining(element -> {
|
try {
|
||||||
Map<String, Object> data = ((JSONObject) element).toMap();
|
CollectionType tagCollection = TypeFactory.defaultInstance().constructCollectionType(LinkedList.class, Tag.class);
|
||||||
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
|
values = apiContext.getUtilitiesService().getGenericObjectMapper().readValue(stringValue, tagCollection);
|
||||||
});
|
values.iterator().forEachRemaining(element -> this.addTag(tags, wizardModel.getTags(), element.getId(), element.getName()));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
List<String> values = Arrays.asList(value.textValue().split(", "));
|
List<String> values = Arrays.asList(value.textValue().split(", "));
|
||||||
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
|
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
|
||||||
|
|
|
@ -60,6 +60,10 @@ public class FileManager {
|
||||||
databaseRepository.getFileUploadDao().createOrUpdate(fileUpload);
|
databaseRepository.getFileUploadDao().createOrUpdate(fileUpload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FileUpload> getDeletedFileUploads() {
|
||||||
|
return databaseRepository.getFileUploadDao().asQueryable().where(((builder, root) -> builder.equal(root.get("isDeleted"), true))).toList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<FileUpload> getFileUploadsForEntityId(String entityId) {
|
public List<FileUpload> getFileUploadsForEntityId(String entityId) {
|
||||||
return databaseRepository.getFileUploadDao().asQueryable()
|
return databaseRepository.getFileUploadDao().asQueryable()
|
||||||
.where((builder, root) -> builder.equal(root.get("entityId"), entityId)).toList();
|
.where((builder, root) -> builder.equal(root.get("entityId"), entityId)).toList();
|
||||||
|
@ -74,9 +78,7 @@ public class FileManager {
|
||||||
|
|
||||||
public void markAllFilesOfEntityIdAsDeleted(UUID entityId) {
|
public void markAllFilesOfEntityIdAsDeleted(UUID entityId) {
|
||||||
List<FileUpload> fileUploads = this.getCurrentFileUploadsForEntityId(entityId);
|
List<FileUpload> fileUploads = this.getCurrentFileUploadsForEntityId(entityId);
|
||||||
fileUploads.forEach(fileUpload -> {
|
fileUploads.forEach(this::markOldFileAsDeleted);
|
||||||
this.markOldFileAsDeleted(fileUpload);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createFile(String id, String fileName, String fileType, String entityId, FileUpload.EntityType entityType, UserInfo userInfo) {
|
public void createFile(String id, String fileName, String fileType, String entityId, FileUpload.EntityType entityType, UserInfo userInfo) {
|
||||||
|
|
|
@ -33,7 +33,6 @@ import eu.eudat.models.data.userinfo.UserProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -129,13 +128,13 @@ public class UserManager {
|
||||||
eu.eudat.data.entities.UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
eu.eudat.data.entities.UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
|
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
|
||||||
HashMap<String, Object> result =
|
HashMap<String, Object> result =
|
||||||
new ObjectMapper().readValue(userInfo.getAdditionalinfo(), HashMap.class);
|
apiContext.getUtilitiesService().getGenericObjectMapper().readValue(userInfo.getAdditionalinfo(), HashMap.class);
|
||||||
userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName()));
|
userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName()));
|
||||||
settings.remove("name");
|
settings.remove("name");
|
||||||
result.putAll(settings);
|
result.putAll(settings);
|
||||||
userInfo.setAdditionalinfo(new JSONObject(result).toString());
|
userInfo.setAdditionalinfo(apiContext.getUtilitiesService().getGenericObjectMapper().writeValueAsString(result));
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
|
||||||
.createOrUpdate(userInfo);
|
.createOrUpdate(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrincipalModel authenticate(AuthenticationService authenticationServiceImpl, Credentials credentials) throws NullEmailException {
|
public PrincipalModel authenticate(AuthenticationService authenticationServiceImpl, Credentials credentials) throws NullEmailException {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import eu.eudat.models.data.datasetprofile.RenderStyle;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
import eu.eudat.models.data.license.LicenseModel;
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -35,6 +35,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PrefillingMapper {
|
public class PrefillingMapper {
|
||||||
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
||||||
|
private static final List<String> tagDelimiters = Arrays.asList(", ", "; ");
|
||||||
|
|
||||||
public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
||||||
DatasetProfile profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
DatasetProfile profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
||||||
|
@ -155,10 +156,10 @@ public class PrefillingMapper {
|
||||||
properties.put(id, mapper.valueToTree(parseTags(parsedValue)).toString());
|
properties.put(id, mapper.valueToTree(parseTags(parsedValue)).toString());
|
||||||
break;
|
break;
|
||||||
case DATASET_IDENTIFIER:
|
case DATASET_IDENTIFIER:
|
||||||
JSONObject datasetID = new JSONObject();
|
Map<String, String> datasetId = new LinkedHashMap<>();
|
||||||
datasetID.put("identifier", parsedValue);
|
datasetId.put("identifier", parsedValue);
|
||||||
if(type.equals("zenodo")){
|
if (type.equals("zenodo")) {
|
||||||
datasetID.put("type", "doi");
|
datasetId.put("type", "doi");
|
||||||
}
|
}
|
||||||
properties.put(id, datasetID.toString());
|
properties.put(id, datasetID.toString());
|
||||||
break;
|
break;
|
||||||
|
@ -225,13 +226,23 @@ public class PrefillingMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Tag> parseTags(String value) throws JsonProcessingException {
|
private static List<Tag> parseTags(String value) throws JsonProcessingException {
|
||||||
|
|
||||||
if (value == null || value.isEmpty())
|
if (value == null || value.isEmpty())
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
String[] rawTags = value.split(", ");
|
String[] rawTags = null;
|
||||||
List<Tag> parsedTags = new LinkedList<>();
|
for (String tagDelim : tagDelimiters) {
|
||||||
for (String rawTag : rawTags) {
|
rawTags = value.split(tagDelim);
|
||||||
parsedTags.add(new Tag(rawTag, rawTag));
|
if (rawTags.length > 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parsedTags;
|
if (rawTags != null) {
|
||||||
|
List<Tag> parsedTags = new LinkedList<>();
|
||||||
|
for (String rawTag : rawTags) {
|
||||||
|
parsedTags.add(new Tag(rawTag, rawTag));
|
||||||
|
}
|
||||||
|
return parsedTags;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.net.*;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
public class Proxy {
|
public class Proxy {
|
||||||
|
|
||||||
private String allowedHost;
|
private String allowedHost;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.eudat.logic.security.customproviders.B2Access;
|
package eu.eudat.logic.security.customproviders.B2Access;
|
||||||
|
|
||||||
import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
|
|
||||||
import eu.eudat.logic.security.validators.b2access.helpers.B2AccessResponseToken;
|
import eu.eudat.logic.security.validators.b2access.helpers.B2AccessResponseToken;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -14,6 +13,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Component("b2AccessCustomProvider")
|
@Component("b2AccessCustomProvider")
|
||||||
|
@ -60,8 +60,7 @@ public class B2AccessCustomProviderImpl implements B2AccessCustomProvider {
|
||||||
private HttpHeaders createBasicAuthHeaders(String username, String password) {
|
private HttpHeaders createBasicAuthHeaders(String username, String password) {
|
||||||
return new HttpHeaders() {{
|
return new HttpHeaders() {{
|
||||||
String auth = username + ":" + password;
|
String auth = username + ":" + password;
|
||||||
byte[] encodedAuth = Base64.encodeBase64(
|
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(Charset.forName("US-ASCII")));
|
||||||
auth.getBytes(Charset.forName("US-ASCII")));
|
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
String authHeader = "Basic " + new String(encodedAuth);
|
||||||
set("Authorization", authHeader);
|
set("Authorization", authHeader);
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;
|
||||||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
||||||
import com.google.api.client.http.HttpTransport;
|
import com.google.api.client.http.HttpTransport;
|
||||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
import com.google.api.client.json.gson.GsonFactory;
|
||||||
import eu.eudat.logic.security.validators.TokenValidator;
|
import eu.eudat.logic.security.validators.TokenValidator;
|
||||||
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
||||||
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
||||||
|
@ -29,9 +29,9 @@ public class GoogleTokenValidator implements TokenValidator {
|
||||||
@Autowired
|
@Autowired
|
||||||
public GoogleTokenValidator(Environment environment, AuthenticationService nonVerifiedUserAuthenticationService) {
|
public GoogleTokenValidator(Environment environment, AuthenticationService nonVerifiedUserAuthenticationService) {
|
||||||
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
||||||
verifier = new GoogleIdTokenVerifier.Builder(transport, JacksonFactory.getDefaultInstance())
|
verifier = new GoogleIdTokenVerifier.Builder(transport, GsonFactory.getDefaultInstance())
|
||||||
.setAudience(Collections.singletonList(environment.getProperty("google.login.clientId")))
|
.setAudience(Collections.singletonList(environment.getProperty("google.login.clientId")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GoogleIdToken verifyUserAndGetUser(String idTokenString) throws IOException, GeneralSecurityException {
|
private GoogleIdToken verifyUserAndGetUser(String idTokenString) throws IOException, GeneralSecurityException {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.services.operations.authentication;
|
package eu.eudat.logic.services.operations.authentication;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.data.entities.Credential;
|
import eu.eudat.data.entities.Credential;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserRole;
|
import eu.eudat.data.entities.UserRole;
|
||||||
|
@ -14,7 +15,6 @@ import eu.eudat.models.data.login.Credentials;
|
||||||
import eu.eudat.models.data.loginprovider.LoginProviderUser;
|
import eu.eudat.models.data.loginprovider.LoginProviderUser;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -164,8 +164,13 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Map<String, Object> additionalInfo = userInfo.getAdditionalinfo() != null ?
|
Map<String, Object> additionalInfo = null;
|
||||||
new JSONObject(userInfo.getAdditionalinfo()).toMap() : new HashMap<>();
|
try {
|
||||||
|
additionalInfo = userInfo.getAdditionalinfo() != null ?
|
||||||
|
apiContext.getUtilitiesService().getGenericObjectMapper().readValue(userInfo.getAdditionalinfo(), LinkedHashMap.class) : new HashMap<>();
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
if (profile.getAvatarUrl() != null && !profile.getAvatarUrl().isEmpty() && !profile.getAvatarUrl().equals("null")) {
|
if (profile.getAvatarUrl() != null && !profile.getAvatarUrl().isEmpty() && !profile.getAvatarUrl().equals("null")) {
|
||||||
additionalInfo.put("avatarUrl", profile.getAvatarUrl());
|
additionalInfo.put("avatarUrl", profile.getAvatarUrl());
|
||||||
}
|
}
|
||||||
|
@ -182,7 +187,11 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
|
||||||
additionalInfo.put("zenodoEmail", profile.getEmail());
|
additionalInfo.put("zenodoEmail", profile.getEmail());
|
||||||
}
|
}
|
||||||
userInfo.setLastloggedin(new Date());
|
userInfo.setLastloggedin(new Date());
|
||||||
userInfo.setAdditionalinfo(new JSONObject(additionalInfo).toString());
|
try {
|
||||||
|
userInfo.setAdditionalinfo(apiContext.getUtilitiesService().getGenericObjectMapper().writeValueAsString(additionalInfo));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
Set<Credential> credentials = userInfo.getCredentials();
|
Set<Credential> credentials = userInfo.getCredentials();
|
||||||
if (credentials.contains(credential)) {
|
if (credentials.contains(credential)) {
|
||||||
Credential oldCredential = credentials.stream().filter(item -> credential.getProvider().equals(item.getProvider())).findFirst().get();
|
Credential oldCredential = credentials.stream().filter(item -> credential.getProvider().equals(item.getProvider())).findFirst().get();
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
package eu.eudat.logic.services.operations.authentication;
|
package eu.eudat.logic.services.operations.authentication;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.Credential;
|
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserRole;
|
import eu.eudat.data.entities.UserRole;
|
||||||
import eu.eudat.data.entities.UserToken;
|
import eu.eudat.data.entities.UserToken;
|
||||||
import eu.eudat.exceptions.security.NullEmailException;
|
import eu.eudat.exceptions.security.NullEmailException;
|
||||||
import eu.eudat.logic.builders.entity.CredentialBuilder;
|
|
||||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
|
||||||
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
|
||||||
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
||||||
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.login.Credentials;
|
|
||||||
import eu.eudat.models.data.loginprovider.LoginProviderUser;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Service("verifiedUserAuthenticationService")
|
@Service("verifiedUserAuthenticationService")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
import eu.eudat.models.data.mail.SimpleMail;
|
import eu.eudat.models.data.mail.SimpleMail;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,10 +16,15 @@ import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.MimeBodyPart;
|
import javax.mail.internet.MimeBodyPart;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
import javax.mail.internet.MimeMultipart;
|
import javax.mail.internet.MimeMultipart;
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("mailService")
|
@Service("mailService")
|
||||||
|
@ -84,10 +88,11 @@ public class MailServiceImpl implements MailService {
|
||||||
Resource resource = applicationContext.getResource(resourceTemplate);
|
Resource resource = applicationContext.getResource(resourceTemplate);
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = resource.getInputStream();
|
InputStream inputStream = resource.getInputStream();
|
||||||
StringWriter writer = new StringWriter();
|
String tempate = new BufferedReader(
|
||||||
IOUtils.copy(inputStream, writer, "UTF-8");
|
new InputStreamReader(inputStream, StandardCharsets.UTF_8)
|
||||||
|
).lines().collect(Collectors.joining("\n"));
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
return writer.toString();
|
return tempate;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,4 +13,6 @@ public interface UtilitiesService {
|
||||||
MailService getMailService();
|
MailService getMailService();
|
||||||
|
|
||||||
ConfirmationEmailService getConfirmationEmailService();
|
ConfirmationEmailService getConfirmationEmailService();
|
||||||
|
|
||||||
|
ObjectMapper getGenericObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -14,12 +15,14 @@ public class UtilitiesServiceImpl implements UtilitiesService {
|
||||||
private InvitationService invitationService;
|
private InvitationService invitationService;
|
||||||
private MailService mailService;
|
private MailService mailService;
|
||||||
private ConfirmationEmailService confirmationEmailService;
|
private ConfirmationEmailService confirmationEmailService;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, ConfirmationEmailService confirmationEmailService) {
|
public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, ConfirmationEmailService confirmationEmailService) {
|
||||||
this.invitationService = invitationService;
|
this.invitationService = invitationService;
|
||||||
this.mailService = mailService;
|
this.mailService = mailService;
|
||||||
this.confirmationEmailService = confirmationEmailService;
|
this.confirmationEmailService = confirmationEmailService;
|
||||||
|
this.objectMapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +30,11 @@ public class UtilitiesServiceImpl implements UtilitiesService {
|
||||||
return confirmationEmailService;
|
return confirmationEmailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectMapper getGenericObjectMapper() {
|
||||||
|
return this.objectMapper;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InvitationService getInvitationService() {
|
public InvitationService getInvitationService() {
|
||||||
return invitationService;
|
return invitationService;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.utilities.builders;
|
package eu.eudat.logic.utilities.builders;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.helpers.FieldFactory;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.DatabaseViewStyleDefinition;
|
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.models.data.components.commons.datafield.*;
|
import eu.eudat.models.data.components.commons.datafield.*;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
|
import eu.eudat.models.data.entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
|
||||||
|
@ -20,9 +21,7 @@ public class ModelBuilder {
|
||||||
for (U item : items) {
|
for (U item : items) {
|
||||||
try {
|
try {
|
||||||
list.add(item.toDatabaseDefinition(clazz.newInstance()));
|
list.add(item.toDatabaseDefinition(clazz.newInstance()));
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +33,7 @@ public class ModelBuilder {
|
||||||
for (U item : items) {
|
for (U item : items) {
|
||||||
try {
|
try {
|
||||||
list.add(item.toDatabaseDefinition(clazz.newInstance()));
|
list.add(item.toDatabaseDefinition(clazz.newInstance()));
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,64 +47,71 @@ public class ModelBuilder {
|
||||||
U modelItem = clazz.newInstance();
|
U modelItem = clazz.newInstance();
|
||||||
modelItem.fromDatabaseDefinition(item);
|
modelItem.fromDatabaseDefinition(item);
|
||||||
list.add(modelItem);
|
list.add(modelItem);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <U> FieldData<U> toFieldData(Object data, String type, Element dataElement) {
|
public FieldData toFieldData(Object data, String type, Element dataElement) {
|
||||||
if (type.equals("combobox")) {
|
if (dataElement != null && dataElement.hasAttribute("type")) {
|
||||||
|
logger.info("Type " + type + " SubType " + dataElement.getAttribute("type"));
|
||||||
|
return FieldFactory.fromData(type, data, dataElement.getAttribute("type"));
|
||||||
|
}
|
||||||
|
return FieldFactory.fromData(type, data);
|
||||||
|
/*if (type.equals("combobox")) {
|
||||||
if (dataElement != null) {
|
if (dataElement != null) {
|
||||||
if (dataElement.getAttribute("type").equals("autocomplete")) {
|
if (dataElement.getAttribute("type").equals("autocomplete")) {
|
||||||
return (FieldData<U>) new AutoCompleteData().fromData(data);
|
return new AutoCompleteData().fromData(data);
|
||||||
} else if (dataElement.getAttribute("type").equals("wordlist"))
|
} else if (dataElement.getAttribute("type").equals("wordlist"))
|
||||||
return (FieldData<U>) new WordListData().fromData(data);
|
return new WordListData().fromData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.equals("internalDmpEntities")) {
|
if (type.equals("internalDmpEntities")) {
|
||||||
if (dataElement != null) {
|
if (dataElement != null) {
|
||||||
if (dataElement.getAttribute("type").equals("researchers")) {
|
if (dataElement.getAttribute("type").equals("researchers")) {
|
||||||
return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data);
|
return new ResearchersAutoCompleteData().fromData(data);
|
||||||
}
|
}
|
||||||
else if (dataElement.getAttribute("type").equals("datasets"))
|
else if (dataElement.getAttribute("type").equals("datasets"))
|
||||||
return (FieldData<U>) new DatasetsAutoCompleteData().fromData(data);
|
return new DatasetsAutoCompleteData().fromData(data);
|
||||||
else if (dataElement.getAttribute("type").equals("dmps"))
|
else if (dataElement.getAttribute("type").equals("dmps"))
|
||||||
return (FieldData<U>) new DMPsAutoCompleteData().fromData(data);
|
return new DMPsAutoCompleteData().fromData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.equals("booleanDecision")) return (FieldData<U>) new BooleanDecisionData().fromData(data);
|
if (type.equals("booleanDecision")) return new BooleanDecisionData().fromData(data);
|
||||||
if (type.equals("radiobox")) return (FieldData<U>) new RadioBoxData().fromData(data);
|
if (type.equals("radiobox")) return new RadioBoxData().fromData(data);
|
||||||
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
if (type.equals("checkBox")) return new CheckBoxData().fromData(data);
|
||||||
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
if (type.equals("freetext")) return new FreeTextData().fromData(data);
|
||||||
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
if (type.equals("textarea")) return new TextAreaData().fromData(data);
|
||||||
if (type.equals("richTextarea")) return (FieldData<U>) new RichTextAreaData().fromData(data);
|
if (type.equals("richTextarea")) return new RichTextAreaData().fromData(data);
|
||||||
if (type.equals("upload")) return (FieldData<U>) new UploadData().fromData(data);
|
if (type.equals("upload")) return new UploadData().fromData(data);
|
||||||
// if (type.equals("table")) return (FieldData<U>) new TableData().fromData(data);
|
// if (type.equals("table")) return (FieldData<U>) new TableData().fromData(data);
|
||||||
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
|
if (type.equals("datePicker")) return new DatePickerData().fromData(data);
|
||||||
if (type.equals("externalDatasets")) return (FieldData<U>) new ExternalDatasetsData().fromData(data);
|
if (type.equals("externalDatasets")) return new ExternalDatasetsData().fromData(data);
|
||||||
if (type.equals("dataRepositories")) return (FieldData<U>) new DataRepositoriesData().fromData(data);
|
if (type.equals("dataRepositories")) return new DataRepositoriesData().fromData(data);
|
||||||
if (type.equals("pubRepositories")) return (FieldData<U>) new DataRepositoriesData().fromData(data);
|
if (type.equals("pubRepositories")) return new DataRepositoriesData().fromData(data);
|
||||||
if (type.equals("journalRepositories")) return (FieldData<U>) new DataRepositoriesData().fromData(data);
|
if (type.equals("journalRepositories")) return new DataRepositoriesData().fromData(data);
|
||||||
if (type.equals("taxonomies")) return (FieldData<U>) new TaxonomiesData().fromData(data);
|
if (type.equals("taxonomies")) return new TaxonomiesData().fromData(data);
|
||||||
if (type.equals("licenses")) return (FieldData<U>) new LicensesData().fromData(data);
|
if (type.equals("licenses")) return new LicensesData().fromData(data);
|
||||||
if (type.equals("publications")) return (FieldData<U>) new PublicationsData().fromData(data);
|
if (type.equals("publications")) return new PublicationsData().fromData(data);
|
||||||
if (type.equals("registries")) return (FieldData<U>) new RegistriesData().fromData(data);
|
if (type.equals("registries")) return new RegistriesData().fromData(data);
|
||||||
if (type.equals("services")) return (FieldData<U>) new ServicesData().fromData(data);
|
if (type.equals("services")) return new ServicesData().fromData(data);
|
||||||
if (type.equals("tags")) return (FieldData<U>) new TagsData().fromData(data);
|
if (type.equals("tags")) return new TagsData().fromData(data);
|
||||||
if (type.equals("researchers")) return (FieldData<U>) new ResearcherData().fromData(data);
|
if (type.equals("researchers")) return new ResearcherData().fromData(data);
|
||||||
if (type.equals("organizations")) return (FieldData<U>) new OrganizationsData().fromData(data);
|
if (type.equals("organizations")) return new OrganizationsData().fromData(data);
|
||||||
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
|
if (type.equals("datasetIdentifier")) return new DatasetIdentifierData().fromData(data);
|
||||||
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
|
if (type.equals("currency")) return new CurrencyData().fromData(data);
|
||||||
if (type.equals("validation")) return (FieldData<U>) new ValidationData().fromData(data);
|
if (type.equals("validation")) return new ValidationData().fromData(data);*/
|
||||||
return null;
|
//return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <U> FieldData<U> toFieldData(Object data, String type) {
|
public FieldData toFieldData(Object data, String type) {
|
||||||
if (type.equals("combobox")) {
|
if (data != null && ((Map<String, Object>) data).containsKey("type")) {
|
||||||
|
return FieldFactory.fromData(type, data, (String) ((Map<String, Object>) data).get("type"));
|
||||||
|
}
|
||||||
|
return FieldFactory.fromData(type, data);
|
||||||
|
/*if (type.equals("combobox")) {
|
||||||
String comboboxType = (String) ((Map<String, Object>) data).get("type");
|
String comboboxType = (String) ((Map<String, Object>) data).get("type");
|
||||||
if (comboboxType.equals("autocomplete")) {
|
if (comboboxType.equals("autocomplete")) {
|
||||||
return (FieldData<U>) new AutoCompleteData().fromData(data);
|
return (FieldData<U>) new AutoCompleteData().fromData(data);
|
||||||
|
@ -150,6 +154,6 @@ public class ModelBuilder {
|
||||||
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
|
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
|
||||||
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
|
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
|
||||||
if (type.equals("validation")) return (FieldData<U>) new ValidationData().fromData(data);
|
if (type.equals("validation")) return (FieldData<U>) new ValidationData().fromData(data);
|
||||||
return null;
|
return null;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.logic.utilities.documents.pdf;
|
package eu.eudat.logic.utilities.documents.pdf;
|
||||||
|
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
@ -36,7 +35,8 @@ public class PDFUtils {
|
||||||
|
|
||||||
File resultPdf = new File(environment.getProperty("temp.temp") + uuid + ".pdf");
|
File resultPdf = new File(environment.getProperty("temp.temp") + uuid + ".pdf");
|
||||||
FileOutputStream output = new FileOutputStream(resultPdf);
|
FileOutputStream output = new FileOutputStream(resultPdf);
|
||||||
IOUtils.write(queueResult, output);
|
output.write(queueResult);
|
||||||
|
output.flush();
|
||||||
output.close();
|
output.close();
|
||||||
Files.deleteIfExists(file.getFile().toPath());
|
Files.deleteIfExists(file.getFile().toPath());
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.utilities.documents.word;
|
package eu.eudat.logic.utilities.documents.word;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
|
@ -15,11 +16,12 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STNumberFormat;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -45,26 +47,27 @@ import static org.apache.poi.xwpf.usermodel.Document.*;
|
||||||
|
|
||||||
public class WordBuilder {
|
public class WordBuilder {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WordBuilder.class);
|
private static final Logger logger = LoggerFactory.getLogger(WordBuilder.class);
|
||||||
private static final Map<String, Integer> IMAGE_TYPE_MAP = Stream.of(new Object[][] {
|
private static final Map<String, Integer> IMAGE_TYPE_MAP = Stream.of(new Object[][]{
|
||||||
{"image/jpeg", PICTURE_TYPE_JPEG},
|
{"image/jpeg", PICTURE_TYPE_JPEG},
|
||||||
{"image/png", PICTURE_TYPE_PNG},
|
{"image/png", PICTURE_TYPE_PNG},
|
||||||
{"image/gif", PICTURE_TYPE_GIF},
|
{"image/gif", PICTURE_TYPE_GIF},
|
||||||
{"image/tiff", PICTURE_TYPE_TIFF},
|
{"image/tiff", PICTURE_TYPE_TIFF},
|
||||||
{"image/bmp", PICTURE_TYPE_BMP},
|
{"image/bmp", PICTURE_TYPE_BMP},
|
||||||
{"image/wmf", PICTURE_TYPE_WMF}
|
{"image/wmf", PICTURE_TYPE_WMF}
|
||||||
}
|
}
|
||||||
).collect(Collectors.toMap(objects -> (String)objects[0], o -> (Integer)o[1]));
|
).collect(Collectors.toMap(objects -> (String) objects[0], o -> (Integer) o[1]));
|
||||||
|
|
||||||
private Map<ParagraphStyle, ApplierWithValue<XWPFDocument, Object, XWPFParagraph>> options = new HashMap<>();
|
private final Map<ParagraphStyle, ApplierWithValue<XWPFDocument, Object, XWPFParagraph>> options = new HashMap<>();
|
||||||
private CTAbstractNum cTAbstractNum;
|
private final CTAbstractNum cTAbstractNum;
|
||||||
private BigInteger numId;
|
private BigInteger numId;
|
||||||
private Integer indent;
|
private Integer indent;
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
public WordBuilder(Environment environment) {
|
public WordBuilder(Environment environment) {
|
||||||
this.cTAbstractNum = CTAbstractNum.Factory.newInstance();
|
this.cTAbstractNum = CTAbstractNum.Factory.newInstance();
|
||||||
this.cTAbstractNum.setAbstractNumId(BigInteger.valueOf(1));
|
this.cTAbstractNum.setAbstractNumId(BigInteger.valueOf(1));
|
||||||
this.indent = 0;
|
this.indent = 0;
|
||||||
|
this.mapper = new ObjectMapper();
|
||||||
this.buildOptions(environment);
|
this.buildOptions(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +167,7 @@ public class WordBuilder {
|
||||||
int format;
|
int format;
|
||||||
format = IMAGE_TYPE_MAP.getOrDefault(fileType, 0);
|
format = IMAGE_TYPE_MAP.getOrDefault(fileType, 0);
|
||||||
try {
|
try {
|
||||||
FileInputStream image = new FileInputStream(environment.getProperty("file.storage") + imageId);
|
|
||||||
ImageInputStream iis = ImageIO.createImageInputStream(new File(environment.getProperty("file.storage") + imageId));
|
ImageInputStream iis = ImageIO.createImageInputStream(new File(environment.getProperty("file.storage") + imageId));
|
||||||
Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
|
Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
|
||||||
if (readers.hasNext()) {
|
if (readers.hasNext()) {
|
||||||
|
@ -174,30 +177,30 @@ public class WordBuilder {
|
||||||
int initialImageWidth = reader.getWidth(0);
|
int initialImageWidth = reader.getWidth(0);
|
||||||
int initialImageHeight = reader.getHeight(0);
|
int initialImageHeight = reader.getHeight(0);
|
||||||
|
|
||||||
float ratio = initialImageHeight / (float)initialImageWidth;
|
float ratio = initialImageHeight / (float) initialImageWidth;
|
||||||
|
|
||||||
int marginLeftInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getLeft().intValue();
|
int marginLeftInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getLeft()).intValue();
|
||||||
int marginRightInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getRight().intValue();
|
int marginRightInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getRight()).intValue();
|
||||||
int pageWidthInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getW().intValue();
|
int pageWidthInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getW()).intValue();
|
||||||
int pageWidth = Math.round((pageWidthInDXA - marginLeftInDXA - marginRightInDXA) / (float)20); // /20 converts dxa to points
|
int pageWidth = Math.round((pageWidthInDXA - marginLeftInDXA - marginRightInDXA) / (float) 20); // /20 converts dxa to points
|
||||||
|
|
||||||
int imageWidth = Math.round(initialImageWidth*(float)0.75); // *0.75 converts pixels to points
|
int imageWidth = Math.round(initialImageWidth * (float) 0.75); // *0.75 converts pixels to points
|
||||||
int width = Math.min(imageWidth, pageWidth);
|
int width = Math.min(imageWidth, pageWidth);
|
||||||
|
|
||||||
int marginTopInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getTop().intValue();
|
int marginTopInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getTop()).intValue();
|
||||||
int marginBottomInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getBottom().intValue();
|
int marginBottomInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgMar().getBottom()).intValue();
|
||||||
int pageHeightInDXA = mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getH().intValue();
|
int pageHeightInDXA = ((BigInteger) mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getH()).intValue();
|
||||||
int pageHeight = Math.round((pageHeightInDXA - marginTopInDXA - marginBottomInDXA) / (float)20); // /20 converts dxa to points
|
int pageHeight = Math.round((pageHeightInDXA - marginTopInDXA - marginBottomInDXA) / (float) 20); // /20 converts dxa to points
|
||||||
|
|
||||||
int imageHeight = Math.round(initialImageHeight * ((float)0.75)); // *0.75 converts pixels to points
|
int imageHeight = Math.round(initialImageHeight * ((float) 0.75)); // *0.75 converts pixels to points
|
||||||
|
|
||||||
int height = Math.round(width*ratio);
|
int height = Math.round(width * ratio);
|
||||||
if(height > pageHeight) {
|
if (height > pageHeight) {
|
||||||
// height calculated with ratio is too large. Image may have Portrait (vertical) orientation. Recalculate image dimensions.
|
// height calculated with ratio is too large. Image may have Portrait (vertical) orientation. Recalculate image dimensions.
|
||||||
height = Math.min(imageHeight, pageHeight);
|
height = Math.min(imageHeight, pageHeight);
|
||||||
width = Math.round(height/ratio);
|
width = Math.round(height / ratio);
|
||||||
}
|
}
|
||||||
|
FileInputStream image = new FileInputStream(environment.getProperty("file.storage") + imageId);
|
||||||
run.addPicture(image, format, fileName, Units.toEMU(width), Units.toEMU(height));
|
run.addPicture(image, format, fileName, Units.toEMU(width), Units.toEMU(height));
|
||||||
paragraph.setPageBreak(false);
|
paragraph.setPageBreak(false);
|
||||||
}
|
}
|
||||||
|
@ -380,16 +383,16 @@ public class WordBuilder {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
JSONArray array = new JSONArray(JavaToJson.objectStringToJson(format));
|
List<Map<String, Object>> array = this.mapper.readValue(JavaToJson.objectStringToJson(format), ArrayList.class);
|
||||||
StringBuilder multipleFormats = new StringBuilder();
|
StringBuilder multipleFormats = new StringBuilder();
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (Map<String, Object> node : array) {
|
||||||
multipleFormats.append(array.getJSONObject(i).getString(attribute)).append(", ");
|
multipleFormats.append(node.get(attribute)).append(", ");
|
||||||
}
|
}
|
||||||
if (multipleFormats.length() > 0) {
|
if (multipleFormats.length() > 0) {
|
||||||
multipleFormats.setLength(multipleFormats.length() - 2);
|
multipleFormats.setLength(multipleFormats.length() - 2);
|
||||||
}
|
}
|
||||||
return multipleFormats.toString();
|
return multipleFormats.toString();
|
||||||
} catch (JSONException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml;
|
package eu.eudat.logic.utilities.documents.xml;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.models.data.components.commons.datafield.ExternalDatasetsData;
|
import eu.eudat.models.data.components.commons.datafield.ExternalDatasetsData;
|
||||||
|
@ -10,8 +9,6 @@ import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||||
import eu.eudat.models.data.user.composite.DatasetProfilePage;
|
import eu.eudat.models.data.user.composite.DatasetProfilePage;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package eu.eudat.logic.utilities.helpers;
|
||||||
|
|
||||||
|
import eu.eudat.models.data.components.commons.datafield.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class FieldFactory {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FieldFactory.class);
|
||||||
|
private static final Map<String, Class<? extends FieldData>> fieldMap = Stream.of(new Object[][]{
|
||||||
|
{"combobox", ComboBoxData.class},
|
||||||
|
{"autocomplete", AutoCompleteData.class},
|
||||||
|
{"wordlist", WordListData.class},
|
||||||
|
{"internalDmpEntities", InternalDmpEntitiesData.class},
|
||||||
|
{"researchers", ResearcherData.class},
|
||||||
|
{"datasets", DatasetsAutoCompleteData.class},
|
||||||
|
{"dmps", DMPsAutoCompleteData.class},
|
||||||
|
{"booleanDecision", BooleanDecisionData.class},
|
||||||
|
{"radiobox", RadioBoxData.class},
|
||||||
|
{"checkBox", CheckBoxData.class},
|
||||||
|
{"freetext", FreeTextData.class},
|
||||||
|
{"textarea", TextAreaData.class},
|
||||||
|
{"richTextarea", RichTextAreaData.class},
|
||||||
|
{"upload", UploadData.class},
|
||||||
|
{"datePicker", DatePickerData.class},
|
||||||
|
{"externalDatasets", ExternalDatasetsData.class},
|
||||||
|
{"dataRepositories", DataRepositoriesData.class},
|
||||||
|
{"pubRepositories", DataRepositoriesData.class},
|
||||||
|
{"journalRepositories", DataRepositoriesData.class},
|
||||||
|
{"taxonomies", TaxonomiesData.class},
|
||||||
|
{"licenses", LicensesData.class},
|
||||||
|
{"publications", PublicationsData.class},
|
||||||
|
{"registries", RegistriesData.class},
|
||||||
|
{"services", ServicesData.class},
|
||||||
|
{"tags", TagsData.class},
|
||||||
|
{"organizations", OrganizationsData.class},
|
||||||
|
{"datasetIdentifier", DatasetIdentifierData.class},
|
||||||
|
{"currency", CurrencyData.class},
|
||||||
|
{"validation", ValidationData.class}
|
||||||
|
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Class<? extends FieldData>) data[1]));
|
||||||
|
|
||||||
|
public static FieldData fromData(String type, Object data, String subType) {
|
||||||
|
if (Modifier.isAbstract(fieldMap.get(type).getModifiers())) {
|
||||||
|
return fromData(subType, data);
|
||||||
|
} else {
|
||||||
|
return fromData(type, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FieldData fromData(String type, Object data) {
|
||||||
|
try {
|
||||||
|
return (FieldData) fieldMap.get(type).newInstance().fromData(data);
|
||||||
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package eu.eudat.logic.utilities.schedule.file;
|
||||||
|
|
||||||
|
import eu.eudat.configurations.file.PermProperties;
|
||||||
|
import eu.eudat.configurations.file.TimeProperties;
|
||||||
|
import eu.eudat.configurations.file.TmpProperties;
|
||||||
|
import eu.eudat.data.entities.FileUpload;
|
||||||
|
import eu.eudat.logic.managers.FileManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FileCleanUpJobs {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FileCleanUpJobs.class);
|
||||||
|
|
||||||
|
private final FileManager fileManager;
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FileCleanUpJobs(FileManager fileManager, Environment environment, PermProperties permProperties, TmpProperties tmpProperties) {
|
||||||
|
this.fileManager = fileManager;
|
||||||
|
this.environment = environment;
|
||||||
|
if (permProperties != null) {
|
||||||
|
System.getProperties().put("perm.cron", createCron(permProperties.getTime()));
|
||||||
|
}
|
||||||
|
if (tmpProperties != null) {
|
||||||
|
System.getProperties().put("temp.cron", createCron(tmpProperties.getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "${perm.cron}")
|
||||||
|
public void deleteUnusedPermFiles() {
|
||||||
|
logger.info("Start deleting unused permanent files");
|
||||||
|
List<FileUpload> fileUploads = fileManager.getDeletedFileUploads();
|
||||||
|
try {
|
||||||
|
List<Path> tempFilePaths = Files.walk(Paths.get(Objects.requireNonNull(environment.getProperty("file.storage")))).filter(Files::isRegularFile).collect(Collectors.toList());
|
||||||
|
for (Path tempFilePath : tempFilePaths) {
|
||||||
|
if (fileUploads.stream().map(FileUpload::getId).anyMatch(uuid -> tempFilePath.endsWith(uuid.toString()))) {
|
||||||
|
Files.deleteIfExists(tempFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("Unused permanent files have been successfully deleted");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "${temp.cron}")
|
||||||
|
public void deleteTempFiles() {
|
||||||
|
logger.info("Start deleting temporary files");
|
||||||
|
try {
|
||||||
|
List<Path> tempFilePaths = Files.walk(Paths.get(Objects.requireNonNull(environment.getProperty("temp.temp")))).filter(Files::isRegularFile).collect(Collectors.toList());
|
||||||
|
for (Path tempFilePath : tempFilePaths) {
|
||||||
|
Files.deleteIfExists(tempFilePath);
|
||||||
|
}
|
||||||
|
logger.info("Temporary files have been successfully deleted");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createCron(TimeProperties timeProperties) {
|
||||||
|
List<String> cronList = new LinkedList<>();
|
||||||
|
cronList.add("0");
|
||||||
|
switch (timeProperties.getTimeUnit()) {
|
||||||
|
case MINUTES:
|
||||||
|
cronList.add("0/" + timeProperties.getInterval());
|
||||||
|
break;
|
||||||
|
case HOURS:
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||||
|
cronList.add("0/" + timeProperties.getInterval());
|
||||||
|
break;
|
||||||
|
case DAYS:
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||||
|
cronList.add("*/" + timeProperties.getInterval());
|
||||||
|
break;
|
||||||
|
case MONTHS:
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getDayOfMonth(), "1"));
|
||||||
|
cronList.add("*/" + timeProperties.getInterval());
|
||||||
|
break;
|
||||||
|
case WEEKS:
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||||
|
cronList.add("*/" + (timeProperties.getInterval() * 7));
|
||||||
|
cronList.add("*");
|
||||||
|
cronList.add(toSafeString(timeProperties.getStartTime().getDayOfWeek(), "1"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (cronList.size() < 6) {
|
||||||
|
for (int i = cronList.size(); i < 6; i++) {
|
||||||
|
cronList.add("*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.join(" ", cronList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toSafeString(Object object) {
|
||||||
|
return toSafeString(object, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toSafeString(Object object, String defaultValue) {
|
||||||
|
return object != null ? object.toString() : defaultValue;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,20 +18,20 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NotificationScheduleJob {
|
public class NotificationScheduleJob {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(NotificationScheduleJob.class);
|
private static final Logger logger = LoggerFactory.getLogger(NotificationScheduleJob.class);
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private NotificationManager notificationManager;
|
private final NotificationManager notificationManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public NotificationScheduleJob(ApiContext apiContext, NotificationManager notificationManager) {
|
public NotificationScheduleJob(ApiContext apiContext, NotificationManager notificationManager) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.notificationManager = notificationManager;
|
this.notificationManager = notificationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Scheduled(fixedRateString = "${notification.rateInterval}")
|
@Scheduled(fixedRateString = "${notification.rateInterval}")
|
||||||
public void sendNotifications() {
|
public void sendNotifications() {
|
||||||
List<CompletableFuture<Notification>> futures = new LinkedList<>();
|
List<CompletableFuture<Notification>> futures = new LinkedList<>();
|
||||||
this.apiContext.getOperationsContext().getDatabaseRepository().getNotificationDao().asQueryable().where(((builder, root) ->
|
this.apiContext.getOperationsContext().getDatabaseRepository().getNotificationDao().asQueryable().where(((builder, root) ->
|
||||||
builder.and(
|
builder.and(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.models.data.components.commons.datafield;
|
package eu.eudat.models.data.components.commons.datafield;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.helpers.FieldFactory;
|
||||||
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -21,6 +22,10 @@ public abstract class FieldData<T> implements XmlSerializable<T> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T fromData(Object data, String subType) {
|
||||||
|
return (T) FieldFactory.fromData(subType, data);
|
||||||
|
}
|
||||||
|
|
||||||
public Object toData() {
|
public Object toData() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class UploadData extends FieldData<UploadData> {
|
public class UploadData extends FieldData<UploadData> {
|
||||||
public class Option implements XmlSerializable<UploadData.Option> {
|
public static class Option implements XmlSerializable<UploadData.Option> {
|
||||||
private String label;
|
private String label;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class UploadData extends FieldData<UploadData> {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
List<Map<String, String>> types = ((Map<String, List<Map<String, String>>>) data).get("types");
|
List<Map<String, String>> types = ((Map<String, List<Map<String, String>>>) data).get("types");
|
||||||
for (Map<String, String> map : types) {
|
for (Map<String, String> map : types) {
|
||||||
UploadData.Option newOption = new UploadData.Option();
|
UploadData.Option newOption = new Option();
|
||||||
newOption.setLabel(map.get("label"));
|
newOption.setLabel(map.get("label"));
|
||||||
newOption.setValue(map.get("value"));
|
newOption.setValue(map.get("value"));
|
||||||
this.types.add(newOption);
|
this.types.add(newOption);
|
||||||
|
@ -125,7 +125,7 @@ public class UploadData extends FieldData<UploadData> {
|
||||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||||
Node optionElement = optionElements.item(temp);
|
Node optionElement = optionElements.item(temp);
|
||||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
this.types.add(new UploadData.Option().fromXml((Element) optionElement));
|
this.types.add(new Option().fromXml((Element) optionElement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -7,18 +9,21 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||||
import eu.eudat.models.data.funder.Funder;
|
import eu.eudat.models.data.funder.Funder;
|
||||||
import eu.eudat.models.data.helpermodels.Tuple;
|
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
|
||||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
|
||||||
import eu.eudat.models.data.grant.Grant;
|
import eu.eudat.models.data.grant.Grant;
|
||||||
|
import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
|
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlan.class);
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -233,67 +238,71 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlan fromDataModel(DMP entity) {
|
public DataManagementPlan fromDataModel(DMP entity) {
|
||||||
this.id = entity.getId();
|
try {
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
this.id = entity.getId();
|
||||||
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||||
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.version = entity.getVersion();
|
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
this.version = entity.getVersion();
|
||||||
this.label = entity.getLabel();
|
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
||||||
this.grant = new Grant();
|
this.label = entity.getLabel();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
this.grant = new Grant();
|
||||||
this.grant.fromDataModel(entity.getGrant());
|
this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), LinkedHashMap.class) : null;
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
this.grant.fromDataModel(entity.getGrant());
|
||||||
this.groupId = entity.getGroupId();
|
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
this.groupId = entity.getGroupId();
|
||||||
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
||||||
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
||||||
this.definition.getFields().forEach(item -> {
|
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
||||||
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
this.definition.getFields().forEach(item -> {
|
||||||
if (fieldOptional.isPresent()) item.setValue(fieldOptional.get().get("value"));
|
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
||||||
});
|
if (fieldOptional.isPresent()) item.setValue(fieldOptional.get().get("value"));
|
||||||
}
|
});
|
||||||
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
|
||||||
this.profiles = new LinkedList<>();
|
|
||||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
|
||||||
this.profiles.add(associatedProfile);
|
|
||||||
}
|
}
|
||||||
}
|
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
if (entity.getDataset() != null) {
|
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
if (entity.isPublic()) {
|
|
||||||
this.datasets = entity.getDataset().stream()
|
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()) && !dataset.getStatus().equals(Dataset.Status.SAVED.getValue()))
|
this.profiles = new LinkedList<>();
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) {
|
||||||
} else {
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||||
this.datasets = entity.getDataset().stream()
|
this.profiles.add(associatedProfile);
|
||||||
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
|
}
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
}
|
if (entity.getDataset() != null) {
|
||||||
this.modified = entity.getModified();
|
if (entity.isPublic()) {
|
||||||
this.created = entity.getCreated();
|
this.datasets = entity.getDataset().stream()
|
||||||
this.description = entity.getDescription();
|
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()) && !dataset.getStatus().equals(Dataset.Status.SAVED.getValue()))
|
||||||
this.status = entity.getStatus();
|
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
} else {
|
||||||
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
this.datasets = entity.getDataset().stream()
|
||||||
this.doi = entity.getDoi();
|
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
|
||||||
|
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.modified = entity.getModified();
|
||||||
|
this.created = entity.getCreated();
|
||||||
|
this.description = entity.getDescription();
|
||||||
|
this.status = entity.getStatus();
|
||||||
|
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
this.doi = entity.getDoi();
|
||||||
|
|
||||||
if (entity.getProject() != null) {
|
if (entity.getProject() != null) {
|
||||||
this.project = new Project();
|
this.project = new Project();
|
||||||
this.project = new Project().fromDataModel(entity.getProject());
|
this.project = new Project().fromDataModel(entity.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getGrant().getFunder() != null) {
|
if (entity.getGrant().getFunder() != null) {
|
||||||
this.funder = new Funder();
|
this.funder = new Funder();
|
||||||
this.funder.fromDataModel(entity.getGrant().getFunder());
|
this.funder.fromDataModel(entity.getGrant().getFunder());
|
||||||
}
|
}
|
||||||
this.isPublic = entity.isPublic();
|
this.isPublic = entity.isPublic();
|
||||||
|
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
this.extraProperties = entity.getExtraProperties() != null ? objectMapper.readValue(entity.getExtraProperties(), LinkedHashMap.class) : null;
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -342,54 +351,58 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlan fromDataModelNoDatasets(DMP entity) {
|
public DataManagementPlan fromDataModelNoDatasets(DMP entity) {
|
||||||
this.id = entity.getId();
|
try {
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
this.id = entity.getId();
|
||||||
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||||
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.version = entity.getVersion();
|
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.label = entity.getLabel();
|
this.version = entity.getVersion();
|
||||||
this.grant = new Grant();
|
this.label = entity.getLabel();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
this.grant = new Grant();
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), LinkedHashMap.class) : null;
|
||||||
this.groupId = entity.getGroupId();
|
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
this.groupId = entity.getGroupId();
|
||||||
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
||||||
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
||||||
this.definition.getFields().forEach(item -> {
|
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
||||||
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
this.definition.getFields().forEach(item -> {
|
||||||
fieldOptional.ifPresent(stringObjectMap -> item.setValue(stringObjectMap.get("value")));
|
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
||||||
});
|
fieldOptional.ifPresent(stringObjectMap -> item.setValue(stringObjectMap.get("value")));
|
||||||
}
|
});
|
||||||
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
|
||||||
this.profiles = new LinkedList<>();
|
|
||||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
|
||||||
this.profiles.add(associatedProfile);
|
|
||||||
}
|
}
|
||||||
}
|
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
this.modified = entity.getModified();
|
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.description = entity.getDescription();
|
|
||||||
this.status = entity.getStatus();
|
|
||||||
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
|
||||||
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
|
||||||
this.doi = entity.getDoi();
|
|
||||||
this.grant.fromDataModel(entity.getGrant());
|
|
||||||
|
|
||||||
if (entity.getProject() != null) {
|
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.project = new Project();
|
this.profiles = new LinkedList<>();
|
||||||
this.project = new Project().fromDataModel(entity.getProject());
|
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) {
|
||||||
}
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||||
if (entity.getGrant().getFunder() != null) {
|
this.profiles.add(associatedProfile);
|
||||||
this.funder = new Funder();
|
}
|
||||||
this.funder.fromDataModel(entity.getGrant().getFunder());
|
}
|
||||||
}
|
this.modified = entity.getModified();
|
||||||
this.isPublic = entity.isPublic();
|
this.created = entity.getCreated();
|
||||||
|
this.description = entity.getDescription();
|
||||||
|
this.status = entity.getStatus();
|
||||||
|
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
this.doi = entity.getDoi();
|
||||||
|
this.grant.fromDataModel(entity.getGrant());
|
||||||
|
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
if (entity.getProject() != null) {
|
||||||
|
this.project = new Project();
|
||||||
|
this.project = new Project().fromDataModel(entity.getProject());
|
||||||
|
}
|
||||||
|
if (entity.getGrant().getFunder() != null) {
|
||||||
|
this.funder = new Funder();
|
||||||
|
this.funder.fromDataModel(entity.getGrant().getFunder());
|
||||||
|
}
|
||||||
|
this.isPublic = entity.isPublic();
|
||||||
|
|
||||||
|
this.extraProperties = entity.getExtraProperties() != null ? objectMapper.readValue(entity.getExtraProperties(), LinkedHashMap.class) : null;
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -14,11 +17,15 @@ import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagementPlanEditorModel> {
|
public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagementPlanEditorModel> {
|
||||||
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanEditorModel.class);
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -224,49 +231,53 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
||||||
this.id = entity.getId();
|
try {
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
this.id = entity.getId();
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.version = entity.getVersion();
|
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
this.version = entity.getVersion();
|
||||||
this.label = entity.getLabel();
|
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
||||||
this.grant = new GrantDMPEditorModel();
|
this.label = entity.getLabel();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
this.grant = new GrantDMPEditorModel();
|
||||||
this.grant.getExistGrant().fromDataModel(entity.getGrant());
|
this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), LinkedHashMap.class) : null;
|
||||||
this.grant.getExistGrant().setSource("");
|
this.grant.getExistGrant().fromDataModel(entity.getGrant());
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
this.grant.getExistGrant().setSource("");
|
||||||
this.groupId = entity.getGroupId();
|
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.lockable = entity.getDataset().stream().findAny().isPresent();
|
this.groupId = entity.getGroupId();
|
||||||
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
this.lockable = entity.getDataset().stream().findAny().isPresent();
|
||||||
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
||||||
this.definition.getFields().forEach(item -> {
|
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
||||||
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
this.definition.getFields().forEach(item -> {
|
||||||
if (fieldOptional.isPresent()) item.setValue(fieldOptional.get().get("value"));
|
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
||||||
});
|
if (fieldOptional.isPresent()) item.setValue(fieldOptional.get().get("value"));
|
||||||
}
|
});
|
||||||
if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
|
||||||
this.profiles = new LinkedList<>();
|
|
||||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
|
||||||
this.profiles.add(associatedProfile);
|
|
||||||
}
|
}
|
||||||
|
if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
|
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
|
|
||||||
|
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
|
this.profiles = new LinkedList<>();
|
||||||
|
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) {
|
||||||
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||||
|
this.profiles.add(associatedProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.datasets = entity.getDataset().stream().map(item -> new DatasetWizardModel().fromDataModelNoDmp(item)).collect(Collectors.toList());
|
||||||
|
this.modified = entity.getModified();
|
||||||
|
this.created = entity.getCreated();
|
||||||
|
this.description = entity.getDescription();
|
||||||
|
this.status = entity.getStatus();
|
||||||
|
this.project = new ProjectDMPEditorModel();
|
||||||
|
this.project.getExistProject().fromDataModel(entity.getProject());
|
||||||
|
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||||
|
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
this.funder = new FunderDMPEditorModel();
|
||||||
|
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
||||||
|
this.extraProperties = entity.getExtraProperties() != null ? objectMapper.readValue(entity.getExtraProperties(), LinkedHashMap.class) : null;
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
this.datasets = entity.getDataset().stream().map(item -> new DatasetWizardModel().fromDataModelNoDmp(item)).collect(Collectors.toList());
|
|
||||||
this.modified = entity.getModified();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.description = entity.getDescription();
|
|
||||||
this.status = entity.getStatus();
|
|
||||||
this.project = new ProjectDMPEditorModel();
|
|
||||||
this.project.getExistProject().fromDataModel(entity.getProject());
|
|
||||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
|
||||||
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
this.funder = new FunderDMPEditorModel();
|
|
||||||
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.UserInfo;
|
|
||||||
|
|
||||||
public class ContactRDAExportModel {
|
|
||||||
private String mbox;
|
|
||||||
private String name;
|
|
||||||
private IdRDAExportModel contact_id;
|
|
||||||
|
|
||||||
public String getMbox() {
|
|
||||||
return mbox;
|
|
||||||
}
|
|
||||||
public void setMbox(String mbox) {
|
|
||||||
this.mbox = mbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdRDAExportModel getContact_id() {
|
|
||||||
return contact_id;
|
|
||||||
}
|
|
||||||
public void setContact_id(IdRDAExportModel contact_id) {
|
|
||||||
this.contact_id = contact_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactRDAExportModel fromDataModel(UserInfo entity) {
|
|
||||||
ContactRDAExportModel contact = new ContactRDAExportModel();
|
|
||||||
contact.mbox = entity.getEmail();
|
|
||||||
contact.name = entity.getName();
|
|
||||||
// TODO: we should use a contact_id and not our UUID.
|
|
||||||
if (!entity.getId().toString().isEmpty()) {
|
|
||||||
contact.contact_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
contact.contact_id = null;
|
|
||||||
}
|
|
||||||
return contact;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DatasetDistributionRDAExportModel {
|
|
||||||
private String access_url;
|
|
||||||
private String available_till;
|
|
||||||
private String byte_size;
|
|
||||||
private String data_access; // Allowed values: open / shared / closed
|
|
||||||
private String description;
|
|
||||||
private String download_url;
|
|
||||||
private List<String> format; // Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format
|
|
||||||
private HostRDAExportModel host;
|
|
||||||
private List<LicenseRDAExportModel> license;
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public String getAccess_url() {
|
|
||||||
return access_url;
|
|
||||||
}
|
|
||||||
public void setAccess_url(String access_url) {
|
|
||||||
this.access_url = access_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAvailable_till() {
|
|
||||||
return available_till;
|
|
||||||
}
|
|
||||||
public void setAvailable_till(String available_till) {
|
|
||||||
this.available_till = available_till;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getByte_size() {
|
|
||||||
return byte_size;
|
|
||||||
}
|
|
||||||
public void setByte_size(String byte_size) {
|
|
||||||
this.byte_size = byte_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData_access() {
|
|
||||||
return data_access;
|
|
||||||
}
|
|
||||||
public void setData_access(String data_access) {
|
|
||||||
this.data_access = data_access;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDownload_url() {
|
|
||||||
return download_url;
|
|
||||||
}
|
|
||||||
public void setDownload_url(String download_url) {
|
|
||||||
this.download_url = download_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getFormat() {
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
public void setFormat(List<String> format) {
|
|
||||||
this.format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HostRDAExportModel getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
public void setHost(HostRDAExportModel host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LicenseRDAExportModel> getLicense() {
|
|
||||||
return license;
|
|
||||||
}
|
|
||||||
public void setLicense(List<LicenseRDAExportModel> license) {
|
|
||||||
this.license = license;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public boolean isValid() {
|
|
||||||
return title != null || data_access != null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
public class DatasetMetadataRDAExportModel {
|
|
||||||
private String description; // Not mandatory.
|
|
||||||
private String language;
|
|
||||||
private IdRDAExportModel metadata_standard_id;
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
public void setLanguage(String language) {
|
|
||||||
this.language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdRDAExportModel getMetadata_standard_id() {
|
|
||||||
return metadata_standard_id;
|
|
||||||
}
|
|
||||||
public void setMetadata_standard_id(IdRDAExportModel metadata_standard_id) {
|
|
||||||
this.metadata_standard_id = metadata_standard_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatasetMetadataRDAExportModel fromDataModel(String key, Object value) {
|
|
||||||
DatasetMetadataRDAExportModel metadataRDAExportModel = new DatasetMetadataRDAExportModel();
|
|
||||||
if (key.contains("metadata_standard_id"))
|
|
||||||
metadataRDAExportModel.setMetadata_standard_id(new IdRDAExportModel(value.toString(), "other"));
|
|
||||||
else if (key.contains("language"))
|
|
||||||
metadataRDAExportModel.setLanguage(value.toString());
|
|
||||||
else if (key.contains("description"))
|
|
||||||
metadataRDAExportModel.setDescription(value.toString());
|
|
||||||
|
|
||||||
return metadataRDAExportModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public boolean isValid() {
|
|
||||||
return description != null || language != null || metadata_standard_id != null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,474 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
|
||||||
import eu.eudat.data.entities.Dataset;
|
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import javax.xml.xpath.*;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.groupingBy;
|
|
||||||
|
|
||||||
public class DatasetRDAExportModel {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAExportModel.class);
|
|
||||||
|
|
||||||
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
private Map<String, String> multiplicityIdToFieldSetId = new HashMap<>();
|
|
||||||
|
|
||||||
private List<String> data_quality_assurance;
|
|
||||||
private IdRDAExportModel dataset_id;
|
|
||||||
private String description;
|
|
||||||
private List<DatasetDistributionRDAExportModel> distribution;
|
|
||||||
private String issued; // Created Date, could also use finalized one.
|
|
||||||
private List<String> keyword;
|
|
||||||
private String language;
|
|
||||||
private List<DatasetMetadataRDAExportModel> metadata;
|
|
||||||
private String personal_data; // Allowed Values: yes no unknown.
|
|
||||||
private String preservation_statement;
|
|
||||||
private List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy;
|
|
||||||
private String sensitive_data; // Allowed Values: yes no unknown.
|
|
||||||
private List<DatasetTechnicalResourceRDAExportModel> technical_resource;
|
|
||||||
private String title;
|
|
||||||
private String type; // Type according to: http://vocabularies.coar-repositories.org/pubby/resource_type.html
|
|
||||||
|
|
||||||
public List<String> getData_quality_assurance() {
|
|
||||||
return data_quality_assurance;
|
|
||||||
}
|
|
||||||
public void setData_quality_assurance(List<String> data_quality_assurance) {
|
|
||||||
this.data_quality_assurance = data_quality_assurance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdRDAExportModel getDataset_id() {
|
|
||||||
return dataset_id;
|
|
||||||
}
|
|
||||||
public void setDataset_id(IdRDAExportModel dataset_id) {
|
|
||||||
this.dataset_id = dataset_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DatasetDistributionRDAExportModel> getDistribution() {
|
|
||||||
return distribution;
|
|
||||||
}
|
|
||||||
public void setDistribution(List<DatasetDistributionRDAExportModel> distribution) {
|
|
||||||
this.distribution = distribution;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIssued() {
|
|
||||||
return issued;
|
|
||||||
}
|
|
||||||
public void setIssued(String issued) {
|
|
||||||
this.issued = issued;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getKeyword() {
|
|
||||||
return keyword;
|
|
||||||
}
|
|
||||||
public void setKeyword(List<String> keyword) {
|
|
||||||
this.keyword = keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
public void setLanguage(String language) {
|
|
||||||
this.language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DatasetMetadataRDAExportModel> getMetadata() {
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
public void setMetadata(List<DatasetMetadataRDAExportModel> metadata) {
|
|
||||||
this.metadata = metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPersonal_data() {
|
|
||||||
return personal_data;
|
|
||||||
}
|
|
||||||
public void setPersonal_data(String personal_data) {
|
|
||||||
this.personal_data = personal_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreservation_statement() {
|
|
||||||
return preservation_statement;
|
|
||||||
}
|
|
||||||
public void setPreservation_statement(String preservation_statement) {
|
|
||||||
this.preservation_statement = preservation_statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DatasetSecurityAndPrivacyRDAExportModel> getSecurity_and_privacy() {
|
|
||||||
return security_and_privacy;
|
|
||||||
}
|
|
||||||
public void setSecurity_and_privacy(List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy) {
|
|
||||||
this.security_and_privacy = security_and_privacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSensitive_data() {
|
|
||||||
return sensitive_data;
|
|
||||||
}
|
|
||||||
public void setSensitive_data(String sensitive_data) {
|
|
||||||
this.sensitive_data = sensitive_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DatasetTechnicalResourceRDAExportModel> getTechnical_resource() {
|
|
||||||
return technical_resource;
|
|
||||||
}
|
|
||||||
public void setTechnical_resource(List<DatasetTechnicalResourceRDAExportModel> technical_resource) {
|
|
||||||
this.technical_resource = technical_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DatasetRDAExportModel fromDataModel(Dataset dataset, DatasetManager datasetManager, Principal principal) {
|
|
||||||
// Map of template Ids to rda values.
|
|
||||||
JSONObject jObject = new JSONObject(dataset.getProperties());
|
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
|
||||||
|
|
||||||
/*--------- Building dataset rda export model ---------*/
|
|
||||||
DatasetRDAExportModel datasetRDAExportModel = new DatasetRDAExportModel();
|
|
||||||
datasetRDAExportModel.setDataset_id(new IdRDAExportModel(dataset.getId().toString(), "other"));
|
|
||||||
if (dataset.getDescription() != null) datasetRDAExportModel.setDescription(dataset.getDescription().replace("\n", " "));
|
|
||||||
datasetRDAExportModel.setIssued(DateFormat.getDateInstance(DateFormat.SHORT).format(dataset.getCreated()));
|
|
||||||
datasetRDAExportModel.setLanguage("en"); // mock data
|
|
||||||
datasetRDAExportModel.setTitle(dataset.getLabel());
|
|
||||||
|
|
||||||
// Transform the answered dataset description to json so we can parse it and fill the rda model.
|
|
||||||
JSONObject datasetDescriptionJson = null;
|
|
||||||
try {
|
|
||||||
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString(), principal).getDatasetProfileDefinition());
|
|
||||||
datasetDescriptionJson = new JSONObject(jsonResult);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
setMultiplicityIdToFieldSetId(datasetDescriptionJson);
|
|
||||||
|
|
||||||
/*--------- Building personal data. ---------*/
|
|
||||||
String personalData = buildSingleProperties("dataset.personal_data", datasetDescriptionJson, templateIdsToValues);
|
|
||||||
if (personalData != null) {
|
|
||||||
datasetRDAExportModel.setPersonal_data(personalData);
|
|
||||||
} else {
|
|
||||||
datasetRDAExportModel.setPersonal_data("unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------- Building preservation statement. ---------*/
|
|
||||||
datasetRDAExportModel.setPreservation_statement(buildSingleProperties("dataset.preservation_statement", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
|
|
||||||
/*--------- Building sensitive data. ---------*/
|
|
||||||
String sensitiveData = buildSingleProperties("dataset.sensitive_data", datasetDescriptionJson, templateIdsToValues);
|
|
||||||
if (personalData != null) {
|
|
||||||
datasetRDAExportModel.setSensitive_data(sensitiveData);
|
|
||||||
} else {
|
|
||||||
datasetRDAExportModel.setSensitive_data("unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------- Building type. ---------*/
|
|
||||||
datasetRDAExportModel.setType(buildSingleProperties("dataset.type", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
|
|
||||||
/*--------- Building data_quality_assurance. ---------*/
|
|
||||||
datasetRDAExportModel.setData_quality_assurance(buildDataQualityAssurance(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
/*--------- Building distribution. ---------*/
|
|
||||||
datasetRDAExportModel.setDistribution(buildDistribution(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
/*--------- Building keywords. ---------*/
|
|
||||||
datasetRDAExportModel.setKeyword(buildKeywords(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
/*--------- Building metadata items. ---------*/
|
|
||||||
datasetRDAExportModel.setMetadata(buildMetadata(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
/*--------- Building security and privacy items. ---------*/
|
|
||||||
datasetRDAExportModel.setSecurity_and_privacy(buildSecurityAndPrivacy(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
/*--------- Building technical_resource. ---------*/
|
|
||||||
datasetRDAExportModel.setTechnical_resource(buildTechnicalResource(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
|
||||||
|
|
||||||
return datasetRDAExportModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildSingleProperties(String rdaKey, JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues) {
|
|
||||||
String expression = "$..fields[*][?(@.rdaProperty == \"" + rdaKey + "\" )].id";
|
|
||||||
List<String> list = jsonValueListFromExpression(datasetDescriptionJson, expression);
|
|
||||||
if (!list.isEmpty()) {
|
|
||||||
return templateIdsToValues.get(list.get(0)).toString();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> buildDataQualityAssurance(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.data_quality_assurance"}, datasetProfileDefinition);
|
|
||||||
for (RdaField rdaField : dataQualityFields) {
|
|
||||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
|
||||||
}
|
|
||||||
List<String> dataQualityAssuranceList = new LinkedList<>();
|
|
||||||
for (RdaField rdaField : dataQualityFields) {
|
|
||||||
dataQualityAssuranceList.add(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataQualityAssuranceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DatasetDistributionRDAExportModel> buildDistribution(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
DatasetDistributionRDAExportModel distributionModel = new DatasetDistributionRDAExportModel();
|
|
||||||
distributionModel.setAccess_url(buildSingleProperties("dataset.distribution.access_url", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setAvailable_till(buildSingleProperties("dataset.distribution.available_till", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setByte_size(buildSingleProperties("dataset.distribution.byte_size", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setData_access(buildSingleProperties("dataset.distribution.data_access", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setDescription(buildSingleProperties("dataset.distribution.description", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setDownload_url(buildSingleProperties("dataset.distribution.download_url", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
distributionModel.setTitle(buildSingleProperties("dataset.distribution.title", datasetDescriptionJson, templateIdsToValues));
|
|
||||||
|
|
||||||
/*--------- Building format. ---------*/
|
|
||||||
|
|
||||||
|
|
||||||
// We currently support the return of only one distribution.
|
|
||||||
List<DatasetDistributionRDAExportModel> distributionList = new LinkedList<>();
|
|
||||||
if (distributionModel.isValid()) {
|
|
||||||
distributionList.add(distributionModel);
|
|
||||||
} else {
|
|
||||||
DatasetDistributionRDAExportModel model = new DatasetDistributionRDAExportModel();
|
|
||||||
model.setDescription("Distribution data was not valid");
|
|
||||||
distributionList.add(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return distributionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> buildKeywords(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> keywordFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.keyword"}, datasetProfileDefinition);
|
|
||||||
for (RdaField rdaField : keywordFields) {
|
|
||||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
|
||||||
}
|
|
||||||
List<String> keywordsList = new LinkedList<>();
|
|
||||||
for (RdaField rdaField : keywordFields) {
|
|
||||||
keywordsList.add(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return keywordsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DatasetMetadataRDAExportModel> buildMetadata(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> metadataFields = getRDAFieldsFromJson(datasetDescriptionJson,
|
|
||||||
new String[]{"dataset.metadata.metadata_standard_id.type", "dataset.metadata.metadata_standard_id.identifier", "dataset.metadata.description", "dataset.metadata.language", "dataset.metadata.metadata_standard_id"},
|
|
||||||
datasetProfileDefinition);
|
|
||||||
|
|
||||||
// Adding rdaValue and FieldSetIds on metadataFields.
|
|
||||||
for (RdaField rdaField : metadataFields) {
|
|
||||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
|
||||||
}
|
|
||||||
// Group metadataFields based on their field set id.
|
|
||||||
Map<String, List<RdaField>> groupedMetadataFields = metadataFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
|
||||||
|
|
||||||
// Creating the metadata.
|
|
||||||
List<DatasetMetadataRDAExportModel> metadataRDAExportModelList = new LinkedList<>();
|
|
||||||
for (String fieldSetId : groupedMetadataFields.keySet()) {
|
|
||||||
DatasetMetadataRDAExportModel metadataRda = new DatasetMetadataRDAExportModel();
|
|
||||||
for (RdaField rdaField : groupedMetadataFields.get(fieldSetId)) {
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.identifier")) {
|
|
||||||
if (metadataRda.getMetadata_standard_id() != null) {
|
|
||||||
metadataRda.getMetadata_standard_id().setIdentifier(rdaField.getRdaValue());
|
|
||||||
} else {
|
|
||||||
metadataRda.setMetadata_standard_id(new IdRDAExportModel(rdaField.getRdaValue(), "other"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.type")) {
|
|
||||||
if (metadataRda.getMetadata_standard_id() != null) {
|
|
||||||
metadataRda.getMetadata_standard_id().setType(rdaField.getRdaValue());
|
|
||||||
} else {
|
|
||||||
metadataRda.setMetadata_standard_id(new IdRDAExportModel("", rdaField.getRdaValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.metadata.description")) {
|
|
||||||
metadataRda.setDescription(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.metadata.language")) {
|
|
||||||
metadataRda.setLanguage(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id") && !rdaField.getRdaValue().isEmpty()) {
|
|
||||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
|
||||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
||||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
|
||||||
DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel();
|
|
||||||
// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString()));
|
|
||||||
metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url"));
|
|
||||||
metadataRDAExportModelList.add(metadataRda1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (metadataRda.isValid()) {
|
|
||||||
metadataRDAExportModelList.add(metadataRda);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LinkedList<>(metadataRDAExportModelList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DatasetSecurityAndPrivacyRDAExportModel> buildSecurityAndPrivacy(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> secAndPrFields = getRDAFieldsFromJson(
|
|
||||||
datasetDescriptionJson,
|
|
||||||
new String[]{"dataset.security_and_privacy.description", "dataset.security_and_privacy.title", "dataset.security_and_privacy"},
|
|
||||||
datasetProfileDefinition);
|
|
||||||
for (RdaField rdaField : secAndPrFields) {
|
|
||||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
|
||||||
}
|
|
||||||
Map<String, List<RdaField>> groupedSecurityAndPrivacyFields = secAndPrFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
|
||||||
|
|
||||||
List<DatasetSecurityAndPrivacyRDAExportModel> securityAndPrivacyRDAExportModelList = new LinkedList<>();
|
|
||||||
for (String fieldSetId : groupedSecurityAndPrivacyFields.keySet()) {
|
|
||||||
DatasetSecurityAndPrivacyRDAExportModel securityAndPrivacyModel = new DatasetSecurityAndPrivacyRDAExportModel();
|
|
||||||
for (RdaField rdaField : groupedSecurityAndPrivacyFields.get(fieldSetId)) {
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.description")) {
|
|
||||||
securityAndPrivacyModel.setDescription(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.title")) {
|
|
||||||
securityAndPrivacyModel.setTitle(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
|
|
||||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
|
||||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
||||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
|
||||||
DatasetSecurityAndPrivacyRDAExportModel secAndPrivacy = new DatasetSecurityAndPrivacyRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString());
|
|
||||||
securityAndPrivacyRDAExportModelList.add(secAndPrivacy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
securityAndPrivacyRDAExportModelList.add(securityAndPrivacyModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return securityAndPrivacyRDAExportModelList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DatasetTechnicalResourceRDAExportModel> buildTechnicalResource(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson,
|
|
||||||
new String[]{"dataset.technical_resource.technical_resource", "dataset.technical_resource.technical_resource.description", "dataset.technical_resource.technical_resource.name"},
|
|
||||||
datasetProfileDefinition);
|
|
||||||
for (RdaField rdaField : dataQualityFields) {
|
|
||||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
|
||||||
}
|
|
||||||
List<DatasetTechnicalResourceRDAExportModel> technicalResourceList = new LinkedList<>();
|
|
||||||
Map<String, List<RdaField>> groupedDataQualityFields = dataQualityFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
|
||||||
for (String fieldSetId : groupedDataQualityFields.keySet()) {
|
|
||||||
DatasetTechnicalResourceRDAExportModel technicalResourceModel = new DatasetTechnicalResourceRDAExportModel();
|
|
||||||
for (RdaField rdaField : groupedDataQualityFields.get(fieldSetId)) {
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.description")) {
|
|
||||||
technicalResourceModel.setDescription(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.name")) {
|
|
||||||
technicalResourceModel.setName(rdaField.getRdaValue());
|
|
||||||
}
|
|
||||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
|
|
||||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
|
||||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
||||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
|
||||||
DatasetTechnicalResourceRDAExportModel technicalResource = new DatasetTechnicalResourceRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("label").toString());
|
|
||||||
technicalResourceList.add(technicalResource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
technicalResourceList.add(technicalResourceModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return technicalResourceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMultiplicityIdToFieldSetId(JSONObject json) {
|
|
||||||
String multiplicityItemsFieldSetIdExp = "$..multiplicityItems[*].id";
|
|
||||||
List<String> multiplicityItemsFieldSetIdList = jsonValueListFromExpression(json, multiplicityItemsFieldSetIdExp);
|
|
||||||
for (String fieldSetId : multiplicityItemsFieldSetIdList) {
|
|
||||||
String fieldsFromFieldSetIdExp = "$..multiplicityItems[*][?(@.id == \""+ fieldSetId +"\")].fields[*].id";
|
|
||||||
List<String> fieldsIdList = jsonValueListFromExpression(json, fieldsFromFieldSetIdExp);
|
|
||||||
for (String fieldId : fieldsIdList) {
|
|
||||||
this.multiplicityIdToFieldSetId.put(fieldId, fieldSetId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<RdaField> getRDAFieldsFromJson(JSONObject json, String[] rdaKey, String datasetProfileDefinition) {
|
|
||||||
List<RdaField> rdaFields = new LinkedList<>();
|
|
||||||
for (String key : rdaKey) {
|
|
||||||
String fieldIdExpression = "$..fields[*][?(@.rdaProperty == \"" + key + "\" )].id";
|
|
||||||
List<String> listFromExpression = jsonValueListFromExpression(json, fieldIdExpression);
|
|
||||||
for (String fieldId : listFromExpression) {
|
|
||||||
RdaField rdaField = new RdaField();
|
|
||||||
rdaField.setRdaProperty(key);
|
|
||||||
rdaField.setFieldId(fieldId);
|
|
||||||
if (fieldId.startsWith("multiple_")) {
|
|
||||||
rdaField.setFieldSetId(this.multiplicityIdToFieldSetId.get(fieldId));
|
|
||||||
} else {
|
|
||||||
rdaField.setFieldSetId(getFieldSetIdForFieldFromXML(datasetProfileDefinition, fieldId));
|
|
||||||
}
|
|
||||||
rdaFields.add(rdaField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rdaFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> jsonValueListFromExpression(JSONObject json, String expression) {
|
|
||||||
net.minidev.json.JSONArray jsonArray = JsonPath.parse(json.toString()).read(expression);
|
|
||||||
List<String> valueList = new LinkedList<>();
|
|
||||||
for (Object o : jsonArray) {
|
|
||||||
valueList.add(o.toString());
|
|
||||||
}
|
|
||||||
return valueList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFieldSetIdForFieldFromXML(String datasetProfileDefinition, String fieldId) {
|
|
||||||
String fieldSetIdExpression = "//field[@id ='" + fieldId + "']/ancestor::fieldSet/@id";
|
|
||||||
List<String> listFromExpression = xmlValueListFromExpression(datasetProfileDefinition, fieldSetIdExpression);
|
|
||||||
if (listFromExpression.size() == 1) return listFromExpression.get(0);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> xmlValueListFromExpression(String xml, String expression) {
|
|
||||||
List<String> valuesList = new LinkedList<>();
|
|
||||||
Document document = XmlBuilder.fromXml(xml);
|
|
||||||
XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
||||||
XPath xpath = xpathFactory.newXPath();
|
|
||||||
try {
|
|
||||||
XPathExpression expr = xpath.compile(expression);
|
|
||||||
NodeList nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
|
||||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
|
||||||
Node node = nodeList.item(i);
|
|
||||||
valuesList.add(node.getNodeValue());
|
|
||||||
}
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return valuesList;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class DatasetSecurityAndPrivacyRDAExportModel {
|
|
||||||
private String description;
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public DatasetSecurityAndPrivacyRDAExportModel() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatasetSecurityAndPrivacyRDAExportModel(String description, String title) {
|
|
||||||
this.description = description;
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class DatasetTechnicalResourceRDAExportModel {
|
|
||||||
private String description;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatasetTechnicalResourceRDAExportModel(String description, String name) {
|
|
||||||
this.description = description;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatasetTechnicalResourceRDAExportModel() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.UserInfo;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DmpContributorRDAExportModel {
|
|
||||||
private IdRDAExportModel contributor_id;
|
|
||||||
private String mbox;
|
|
||||||
private String name;
|
|
||||||
private List<String> role;
|
|
||||||
|
|
||||||
public IdRDAExportModel getContributor_id() {
|
|
||||||
return contributor_id;
|
|
||||||
}
|
|
||||||
public void setContributor_id(IdRDAExportModel contributor_id) {
|
|
||||||
this.contributor_id = contributor_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMbox() {
|
|
||||||
return mbox;
|
|
||||||
}
|
|
||||||
public void setMbox(String mbox) {
|
|
||||||
this.mbox = mbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
public void setRole(List<String> role) {
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmpContributorRDAExportModel fromDataModel(UserInfo user, String role) {
|
|
||||||
DmpContributorRDAExportModel contributor = new DmpContributorRDAExportModel();
|
|
||||||
contributor.contributor_id = new IdRDAExportModel(user.getId().toString(), "other");
|
|
||||||
contributor.mbox = user.getEmail();
|
|
||||||
contributor.name = user.getName();
|
|
||||||
contributor.role = new LinkedList<>();
|
|
||||||
contributor.role.add(role);
|
|
||||||
|
|
||||||
return contributor;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class DmpCostRDAExportModel {
|
|
||||||
private String currency_code; //Allowed values defined by ISO 4217.
|
|
||||||
private String description;
|
|
||||||
private String title;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public String getCurrency_code() {
|
|
||||||
return currency_code;
|
|
||||||
}
|
|
||||||
public void setCurrency_code(String currency_code) {
|
|
||||||
this.currency_code = currency_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,164 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
|
||||||
import eu.eudat.data.entities.Dataset;
|
|
||||||
import eu.eudat.data.entities.UserDMP;
|
|
||||||
import eu.eudat.data.entities.UserInfo;
|
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class DmpRDAExportModel {
|
|
||||||
private ContactRDAExportModel contact;
|
|
||||||
private List<DmpContributorRDAExportModel> contributor;
|
|
||||||
private List<DmpCostRDAExportModel> cost;
|
|
||||||
private String created;
|
|
||||||
private List<DatasetRDAExportModel> dataset;
|
|
||||||
private String description;
|
|
||||||
private IdRDAExportModel dmp_id;
|
|
||||||
private String ethical_issues_description;
|
|
||||||
private String ethical_issues_exist; // Allowed Values: yes no unknown.
|
|
||||||
private String ethical_issues_report;
|
|
||||||
private String language;
|
|
||||||
private String modified;
|
|
||||||
private ProjectRDAExportModel project;
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public ContactRDAExportModel getContact() {
|
|
||||||
return contact;
|
|
||||||
}
|
|
||||||
public void setContact(ContactRDAExportModel contact) {
|
|
||||||
this.contact = contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DmpContributorRDAExportModel> getContributor() {
|
|
||||||
return contributor;
|
|
||||||
}
|
|
||||||
public void setContributor(List<DmpContributorRDAExportModel> contributor) {
|
|
||||||
this.contributor = contributor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DmpCostRDAExportModel> getCost() {
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
public void setCost(List<DmpCostRDAExportModel> cost) {
|
|
||||||
this.cost = cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(String created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DatasetRDAExportModel> getDataset() {
|
|
||||||
return dataset;
|
|
||||||
}
|
|
||||||
public void setDataset(List<DatasetRDAExportModel> dataset) {
|
|
||||||
this.dataset = dataset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdRDAExportModel getDmp_id() {
|
|
||||||
return dmp_id;
|
|
||||||
}
|
|
||||||
public void setDmp_id(IdRDAExportModel dmp_id) {
|
|
||||||
this.dmp_id = dmp_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEthical_issues_description() {
|
|
||||||
return ethical_issues_description;
|
|
||||||
}
|
|
||||||
public void setEthical_issues_description(String ethical_issues_description) {
|
|
||||||
this.ethical_issues_description = ethical_issues_description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEthical_issues_exist() {
|
|
||||||
return ethical_issues_exist;
|
|
||||||
}
|
|
||||||
public void setEthical_issues_exist(String ethical_issues_exist) {
|
|
||||||
this.ethical_issues_exist = ethical_issues_exist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEthical_issues_report() {
|
|
||||||
return ethical_issues_report;
|
|
||||||
}
|
|
||||||
public void setEthical_issues_report(String ethical_issues_report) {
|
|
||||||
this.ethical_issues_report = ethical_issues_report;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
public void setLanguage(String language) {
|
|
||||||
this.language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(String modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectRDAExportModel getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
public void setProject(ProjectRDAExportModel project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmpRDAExportModel fromDataModel(DMP entity, DatasetManager datasetManager, Principal principal) {
|
|
||||||
DmpRDAExportModel dmpRda = new DmpRDAExportModel();
|
|
||||||
dmpRda.contact = new ContactRDAExportModel().fromDataModel(entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
|
||||||
if (entity.getUsers().stream().anyMatch(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue()))) {
|
|
||||||
dmpRda.contributor = new LinkedList<>();
|
|
||||||
for (UserDMP userdmp : entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())).collect(Collectors.toList())) {
|
|
||||||
dmpRda.contributor.add(new DmpContributorRDAExportModel().fromDataModel(userdmp.getUser(), UserDMP.UserDMPRoles.fromInteger(userdmp.getRole()).toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dmpRda.cost = null;
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
|
||||||
dmpRda.created = formatter.format(entity.getCreated());
|
|
||||||
dmpRda.dataset = new LinkedList<>();
|
|
||||||
for (Dataset dataset : entity.getDataset()) {
|
|
||||||
if (dataset.getStatus() != Dataset.Status.DELETED.getValue() && dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
|
||||||
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(dataset, datasetManager, principal));
|
|
||||||
}
|
|
||||||
dmpRda.description = entity.getDescription().replace("\n", " ");
|
|
||||||
if (entity.getDoi() != null) {
|
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getDoi(), "zenodo");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
|
||||||
}
|
|
||||||
// Mock up data on "language" and "ethical_issues_*" for now.
|
|
||||||
dmpRda.ethical_issues_exist = "unknown";
|
|
||||||
dmpRda.language = "en";
|
|
||||||
dmpRda.modified = formatter.format(new Date());
|
|
||||||
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
|
||||||
dmpRda.title = entity.getLabel();
|
|
||||||
|
|
||||||
return dmpRda;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.Funder;
|
|
||||||
import eu.eudat.data.entities.Grant;
|
|
||||||
|
|
||||||
public class FundingRDAExportModel {
|
|
||||||
private IdRDAExportModel funder_id;
|
|
||||||
private IdRDAExportModel grant_id;
|
|
||||||
private String funding_status;
|
|
||||||
|
|
||||||
public IdRDAExportModel getFunder_id() {
|
|
||||||
return funder_id;
|
|
||||||
}
|
|
||||||
public void setFunder_id(IdRDAExportModel funder_id) {
|
|
||||||
this.funder_id = funder_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdRDAExportModel getGrant_id() {
|
|
||||||
return grant_id;
|
|
||||||
}
|
|
||||||
public void setGrant_id(IdRDAExportModel grant_id) {
|
|
||||||
this.grant_id = grant_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunding_status() {
|
|
||||||
return funding_status;
|
|
||||||
}
|
|
||||||
public void setFunding_status(String funding_status) {
|
|
||||||
this.funding_status = funding_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FundingRDAExportModel fromDataModel(Funder funder, Grant grant) {
|
|
||||||
FundingRDAExportModel funding = new FundingRDAExportModel();
|
|
||||||
funding.funding_status = "planned"; // mock data
|
|
||||||
if (funder != null) {
|
|
||||||
funding.funder_id = new IdRDAExportModel(funder.getReference(), "other");
|
|
||||||
}
|
|
||||||
if (grant != null) {
|
|
||||||
funding.grant_id = new IdRDAExportModel(grant.getReference(), "other");
|
|
||||||
}
|
|
||||||
return funding;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class HostRDAExportModel {
|
|
||||||
private String availability;
|
|
||||||
private String backup__frequency;
|
|
||||||
private String backup_type;
|
|
||||||
private String certified_with; // Repository certified with one the following standards: DIN31644 / DINI-Zertifikat / DSA / ISO16363 / ISO16919 /TRAC / WDS / CoreTrustSeal
|
|
||||||
private String description;
|
|
||||||
private String geo_location; // Physical location of the data expressed using ISO 3166-1 country code.
|
|
||||||
private List<String> pid_system; // PID System: ark arxiv bibcode doi ean13 eissn handle igsn isbn issn istc lissn lsid pmid purl upc url urn other
|
|
||||||
private String storage_type;
|
|
||||||
private String support_versioning; // Allowed values: yes / no / unknown
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public String getAvailability() {
|
|
||||||
return availability;
|
|
||||||
}
|
|
||||||
public void setAvailability(String availability) {
|
|
||||||
this.availability = availability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackup__frequency() {
|
|
||||||
return backup__frequency;
|
|
||||||
}
|
|
||||||
public void setBackup__frequency(String backup__frequency) {
|
|
||||||
this.backup__frequency = backup__frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackup_type() {
|
|
||||||
return backup_type;
|
|
||||||
}
|
|
||||||
public void setBackup_type(String backup_type) {
|
|
||||||
this.backup_type = backup_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCertified_with() {
|
|
||||||
return certified_with;
|
|
||||||
}
|
|
||||||
public void setCertified_with(String certified_with) {
|
|
||||||
this.certified_with = certified_with;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGeo_location() {
|
|
||||||
return geo_location;
|
|
||||||
}
|
|
||||||
public void setGeo_location(String geo_location) {
|
|
||||||
this.geo_location = geo_location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getPid_system() {
|
|
||||||
return pid_system;
|
|
||||||
}
|
|
||||||
public void setPid_system(List<String> pid_system) {
|
|
||||||
this.pid_system = pid_system;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStorage_type() {
|
|
||||||
return storage_type;
|
|
||||||
}
|
|
||||||
public void setStorage_type(String storage_type) {
|
|
||||||
this.storage_type = storage_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupport_versioning() {
|
|
||||||
return support_versioning;
|
|
||||||
}
|
|
||||||
public void setSupport_versioning(String support_versioning) {
|
|
||||||
this.support_versioning = support_versioning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class IdRDAExportModel {
|
|
||||||
private String identifier;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return identifier;
|
|
||||||
}
|
|
||||||
public void setIdentifier(String identifier) {
|
|
||||||
this.identifier = identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdRDAExportModel(String identifier, String type) {
|
|
||||||
this.identifier = identifier;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class LicenseRDAExportModel {
|
|
||||||
private String license_ref;
|
|
||||||
private String start_date; // If date is set in the future, it indicates embargo period.
|
|
||||||
|
|
||||||
public String getLicense_ref() {
|
|
||||||
return license_ref;
|
|
||||||
}
|
|
||||||
public void setLicense_ref(String license_ref) {
|
|
||||||
this.license_ref = license_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStart_date() {
|
|
||||||
return start_date;
|
|
||||||
}
|
|
||||||
public void setStart_date(String start_date) {
|
|
||||||
this.start_date = start_date;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.Grant;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ProjectRDAExportModel {
|
|
||||||
private String title;
|
|
||||||
private String description;
|
|
||||||
private Date project_start;
|
|
||||||
private Date project_end;
|
|
||||||
private FundingRDAExportModel funding;
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getProject_start() {
|
|
||||||
return project_start;
|
|
||||||
}
|
|
||||||
public void setProject_start(Date project_start) {
|
|
||||||
this.project_start = project_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getProject_end() {
|
|
||||||
return project_end;
|
|
||||||
}
|
|
||||||
public void setProject_end(Date project_end) {
|
|
||||||
this.project_end = project_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FundingRDAExportModel getFunding() {
|
|
||||||
return funding;
|
|
||||||
}
|
|
||||||
public void setFunding(FundingRDAExportModel funding) {
|
|
||||||
this.funding = funding;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ProjectRDAExportModel fromDataModel(Grant grant) {
|
|
||||||
this.funding = new FundingRDAExportModel().fromDataModel(grant.getFunder(), grant);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
|
||||||
import eu.eudat.data.entities.Dataset;
|
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RDAExportModel {
|
|
||||||
private DmpRDAExportModel dmp;
|
|
||||||
|
|
||||||
public DmpRDAExportModel getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
public void setDmp(DmpRDAExportModel dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RDAExportModel fromDataModel(DMP dmp, DatasetManager datasetManager, Principal principal) {
|
|
||||||
this.dmp = new DmpRDAExportModel().fromDataModel(dmp, datasetManager, principal);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package eu.eudat.models.data.rda;
|
|
||||||
|
|
||||||
public class RdaField {
|
|
||||||
private String rdaProperty;
|
|
||||||
private String rdaValue;
|
|
||||||
private String fieldId;
|
|
||||||
private String fieldSetId;
|
|
||||||
|
|
||||||
public String getRdaProperty() {
|
|
||||||
return rdaProperty;
|
|
||||||
}
|
|
||||||
public void setRdaProperty(String rdaProperty) {
|
|
||||||
this.rdaProperty = rdaProperty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRdaValue() {
|
|
||||||
return rdaValue;
|
|
||||||
}
|
|
||||||
public void setRdaValue(String rdaValue) {
|
|
||||||
this.rdaValue = rdaValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldId() {
|
|
||||||
return fieldId;
|
|
||||||
}
|
|
||||||
public void setFieldId(String fieldId) {
|
|
||||||
this.fieldId = fieldId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldSetId() {
|
|
||||||
return fieldSetId;
|
|
||||||
}
|
|
||||||
public void setFieldSetId(String fieldSetId) {
|
|
||||||
this.fieldSetId = fieldSetId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,18 +2,14 @@ package eu.eudat.models.data.user.components.datasetprofile;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
|
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||||
import eu.eudat.models.data.components.commons.DefaultValue;
|
import eu.eudat.models.data.components.commons.DefaultValue;
|
||||||
import eu.eudat.models.data.components.commons.Multiplicity;
|
import eu.eudat.models.data.components.commons.Multiplicity;
|
||||||
import eu.eudat.models.data.components.commons.ViewStyle;
|
import eu.eudat.models.data.components.commons.ViewStyle;
|
||||||
import eu.eudat.models.data.components.commons.Visibility;
|
import eu.eudat.models.data.components.commons.Visibility;
|
||||||
import eu.eudat.models.data.properties.PropertiesGenerator;
|
import eu.eudat.models.data.properties.PropertiesGenerator;
|
||||||
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
||||||
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
|
||||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -26,6 +22,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
|
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Field.class);
|
private static final Logger logger = LoggerFactory.getLogger(Field.class);
|
||||||
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private String id;
|
private String id;
|
||||||
private Integer ordinal;
|
private Integer ordinal;
|
||||||
private Object value;
|
private Object value;
|
||||||
|
@ -205,10 +202,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties) {
|
public void fromJsonObject(Map<String, Object> properties) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
List<String> stringList = objectMapper.readValue(properties.get(this.id).toString(), LinkedList.class);
|
||||||
List<String> stringList = mapper.readValue(properties.get(this.id).toString(), LinkedList.class);
|
|
||||||
this.value = stringList;
|
this.value = stringList;
|
||||||
} catch (JSONException | NullPointerException | IOException e) {
|
} catch (NullPointerException | IOException e) {
|
||||||
try {
|
try {
|
||||||
this.value = (String) properties.get(this.id);
|
this.value = (String) properties.get(this.id);
|
||||||
} catch (ClassCastException ce) {
|
} catch (ClassCastException ce) {
|
||||||
|
|
|
@ -175,12 +175,12 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe
|
||||||
|
|
||||||
private FieldSet CloneForMultiplicity2(List<String> key, Map<String, Object> properties,String[] ids, int index){
|
private FieldSet CloneForMultiplicity2(List<String> key, Map<String, Object> properties,String[] ids, int index){
|
||||||
FieldSet newFieldSet = new FieldSet();
|
FieldSet newFieldSet = new FieldSet();
|
||||||
newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2] + (ids.length > 4 ? "_" + ids[3] : "");
|
newFieldSet.id = ids[0] + "_" + ids[1] + "_" + ids[2] + (ids.length > 3 && !ids[ids.length - 1].isEmpty() ? "_" + ids[ids.length - 1] : "");
|
||||||
newFieldSet.description = this.description;
|
newFieldSet.description = this.description;
|
||||||
newFieldSet.extendedDescription = this.extendedDescription;
|
newFieldSet.extendedDescription = this.extendedDescription;
|
||||||
newFieldSet.additionalInformation=this.additionalInformation;
|
newFieldSet.additionalInformation=this.additionalInformation;
|
||||||
newFieldSet.title = this.title;
|
newFieldSet.title = this.title;
|
||||||
newFieldSet.ordinal = ids.length > 4 ? Integer.valueOf(ids[3]) : this.ordinal;
|
newFieldSet.ordinal = ids.length > 3 && !ids[ids.length - 1].isEmpty() && ids[ids.length - 1].matches("[0-9]+") ? Integer.valueOf(ids[ids.length - 1]) : this.ordinal;
|
||||||
newFieldSet.fields = new LinkedList();
|
newFieldSet.fields = new LinkedList();
|
||||||
|
|
||||||
for (Field field: this.fields) {
|
for (Field field: this.fields) {
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package eu.eudat.models.deposit.zenodo.mapper;
|
package eu.eudat.models.deposit.zenodo.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Organisation;
|
import eu.eudat.data.entities.Organisation;
|
||||||
import eu.eudat.data.entities.UserDMP;
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.logic.proxy.config.DOIFunder;
|
import eu.eudat.logic.proxy.config.DOIFunder;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.models.deposit.zenodo.*;
|
import eu.eudat.models.deposit.zenodo.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -13,9 +17,16 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DMPToZenodoMapper {
|
public class DMPToZenodoMapper {
|
||||||
|
private static final ObjectMapper objectmapper = new ObjectMapper();
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DMPToZenodoMapper.class);
|
||||||
|
|
||||||
public static ZenodoDeposit fromDMP(DMP dmp, Environment environment, ConfigLoader configLoader) {
|
public static ZenodoDeposit fromDMP(DMP dmp, Environment environment, ConfigLoader configLoader) {
|
||||||
Map<String, Object> extraProperties = dmp.getExtraProperties() != null ? new org.json.JSONObject(dmp.getExtraProperties()).toMap() : new HashMap<>();
|
Map<String, Object> extraProperties = null;
|
||||||
|
try {
|
||||||
|
extraProperties = dmp.getExtraProperties() != null ? objectmapper.readValue(dmp.getExtraProperties(), LinkedHashMap.class) : new HashMap<>();
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
ZenodoDeposit deposit = new ZenodoDeposit();
|
ZenodoDeposit deposit = new ZenodoDeposit();
|
||||||
deposit.setMetadata(new ZenodoDepositMetadata());
|
deposit.setMetadata(new ZenodoDepositMetadata());
|
||||||
deposit.getMetadata().setTitle(dmp.getLabel());
|
deposit.getMetadata().setTitle(dmp.getLabel());
|
||||||
|
@ -26,11 +37,11 @@ public class DMPToZenodoMapper {
|
||||||
ZenodoComunity community = new ZenodoComunity();
|
ZenodoComunity community = new ZenodoComunity();
|
||||||
community.setIdentifier(environment.getProperty("zenodo.community"));
|
community.setIdentifier(environment.getProperty("zenodo.community"));
|
||||||
deposit.getMetadata().setCommunities(Collections.singletonList(community));
|
deposit.getMetadata().setCommunities(Collections.singletonList(community));
|
||||||
if (extraProperties.get("visible") == null) {
|
if (extraProperties != null && extraProperties.get("visible") == null) {
|
||||||
deposit.getMetadata().setAccessRight(ZenodoAccessRight.RESTRICTED);
|
deposit.getMetadata().setAccessRight(ZenodoAccessRight.RESTRICTED);
|
||||||
deposit.getMetadata().setAccessConditions("");
|
deposit.getMetadata().setAccessConditions("");
|
||||||
} else {
|
} else {
|
||||||
if (((Boolean) extraProperties.get("visible"))) {
|
if (extraProperties != null && ((Boolean) extraProperties.get("visible"))) {
|
||||||
Instant publicationDate = Instant.parse(extraProperties.get("publicDate").toString());
|
Instant publicationDate = Instant.parse(extraProperties.get("publicDate").toString());
|
||||||
if (publicationDate.isBefore(Instant.now())) {
|
if (publicationDate.isBefore(Instant.now())) {
|
||||||
deposit.getMetadata().setAccessRight(ZenodoAccessRight.OPEN);
|
deposit.getMetadata().setAccessRight(ZenodoAccessRight.OPEN);
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
package eu.eudat.models.rda.mapper;
|
package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.utilities.json.JavaToJson;
|
|
||||||
import eu.eudat.models.rda.Cost;
|
import eu.eudat.models.rda.Cost;
|
||||||
import eu.eudat.models.rda.PidSystem;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CostRDAMapper {
|
public class CostRDAMapper {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class);
|
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class);
|
||||||
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
public static Cost toRDA(Map<String, Object> cost) {
|
public static Cost toRDA(Map<String, Object> cost) {
|
||||||
Cost rda = new Cost();
|
Cost rda = new Cost();
|
||||||
Map<String, Object> code = new org.json.JSONObject((String) cost.get("code")).toMap();
|
try {
|
||||||
rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
|
Map<String, Object> code = objectMapper.readValue((String) cost.get("code"), LinkedHashMap.class);
|
||||||
rda.setDescription((String) cost.get("description"));
|
rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
|
||||||
if (cost.get("title") == null) {
|
rda.setDescription((String) cost.get("description"));
|
||||||
throw new IllegalArgumentException("Cost Title is missing");
|
if (cost.get("title") == null) {
|
||||||
|
throw new IllegalArgumentException("Cost Title is missing");
|
||||||
|
}
|
||||||
|
rda.setTitle((String) cost.get("title"));
|
||||||
|
rda.setValue(((Integer) cost.get("value")).doubleValue());
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
rda.setTitle((String) cost.get("title"));
|
|
||||||
rda.setValue(((Integer) cost.get("value")).doubleValue());
|
|
||||||
return rda;
|
return rda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +58,8 @@ public class CostRDAMapper {
|
||||||
rda.setValue(Double.valueOf(rdaValue));
|
rda.setValue(Double.valueOf(rdaValue));
|
||||||
}
|
}
|
||||||
else if(rdaProperty.contains("currency_code")){
|
else if(rdaProperty.contains("currency_code")){
|
||||||
HashMap<String,String> result =
|
HashMap<String, String> result =
|
||||||
new ObjectMapper().readValue(rdaValue, HashMap.class);
|
objectMapper.readValue(rdaValue, HashMap.class);
|
||||||
rda.setCurrencyCode(Cost.CurrencyCode.fromValue(result.get("value")));
|
rda.setCurrencyCode(Cost.CurrencyCode.fromValue(result.get("value")));
|
||||||
}
|
}
|
||||||
else if(rdaProperty.contains("title")){
|
else if(rdaProperty.contains("title")){
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue