Update Depedencies

This commit is contained in:
George Kalampokis 2022-01-14 18:17:32 +02:00
parent 64ec74363b
commit 30c669cb8c
36 changed files with 312 additions and 1543 deletions

View File

@ -27,7 +27,7 @@
<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.14</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>-->
@ -36,27 +36,27 @@
--> -->
<!--<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.6.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.17.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.10</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>-->
</properties> </properties>
<dependencies> <dependencies>
<dependency> <!--<dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20160810</version> <version>20160810</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
@ -91,19 +91,18 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId> <artifactId>httpcore-nio</artifactId>
<version>4.4.13</version> <version>4.4.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <artifactId>httpcore</artifactId>
<version>4.4.13</version> <version>4.4.15</version>
</dependency> </dependency>
<dependency> <dependency>
@ -127,13 +126,13 @@
<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>1.33.0</version>
</dependency> </dependency>
<!-- 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>2.6.0</version>
</dependency> </dependency>
@ -141,7 +140,7 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId> <groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId> <artifactId>jackson-dataformat-xml</artifactId>
<version>2.12.3</version> <version>2.13.1</version>
</dependency> </dependency>
@ -149,13 +148,13 @@
<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>2.13.1</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>2.13.1</version>
</dependency> </dependency>
<!-- g/a spring --> <!-- g/a spring -->
@ -167,26 +166,25 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency> </dependency>
<!-- 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>5.0.0</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>5.0.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop --> <!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId> <artifactId>fop</artifactId>
<version>2.3</version> <version>2.6</version>
</dependency> </dependency>
<dependency> <dependency>
@ -210,13 +208,13 @@
<dependency> <dependency>
<groupId>fr.opensagres.xdocreport</groupId> <groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.itext.extension</artifactId> <artifactId>fr.opensagres.xdocreport.itext.extension</artifactId>
<version>2.0.1</version> <version>2.0.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.1</version> <version>2.11.0</version>
</dependency> </dependency>
<!--<dependency> <!--<dependency>
@ -247,14 +245,14 @@
<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>3.0.1</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>3.0.1</version>
</dependency> </dependency>
@ -262,7 +260,6 @@
<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>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api --> <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
@ -277,32 +274,32 @@
<dependency> <dependency>
<groupId>io.prometheus</groupId> <groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId> <artifactId>simpleclient</artifactId>
<version>0.11.0</version> <version>0.14.1</version>
</dependency> </dependency>
<!-- Hotspot JVM metrics--> <!-- Hotspot JVM metrics-->
<dependency> <dependency>
<groupId>io.prometheus</groupId> <groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId> <artifactId>simpleclient_hotspot</artifactId>
<version>0.11.0</version> <version>0.14.1</version>
</dependency> </dependency>
<!-- Exposition HTTPServer--> <!-- Exposition HTTPServer-->
<dependency> <dependency>
<groupId>io.prometheus</groupId> <groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId> <artifactId>simpleclient_httpserver</artifactId>
<version>0.11.0</version> <version>0.14.1</version>
</dependency> </dependency>
<!-- Pushgateway exposition--> <!-- Pushgateway exposition-->
<dependency> <dependency>
<groupId>io.prometheus</groupId> <groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId> <artifactId>simpleclient_pushgateway</artifactId>
<version>0.11.0</version> <version>0.14.1</version>
</dependency> </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> <version>1.8.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -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,9 +17,7 @@ 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;

View File

@ -52,7 +52,6 @@ public class UserInvitationController extends BaseController {
public @ResponseBody public @ResponseBody
// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException { // ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException {
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal, @RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException { ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal, @RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
System.out.println(userInfoRequestItem.getCriteria().getLike());
// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal); // List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(principal, userInfoRequestItem); List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(principal, userInfoRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));

View File

@ -1,7 +1,6 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.configurations.dynamicgrant.entities.Property;
@ -64,7 +63,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;
@ -299,15 +297,21 @@ public class DataManagementPlanManager {
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED) && !dataset.getStatus().equals(Dataset.Status.CANCELED)) .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED) && !dataset.getStatus().equals(Dataset.Status.CANCELED))
.forEach(dataset -> { .forEach(dataset -> {
dataManagementPlan.getDatasets().stream().filter(datasetWizardModel -> datasetWizardModel.getId().equals(dataset.getId())).forEach(datasetWizardModel -> { dataManagementPlan.getDatasets().stream().filter(datasetWizardModel -> datasetWizardModel.getId().equals(dataset.getId())).forEach(datasetWizardModel -> {
DatasetWizardModel wizardModel = datasetManager.getSingle(datasetWizardModel.getId().toString(), principal); DatasetWizardModel wizardModel;
try {
wizardModel = datasetManager.getSingle(datasetWizardModel.getId().toString(), principal);
datasetWizardModel.setDatasetProfileDefinition(wizardModel.getDatasetProfileDefinition()); datasetWizardModel.setDatasetProfileDefinition(wizardModel.getDatasetProfileDefinition());
datasetWizardModel.setTags(wizardModel.getTags()); datasetWizardModel.setTags(wizardModel.getTags());
} catch (JsonProcessingException e) {
logger.error(e.getLocalizedMessage(), e);
}
}); });
}); });
if (isPublic) { if (isPublic) {
dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList())); dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
} }
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null; Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? apiContext.getObjectMapper().readValue(dataManagementPlanEntity.getDmpProperties(), HashMap.class) : null;
if (dmpProperties != null && dataManagementPlan.getDynamicFields() != null) if (dmpProperties != null && dataManagementPlan.getDynamicFields() != null)
dataManagementPlan.getDynamicFields().forEach(item -> { dataManagementPlan.getDynamicFields().forEach(item -> {
@ -1305,10 +1309,11 @@ public class DataManagementPlanManager {
datasetDescriptionRun.setBold(true); datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(12); datasetDescriptionRun.setFontSize(12);
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity); PagedDatasetProfile pagedDatasetProfile = null;
try {
pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties); visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules()); visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
try {
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService); wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
@ -1456,8 +1461,7 @@ 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.getObjectMapper().readValue(dataset.getProperties(), HashMap.class);
properties = jobject.toMap();
} }
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset); PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset);
visibilityRuleService.setProperties(properties); visibilityRuleService.setProperties(properties);
@ -2017,7 +2021,7 @@ public class DataManagementPlanManager {
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
String createData = null; String createData = null;
Map<String, Object> extraProperties = dmp.getExtraProperties() != null ? new org.json.JSONObject(dmp.getExtraProperties()).toMap() : new HashMap<>(); Map<String, Object> extraProperties = dmp.getExtraProperties() != null ? apiContext.getObjectMapper().readValue(dmp.getExtraProperties(), HashMap.class) : new HashMap<>();
StringBuilder dataBuilder = new StringBuilder(); StringBuilder dataBuilder = new StringBuilder();
dataBuilder.append("{\n \"metadata\": {\n"); dataBuilder.append("{\n \"metadata\": {\n");
dataBuilder.append( " \"title\": \"").append(dmp.getLabel()).append("\",\n"); dataBuilder.append( " \"title\": \"").append(dmp.getLabel()).append("\",\n");

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
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.dao.criteria.*; import eu.eudat.data.dao.criteria.*;
@ -49,22 +50,19 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor; 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;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders;
import org.springframework.http.*; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -91,8 +89,6 @@ import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@Component @Component
public class DatasetManager { public class DatasetManager {
@ -279,7 +275,7 @@ public class DatasetManager {
return dataTable; return dataTable;
} }
public DatasetWizardModel getSingle(String id, Principal principal) { public DatasetWizardModel getSingle(String id, Principal principal) throws JsonProcessingException {
DatasetWizardModel dataset = new DatasetWizardModel(); DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
if (datasetEntity.getDmp().getUsers() if (datasetEntity.getDmp().getUsers()
@ -380,12 +376,11 @@ public class DatasetManager {
return databaseRepository.getDatasetDao().find(id); return databaseRepository.getDatasetDao().find(id);
} }
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) { public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) throws JsonProcessingException {
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 = apiContext.getObjectMapper().readValue(datasetEntity.getProperties(), HashMap.class);
Map<String, Object> properties = jObject.toMap();
datasetprofile.fromJsonObject(properties); datasetprofile.fromJsonObject(properties);
} }
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
@ -451,8 +446,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.getObjectMapper().readValue(datasetEntity.getProperties(), HashMap.class);
properties = jObject.toMap();
} }
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO); wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
@ -484,8 +478,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.getObjectMapper().readValue(propertiesModelToString(dataset.getDatasetProfileDefinition()), HashMap.class);
properties = jObject.toMap();
} }
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO); wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
@ -542,8 +535,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.getObjectMapper().readValue(datasetEntity.getProperties(), HashMap.class);
properties = jobject.toMap();
} }
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity); PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties); visibilityRuleService.setProperties(properties);
@ -656,9 +648,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.getObjectMapper().readValue(dataset.getProperties(), HashMap.class);
VisibilityRuleService visibilityRuleService = this.apiContext.getUtilitiesService().getVisibilityRuleService(); VisibilityRuleService visibilityRuleService = this.apiContext.getUtilitiesService().getVisibilityRuleService();
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);
@ -666,7 +658,7 @@ public class DatasetManager {
for (String validator : datasetProfileValidators) { for (String validator : datasetProfileValidators) {
if ((obj.has(validator) && (obj.getString(validator) == null || obj.getString(validator).trim().isEmpty())) && isElementVisible(nodeList, validator, visibilityRuleService)) { if ((obj.containsKey(validator) && (obj.get(validator) == null || obj.get(validator).toString().trim().isEmpty())) && isElementVisible(nodeList, validator, visibilityRuleService)) {
throw new Exception("Field value of " + validator + " must be filled."); throw new Exception("Field value of " + validator + " must be filled.");
} }
} }
@ -695,11 +687,10 @@ public class DatasetManager {
} }
} }
private String propertiesModelToString(PagedDatasetProfile pagedDatasetProfile) { private String propertiesModelToString(PagedDatasetProfile pagedDatasetProfile) throws JsonProcessingException {
Map<String, Object> values = new LinkedHashMap<>(); Map<String, Object> values = new LinkedHashMap<>();
pagedDatasetProfile.toMap(values); pagedDatasetProfile.toMap(values);
JSONObject jobject = new JSONObject(values); return apiContext.getObjectMapper().writeValueAsString(values);
return jobject.toString();
} }
public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception { public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception {
@ -908,12 +899,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.getObjectMapper().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));
@ -942,7 +930,7 @@ public class DatasetManager {
// TODO: When tags functionality return. // TODO: When tags functionality return.
} }
public DatasetWizardModel datasetUpdateProfile(String id) { public DatasetWizardModel datasetUpdateProfile(String id) throws JsonProcessingException {
DatasetWizardModel dataset = new DatasetWizardModel(); DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
eu.eudat.elastic.entities.Dataset datasetElastic; eu.eudat.elastic.entities.Dataset datasetElastic;
@ -982,12 +970,11 @@ public class DatasetManager {
return dataset; return dataset;
} }
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DatasetProfile profile) { public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DatasetProfile profile) throws JsonProcessingException {
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 = apiContext.getObjectMapper().readValue(datasetEntity.getProperties(), HashMap.class);
Map<String, Object> properties = jobject.toMap();
datasetprofile.fromJsonObject(properties); datasetprofile.fromJsonObject(properties);
} }
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
@ -1053,10 +1040,15 @@ public class DatasetManager {
JsonNode value = node.get("value"); JsonNode value = node.get("value");
if (!value.toString().equals("\"\"")) { if (!value.toString().equals("\"\"")) {
String stringValue = value.toString().replaceAll("=", ":"); String stringValue = value.toString().replaceAll("=", ":");
JSONArray values = new JSONArray(stringValue); List<Map<String, Object>> values = null;
try {
values = apiContext.getObjectMapper().readValue(stringValue, LinkedList.class);
} catch (JsonProcessingException e) {
logger.error(e.getLocalizedMessage(), e);
}
if (values != null) { if (values != null) {
values.iterator().forEachRemaining(element -> { values.iterator().forEachRemaining(element -> {
Map<String, Object> data = ((JSONObject) element).toMap(); Map<String, Object> data = element;
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString()); this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
}); });
} else { } else {

View File

@ -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;
@ -133,7 +132,7 @@ public class UserManager {
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(new ObjectMapper().writeValueAsString(result));
apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao() apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
.createOrUpdate(userInfo); .createOrUpdate(userInfo);
} }

View File

@ -23,7 +23,6 @@ public class PrefillingConfigMapAdapter extends XmlAdapter<Object, Map<String, P
String id = element.getChildNodes().item(i).getAttributes().getNamedItem("id").getNodeValue(); String id = element.getChildNodes().item(i).getAttributes().getNamedItem("id").getNodeValue();
PrefillingConfig prefillingConfig = (PrefillingConfig) jaxbUnmarshaller.unmarshal(element.getChildNodes().item(i)); PrefillingConfig prefillingConfig = (PrefillingConfig) jaxbUnmarshaller.unmarshal(element.getChildNodes().item(i));
prefillingConfig = configMap.put(id, prefillingConfig); prefillingConfig = configMap.put(id, prefillingConfig);
System.out.println(prefillingConfig);
} }
return configMap; return configMap;
} }

View File

@ -1,7 +1,7 @@
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.apache.commons.codec.binary.Base64;
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.HttpEntity; import org.springframework.http.HttpEntity;

View File

@ -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,7 +29,7 @@ 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, new GsonFactory())
.setAudience(Collections.singletonList(environment.getProperty("google.login.clientId"))) .setAudience(Collections.singletonList(environment.getProperty("google.login.clientId")))
.build(); .build();
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.services; package eu.eudat.logic.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.services.helpers.HelpersService; import eu.eudat.logic.services.helpers.HelpersService;
import eu.eudat.logic.services.operations.OperationsContext; import eu.eudat.logic.services.operations.OperationsContext;
import eu.eudat.logic.services.utilities.UtilitiesService; import eu.eudat.logic.services.utilities.UtilitiesService;
@ -11,4 +12,6 @@ public interface ApiContext {
OperationsContext getOperationsContext(); OperationsContext getOperationsContext();
UtilitiesService getUtilitiesService(); UtilitiesService getUtilitiesService();
ObjectMapper getObjectMapper();
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.services; package eu.eudat.logic.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.services.helpers.HelpersService; import eu.eudat.logic.services.helpers.HelpersService;
import eu.eudat.logic.services.operations.OperationsContext; import eu.eudat.logic.services.operations.OperationsContext;
import eu.eudat.logic.services.utilities.UtilitiesService; import eu.eudat.logic.services.utilities.UtilitiesService;
@ -9,6 +10,7 @@ import org.springframework.stereotype.Service;
@Service("apiContext") @Service("apiContext")
public class ApiContextImpl implements ApiContext { public class ApiContextImpl implements ApiContext {
private static final ObjectMapper mapper = new ObjectMapper();
private OperationsContext operationsContext; private OperationsContext operationsContext;
private HelpersService helpersService; private HelpersService helpersService;
@ -35,4 +37,9 @@ public class ApiContextImpl implements ApiContext {
public UtilitiesService getUtilitiesService() { public UtilitiesService getUtilitiesService() {
return utilitiesService; return utilitiesService;
} }
@Override
public ObjectMapper getObjectMapper() {
return mapper;
}
} }

View File

@ -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,10 @@ 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.getObjectMapper().readValue(userInfo.getAdditionalinfo(), HashMap.class) : new HashMap<>();
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 +184,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()); userInfo.setAdditionalinfo(apiContext.getObjectMapper().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();

View File

@ -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")

View File

@ -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;

View File

@ -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,20 @@ 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 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,6 +237,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
@Override @Override
public DataManagementPlan fromDataModel(DMP entity) { public DataManagementPlan fromDataModel(DMP entity) {
try {
ObjectMapper objectMapper = new ObjectMapper();
this.id = entity.getId(); this.id = entity.getId();
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().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<>();
@ -241,7 +247,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.groupId = this.groupId == null ? null : entity.getGroupId(); this.groupId = this.groupId == null ? null : entity.getGroupId();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.grant = new Grant(); this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null; this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), HashMap.class) : null;
this.grant.fromDataModel(entity.getGrant()); this.grant.fromDataModel(entity.getGrant());
this.creator = new eu.eudat.models.data.userinfo.UserInfo(); this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId(); this.groupId = entity.getGroupId();
@ -293,7 +299,10 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
} }
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(), HashMap.class) : null;
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
return this; return this;
} }
@ -342,6 +351,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
} }
public DataManagementPlan fromDataModelNoDatasets(DMP entity) { public DataManagementPlan fromDataModelNoDatasets(DMP entity) {
try {
ObjectMapper objectMapper = new ObjectMapper();
this.id = entity.getId(); this.id = entity.getId();
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().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<>();
@ -349,7 +360,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.version = entity.getVersion(); this.version = entity.getVersion();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.grant = new Grant(); this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null; this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), HashMap.class) : null;
this.creator = new eu.eudat.models.data.userinfo.UserInfo(); this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId(); this.groupId = entity.getGroupId();
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent(); this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
@ -389,7 +400,10 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
} }
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(), HashMap.class) : null;
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
return this; return this;
} }

View File

@ -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,20 @@ 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.FunderDMPEditorModel; import eu.eudat.models.data.funder.FunderDMPEditorModel;
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.GrantDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
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 Logger logger = LoggerFactory.getLogger(DataManagementPlan.class);
private UUID id; private UUID id;
private String label; private String label;
private UUID groupId; private UUID groupId;
@ -224,6 +228,8 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
@Override @Override
public DataManagementPlanEditorModel fromDataModel(DMP entity) { public DataManagementPlanEditorModel fromDataModel(DMP entity) {
try {
ObjectMapper objectMapper = new ObjectMapper();
this.id = entity.getId(); this.id = entity.getId();
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()); this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
@ -232,7 +238,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.groupId = this.groupId == null ? null : entity.getGroupId(); this.groupId = this.groupId == null ? null : entity.getGroupId();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.grant = new GrantDMPEditorModel(); this.grant = new GrantDMPEditorModel();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null; this.properties = entity.getProperties() != null ? objectMapper.readValue(entity.getProperties(), HashMap.class) : null;
this.grant.getExistGrant().fromDataModel(entity.getGrant()); this.grant.getExistGrant().fromDataModel(entity.getGrant());
this.grant.getExistGrant().setSource(""); this.grant.getExistGrant().setSource("");
this.creator = new eu.eudat.models.data.userinfo.UserInfo(); this.creator = new eu.eudat.models.data.userinfo.UserInfo();
@ -266,8 +272,10 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()); this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
this.funder = new FunderDMPEditorModel(); this.funder = new FunderDMPEditorModel();
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder()); this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null; this.extraProperties = entity.getExtraProperties() != null ? objectMapper.readValue(entity.getExtraProperties(), HashMap.class) : null;
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
return this; return this;
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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() {
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -11,9 +11,6 @@ import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition; import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import eu.eudat.logic.utilities.builders.ModelBuilder; 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;
@ -205,7 +202,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
List<String> stringList = mapper.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) {
this.value = (String) properties.get(this.id); this.value = (String) properties.get(this.id);
} }
this.multiplicityItems = new LinkedList<>(); this.multiplicityItems = new LinkedList<>();

View File

@ -1,24 +1,31 @@
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.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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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);
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(); Map<String, Object> code;
try {
code = new ObjectMapper().readValue((String) cost.get("code"), HashMap.class);
rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value"))); rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
} catch (JsonProcessingException e) {
logger.error(e.getLocalizedMessage(), e);
}
rda.setDescription((String) cost.get("description")); rda.setDescription((String) cost.get("description"));
if (cost.get("title") == null) { if (cost.get("title") == null) {
throw new IllegalArgumentException("Cost Title is missing"); throw new IllegalArgumentException("Cost Title is missing");

View File

@ -10,7 +10,6 @@ import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.rda.*; import eu.eudat.models.rda.*;
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;
@ -51,8 +50,7 @@ public class DatasetRDAMapper {
rda.setDescription(dataset.getDescription()); rda.setDescription(dataset.getDescription());
rda.setAdditionalProperty("template", dataset.getProfile().getId()); rda.setAdditionalProperty("template", dataset.getProfile().getId());
try { try {
JSONObject jObject = new JSONObject(dataset.getProperties()); Map<String, Object> templateIdsToValues = apiContext.getObjectMapper().readValue(dataset.getProperties(), HashMap.class);
Map<String, Object> templateIdsToValues = jObject.toMap();
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset));
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();

View File

@ -1,12 +1,14 @@
package eu.eudat.models.rda.mapper; package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.rda.Cost;
import eu.eudat.models.rda.Dmp; import eu.eudat.models.rda.Dmp;
import eu.eudat.models.rda.DmpId; import eu.eudat.models.rda.DmpId;
import net.minidev.json.JSONObject; import net.minidev.json.JSONObject;
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.stereotype.Component; import org.springframework.stereotype.Component;
@ -17,6 +19,7 @@ import java.util.stream.Collectors;
@Component @Component
public class DmpRDAMapper { public class DmpRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DmpRDAMapper.class);
private DatasetRDAMapper datasetRDAMapper; private DatasetRDAMapper datasetRDAMapper;
private ApiContext apiContext; private ApiContext apiContext;
@ -34,17 +37,22 @@ public class DmpRDAMapper {
if (dmp.getDataset() == null || dmp.getDataset().isEmpty()) { if (dmp.getDataset() == null || dmp.getDataset().isEmpty()) {
throw new IllegalArgumentException("DMP has no Datasets"); throw new IllegalArgumentException("DMP has no Datasets");
} }
Map<String, Object> extraProperties; Map<String, Object> extraProperties = null;
if (dmp.getExtraProperties() == null) { if (dmp.getExtraProperties() == null) {
throw new IllegalArgumentException("DMP is missing language and contact properties"); throw new IllegalArgumentException("DMP is missing language and contact properties");
} else { } else {
extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap(); try {
extraProperties = apiContext.getObjectMapper().readValue(dmp.getExtraProperties(), HashMap.class);
/*if (extraProperties.get("language") == null) { /*if (extraProperties.get("language") == null) {
throw new IllegalArgumentException("DMP must have it's language property defined"); throw new IllegalArgumentException("DMP must have it's language property defined");
}*/ }*/
if (extraProperties.get("contact") == null) { if (extraProperties.get("contact") == null) {
throw new IllegalArgumentException("DMP must have it's contact property defined"); throw new IllegalArgumentException("DMP must have it's contact property defined");
} }
} catch (JsonProcessingException e) {
logger.error(e.getLocalizedMessage(), e);
}
} }
Dmp rda = new Dmp(); Dmp rda = new Dmp();
if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) {
@ -66,7 +74,7 @@ public class DmpRDAMapper {
rda.setModified(dmp.getModified()); rda.setModified(dmp.getModified());
rda.setTitle(dmp.getLabel()); rda.setTitle(dmp.getLabel());
if (!extraProperties.isEmpty()) { if (extraProperties != null && !extraProperties.isEmpty()) {
if (extraProperties.get("ethicalIssues") != null) { if (extraProperties.get("ethicalIssues") != null) {
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString())); rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString()));
} else { } else {