Merge branch 'Development'

* Development: (72 commits)
  splash screen fixes
  splash spell error fix
  Properly remove associate Collaborators from a DMP
  splash changes
  Fixed issue with DMP filter on public datasets
  Fixed issue when using the copy dataset dialog
  Minor styling improvement over DMP Overview
  Code clean up
  Add support for newer versions of java (11) (expirimental)
  Add Zenodo file visibility field for DMP (ref #274)
  Fixed issue not passing DMP Extra Properties on clones and new Versions
  Add DMP Zenodo license field (ref #274)
  more splash screen changes
  Allow splash to send contact emails
  splash screen changes
  Hide Uri field on Dataset Editor (ref #275)
  When logging in remove the cookie consent popup
  Fixed minor issues with RDA Mapping
  Add currency field type for dataset templates
  Add DMP language a placeholder on UI
  ...

# Conflicts:
#	dmp-backend/web/src/main/resources/RDACommonStandards.txt
#	dmp-backend/web/src/main/resources/config/application-production.properties
This commit is contained in:
Diamantis Tziotzios 2020-07-03 11:00:07 +03:00
commit 9f5054668e
279 changed files with 57488 additions and 1947 deletions

View File

@ -1,15 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import java.util.List;
import java.util.UUID;
public interface UserAssociationDao extends DatabaseAccessLayer<UserAssociation, UUID> {
public List<UserAssociation> getAssociated(UserInfo userId);
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser);
}

View File

@ -1,73 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("UserAssociationDao")
public class UserAssociationDaoImpl extends DatabaseAccess<UserAssociation> implements UserAssociationDao {
@Autowired
public UserAssociationDaoImpl(DatabaseService<UserAssociation> databaseService) {
super(databaseService);
}
@Override
public UserAssociation createOrUpdate(UserAssociation item) {
return this.getDatabaseService().createOrUpdate(item, UserAssociation.class);
}
@Override
public CompletableFuture<UserAssociation> createOrUpdateAsync(UserAssociation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserAssociation find(UUID id) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
}
@Override
public UserAssociation find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(UserAssociation item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserAssociation> asQueryable() {
return this.getDatabaseService().getQueryable(UserAssociation.class);
}
@Override
public List<UserAssociation> getAssociated(UserInfo userId) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(builder.equal(root.get("firstUser"), userId), builder.equal(root.get("secondUser"), userId)))).toList();
}
@Override
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(
builder.and(
builder.equal(root.get("firstUser"), firstUser),
builder.equal(root.get("secondUser"), secondUser)
),
builder.and(
builder.equal(root.get("secondUser"), firstUser),
builder.equal(root.get("firstUser"), secondUser)
)
))).count() > 0;
}
}

View File

@ -2,7 +2,6 @@ package eu.eudat.data.dao.entities.security;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.Credential;
import sun.security.krb5.Credentials;
import java.util.UUID;

View File

@ -174,6 +174,9 @@ public class DMP implements DataEntity<DMP, UUID> {
@JoinColumn(name = "\"Project\"")
private Project project;
@Column(name = "\"extraProperties\"")
private String extraProperties;
public String getDescription() {
return description;
@ -336,6 +339,14 @@ public class DMP implements DataEntity<DMP, UUID> {
this.project = project;
}
public String getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(String extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public void update(DMP entity) {
this.associatedDmps = entity.associatedDmps;
@ -356,6 +367,7 @@ public class DMP implements DataEntity<DMP, UUID> {
if (entity.isPublic) this.setPublishedAt(new Date());
if (entity.getUsers() != null) this.users = entity.getUsers();
if (entity.getDoi() != null && entity.getDoi().trim().isEmpty()) this.doi = entity.doi;
this.extraProperties = entity.getExtraProperties();
}
@Override

View File

@ -86,6 +86,9 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
)
private List<DMP> dmps;
@Column(name = "\"Language\"", nullable = false)
private String language;
public String getDescription() {
return description;
@ -147,9 +150,17 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
public Short getVersion() { return version; }
public void setVersion(Short version) { this.version = version; }
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
@Override
public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + "]";
}
@Override

View File

@ -1,66 +0,0 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"UserAssociation\"")
public class UserAssociation implements DataEntity<UserAssociation, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"firstUser\"")
private UserInfo firstUser;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"secondUser\"")
private UserInfo secondUser;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserInfo getFirstUser() {
return firstUser;
}
public void setFirstUser(UserInfo firstUser) {
this.firstUser = firstUser;
}
public UserInfo getSecondUser() {
return secondUser;
}
public void setSecondUser(UserInfo secondUser) {
this.secondUser = secondUser;
}
@Override
public void update(UserAssociation entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public UserAssociation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -2,12 +2,14 @@ package eu.eudat.data.query.items.item.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.Query;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DatasetProfileAutocompleteRequest extends Query<DatasetProfileCriteria,DatasetProfile> {
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> {
@Override
public QueryableList<DatasetProfile> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery();
@ -15,4 +17,9 @@ public class DatasetProfileAutocompleteRequest extends Query<DatasetProfileCrite
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query;
}
@Override
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dmp-backend</groupId>
<artifactId>logging</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>eu.eudat</groupId>
<artifactId>dmp-backend</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
</dependencies>
</project>

View File

@ -1,48 +0,0 @@
package eu.eudat.core.logger;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
/**
* Created by ikalyvas on 5/30/2018.
*/
public interface Logger {
<T> void debug(T model);
<T> void debug(T model,String message);
<T> void debug(String message);
<T extends Exception> void debug(T exception);
<T extends Exception> void debug(T exception,String message);
<T> void warn(T model);
<T> void warn(T model,String message);
<T> void warn(String message);
<T extends Exception> void warn(T exception);
<T extends Exception> void warn(T exception,String message);
<T> void info(String message);
<T> void info(T model);
<T> void info(T model,String message);
<T extends RuntimeException> void info(T exception);
<T extends RuntimeException> void info(T exception,String message);
<T> void error(T loggingModel);
<E extends Exception,P> void error(ApiExceptionLoggingModel<E,P> model);
<T extends Exception> void error(T exception);
<T extends Exception> void error(T exception,String message);
}

View File

@ -1,57 +0,0 @@
package eu.eudat.core.logger.common;
import org.json.JSONObject;
import org.springframework.core.env.Environment;
import types.LoggingOutputType;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by ikalyvas on 5/30/2018.
*/
public abstract class AbstractBatchLogger {
private Map<String, Object> concurrentHashMap = new ConcurrentHashMap<String, Object>();
public AbstractBatchLogger(Environment environment) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(() -> this.outputData(), Long.parseLong(environment.getProperty("http-logger.initial-delay")), Long.parseLong(environment.getProperty("http-logger.delay")), TimeUnit.SECONDS);
}
public abstract LoggingOutputType logOutputType();
public <T> void put(String key, T data) {
this.concurrentHashMap.put(key, data);
}
public void clear() {
this.concurrentHashMap.clear();
}
private Map<String, Object> getAndClear() {
Map<String, Object> map = new HashMap<>();
map.putAll(this.concurrentHashMap);
this.concurrentHashMap.keySet().removeAll(map.keySet());
return map;
}
public String tranformLog() {
if (this.concurrentHashMap.size() > 0) {
Map<String, Collection<Object>> transformedMap = new HashMap<>();
transformedMap.put("entries", this.getAndClear().values());
if (this.logOutputType().equals(LoggingOutputType.JSON))
return new JSONObject(transformedMap).toString();
if (this.logOutputType().equals(LoggingOutputType.FILE))
return transformedMap.toString(); //TODO actual implementation of file Logger
else throw new RuntimeException("Unsupported LoggingOutputType type");
} else return null;
}
public abstract void outputData();
}

View File

@ -1,287 +0,0 @@
package eu.eudat.core.logger.remote.http;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import eu.eudat.core.logger.Logger;
import eu.eudat.core.logger.common.AbstractBatchLogger;
import eu.eudat.core.models.LoggingModel;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.core.models.exception.ExceptionLoggingModel;
import eu.eudat.core.models.simple.SimpleAuditModel;
import eu.eudat.core.models.simple.SimpleLoggingModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import types.LoggingOutputType;
import types.LoggingType;
import java.util.HashMap;
import java.util.Map;
/**
* Created by ikalyvas on 5/30/2018.
*/
//@Service("logger")
public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
private RestTemplate rest;
private HttpHeaders headers;
private Environment environment;
//@Autowired
public HttpRemoteLogger(Environment environment) {
super(environment);
this.rest = new RestTemplate();
this.headers = new HttpHeaders();
this.environment = environment;
headers.add("Content-Type", "application/json");
headers.add("Accept", "*/*");
}
@Override
public void outputData() {
try {
String log = this.tranformLog();
if (log != null) {
HttpEntity<String> requestEntity = new HttpEntity(log, headers);
ResponseEntity<String> Object = rest.exchange(this.environment.getProperty("http-logger.server-address"), HttpMethod.POST, requestEntity, String.class);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public LoggingOutputType logOutputType() {
return LoggingOutputType.JSON;
}
@Override
public <T> void debug(T model) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setData(model);
loggingModel.setType(LoggingType.DEBUG);
this.put(String.valueOf(model.hashCode()), loggingModel);
}
@Override
public <T> void debug(T model, String message) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setData(model);
loggingModel.setMessage(message);
loggingModel.setType(LoggingType.DEBUG);
this.put(String.valueOf(model.hashCode()), loggingModel);
}
@Override
public <T> void debug(String message) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setMessage(message);
loggingModel.setType(LoggingType.DEBUG);
this.put(String.valueOf(message.hashCode()), loggingModel);
}
@Override
public <T extends Exception> void debug(T exception) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setType(LoggingType.DEBUG);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T extends Exception> void debug(T exception, String message) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setMessage(message);
exceptionLoggingModel.setType(LoggingType.DEBUG);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T> void warn(T model) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setData(model);
loggingModel.setType(LoggingType.WARNING);
this.put(String.valueOf(model.hashCode()), loggingModel);
}
@Override
public <T> void warn(T model, String message) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setData(model);
loggingModel.setMessage(message);
loggingModel.setType(LoggingType.WARNING);
this.put(String.valueOf(model.hashCode()), loggingModel);
}
@Override
public <T> void warn(String message) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setMessage(message);
loggingModel.setType(LoggingType.WARNING);
this.put(String.valueOf(message.hashCode()), loggingModel);
}
@Override
public <T extends Exception> void warn(T exception) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setType(LoggingType.WARNING);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T extends Exception> void warn(T exception, String message) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setMessage(message);
exceptionLoggingModel.setType(LoggingType.WARNING);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T> void info(String message) {
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
simpleAuditModel.setMessage(message);
simpleAuditModel.setType(LoggingType.INFO);
this.put(String.valueOf(simpleAuditModel.hashCode()), simpleAuditModel);
}
@Override
public <T> void info(T model) {
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
simpleAuditModel.setData(model);
simpleAuditModel.setType(LoggingType.INFO);
this.put(String.valueOf(model.hashCode()), simpleAuditModel);
}
@Override
public <T> void info(T model, String message) {
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
simpleAuditModel.setData(model);
simpleAuditModel.setMessage(message);
simpleAuditModel.setType(LoggingType.INFO);
this.put(String.valueOf(model.hashCode()), simpleAuditModel);
}
@Override
public <T extends RuntimeException> void info(T exception) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setType(LoggingType.INFO);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T extends RuntimeException> void info(T exception, String message) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setMessage(message);
exceptionLoggingModel.setType(LoggingType.INFO);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <E extends Exception, P> void error(ApiExceptionLoggingModel<E, P> model) {
this.put(String.valueOf(model.hashCode()), model);
}
@Override
public <T> void error(T model) {
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
loggingModel.setType(LoggingType.DEBUG);
loggingModel.setData(model);
this.put(String.valueOf(model.hashCode()), loggingModel);
}
@Override
public <T extends Exception> void error(T exception) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setType(LoggingType.ERROR);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
@Override
public <T extends Exception> void error(T exception, String message) {
ExceptionLoggingModel exceptionLoggingModel = new ExceptionLoggingModel();
Map<String, String> map = new HashMap<>();
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(exception);
map.put("exception", json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
exceptionLoggingModel.setData(map);
exceptionLoggingModel.setMessage(message);
exceptionLoggingModel.setType(LoggingType.ERROR);
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
}
}

View File

@ -1,8 +0,0 @@
package eu.eudat.core.models;
/**
* Created by ikalyvas on 5/30/2018.
*/
public abstract class AuditModel<T> extends LoggingModel<T>{
}

View File

@ -1,36 +0,0 @@
package eu.eudat.core.models;
import types.LoggingType;
/**
* Created by ikalyvas on 5/30/2018.
*/
public abstract class LoggingModel<T> {
private T data;
private LoggingType type;
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public LoggingType getType() {
return type;
}
public void setType(LoggingType type) {
this.type = type;
}
}

View File

@ -1,35 +0,0 @@
package eu.eudat.core.models.exception;
import eu.eudat.core.models.LoggingModel;
import org.springframework.http.HttpStatus;
import java.util.Map;
/**
* Created by ikalyvas on 6/12/2018.
*/
public class ApiExceptionLoggingModel<E, P> extends LoggingModel<E> {
private HttpStatus code;
private P user;
private final String indexType = "api-exception-logging";
public String getIndexType() {
return indexType;
}
public P getUser() {
return user;
}
public void setUser(P user) {
this.user = user;
}
public HttpStatus getCode() {
return code;
}
public void setCode(HttpStatus code) {
this.code = code;
}
}

View File

@ -1,21 +0,0 @@
package eu.eudat.core.models.exception;
import eu.eudat.core.models.LoggingModel;
import java.util.Map;
/**
* Created by ikalyvas on 5/30/2018.
*/
public class ExceptionLoggingModel extends LoggingModel<Map<String, String>> {
private final String indexType = "exception-logging";
public String getIndexType() {
return indexType;
}
@Override
public Map<String, String> getData() {
return super.getData();
}
}

View File

@ -1,14 +0,0 @@
package eu.eudat.core.models.simple;
import eu.eudat.core.models.AuditModel;
/**
* Created by ikalyvas on 5/30/2018.
*/
public class SimpleAuditModel<T> extends AuditModel<T> {
private final String indexType = "simple-audit";
public String getIndexType() {
return indexType;
}
}

View File

@ -1,14 +0,0 @@
package eu.eudat.core.models.simple;
import eu.eudat.core.models.LoggingModel;
/**
* Created by ikalyvas on 5/30/2018.
*/
public class SimpleLoggingModel<T> extends LoggingModel<T> {
private final String indexType = "simple-logging";
public String getIndexType() {
return indexType;
}
}

View File

@ -1,29 +0,0 @@
package types;
/**
* Created by ikalyvas on 5/30/2018.
*/
public enum LoggingOutputType {
FILE(0), JSON(1);
private Integer value;
private LoggingOutputType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static LoggingOutputType fromInteger(Integer value) {
switch (value) {
case 0:
return FILE;
case 1:
return JSON;
default:
throw new RuntimeException("Unsupported Logging LoggingOutputType");
}
}
}

View File

@ -1,33 +0,0 @@
package types;
/**
* Created by ikalyvas on 5/30/2018.
*/
public enum LoggingType {
WARNING(0), ERROR(1), INFO(2), DEBUG(3);
private Integer value;
private LoggingType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static LoggingType fromInteger(Integer value) {
switch (value) {
case 0:
return WARNING;
case 1:
return ERROR;
case 2:
return INFO;
case 3:
return DEBUG;
default:
throw new RuntimeException("Unsupported LoggingType");
}
}
}

View File

@ -17,7 +17,6 @@
<module>queryable</module>
<module>web</module>
<module>data</module>
<module>logging</module>
<module>elastic</module>
</modules>
@ -196,6 +195,36 @@
<artifactId>log4j-to-slf4j</artifactId>
<version>2.8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-core -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>

View File

@ -21,11 +21,6 @@
<artifactId>data</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>dmp-backend</groupId>
<artifactId>logging</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>dmp-backend</groupId>
<artifactId>queryable</artifactId>

View File

@ -40,6 +40,8 @@ public class ResponsesCache {
caches.add(new GuavaCache("tags", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("currencies", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("licenses", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
simpleCacheManager.setCaches(caches);
logger.info("OK");
return simpleCacheManager;

View File

@ -1,6 +1,5 @@
package eu.eudat.controllers;
import eu.eudat.core.logger.Logger;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
@ -71,6 +70,7 @@ public class Admin extends BaseController {
datasetprofile.setStatus(modelDefinition.getStatus());
datasetprofile.setLabel(modelDefinition.getLabel());
datasetprofile.setDescription(modelDefinition.getDescription());
datasetprofile.setLanguage(modelDefinition.getLanguage());
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
}
@ -114,6 +114,7 @@ public class Admin extends BaseController {
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel() + " new ");
datasetprofile.setLanguage(profile.getLanguage());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
}

View File

@ -1,6 +1,5 @@
package eu.eudat.controllers;
import eu.eudat.core.logger.Logger;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.validators.*;
import org.springframework.web.bind.WebDataBinder;
@ -9,18 +8,12 @@ import org.springframework.web.bind.annotation.InitBinder;
public abstract class BaseController {
/*private Logger logger;*/
private ApiContext apiContext;
public ApiContext getApiContext() {
return apiContext;
}
/*public Logger getLoggerService() {
return logger;
}*/
public BaseController(ApiContext apiContext) {
this.apiContext = apiContext;

View File

@ -2,6 +2,7 @@ package eu.eudat.controllers;
import eu.eudat.logic.managers.ContactEmailManager;
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
@ -38,4 +39,18 @@ public class ContactEmail {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, path = "public", consumes = "application/x-www-form-urlencoded", produces = "application/json")
public @ResponseBody
ResponseEntity sendContactEmailNoAuth(@ModelAttribute PublicContactEmailModel contactEmailModel) {
logger.info(contactEmailModel.toString());
try {
this.contactEmailManager.sendContactEmailNoAuth(contactEmailModel);
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
}
}
}

View File

@ -0,0 +1,31 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.LocalFetchManager;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.local.LocalFetchModel;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping(value = "api/currency")
public class CurrencyController {
private LocalFetchManager localFetchManager;
@Autowired
public CurrencyController(LocalFetchManager localFetchManager) {
this.localFetchManager = localFetchManager;
}
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<ResponseItem<List<LocalFetchModel>>> getCurrencies( @RequestParam(value = "query", required = false) String query) throws Exception {
List<LocalFetchModel> currencies = localFetchManager.getCurrency(query);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<LocalFetchModel>>().status(ApiMessageCode.NO_MESSAGE).payload(currencies));
}
}

View File

@ -235,9 +235,9 @@ public class DMPs extends BaseController {
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception {
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, @RequestParam(name = "profiles", required = false)String[] profiles, Principal principal) throws Exception {
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
this.dataManagementPlanManager.createFromRDA(files, principal);
this.dataManagementPlanManager.createFromRDA(files, principal, profiles);
} else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) {
this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal);
}
@ -266,6 +266,17 @@ public class DMPs extends BaseController {
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
public ResponseEntity<ResponseItem<DMP>> undoFinalize(@PathVariable String id, Principal principal) {
try {
this.dataManagementPlanManager.undoFinalize(UUID.fromString(id), principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made active."));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
/*
* DOI Generation
* */

View File

@ -0,0 +1,41 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.LicenseManager;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.license.LicenseModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/external/licenses"})
public class Licenses extends BaseController {
private LicenseManager licenseManager;
@Autowired
public Licenses(ApiContext apiContext, LicenseManager licenseManager) {
super(apiContext);
this.licenseManager = licenseManager;
}
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<LicenseModel>>> listExternalLicenses(
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
) throws HugeResultSet, NoURLFound {
List<LicenseModel> licenseModels = this.licenseManager.getLicenses(query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<LicenseModel>>().status(ApiMessageCode.NO_MESSAGE).payload(licenseModels));
}
}

View File

@ -1,8 +1,6 @@
package eu.eudat.controllers;
import com.sun.org.apache.xpath.internal.operations.Bool;
import eu.eudat.logic.managers.LockManager;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.lock.Lock;
import eu.eudat.models.data.security.Principal;

View File

@ -1,26 +1,18 @@
package eu.eudat.controllers.controllerhandler;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import types.LoggingType;
import javax.annotation.Priority;
import java.util.HashMap;
import java.util.Map;
/**
* Created by ikalyvas on 6/12/2018.
@ -30,31 +22,10 @@ import java.util.Map;
public class ControllerErrorHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
// private Logger logger;
/*@Autowired
public ControllerErrorHandler(Logger logger) {
this.logger = logger;
}*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ResponseItem<Exception> processValidationError(Principal principal, Exception ex) throws Exception {
ApiExceptionLoggingModel<String, Principal> apiExceptionLoggingModel = new ApiExceptionLoggingModel<>();
apiExceptionLoggingModel.setCode(HttpStatus.BAD_REQUEST);
apiExceptionLoggingModel.setUser(principal);
Map<String, String> exceptionMap = new HashMap<>();
ObjectWriter ow = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false).writer().withDefaultPrettyPrinter();
try {
String json = ow.writeValueAsString(ex);
exceptionMap.put("exception", json);
apiExceptionLoggingModel.setData(ow.writeValueAsString(exceptionMap));
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
apiExceptionLoggingModel.setMessage(ex.getMessage());
apiExceptionLoggingModel.setType(LoggingType.ERROR);
logger.error(ex.getMessage(), ex);
return new ResponseItem<Exception>().message(ex.getMessage()).status(ApiMessageCode.DEFAULT_ERROR_MESSAGE);
}

View File

@ -4,7 +4,6 @@ import eu.eudat.exceptions.security.UnauthorisedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -20,11 +19,9 @@ import javax.annotation.Priority;
@Priority(4)
public class ControllerUnauthorisedHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerUnauthorisedHandler.class);
// private Logger logger;
@Autowired
public ControllerUnauthorisedHandler(/*Logger logger*/) {
// this.logger = logger;
public ControllerUnauthorisedHandler() {
}
@ExceptionHandler(UnauthorisedException.class)

View File

@ -1,6 +1,5 @@
package eu.eudat.controllers.interceptors;
import eu.eudat.logic.services.helpers.LoggerService;
import eu.eudat.types.WarningLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -18,11 +17,9 @@ import java.util.Date;
@Component
public class RequestInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = LoggerFactory.getLogger(RequestInterceptor.class);
// private LoggerService loggerService;
@Autowired
public RequestInterceptor(/*LoggerService loggerService*/) {
// this.loggerService = loggerService;
public RequestInterceptor() {
}
@Override

View File

@ -29,6 +29,8 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
private String description;
private String language;
public DatasetProfileBuilder id(UUID id) {
this.id = id;
return this;
@ -69,6 +71,11 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
return this;
}
public DatasetProfileBuilder language(String language) {
this.language = language;
return this;
}
@Override
public DatasetProfile build() {
DatasetProfile datasetProfile = new DatasetProfile();
@ -80,6 +87,7 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
datasetProfile.setDescription(description);
datasetProfile.setModified(modified);
datasetProfile.setLabel(label);
datasetProfile.setLanguage(language);
return datasetProfile;
}
}

View File

@ -26,10 +26,26 @@ public class AdminManager {
viewStyleDoc.appendChild(elementViewStyle);
String xml = XmlBuilder.generateXml(viewStyleDoc);
if (profile.getDescription() == null) {
profile.setDescription("");
}
if (profile.getLanguage() == null) {
profile.setLanguage("en");
}
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
.status(profile.getStatus()).created(new Date()).description(profile.getDescription())
.status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage())
.build();
if (datasetProfile.getGroupId() == null) {
datasetProfile.setGroupId(UUID.randomUUID());
}
if (datasetProfile.getVersion() == null) {
datasetProfile.setVersion((short)1);
}
return datasetProfile;
}

View File

@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
import eu.eudat.models.data.mail.SimpleMail;
import eu.eudat.models.data.security.Principal;
import org.springframework.core.env.Environment;
@ -35,6 +36,17 @@ public class ContactEmailManager {
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
}
public void sendContactEmailNoAuth(PublicContactEmailModel contactEmailModel) throws MessagingException {
SimpleMail mail = new SimpleMail();
String enrichedMail = contactEmailModel.getMessage() + "\n\n" + "Send by user: " + contactEmailModel.getEmail() ;
mail.setSubject(contactEmailModel.getAffiliation());
mail.setTo(environment.getProperty("contact_email.mail"));
mail.setContent(enrichedMail);
mail.setFrom(contactEmailModel.getEmail());
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
}
public void emailValidation(ContactEmailModel contactEmailModel) throws Exception {
if (contactEmailModel.getSubject() == null || contactEmailModel.getSubject().trim().isEmpty()) {
throw new Exception("Subject is empty");

View File

@ -1,6 +1,5 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
@ -14,10 +13,8 @@ import eu.eudat.data.enumeration.notification.ActiveStatus;
import eu.eudat.data.enumeration.notification.ContactType;
import eu.eudat.data.enumeration.notification.NotificationType;
import eu.eudat.data.enumeration.notification.NotifyState;
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.elastic.criteria.DmpCriteria;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Dmp;
@ -83,14 +80,13 @@ import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.math.BigInteger;
import java.nio.file.Files;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -372,6 +368,14 @@ public class DataManagementPlanManager {
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) {
clearUsers(newDmp);
for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) {
UserInfo tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId());
assignUser(dmp, tempUser, UserDMP.UserDMPRoles.fromInteger(userListing.getRole()));
}
}
// Dataset manipulation for when the DMP is set to be finalized.
if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
@ -794,7 +798,9 @@ public class DataManagementPlanManager {
});
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
sendNotification(dmp, user, NotificationType.DMP_PUBLISH);
this.createZenodoDoi(dmp.getId(), principal, null);
if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) {
this.createZenodoDoi(dmp.getId(), principal, null, true);
}
}
public void makeFinalize(UUID id, Principal principal, DatasetsToBeFinalized datasetsToBeFinalized) throws Exception {
@ -850,6 +856,17 @@ public class DataManagementPlanManager {
this.updateDatasetsIndex(indexDatasets);
}
public void undoFinalize(UUID id, Principal principal) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id);
if (!isUserOwnerOfDmp(dmp, principal))
throw new Exception("User does not have the privilege to do this action.");
if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue()))
throw new Exception("DMP is already Active");
dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
this.updateIndex(dmp);
}
/*
* Export Data
* */
@ -1366,13 +1383,13 @@ public class DataManagementPlanManager {
return dataManagementPlans;
}
public List<DMP> createFromRDA(MultipartFile[] files, Principal principal) throws IOException {
public List<DMP> createFromRDA(MultipartFile[] files, Principal principal, String[] profiles) throws IOException {
if (principal.getId() == null) {
throw new UnauthorisedException("No user is logged in");
}
List<DMP> result = new ArrayList<>();
for (MultipartFile file: files) {
DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"));
DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"), profiles);
dmp.setLabel(file.getOriginalFilename());
UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
dmp.setModified(new Date());
@ -1381,7 +1398,7 @@ public class DataManagementPlanManager {
dmp.setStatus((short)0);
dmp.setGroupId(UUID.randomUUID());
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
dmp.getResearchers().forEach(researcher -> {
dmp.getResearchers().stream().filter(Objects::nonNull).forEach(researcher -> {
researcher.setId(UUID.randomUUID());
researcher.setCreated(new Date());
researcher.setModified(new Date());
@ -1391,7 +1408,9 @@ public class DataManagementPlanManager {
}
databaseRepository.getDmpDao().createOrUpdate(dmp);
assignUser(dmp, me);
this.updateIndex(dmp);
if (this.apiContext.getOperationsContext().getElasticRepository().getDmpRepository().getClient() != null) {
this.updateIndex(dmp);
}
dmp.getDataset().forEach(dataset -> {
dataset.setStatus(Dataset.Status.SAVED.getValue());
dataset.setCreated(new Date());
@ -1414,8 +1433,11 @@ public class DataManagementPlanManager {
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
if (elastic != null) {
tags = elastic.getTags();
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
datasetWizardModel.setTags(tags);
datasetManager.getTagsFromProfile(datasetWizardModel, dataset);
datasetManager.updateTags(dataset, datasetWizardModel.getTags());
}
datasetManager.updateTags(dataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@ -1431,13 +1453,22 @@ public class DataManagementPlanManager {
* */
private void assignUser(DMP dmp, UserInfo userInfo) {
this.assignUser(dmp, userInfo, UserDMP.UserDMPRoles.OWNER);
}
private void assignUser(DMP dmp, UserInfo userInfo, UserDMP.UserDMPRoles role) {
UserDMP userDMP = new UserDMP();
userDMP.setDmp(dmp);
userDMP.setUser(userInfo);
userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue());
userDMP.setRole(role.getValue());
databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
}
private void clearUsers(DMP dmp) {
List<UserDMP> userDMPs = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP));
}
private void assignGrandUserIfInternal(DMP dmp, UserInfo user) {
if (dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
dmp.getGrant().setCreationUser(user);
@ -1606,6 +1637,10 @@ public class DataManagementPlanManager {
}
public String createZenodoDoi(UUID id, Principal principal, ConfigLoader configLoader) throws Exception {
return this.createZenodoDoi(id, principal, configLoader, false);
}
public String createZenodoDoi(UUID id, Principal principal, ConfigLoader configLoader, boolean update) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id);
if (!isUserOwnerOfDmp(dmp, principal))
throw new Exception("User is not authorized to invoke this action");
@ -1628,6 +1663,7 @@ public class DataManagementPlanManager {
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
String createData = null;
Map<String, Object> extraProperties = dmp.getExtraProperties() != null ? new org.json.JSONObject(dmp.getExtraProperties()).toMap() : new HashMap<>();
StringBuilder dataBuilder = new StringBuilder();
dataBuilder.append("{\n \"metadata\": {\n");
dataBuilder.append( " \"title\": \"").append(dmp.getLabel()).append("\",\n");
@ -1635,9 +1671,28 @@ public class DataManagementPlanManager {
dataBuilder.append(" \"publication_type\": \"datamanagementplan\",\n");
dataBuilder.append(" \"description\": \"").append((dmp.getDescription() != null && !dmp.getDescription().isEmpty() ? dmp.getDescription() : "<p></p>")).append("\",\n");
dataBuilder.append(" \"version\": \"").append(dmp.getVersion()).append("\",\n");
dataBuilder.append(" \"related_identifiers\": [{\n");
dataBuilder.append(" \t\t\"identifier\": \"").append((this.environment.getProperty("dmp.domain") + "/explore-plans/publicOverview/" + id.toString())).append("\",\n");
dataBuilder.append(" \t\t\"relation\": \"isIdenticalTo\"}],\n");
dataBuilder.append(" \"access_right\": \"");
if (((Boolean)extraProperties.get("visible"))) {
Instant publicationDate = Instant.parse(extraProperties.get("publicDate").toString());
if (publicationDate.isBefore(Instant.now())) {
dataBuilder.append("open\",\n");
} else {
dataBuilder.append("embargoed\",\n");
dataBuilder.append(" \"embargo_date\": \"" + publicationDate + "\",\n");
}
if (extraProperties.get("license") != null) {
dataBuilder.append(" \"license\": \"").append(((Map)extraProperties.get("license")).get("pid")).append("\",\n");
}
} else {
dataBuilder.append("restricted\",\n");
dataBuilder.append(" \"access_conditions\": \"\",\n");
}
if (dmp.isPublic()) {
dataBuilder.append(" \"related_identifiers\": [{\n");
dataBuilder.append(" \t\t\"identifier\": \"").append((this.environment.getProperty("dmp.domain") + "/external/zenodo/" + id.toString())).append("\",\n");
dataBuilder.append(" \t\t\"relation\": \"isIdenticalTo\"}],\n");
}
dataBuilder.append(" \"contributors\": [");
int i = 0;
for(UserDMP userDMP: dmp.getUsers()) {
@ -1731,33 +1786,46 @@ public class DataManagementPlanManager {
throw e;
}
}
else {
String listUrl = this.environment.getProperty("zenodo.url") + "deposit/depositions" + "?q=conceptdoi:\"" + previousDOI + "\"&access_token=" + zenodoToken;
ResponseEntity<Map[]> listResponses = restTemplate.getForEntity(listUrl, Map[].class);
createResponse = listResponses.getBody()[0];
links = (LinkedHashMap<String, String>) createResponse.get("links");
}
}
if (unpublishedUrl == null) {
// Second step, add the file to the entry.
HttpHeaders fileHeaders = new HttpHeaders();
fileHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
LinkedMultiValueMap<String, Object> addFileMap = new LinkedMultiValueMap<>();
if (!update) {
if (unpublishedUrl == null) {
// Second step, add the file to the entry.
HttpHeaders fileHeaders = new HttpHeaders();
fileHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
LinkedMultiValueMap<String, Object> addFileMap = new LinkedMultiValueMap<>();
FileEnvelope file = getWordDocument(id.toString(), principal, configLoader);
addFileMap.add("filename", file.getFilename());
FileSystemResource fileSystemResource = new FileSystemResource(file.getFile());
addFileMap.add("file", fileSystemResource);
HttpEntity<MultiValueMap<String, Object>> addFileMapRequest = new HttpEntity<>(addFileMap, fileHeaders);
FileEnvelope file = getWordDocument(id.toString(), principal, configLoader);
addFileMap.add("filename", file.getFilename());
FileSystemResource fileSystemResource = new FileSystemResource(file.getFile());
addFileMap.add("file", fileSystemResource);
HttpEntity<MultiValueMap<String, Object>> addFileMapRequest = new HttpEntity<>(addFileMap, fileHeaders);
String addFileUrl = links.get("files") + "?access_token=" + zenodoToken;
ResponseEntity<String> addFileResponse = restTemplate.postForEntity(addFileUrl, addFileMapRequest, String.class);
Files.deleteIfExists(file.getFile().toPath());
String addFileUrl = links.get("files") + "?access_token=" + zenodoToken;
ResponseEntity<String> addFileResponse = restTemplate.postForEntity(addFileUrl, addFileMapRequest, String.class);
Files.deleteIfExists(file.getFile().toPath());
// Third post call to Zenodo to publish the entry and return the DOI.
publishUrl = links.get("publish") + "?access_token=" + zenodoToken;
} else {
publishUrl = unpublishedUrl + "?access_token=" + zenodoToken;
}
if (dmp.isPublic()) {
// Third post call to Zenodo to publish the entry and return the DOI.
publishUrl = links.get("publish") + "?access_token=" + zenodoToken;
} else {
publishUrl = unpublishedUrl + "?access_token=" + zenodoToken;
}
// if (dmp.isPublic()) {
Map<String, Object> publishResponce = restTemplate.postForObject(publishUrl, "", Map.class);
finalDoi = (String) publishResponce.get("conceptdoi");
// }
} else {
Map<String, Object> editResponce = restTemplate.postForObject(links.get("edit") + "?access_token=" + zenodoToken, "", Map.class);
restTemplate.put(links.get("self") + "?access_token=" + zenodoToken, request);
Map<String, Object> publishResponce = restTemplate.postForObject(links.get("publish") + "?access_token=" + zenodoToken, "", Map.class);
finalDoi = (String) publishResponce.get("conceptdoi");
}
if (finalDoi != null) {

View File

@ -1,5 +1,7 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.DataRepositoryDao;
import eu.eudat.data.dao.entities.DatasetDao;
@ -27,6 +29,8 @@ import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder;
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.datasetImport.DatasetImportField;
import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
@ -563,6 +567,9 @@ public class DatasetManager {
eu.eudat.data.entities.Dataset dataset = datasetWizardModel.toDataModel();
dataset.setDmp(dmp);
dataset.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition()));
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
this.getTagsFromProfile(datasetWizardModel, dataset);
}
if (datasetWizardModel.getStatus() == (int) Dataset.Status.FINALISED.getValue())
checkDatasetValidation(dataset);
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
@ -974,4 +981,47 @@ public class DatasetManager {
}
}
}
public void getTagsFromProfile(DatasetWizardModel wizardModel, Dataset dataset) throws IOException {
dataset.setProfile(apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId()));
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, dataset));
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition());
JsonNode propertiesJson = mapper.readTree(json);
List<Tag> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(new DatasetCriteria()).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
Set<JsonNode> tagNodes = new HashSet<>();
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "renderStyle", "tags", true));
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "rdaProperty", "dataset.keyword"));
if (!tagNodes.isEmpty()) {
tagNodes.forEach(node -> {
JsonNode value = node.get("value");
if (value.isArray()) {
value.elements().forEachRemaining(element -> {
try {
Map<String, String> data = mapper.readValue(element.asText(), HashMap.class);
this.addTag(tags, wizardModel.getTags(), data.get("id"), data.get("name"));
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
} else {
this.addTag(tags, wizardModel.getTags(), "", value.asText());
}
});
}
}
private void addTag(List<Tag> srcTags, List<Tag> dstTags, String id, String name) {
Tag tag = new Tag();
if(srcTags.stream().anyMatch(intag -> intag.getName().equals(name))) {
tag = srcTags.stream().filter(intag -> intag.getName().equals(name)).findFirst().get();
} else {
tag.setName(name);
tag.setId(id);
}
if (dstTags.stream().noneMatch(intag -> intag.getName().equals(name))) {
dstTags.add(tag);
}
}
}

View File

@ -37,6 +37,7 @@ import javax.xml.xpath.*;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
@Component
@ -46,12 +47,14 @@ public class DatasetProfileManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private Environment environment;
private List<String> cache;
@Autowired
public DatasetProfileManager(ApiContext apiContext, Environment environment) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.environment = environment;
this.cache = new ArrayList<>();
}
public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) {
@ -60,13 +63,15 @@ public class DatasetProfileManager {
datasetprofile.setLabel(profile.getLabel());
datasetprofile.setStatus(profile.getStatus());
datasetprofile.setDescription(profile.getDescription());
datasetprofile.setLanguage(profile.getLanguage());
return datasetprofile;
}
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
List<DatasetProfileAutocompleteItem> datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
QueryableList<DatasetProfile> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items);
List<DatasetProfileAutocompleteItem> datasetProfiles = pagedItems.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
return datasetProfiles;
}
@ -106,17 +111,59 @@ public class DatasetProfileManager {
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.valueOf("application/vnd.api+json; charset=utf-8")));
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
DocumentContext jsonContext = null;
HttpEntity<String> entity;
ResponseEntity response;
List<Map<String, String>> jsonItems;
int i = 0;
for (AutoCompleteData.AutoCompleteSingleData singleData: data.getAutoCompleteSingleDataList()) {
switch (AutoCompleteData.AutocompleteType.fromValue(singleData.getAutocompleteType())) {
case UNCACHED:
ResponseEntity<Object> response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class);
DocumentContext jsonContext = JsonPath.parse(response.getBody());
String url = singleData.getUrl();
String mediaType = "";
if (url.contains("openaire")) {
mediaType = "application/json; charset=utf-8";
url = url.replace("{like}", like.equals("") ? "*" : like);
url = url.replace("%20", " ");
url = url.replace("%22", "\"");
url = url.replace("&amp;", "&");
} else {
mediaType = "application/vnd.api+json; charset=utf-8";
url += "?search=" + like;
}
List<Map<String, String>> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri"))));
headers.setAccept(Collections.singletonList(MediaType.valueOf(mediaType)));
headers.setContentType(MediaType.APPLICATION_JSON);
entity = new HttpEntity<>("parameters", headers);
return result;
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
jsonContext = JsonPath.parse(response.getBody());
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(singleData.getAutoCompleteOptions().getValue()), item.get(singleData.getAutoCompleteOptions().getLabel()), item.get(singleData.getAutoCompleteOptions().getSource()), item.get("uri"))));
break;
case CACHED:
headers.setAccept(Collections.singletonList(MediaType.valueOf("text/plain; charset=utf-8")));
headers.setContentType(MediaType.TEXT_PLAIN);
entity = new HttpEntity<>("parameters", headers);
if (this.cache.size() <= i) {
response = restTemplate.exchange(singleData.getUrl(), HttpMethod.GET, entity, String.class);
this.cache.add((String) response.getBody());
}
jsonContext = JsonPath.parse(cache.get(i));
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
jsonItems.stream().filter(item -> item.get(singleData.getAutoCompleteOptions().getLabel()).toLowerCase().contains(like.toLowerCase()))
.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(singleData.getAutoCompleteOptions().getValue()), item.get(singleData.getAutoCompleteOptions().getLabel()), item.get(singleData.getAutoCompleteOptions().getSource()) != null ? item.get(singleData.getAutoCompleteOptions().getSource()) : singleData.getAutoCompleteOptions().getSource(), item.get("uri"))));
i++;
break;
}
}
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
//return result;
}
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
@ -187,6 +234,7 @@ public class DatasetProfileManager {
modelDefinition.setLabel(oldDatasetProfile.getLabel());
modelDefinition.setVersion((short) (oldDatasetProfile.getVersion() + 1));
modelDefinition.setGroupId(oldDatasetProfile.getGroupId());
modelDefinition.setLanguage(oldDatasetProfile.getLanguage());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
return modelDefinition;
} else {

View File

@ -1,23 +1,23 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
public class InvitationsManager {
@ -33,33 +33,38 @@ public class InvitationsManager {
UserInfo principalUser = new UserInfo();
principalUser.setId(principal.getId());
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList());
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList());
List<UserDMP> userInfoToUserDmp = new LinkedList<>();
for (UserInfo userInfo : alreadySignedInUsersEntities) {
UserDMP userDMP = new UserDMP();
userDMP.setUser(userInfo);
userInfoToUserDmp.add(userDMP);
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
/*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(principalUser);
userAssociation.setSecondUser(userInfo);
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
}*/
}
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, principalUser);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
}
public List<UserInfoInvitationModel> getUsers(Principal principal) throws InstantiationException, IllegalAccessException {
UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
/*UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> {
if (userAssociation.getFirstUser().getId().equals(principal.getId())) {
return userAssociation.getSecondUser();
} else {
return userAssociation.getFirstUser();
}
}).collect(Collectors.toList());
}).collect(Collectors.toList());*/
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
.getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
.where(((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), principal.getId(), Stream.of(0, 1).collect(Collectors.toList()))
.toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
.filter(userInfo -> !userInfo.getId().equals(principal.getId())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList());
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
return userModels;
}
@ -74,12 +79,12 @@ public class InvitationsManager {
userDMP.setUser(invitedUser);
userDMP.setDmp(invitation.getDmp());
userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
/*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(invitedUser);
userAssociation.setSecondUser(invitation.getUser());
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
}*/
DMP datamanagementPlan = invitation.getDmp();
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);

View File

@ -0,0 +1,48 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
import eu.eudat.data.entities.DataRepository;
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datarepository.DataRepositoryModel;
import eu.eudat.models.data.license.LicenseModel;
import eu.eudat.models.data.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by ikalyvas on 9/3/2018.
*/
@Component
public class LicenseManager {
private ApiContext apiContext;
@Autowired
public LicenseManager(ApiContext apiContext) {
this.apiContext = apiContext;
}
public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSet, NoURLFound {
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getlicenses(externalUrlCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query);
List<LicenseModel> licenseModels = new LinkedList<>();
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
licenseModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, LicenseModel.class)).collect(Collectors.toList()));
licenseModels = licenseModels.stream().filter(licenseModel -> licenseModel.getName().contains(query)).collect(Collectors.toList());
return licenseModels;
}
}

View File

@ -0,0 +1,28 @@
package eu.eudat.logic.managers;
import eu.eudat.logic.proxy.fetching.LocalFetcher;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.local.LocalFetchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class LocalFetchManager {
private LocalFetcher localFetcher;
@Autowired
public LocalFetchManager(LocalFetcher localFetcher) {
this.localFetcher = localFetcher;
}
public List<LocalFetchModel> getCurrency(String query) throws Exception {
List<Map<String, String>> data = localFetcher.retrieveCurrency();
List<LocalFetchModel> result = data.stream().map(entry -> new LocalFetchModel(entry.get("name"), entry.get("value"))).collect(Collectors.toList());
result = result.stream().filter(localFetchModel -> localFetchModel.getValue() != null).filter(StreamDistinctBy.distinctByKey(LocalFetchModel::getValue)).filter(localFetchModel -> localFetchModel.getName().contains(query)).collect(Collectors.toList());
return result;
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DMP;
@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
@Component
@ -30,18 +32,20 @@ public class RDAManager {
Dmp rdaDmp = dmpRDAMapper.toRDA(dmp);
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"));
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rdaDmp);
RDAModel model = new RDAModel();
model.setDmp(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
return result;
}
public DMP convertToEntity(String json) throws IOException {
public DMP convertToEntity(String json, String[] profiles) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"));
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
Dmp rda = mapper.readValue(json, Dmp.class);
return dmpRDAMapper.toEntity(rda);
Dmp rda = mapper.readValue(json, RDAModel.class).getDmp();
return dmpRDAMapper.toEntity(rda, profiles);
}
}

View File

@ -58,7 +58,7 @@ public class DmpMapper {
}
if (dmp.getDataset() != null) {
elastic.setDatasets(dmp.getDataset().stream().map(dataset -> {
elastic.setDatasets(dmp.getDataset().stream().filter(dataset -> dataset.getId() != null).map(dataset -> {
List<Tag> tags = null;
try {
Dataset dataset1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());

View File

@ -24,6 +24,7 @@ public class ExternalUrls implements Serializable {
DatasetUrls datasets;
/*TagUrls tags;*/
FunderUrls funders;
LicenseUrls licenses;
public RegistryUrls getRegistries() {
@ -133,6 +134,15 @@ public class ExternalUrls implements Serializable {
public void setDatasets(DatasetUrls datasets) {
this.datasets = datasets;
}
public LicenseUrls getLicenses() {
return licenses;
}
@XmlElement(name = "licenses")
public void setLicenses(LicenseUrls licenses) {
this.licenses = licenses;
}
}

View File

@ -0,0 +1,33 @@
package eu.eudat.logic.proxy.config.entities;
import eu.eudat.logic.proxy.config.FetchStrategy;
import eu.eudat.logic.proxy.config.UrlConfiguration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class LicenseUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -0,0 +1,99 @@
package eu.eudat.logic.proxy.fetching;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.proxy.fetching.entities.Config;
import eu.eudat.logic.proxy.fetching.entities.ConfigSingle;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.beans.PropertyDescriptor;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.*;
@Component
public class LocalFetcher {
@Cacheable("currencies")
public List<Map<String, String>> retrieveCurrency() throws Exception {
InputStream is = getClass().getClassLoader().getResource("internal/fetchConfig.xml").openStream();
JAXBContext context = JAXBContext.newInstance(Config.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
Config config = (Config) unmarshaller.unmarshal(is);
ConfigSingle currencyConfig = config.getConfigs().stream().filter(configSingle -> configSingle.getType().equals("currency")).findFirst().get();
return retrieveData(currencyConfig);
}
public List<Map<String, String>> retrieveData(ConfigSingle configSingle) throws Exception {
List<Map<String, String>> result = new ArrayList<>();
InputStream is = getClass().getClassLoader().getResource(configSingle.getFilePath()).openStream();
FileType type = FileType.fromName(configSingle.getFileType());
switch(type) {
case XML:
{
Class<?> aClass = Class.forName(configSingle.getParseClass());
JAXBContext context = JAXBContext.newInstance(aClass);
Unmarshaller unmarshaller = context.createUnmarshaller();
Object object = unmarshaller.unmarshal(is);
Method reader = null;
if (configSingle.getParseField() != null && !configSingle.getParseField().isEmpty()) {
reader = new PropertyDescriptor(configSingle.getParseField(), aClass).getReadMethod();
}
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, String>> values = new ArrayList<>();
int max = 1;
if (reader != null) {
Object invokedField = reader.invoke(object);
if (invokedField instanceof Collection) {
max = ((Collection) invokedField).size();
}
}
for (int i = 0; i< max; i++) {
Object value;
if (reader != null) {
Object invokedField = reader.invoke(object);
if (invokedField instanceof Collection) {
value = ((Collection) invokedField).toArray()[i];
} else {
value = invokedField;
}
} else {
value = object;
}
Map<String, String> map = objectMapper.convertValue(value, Map.class);
result.add(new HashMap<>());
result.get(result.size() - 1).put("name", map.get(configSingle.getName()));
result.get(result.size() - 1).put("value", map.get(configSingle.getValue()));
}
}
}
return result;
}
public enum FileType {
XML("xml"), JSON("json");
private String name;
FileType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static FileType fromName(String name) {
for (FileType type: FileType.values()) {
if (name.equals(type.getName())) {
return type;
}
}
throw new NoSuchElementException("File Type [" + name + "] is not supported");
}
}
}

View File

@ -126,6 +126,15 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("licenses")
public List<Map<String, String>> getlicenses(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getLicenses().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getLicenses().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getLicenses().getFetchMode();
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
@ -268,6 +277,17 @@ public class RemoteFetcher {
+ "[" + jsonDataPath.getFieldsUrlConfiguration().getName()
+ "," + jsonDataPath.getFieldsUrlConfiguration().getId() + "]"),
new HashMap<>(1, 1));
List<Map<String, String>> fixedResults = results.getResults().stream().map(item -> {
String id = jsonDataPath.getFieldsUrlConfiguration().getId().replace("'", "");
if (! (item.get(id) instanceof String)) {
Object obj = item.get(id);
JSONArray jarr = (JSONArray) obj;
item.put(id, jarr.get(0).toString());
}
return item;
}).collect(Collectors.toList());
results = new Results(fixedResults, new HashMap<>(1, 1));
} else if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
results = new Results(jsonContext.read(jsonDataPath.getPath()
+ "[" + jsonDataPath.getFieldsUrlConfiguration().getPath()
@ -312,7 +332,8 @@ public class RemoteFetcher {
}
results.results = results.results.stream().map(e -> e.entrySet().stream().collect(Collectors.toMap(x -> this.transformKey(jsonDataPath,x.getKey()), Map.Entry::getValue)))
.collect(Collectors.toList());
} else if (con.getHeaderField("Content-Type").contains("xml")) {
}
else if (con.getHeaderField("Content-Type").contains("xml")) {
Class<?> aClass = Class.forName(jsonDataPath.getParseClass());
JAXBContext jaxbContext = JAXBContext.newInstance(aClass);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

View File

@ -0,0 +1,21 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "fetchConfig")
public class Config {
private List<ConfigSingle> configs;
@XmlElementWrapper
@XmlElement(name = "config")
public List<ConfigSingle> getConfigs() {
return configs;
}
public void setConfigs(List<ConfigSingle> configs) {
this.configs = configs;
}
}

View File

@ -0,0 +1,71 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "config")
public class ConfigSingle {
private String type;
private String fileType;
private String filePath;
private String parseClass;
private String parseField;
private String name;
private String value;
@XmlElement(name = "type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@XmlElement(name = "fileType")
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
@XmlElement(name = "filePath")
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@XmlElement(name = "parseClass")
public String getParseClass() {
return parseClass;
}
public void setParseClass(String parseClass) {
this.parseClass = parseClass;
}
@XmlElement(name = "parseField")
public String getParseField() {
return parseField;
}
public void setParseField(String parseField) {
this.parseField = parseField;
}
@XmlElement(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "value")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,21 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "ISO_4217")
public class CurrencyModel {
private List<CurrencySingleModel> currencies;
@XmlElementWrapper(name = "CcyTbl")
@XmlElement(name = "CcyNtry")
public List<CurrencySingleModel> getCurrencies() {
return currencies;
}
public void setCurrencies(List<CurrencySingleModel> currencies) {
this.currencies = currencies;
}
}

View File

@ -0,0 +1,53 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "CcyNtry")
public class CurrencySingleModel {
private String country;
private String currency;
private String code;
private Integer numericCode;
private Integer unit;
@XmlElement(name = "CtryNm")
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@XmlElement(name = "CcyNm")
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
@XmlElement(name = "Ccy")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@XmlElement(name = "CcyNbr")
public Integer getNumericCode() {
return numericCode;
}
public void setNumericCode(Integer numericCode) {
this.numericCode = numericCode;
}
@XmlElement(name = "CcyMnrUnts")
public Integer getUnit() {
return unit;
}
public void setUnit(Integer unit) {
this.unit = unit;
}
}

View File

@ -1,41 +0,0 @@
package eu.eudat.logic.services.helpers;
import eu.eudat.core.logger.Logger;
import eu.eudat.types.WarningLevel;
import eu.eudat.logic.utilities.interfaces.Applier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* Created by ikalyvas on 3/1/2018.
*/
//@Service("loggerService")
public class LoggerServiceImpl implements LoggerService {
private Logger logger;
private WarningLevel level;
private Map<WarningLevel, Applier<Logger, String>> options = new HashMap<>();
public void setLevel(WarningLevel level) {
this.level = level;
}
// @Autowired
public LoggerServiceImpl(Logger logger) {
this.logger = logger;
this.options.put(WarningLevel.DEBUG, (log, message) -> log.debug(message));
this.options.put(WarningLevel.INFO, (log, message) -> log.info(message));
this.options.put(WarningLevel.WARN, (log, message) -> log.warn(message));
this.options.put(WarningLevel.ERROR, (log, message) -> log.error(message));
}
public void log(String message) {
this.options.get(this.level).apply(logger, message);
}
public void log(String message, WarningLevel level) {
this.options.get(level).apply(logger, message);
}
}

View File

@ -56,8 +56,6 @@ public interface DatabaseRepository {
NotificationDao getNotificationDao();
UserAssociationDao getUserAssociationDao();
DoiFunderDao getDoiFunderDao();
<T> void detachEntity(T entity);

View File

@ -37,7 +37,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private FunderDao funderDao;
private LockDao lockDao;
private NotificationDao notificationDao;
private UserAssociationDao userAssociationDao;
private DoiFunderDao doiFunderDao;
private EntityManager entityManager;
@ -292,11 +291,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return notificationDao;
}
@Override
public UserAssociationDao getUserAssociationDao() {
return userAssociationDao;
}
@Override
public DoiFunderDao getDoiFunderDao() {
return doiFunderDao;
@ -307,11 +301,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.doiFunderDao = doiFunderDao;
}
@Autowired
public void setUserAssociationDao(UserAssociationDao userAssociationDao) {
this.userAssociationDao = userAssociationDao;
}
@Autowired
public void setNotificationDao(NotificationDao notificationDao) {
this.notificationDao = notificationDao;

View File

@ -1,24 +1,19 @@
package eu.eudat.logic.services.utilities;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.InvitationDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Invitation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.models.data.mail.SimpleMail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import types.LoggingType;
import javax.mail.MessagingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -27,12 +22,10 @@ import java.util.stream.Collectors;
@Service("invitationService")
public class InvitationServiceImpl implements InvitationService {
private static final Logger logger = LoggerFactory.getLogger(InvitationServiceImpl.class);
// private Logger logger;
private Environment environment;
@Autowired
public InvitationServiceImpl(/*Logger logger,*/ Environment environment) {
// this.logger = logger;
public InvitationServiceImpl(Environment environment) {
this.environment = environment;
}

View File

@ -85,6 +85,15 @@ public class ModelBuilder {
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
if (type.equals("externalDatasets")) return (FieldData<U>) new ExternalDatasetsData().fromData(data);
if (type.equals("dataRepositories")) return (FieldData<U>) new DataRepositoriesData().fromData(data);
if (type.equals("registries")) return (FieldData<U>) new RegistriesData().fromData(data);
if (type.equals("services")) return (FieldData<U>) new ServicesData().fromData(data);
if (type.equals("tags")) return (FieldData<U>) new TagsData().fromData(data);
if (type.equals("researchers")) return (FieldData<U>) new ResearcherData().fromData(data);
if (type.equals("organizations")) return (FieldData<U>) new OrganizationsData().fromData(data);
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
return null;
}
@ -114,6 +123,15 @@ public class ModelBuilder {
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
if (type.equals("externalDatasets")) return (FieldData<U>) new ExternalDatasetsData().fromData(data);
if (type.equals("dataRepositories")) return (FieldData<U>) new DataRepositoriesData().fromData(data);
if (type.equals("registries")) return (FieldData<U>) new RegistriesData().fromData(data);
if (type.equals("services")) return (FieldData<U>) new ServicesData().fromData(data);
if (type.equals("tags")) return (FieldData<U>) new TagsData().fromData(data);
if (type.equals("researchers")) return (FieldData<U>) new ResearcherData().fromData(data);
if (type.equals("organizations")) return (FieldData<U>) new OrganizationsData().fromData(data);
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
return null;
}
}

View File

@ -217,13 +217,19 @@ public class ExportXmlBuilderDatasetProfile {
AutoCompleteData autoCompleteDataObject = (AutoCompleteData) field.getData();
dataOut.setAttribute("label", autoCompleteDataObject.getLabel());
dataOut.setAttribute("type", autoCompleteDataObject.getType());
dataOut.setAttribute("optionsRoot", autoCompleteDataObject.getOptionsRoot());
dataOut.setAttribute("url", autoCompleteDataObject.getUrl());
if (autoCompleteDataObject.getAutoCompleteOptions() != null) {
Element optionChild = element.createElement("option");
optionChild.setAttribute("label", autoCompleteDataObject.getAutoCompleteOptions().getLabel());
optionChild.setAttribute("value", autoCompleteDataObject.getAutoCompleteOptions().getValue());
dataOut.appendChild(optionChild);
dataOut.setAttribute("multiAutoComplete", autoCompleteDataObject.getMultiAutoComplete().toString());
for (AutoCompleteData.AutoCompleteSingleData singleData: autoCompleteDataObject.getAutoCompleteSingleDataList()) {
Element singleItem = element.createElement("autocompleteSingle");
singleItem.setAttribute("optionsRoot", singleData.getOptionsRoot());
singleItem.setAttribute("url", singleData.getUrl());
singleItem.setAttribute("autoCompleteType", Integer.toString(singleData.getAutocompleteType()));
if (singleData.getAutoCompleteOptions() != null) {
Element optionChild = element.createElement("option");
optionChild.setAttribute("label", singleData.getAutoCompleteOptions().getLabel());
optionChild.setAttribute("value", singleData.getAutoCompleteOptions().getValue());
singleItem.appendChild(optionChild);
}
dataOut.appendChild(singleItem);
}
}
} else if (field.getViewStyle().getRenderStyle().equals("booleanDecision")) {

View File

@ -10,6 +10,10 @@ import java.util.List;
public class JsonSearcher {
public static List<JsonNode> findNodes(JsonNode root, String key, String value) {
return findNodes(root, key, value, false);
}
public static List<JsonNode> findNodes(JsonNode root, String key, String value, boolean parent) {
List<JsonNode> nodes = new ArrayList<>();
for (Iterator<JsonNode> it = root.elements(); it.hasNext(); ) {
JsonNode node = it.next();
@ -18,14 +22,18 @@ public class JsonSearcher {
String fieldName = iter.next();
if (fieldName.equals(key)) {
if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) {
nodes.add(node);
if (parent) {
nodes.add(root);
} else {
nodes.add(node);
}
found++;
}
}
}
if (found == 0) {
nodes.addAll(findNodes(node, key, value));
nodes.addAll(findNodes(node, key, value, parent));
}
}
return nodes;

View File

@ -0,0 +1,41 @@
package eu.eudat.models.data.ContactEmail;
public class PublicContactEmailModel {
private String fullName;
private String email;
private String affiliation;
private String message;
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAffiliation() {
return affiliation;
}
public void setAffiliation(String affiliation) {
this.affiliation = affiliation;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -15,6 +15,7 @@ public class DatasetProfile {
private List<Section> sections;
private Short status;
private Short version;
private String language;
public String getLabel() {
@ -53,6 +54,13 @@ public class DatasetProfile {
public Short getVersion() { return version; }
public void setVersion(Short version) { this.version = version; }
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
@ -71,6 +79,7 @@ public class DatasetProfile {
shortProfile.setPages(this.pages);
shortProfile.setStatus(this.status);
shortProfile.setVersion(this.version);
shortProfile.setLanguage(this.language);
return shortProfile;
}
}

View File

@ -2,87 +2,156 @@ package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
private String url;
private Option autoCompleteOptions;
private String optionsRoot;
public class AutoCompleteSingleData {
private int autocompleteType;
private String url;
private Option autoCompleteOptions;
private String optionsRoot;
public int getAutocompleteType() {
return autocompleteType;
}
public void setAutocompleteType(int autocompleteType) {
this.autocompleteType = autocompleteType;
}
public String getOptionsRoot() {
return optionsRoot;
}
public void setOptionsRoot(String optionsRoot) {
this.optionsRoot = optionsRoot;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Option getAutoCompleteOptions() {
return autoCompleteOptions;
}
public void setAutoCompleteOptions(Option autoCompleteOptions) {
this.autoCompleteOptions = autoCompleteOptions;
}
}
private Boolean multiAutoComplete;
public String getOptionsRoot() {
return optionsRoot;
}
public void setOptionsRoot(String optionsRoot) {
this.optionsRoot = optionsRoot;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Option getAutoCompleteOptions() {
return autoCompleteOptions;
}
public void setAutoCompleteOptions(Option autoCompleteOptions) {
this.autoCompleteOptions = autoCompleteOptions;
}
private List<AutoCompleteSingleData> autoCompleteSingleDataList;
public Boolean getMultiAutoComplete() { return multiAutoComplete; }
public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; }
public List<AutoCompleteSingleData> getAutoCompleteSingleDataList() {
return autoCompleteSingleDataList;
}
public void setAutoCompleteSingleDataList(List<AutoCompleteSingleData> autoCompleteSingleDataList) {
this.autoCompleteSingleDataList = autoCompleteSingleDataList;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("url", this.url);
root.setAttribute("optionsRoot", this.optionsRoot);
if (this.multiAutoComplete != null)
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
Element element = doc.createElement("option");
element.setAttribute("label", this.autoCompleteOptions.getLabel());
element.setAttribute("value", autoCompleteOptions.getValue());
element.setAttribute("source", autoCompleteOptions.getSource());
root.appendChild(element);
for (AutoCompleteSingleData singleData: this.autoCompleteSingleDataList) {
Element parent = doc.createElement("autocompleteSingle");
parent.setAttribute("url", singleData.url);
parent.setAttribute("optionsRoot", singleData.optionsRoot);
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType));
Element element = doc.createElement("option");
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
parent.appendChild(element);
root.appendChild(parent);
}
return root;
}
@Override
public AutoCompleteData fromXml(Element item) {
super.fromXml(item);
this.url = item.getAttribute("url");
this.optionsRoot = item.getAttribute("optionsRoot");
this.autoCompleteSingleDataList = new ArrayList<>();
NodeList items = item.getElementsByTagName("autocompleteSingle");
if (items != null && items.getLength() > 0) {
for (int i = 0; i < items.getLength(); i++) {
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
Element single = (Element) items.item(i);
this.mapFromXml(single, this.autoCompleteSingleDataList.get(i));
}
} else {
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
this.mapFromXml(item, this.autoCompleteSingleDataList.get(0));
}
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
private void mapFromXml(Element item, AutoCompleteSingleData singleData) {
singleData.url = item.getAttribute("url");
singleData.optionsRoot = item.getAttribute("optionsRoot");
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
if (item.getAttribute("autoCompleteType") == null || item.getAttribute("autoCompleteType").equals("") ) {
singleData.autocompleteType = AutocompleteType.UNCACHED.getValue();
} else {
singleData.autocompleteType = AutocompleteType.fromValue(Integer.parseInt(item.getAttribute("autoCompleteType"))).getValue();
}
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
if (optionElement != null) {
this.autoCompleteOptions = new Option();
this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
this.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
this.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
singleData.autoCompleteOptions = new Option();
singleData.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
singleData.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
}
return this;
}
@Override
public AutoCompleteData fromData(Object data) {
super.fromData(data);
this.autoCompleteOptions = new Option();
this.autoCompleteSingleDataList = new ArrayList<>();
if (data != null) {
this.url = (String) ((Map<String, Object>) data).get("url");
this.optionsRoot = (String) ((Map<String, Object>) data).get("optionsRoot");
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
Map<String, String> options = ((Map<String, Map<String, String>>) data).get("autoCompleteOptions");
if (options != null) {
this.autoCompleteOptions.setLabel(options.get("label"));
this.autoCompleteOptions.setValue(options.get("value"));
this.autoCompleteOptions.setSource(options.get("source"));
this.autoCompleteOptions.setUri(options.get("uri"));
List<Map<String, Object>> dataList = (List<Map<String, Object>>) ((Map<String, Object>) data).get("autocompleteSingle");
this.autoCompleteSingleDataList = new ArrayList<>();
int i = 0;
for (Map<String, Object> singleData: dataList) {
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
if (singleData.get("autoCompleteType") == null) {
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED.getValue();
} else {
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.fromValue((Integer) singleData.get("autoCompleteType")).getValue();
}
Map<String, String> options = (Map<String, String>) singleData.get("autoCompleteOptions");
if (options != null) {
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setLabel(options.get("label"));
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setValue(options.get("value"));
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
}
i++;
}
}
@ -99,16 +168,36 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
dataMap.put("url", item != null ? item.getAttribute("url") : "");
//dataMap.put("url", item != null ? item.getAttribute("url") : "");
dataMap.put("type", item != null ? item.getAttribute("type") : "autocomplete");
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
dataMap.put("multiAutoComplete", item != null ? Boolean.valueOf(item.getAttribute("multiAutoComplete")) : false);
List<Map<String, Object>> autoCompletes = new ArrayList<>();
NodeList autoCompleteSingles = item.getChildNodes();
for (int i = 0; i < autoCompleteSingles.getLength(); i++) {
if (autoCompleteSingles.item(i) instanceof Element && !((Element) autoCompleteSingles.item(i)).getTagName().equals("option")) {
Element node = (Element) autoCompleteSingles.item(i);
if (!node.hasChildNodes()) {
node.appendChild(node);
}
autoCompletes.add(singleToMap(node));
} else if (((Element) autoCompleteSingles.item(i)).getTagName().equals("option")) {
Element node = item.getOwnerDocument().createElement("autocompleteSingle");
node.appendChild(autoCompleteSingles.item(i));
node.setAttribute("url", item.getAttribute("url"));
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
autoCompletes.add(singleToMap(node));
}
}
dataMap.put("autocompleteSingle", autoCompletes);
//dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
//Element optionElement = (Element) item.getElementsByTagName("option").item(0);
// if (optionElement != null) {
// this.autoCompleteOptions = new Option();
// this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
// this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
// }
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
// dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
return dataMap;
}
@ -119,4 +208,41 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
dataMap.put("source", item != null ? item.getAttribute("source") : "");
return dataMap;
}
private Map<String, Object> singleToMap(Element item) {
Map<String, Object> dataMap = new HashMap<>();
if (!item.getAttribute("autoCompleteType").isEmpty()) {
dataMap.put("autoCompleteType", Integer.parseInt(item.getAttribute("autoCompleteType")));
}
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
dataMap.put("url", item != null ? item.getAttribute("url") : "");
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
return dataMap;
}
public enum AutocompleteType {
UNCACHED(0), CACHED(1);
int value;
AutocompleteType(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
public static AutocompleteType fromValue(int value) {
for (AutocompleteType type: AutocompleteType.values()) {
if (type.getValue() == value) {
return type;
}
}
return UNCACHED;
}
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class CurrencyData extends FieldData<CurrencyData> {
@Override
public CurrencyData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public CurrencyData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DataRepositoriesData extends FieldData<DataRepositoriesData> {
@Override
public DataRepositoriesData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public DataRepositoriesData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DatasetIdentifierData extends FieldData<DatasetIdentifierData> {
@Override
public DatasetIdentifierData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public DatasetIdentifierData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ExternalDatasetsData extends FieldData<ExternalDatasetsData> {
@Override
public ExternalDatasetsData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public ExternalDatasetsData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class OrganizationsData extends FieldData<OrganizationsData> {
@Override
public OrganizationsData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public OrganizationsData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class RegistriesData extends FieldData<RegistriesData> {
@Override
public RegistriesData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public RegistriesData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ResearcherData extends FieldData<ResearcherData> {
@Override
public ResearcherData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public ResearcherData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ServicesData extends FieldData<ServicesData> {
@Override
public ServicesData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public ServicesData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class TagsData extends FieldData<TagsData> {
@Override
public TagsData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public TagsData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -43,6 +43,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
private Project project;
private Funder funder;
private Boolean isPublic;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
@ -220,6 +221,14 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
isPublic = aPublic;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlan fromDataModel(DMP entity) {
this.id = entity.getId();
@ -280,6 +289,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
}
this.isPublic = entity.isPublic();
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}
@ -321,6 +332,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
if (this.isPublic != null) {
dataManagementPlanEntity.setPublic(this.isPublic);
}
dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
return dataManagementPlanEntity;
}
@ -328,7 +341,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.id = entity.getId();
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.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.version = entity.getVersion();
this.label = entity.getLabel();
this.grant = new Grant();
@ -372,6 +385,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
}
this.isPublic = entity.isPublic();
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}

View File

@ -42,6 +42,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
private List<UUID> datasetsToBeFinalized;
private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
@ -211,6 +212,14 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.funder = funder;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
this.id = entity.getId();
@ -255,6 +264,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
this.funder = new FunderDMPEditorModel();
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}
@ -360,6 +370,8 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
if (this.dynamicFields != null)
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
return dataManagementPlanEntity;
}

View File

@ -7,6 +7,7 @@ import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.project.ProjectDMPEditorModel;
import eu.eudat.models.data.userinfo.UserInfo;
import net.minidev.json.JSONObject;
import java.util.*;
import java.util.stream.Collectors;
@ -31,6 +32,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
private List<Dataset> datasets;
private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
@ -144,6 +146,14 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
this.funder = funder;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlanNewVersionModel fromDataModel(DMP entity) {
return null;
@ -244,6 +254,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
}
}
entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
if (this.profiles != null)
entity.setAssociatedDmps(this.profiles.stream().map(x -> x.toData()).collect(Collectors.toSet()));
return entity;

View File

@ -1,5 +1,6 @@
package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.eudat.models.DataModel;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import org.slf4j.Logger;
@ -8,6 +9,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.UUID;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Researcher implements DataModel<eu.eudat.data.entities.Researcher, Researcher>, LabelGenerator {
private static final Logger logger = LoggerFactory.getLogger(Researcher.class);
private String label;

View File

@ -0,0 +1,19 @@
package eu.eudat.models.data.external;
import java.util.List;
import java.util.Map;
public class LicensesExternalSourcesModel extends ExternalListingItem<LicensesExternalSourcesModel> {
@Override
public LicensesExternalSourcesModel fromExternalItem(List<Map<String, String>> values) {
for (Map<String, String> item : values) {
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("id"));
model.setUri(item.get("uri"));
model.setName(item.get("name"));
this.add(model);
}
return this;
}
}

View File

@ -0,0 +1,127 @@
package eu.eudat.models.data.license;
import eu.eudat.data.entities.DataRepository;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.models.DataModel;
import java.util.Date;
import java.util.UUID;
public class LicenseModel implements DataModel<DataRepository, LicenseModel> {
private UUID id;
private String name;
private String pid;
private String abbreviation;
private String uri;
private Date created;
private Date modified;
private String tag; // Api fetching the data
private String source; // Actual harvested source
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
@Override
public LicenseModel fromDataModel(DataRepository entity) {
this.setAbbreviation(entity.getAbbreviation());
this.setName(entity.getLabel());
this.setUri(entity.getUri());
this.setId(entity.getId());
this.setPid(entity.getReference());
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
if (source1.equals("dmp")) {
this.source = "Internal";
} else {
this.source = source1;
}
return this;
}
@Override
public DataRepository toDataModel() throws Exception {
DataRepository dataRepository = new DataRepository();
dataRepository.setId(this.id != null ? this.id : UUID.randomUUID());
dataRepository.setAbbreviation(this.abbreviation);
dataRepository.setCreated(this.created != null ? this.created : new Date());
dataRepository.setModified(new Date());
dataRepository.setLabel(this.name);
if (this.source != null) {
if (this.source.equals("Internal") || this.source.equals(this.id.toString().substring(0, this.source.length()))) {
dataRepository.setReference(this.id.toString());
} else {
dataRepository.setReference(this.source + ":" + dataRepository.getId());
}
} else {
dataRepository.setReference("dmp:" + dataRepository.getId());
}
dataRepository.setUri(this.uri);
dataRepository.setStatus((short) 0);
dataRepository.setCreationUser(new UserInfo());
return dataRepository;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -0,0 +1,27 @@
package eu.eudat.models.data.local;
public class LocalFetchModel {
private String name;
private String value;
public LocalFetchModel(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -6,10 +6,7 @@ import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserListingModel;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.*;
public class DmpQuickWizardModel {
@ -19,6 +16,7 @@ public class DmpQuickWizardModel {
private AssociatedProfile datasetProfile;
private String description;
private eu.eudat.models.data.grant.Grant grant;
private String language;
public UUID getId() {
@ -65,6 +63,14 @@ public class DmpQuickWizardModel {
this.grant = grant;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Grant grant, Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
@ -93,6 +99,8 @@ public class DmpQuickWizardModel {
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
userInfo.setId(principal.getId());
dataManagementPlanEntity.setAssociatedUsers(user);
dataManagementPlanEntity.setExtraProperties(new HashMap<>());
dataManagementPlanEntity.getExtraProperties().put("language", this.language);
return dataManagementPlanEntity;
}

View File

@ -1,5 +1,7 @@
package eu.eudat.models.data.user.components.datasetprofile;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.models.data.components.commons.DefaultValue;
import eu.eudat.models.data.components.commons.Multiplicity;
import eu.eudat.models.data.components.commons.ViewStyle;
@ -11,6 +13,9 @@ 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.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
@ -18,6 +23,7 @@ import java.util.Map;
import java.util.stream.Collectors;
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
private static final Logger logger = LoggerFactory.getLogger(Field.class);
private String id;
private Integer ordinal;
private Object value;
@ -224,7 +230,18 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
@Override
public void toMap(Map<String, Object> fieldValues) {
if (this.value != null) {
fieldValues.put(this.id, this.value.toString());
if (this.viewStyle != null && this.viewStyle.getRenderStyle().equals("datasetIdentifier")) {
ObjectMapper mapper = new ObjectMapper();
String valueString = null;
try {
valueString = mapper.writeValueAsString(this.value);
fieldValues.put(this.id, valueString);
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
} else {
fieldValues.put(this.id, this.value.toString());
}
} else {
fieldValues.put(this.id, "");
}

View File

@ -5,7 +5,6 @@ import eu.eudat.models.data.properties.PropertiesGenerator;
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import sun.rmi.runtime.NewThreadAction;
import java.security.Key;
import java.util.*;

View File

@ -107,7 +107,7 @@ public class Dataset implements Serializable
*/
@JsonProperty("language")
@JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.")
private Dataset.Language language;
private Language language;
/**
* The Dataset Metadata Schema
* <p>
@ -328,7 +328,7 @@ public class Dataset implements Serializable
*
*/
@JsonProperty("language")
public Dataset.Language getLanguage() {
public Language getLanguage() {
return language;
}
@ -339,7 +339,7 @@ public class Dataset implements Serializable
*
*/
@JsonProperty("language")
public void setLanguage(Dataset.Language language) {
public void setLanguage(Language language) {
this.language = language;
}
@ -535,228 +535,6 @@ public class Dataset implements Serializable
this.additionalProperties.put(name, value);
}
public enum Language {
AAR("aar"),
ABK("abk"),
AFR("afr"),
AKA("aka"),
AMH("amh"),
ARA("ara"),
ARG("arg"),
ASM("asm"),
AVA("ava"),
AVE("ave"),
AYM("aym"),
AZE("aze"),
BAK("bak"),
BAM("bam"),
BEL("bel"),
BEN("ben"),
BIH("bih"),
BIS("bis"),
BOD("bod"),
BOS("bos"),
BRE("bre"),
BUL("bul"),
CAT("cat"),
CES("ces"),
CHA("cha"),
CHE("che"),
CHU("chu"),
CHV("chv"),
COR("cor"),
COS("cos"),
CRE("cre"),
CYM("cym"),
DAN("dan"),
DEU("deu"),
DIV("div"),
DZO("dzo"),
ELL("ell"),
ENG("eng"),
EPO("epo"),
EST("est"),
EUS("eus"),
EWE("ewe"),
FAO("fao"),
FAS("fas"),
FIJ("fij"),
FIN("fin"),
FRA("fra"),
FRY("fry"),
FUL("ful"),
GLA("gla"),
GLE("gle"),
GLG("glg"),
GLV("glv"),
GRN("grn"),
GUJ("guj"),
HAT("hat"),
HAU("hau"),
HBS("hbs"),
HEB("heb"),
HER("her"),
HIN("hin"),
HMO("hmo"),
HRV("hrv"),
HUN("hun"),
HYE("hye"),
IBO("ibo"),
IDO("ido"),
III("iii"),
IKU("iku"),
ILE("ile"),
INA("ina"),
IND("ind"),
IPK("ipk"),
ISL("isl"),
ITA("ita"),
JAV("jav"),
JPN("jpn"),
KAL("kal"),
KAN("kan"),
KAS("kas"),
KAT("kat"),
KAU("kau"),
KAZ("kaz"),
KHM("khm"),
KIK("kik"),
KIN("kin"),
KIR("kir"),
KOM("kom"),
KON("kon"),
KOR("kor"),
KUA("kua"),
KUR("kur"),
LAO("lao"),
LAT("lat"),
LAV("lav"),
LIM("lim"),
LIN("lin"),
LIT("lit"),
LTZ("ltz"),
LUB("lub"),
LUG("lug"),
MAH("mah"),
MAL("mal"),
MAR("mar"),
MKD("mkd"),
MLG("mlg"),
MLT("mlt"),
MON("mon"),
MRI("mri"),
MSA("msa"),
MYA("mya"),
NAU("nau"),
NAV("nav"),
NBL("nbl"),
NDE("nde"),
NDO("ndo"),
NEP("nep"),
NLD("nld"),
NNO("nno"),
NOB("nob"),
NOR("nor"),
NYA("nya"),
OCI("oci"),
OJI("oji"),
ORI("ori"),
ORM("orm"),
OSS("oss"),
PAN("pan"),
PLI("pli"),
POL("pol"),
POR("por"),
PUS("pus"),
QUE("que"),
ROH("roh"),
RON("ron"),
RUN("run"),
RUS("rus"),
SAG("sag"),
SAN("san"),
SIN("sin"),
SLK("slk"),
SLV("slv"),
SME("sme"),
SMO("smo"),
SNA("sna"),
SND("snd"),
SOM("som"),
SOT("sot"),
SPA("spa"),
SQI("sqi"),
SRD("srd"),
SRP("srp"),
SSW("ssw"),
SUN("sun"),
SWA("swa"),
SWE("swe"),
TAH("tah"),
TAM("tam"),
TAT("tat"),
TEL("tel"),
TGK("tgk"),
TGL("tgl"),
THA("tha"),
TIR("tir"),
TON("ton"),
TSN("tsn"),
TSO("tso"),
TUK("tuk"),
TUR("tur"),
TWI("twi"),
UIG("uig"),
UKR("ukr"),
URD("urd"),
UZB("uzb"),
VEN("ven"),
VIE("vie"),
VOL("vol"),
WLN("wln"),
WOL("wol"),
XHO("xho"),
YID("yid"),
YOR("yor"),
ZHA("zha"),
ZHO("zho"),
ZUL("zul");
private final String value;
private final static Map<String, Dataset.Language> CONSTANTS = new HashMap<String, Dataset.Language>();
static {
for (Dataset.Language c: values()) {
CONSTANTS.put(c.value, c);
}
}
private Language(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
@JsonValue
public String value() {
return this.value;
}
@JsonCreator
public static Dataset.Language fromValue(String value) {
Dataset.Language constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
} else {
return constant;
}
}
}
public enum PersonalData {
YES("yes"),

View File

@ -7,15 +7,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.*;
/**
@ -24,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
*
*
*/
@JsonIgnoreProperties(value = { "schema" })
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"contact",
@ -144,7 +138,7 @@ public class Dmp implements Serializable
*/
@JsonProperty("language")
@JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.")
private Dmp.Language language;
private Language language;
/**
* The DMP Modification Schema
* <p>
@ -414,7 +408,7 @@ public class Dmp implements Serializable
*
*/
@JsonProperty("language")
public Dmp.Language getLanguage() {
public Language getLanguage() {
return language;
}
@ -426,7 +420,7 @@ public class Dmp implements Serializable
*
*/
@JsonProperty("language")
public void setLanguage(Dmp.Language language) {
public void setLanguage(Language language) {
this.language = language;
}
@ -550,226 +544,4 @@ public class Dmp implements Serializable
}
public enum Language {
AAR("aar"),
ABK("abk"),
AFR("afr"),
AKA("aka"),
AMH("amh"),
ARA("ara"),
ARG("arg"),
ASM("asm"),
AVA("ava"),
AVE("ave"),
AYM("aym"),
AZE("aze"),
BAK("bak"),
BAM("bam"),
BEL("bel"),
BEN("ben"),
BIH("bih"),
BIS("bis"),
BOD("bod"),
BOS("bos"),
BRE("bre"),
BUL("bul"),
CAT("cat"),
CES("ces"),
CHA("cha"),
CHE("che"),
CHU("chu"),
CHV("chv"),
COR("cor"),
COS("cos"),
CRE("cre"),
CYM("cym"),
DAN("dan"),
DEU("deu"),
DIV("div"),
DZO("dzo"),
ELL("ell"),
ENG("eng"),
EPO("epo"),
EST("est"),
EUS("eus"),
EWE("ewe"),
FAO("fao"),
FAS("fas"),
FIJ("fij"),
FIN("fin"),
FRA("fra"),
FRY("fry"),
FUL("ful"),
GLA("gla"),
GLE("gle"),
GLG("glg"),
GLV("glv"),
GRN("grn"),
GUJ("guj"),
HAT("hat"),
HAU("hau"),
HBS("hbs"),
HEB("heb"),
HER("her"),
HIN("hin"),
HMO("hmo"),
HRV("hrv"),
HUN("hun"),
HYE("hye"),
IBO("ibo"),
IDO("ido"),
III("iii"),
IKU("iku"),
ILE("ile"),
INA("ina"),
IND("ind"),
IPK("ipk"),
ISL("isl"),
ITA("ita"),
JAV("jav"),
JPN("jpn"),
KAL("kal"),
KAN("kan"),
KAS("kas"),
KAT("kat"),
KAU("kau"),
KAZ("kaz"),
KHM("khm"),
KIK("kik"),
KIN("kin"),
KIR("kir"),
KOM("kom"),
KON("kon"),
KOR("kor"),
KUA("kua"),
KUR("kur"),
LAO("lao"),
LAT("lat"),
LAV("lav"),
LIM("lim"),
LIN("lin"),
LIT("lit"),
LTZ("ltz"),
LUB("lub"),
LUG("lug"),
MAH("mah"),
MAL("mal"),
MAR("mar"),
MKD("mkd"),
MLG("mlg"),
MLT("mlt"),
MON("mon"),
MRI("mri"),
MSA("msa"),
MYA("mya"),
NAU("nau"),
NAV("nav"),
NBL("nbl"),
NDE("nde"),
NDO("ndo"),
NEP("nep"),
NLD("nld"),
NNO("nno"),
NOB("nob"),
NOR("nor"),
NYA("nya"),
OCI("oci"),
OJI("oji"),
ORI("ori"),
ORM("orm"),
OSS("oss"),
PAN("pan"),
PLI("pli"),
POL("pol"),
POR("por"),
PUS("pus"),
QUE("que"),
ROH("roh"),
RON("ron"),
RUN("run"),
RUS("rus"),
SAG("sag"),
SAN("san"),
SIN("sin"),
SLK("slk"),
SLV("slv"),
SME("sme"),
SMO("smo"),
SNA("sna"),
SND("snd"),
SOM("som"),
SOT("sot"),
SPA("spa"),
SQI("sqi"),
SRD("srd"),
SRP("srp"),
SSW("ssw"),
SUN("sun"),
SWA("swa"),
SWE("swe"),
TAH("tah"),
TAM("tam"),
TAT("tat"),
TEL("tel"),
TGK("tgk"),
TGL("tgl"),
THA("tha"),
TIR("tir"),
TON("ton"),
TSN("tsn"),
TSO("tso"),
TUK("tuk"),
TUR("tur"),
TWI("twi"),
UIG("uig"),
UKR("ukr"),
URD("urd"),
UZB("uzb"),
VEN("ven"),
VIE("vie"),
VOL("vol"),
WLN("wln"),
WOL("wol"),
XHO("xho"),
YID("yid"),
YOR("yor"),
ZHA("zha"),
ZHO("zho"),
ZUL("zul");
private final String value;
private final static Map<String, Dmp.Language> CONSTANTS = new HashMap<String, Dmp.Language>();
static {
for (Dmp.Language c: values()) {
CONSTANTS.put(c.value, c);
}
}
private Language(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
@JsonValue
public String value() {
return this.value;
}
@JsonCreator
public static Dmp.Language fromValue(String value) {
Dmp.Language constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
} else {
return constant;
}
}
}
}

View File

@ -0,0 +1,229 @@
package eu.eudat.models.rda;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
public enum Language {
AAR("aar"),
ABK("abk"),
AFR("afr"),
AKA("aka"),
AMH("amh"),
ARA("ara"),
ARG("arg"),
ASM("asm"),
AVA("ava"),
AVE("ave"),
AYM("aym"),
AZE("aze"),
BAK("bak"),
BAM("bam"),
BEL("bel"),
BEN("ben"),
BIH("bih"),
BIS("bis"),
BOD("bod"),
BOS("bos"),
BRE("bre"),
BUL("bul"),
CAT("cat"),
CES("ces"),
CHA("cha"),
CHE("che"),
CHU("chu"),
CHV("chv"),
COR("cor"),
COS("cos"),
CRE("cre"),
CYM("cym"),
DAN("dan"),
DEU("deu"),
DIV("div"),
DZO("dzo"),
ELL("ell"),
ENG("eng"),
EPO("epo"),
EST("est"),
EUS("eus"),
EWE("ewe"),
FAO("fao"),
FAS("fas"),
FIJ("fij"),
FIN("fin"),
FRA("fra"),
FRY("fry"),
FUL("ful"),
GLA("gla"),
GLE("gle"),
GLG("glg"),
GLV("glv"),
GRN("grn"),
GUJ("guj"),
HAT("hat"),
HAU("hau"),
HBS("hbs"),
HEB("heb"),
HER("her"),
HIN("hin"),
HMO("hmo"),
HRV("hrv"),
HUN("hun"),
HYE("hye"),
IBO("ibo"),
IDO("ido"),
III("iii"),
IKU("iku"),
ILE("ile"),
INA("ina"),
IND("ind"),
IPK("ipk"),
ISL("isl"),
ITA("ita"),
JAV("jav"),
JPN("jpn"),
KAL("kal"),
KAN("kan"),
KAS("kas"),
KAT("kat"),
KAU("kau"),
KAZ("kaz"),
KHM("khm"),
KIK("kik"),
KIN("kin"),
KIR("kir"),
KOM("kom"),
KON("kon"),
KOR("kor"),
KUA("kua"),
KUR("kur"),
LAO("lao"),
LAT("lat"),
LAV("lav"),
LIM("lim"),
LIN("lin"),
LIT("lit"),
LTZ("ltz"),
LUB("lub"),
LUG("lug"),
MAH("mah"),
MAL("mal"),
MAR("mar"),
MKD("mkd"),
MLG("mlg"),
MLT("mlt"),
MON("mon"),
MRI("mri"),
MSA("msa"),
MYA("mya"),
NAU("nau"),
NAV("nav"),
NBL("nbl"),
NDE("nde"),
NDO("ndo"),
NEP("nep"),
NLD("nld"),
NNO("nno"),
NOB("nob"),
NOR("nor"),
NYA("nya"),
OCI("oci"),
OJI("oji"),
ORI("ori"),
ORM("orm"),
OSS("oss"),
PAN("pan"),
PLI("pli"),
POL("pol"),
POR("por"),
PUS("pus"),
QUE("que"),
ROH("roh"),
RON("ron"),
RUN("run"),
RUS("rus"),
SAG("sag"),
SAN("san"),
SIN("sin"),
SLK("slk"),
SLV("slv"),
SME("sme"),
SMO("smo"),
SNA("sna"),
SND("snd"),
SOM("som"),
SOT("sot"),
SPA("spa"),
SQI("sqi"),
SRD("srd"),
SRP("srp"),
SSW("ssw"),
SUN("sun"),
SWA("swa"),
SWE("swe"),
TAH("tah"),
TAM("tam"),
TAT("tat"),
TEL("tel"),
TGK("tgk"),
TGL("tgl"),
THA("tha"),
TIR("tir"),
TON("ton"),
TSN("tsn"),
TSO("tso"),
TUK("tuk"),
TUR("tur"),
TWI("twi"),
UIG("uig"),
UKR("ukr"),
URD("urd"),
UZB("uzb"),
VEN("ven"),
VIE("vie"),
VOL("vol"),
WLN("wln"),
WOL("wol"),
XHO("xho"),
YID("yid"),
YOR("yor"),
ZHA("zha"),
ZHO("zho"),
ZUL("zul");
private final String value;
private final static Map<String, Language> CONSTANTS = new HashMap<>();
static {
for (Language c: values()) {
CONSTANTS.put(c.value, c);
}
}
private Language(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
@JsonValue
public String value() {
return this.value;
}
@JsonCreator
public static Language fromValue(String value) {
Language constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
} else {
return constant;
}
}
}

View File

@ -1,14 +1,18 @@
package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.Researcher;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.models.rda.Contributor;
import eu.eudat.models.rda.ContributorId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.io.IOException;
import java.util.*;
public class ContributorRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(ContributorRDAMapper.class);
public static Contributor toRDA(UserDMP userDMP) {
Contributor rda = new Contributor();
@ -28,23 +32,38 @@ public class ContributorRDAMapper {
return rda;
}
public static Contributor toRDA(String value) {
ObjectMapper mapper = new ObjectMapper();
try {
eu.eudat.models.data.dmp.Researcher researcher = mapper.readValue(value, eu.eudat.models.data.dmp.Researcher.class);
return toRDA(researcher.toDataModel());
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return null;
}
public static Researcher toEntity(Contributor rda) {
Researcher entity = new Researcher();
String reference;
if (rda.getContributorId().getType() == ContributorId.Type.ORCID) {
String id = rda.getContributorId().getIdentifier().replace("http://orcid.org/", "");
reference = "orcid:" + id;
} else {
String idParts[] = rda.getContributorId().getIdentifier().split(":");
if (idParts.length == 1) {
reference = "dmp:" + rda.getContributorId().getIdentifier();
if (rda.getContributorId() != null) {
if (rda.getContributorId().getType() == ContributorId.Type.ORCID) {
String id = rda.getContributorId().getIdentifier().replace("http://orcid.org/", "");
reference = "orcid:" + id;
} else {
reference = rda.getContributorId().getIdentifier();
String idParts[] = rda.getContributorId().getIdentifier().split(":");
if (idParts.length == 1) {
reference = "dmp:" + rda.getContributorId().getIdentifier();
} else {
reference = rda.getContributorId().getIdentifier();
}
}
entity.setReference(reference);
entity.setLabel(rda.getName());
entity.setPrimaryEmail(rda.getMbox());
} else {
return null;
}
entity.setReference(reference);
entity.setLabel(rda.getName());
entity.setPrimaryEmail(rda.getMbox());
return entity;
}

View File

@ -1,17 +1,108 @@
package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.rda.DatasetId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DatasetIdRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DatasetIdRDAMapper.class);
public static DatasetId toRDA(UUID id) {
/*public static DatasetId toRDA(UUID id) {
DatasetId rda = new DatasetId();
rda.setIdentifier(id.toString());
rda.setType(DatasetId.Type.OTHER);
return rda;
}*/
public static DatasetId toRDA(List<JsonNode> nodes) {
DatasetId data = new DatasetId();
for (JsonNode node: nodes) {
String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText();
ObjectMapper mapper = new ObjectMapper();
try {
Map<String, Object> values = mapper.readValue(rdaValue, HashMap.class);
if (!values.isEmpty()) {
values.entrySet().forEach(entry -> finalRDAMap(data, entry.getKey(), (String) entry.getValue()));
} else {
finalRDAMap(data, rdaProperty, rdaValue);
}
} catch (IOException e) {
finalRDAMap(data, rdaProperty, rdaValue);
logger.error(e.getMessage(), e);
}
}
if (data.getIdentifier() != null && data.getType() != null) {
return data;
}
return null;
}
private static void finalRDAMap(DatasetId rda, String property, String value) {
for (DatasetIdProperties datasetIdProperties : DatasetIdProperties.values()) {
if (property.contains(datasetIdProperties.getName())) {
switch (datasetIdProperties) {
case IDENTIFIER:
rda.setIdentifier(value);
break;
case TYPE:
rda.setType(DatasetId.Type.fromValue(value));
break;
}
}
}
}
public static Map<String, String> toProperties(DatasetId rda, JsonNode node) {
Map<String, String> properties = new HashMap<>();
List<JsonNode> idNodes = JsonSearcher.findNodes(node, "rdaProperty", "dataset.dataset_id");
for (JsonNode idNode: idNodes) {
for (DatasetIdProperties datasetIdProperties : DatasetIdProperties.values()) {
if (idNode.get("rdaProperty").asText().endsWith(datasetIdProperties.getName())) {
switch (datasetIdProperties) {
case IDENTIFIER:
properties.put(idNode.get("id").asText(), rda.getIdentifier());
break;
case TYPE:
properties.put(idNode.get("id").asText(), rda.getType().value());
break;
}
}
}
}
return properties;
}
private enum DatasetIdProperties {
IDENTIFIER("identifier"),
TYPE("type");
private final String name;
DatasetIdProperties(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -3,11 +3,14 @@ package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.rda.Contributor;
import eu.eudat.models.rda.Dataset;
import eu.eudat.models.rda.Language;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -18,6 +21,7 @@ import javax.transaction.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@Component
public class DatasetRDAMapper {
@ -33,9 +37,9 @@ public class DatasetRDAMapper {
}
@Transactional
public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) {
public Dataset toRDA(eu.eudat.data.entities.Dataset dataset, List<Contributor> contributors) {
Dataset rda = new Dataset();
rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
// rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
rda.setTitle(dataset.getLabel());
rda.setDescription(dataset.getDescription());
rda.setAdditionalProperty("template", dataset.getProfile().getId());
@ -47,13 +51,21 @@ public class DatasetRDAMapper {
ObjectMapper mapper = new ObjectMapper();
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson);
List<JsonNode> idNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.dataset_id");
if (!idNodes.isEmpty()) {
rda.setDatasetId(DatasetIdRDAMapper.toRDA(idNodes));
}
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type");
if (!typeNodes.isEmpty()) {
rda.setType(typeNodes.get(0).get("value").asText());
} else {
rda.setType(dataset.getLabel());
}
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language");
if (!languageNodes.isEmpty()) {
rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText()));
rda.setLanguage(Language.fromValue(languageNodes.get(0).get("value").asText()));
} else {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(dataset.getProfile().getLanguage()));
}
List<JsonNode> metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata");
if (!metadataNodes.isEmpty()) {
@ -61,10 +73,11 @@ public class DatasetRDAMapper {
}
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance");
if (!qaNodes.isEmpty()) {
rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList()));
/*rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList()));
for (int i = 0; i < qaNodes.size(); i++) {
rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText());
}
}*/
rda.setDataQualityAssurance(Collections.singletonList(qaNodes.get(0).get("value").asText()));
}
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
if (!preservationNodes.isEmpty()) {
@ -72,18 +85,30 @@ public class DatasetRDAMapper {
}
List<JsonNode> distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution");
if (!distributionNodes.isEmpty()) {
rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes));
rda.setDistribution(Collections.singletonList(DistributionRDAMapper.toRDA(distributionNodes)));
}
List<JsonNode> keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword");
if (!keywordNodes.isEmpty()) {
rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList()));
rda.setKeyword(keywordNodes.stream().map(keywordNode -> {
JsonNode value = keywordNode.get("value");
if (value.isArray()) {
return StreamSupport.stream(value.spliterator(), false).map(node -> KeywordRDAMapper.toRDA(node.asText())).collect(Collectors.toList());
} else {
return Collections.singletonList(KeywordRDAMapper.toRDA(keywordNode.get("value").asText()));
}
}).flatMap(Collection::stream).collect(Collectors.toList()));
for (int i = 0; i < keywordNodes.size(); i++) {
rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText());
}
} else {
List<String> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString()).getTags().stream().map(Tag::getName).collect(Collectors.toList());
rda.setKeyword(tags);
}
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data");
if (!personalDataNodes.isEmpty()) {
rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get());
} else {
rda.setPersonalData(Dataset.PersonalData.UNKNOWN);
}
List<JsonNode> securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy");
if (!securityAndPrivacyNodes.isEmpty()) {
@ -97,6 +122,21 @@ public class DatasetRDAMapper {
if (!technicalResourceNodes.isEmpty()) {
rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes));
}
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.issued");
if (!issuedNodes.isEmpty()) {
rda.setIssued(issuedNodes.get(0).get("value").asText());
}
List<JsonNode> contributorNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.contributor");
if (!contributorNodes.isEmpty()) {
contributors.addAll(contributorNodes.stream().map(contributorNode -> {
JsonNode value = contributorNode.get("value");
if (value.isArray()) {
return StreamSupport.stream(value.spliterator(), false).map(node -> ContributorRDAMapper.toRDA(node.asText())).collect(Collectors.toList());
} else {
return Collections.singletonList(new Contributor());
}
}).flatMap(Collection::stream).collect(Collectors.toList()));
}
List<JsonNode> foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes,
keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList());
templateIdsToValues.entrySet().forEach(entry -> {
@ -116,7 +156,7 @@ public class DatasetRDAMapper {
}
public eu.eudat.data.entities.Dataset toEntity(Dataset rda) {
public eu.eudat.data.entities.Dataset toEntity(Dataset rda, DatasetProfile defaultProfile) {
eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset();
entity.setLabel(rda.getTitle());
entity.setDescription(rda.getDescription());
@ -125,6 +165,7 @@ public class DatasetRDAMapper {
entity.setProfile(profile);
}catch(Exception e) {
logger.warn(e.getMessage(), e);
entity.setProfile(defaultProfile);
}
try {
Map<String, Object> properties = new HashMap<>();
@ -141,7 +182,7 @@ public class DatasetRDAMapper {
}
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language");
if (!languageNodes.isEmpty()) {
if (!languageNodes.isEmpty() && rda.getLanguage() != null) {
properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value());
}
@ -149,9 +190,17 @@ public class DatasetRDAMapper {
properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata()));
}
List <String> qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
if (rda.getDatasetId() != null) {
properties.putAll(DatasetIdRDAMapper.toProperties(rda.getDatasetId(), datasetDescriptionObj));
}
/*List <String> qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
for (int i = 0; i < qaIds.size(); i++) {
properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i));
}*/
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance");
if (!qaNodes.isEmpty() && rda.getDataQualityAssurance() != null && !rda.getDataQualityAssurance().isEmpty()) {
properties.put(qaNodes.get(0).get("id").asText(), rda.getDataQualityAssurance().get(0));
}
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
@ -159,13 +208,32 @@ public class DatasetRDAMapper {
properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement());
}
if (rda.getDistribution() != null) {
properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution()));
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.issued");
if (!issuedNodes.isEmpty()) {
properties.put(issuedNodes.get(0).get("id").asText(), rda.getIssued());
}
List <String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
for (int i = 0; i < keywordIds.size(); i++) {
properties.put(keywordIds.get(i), rda.getKeyword().get(i));
if (rda.getDistribution() != null) {
properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution().get(0), datasetDescriptionObj));
}
if (rda.getKeyword() != null) {
List<String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
boolean takeAll = false;
if (keywordIds.size() < rda.getKeyword().size()) {
takeAll = true;
}
for (int i = 0; i < keywordIds.size(); i++) {
if (takeAll) {
List<String> tags = new ArrayList<>();
for (String keyword : rda.getKeyword()) {
tags.add(mapper.writeValueAsString(toTagEntity(keyword)));
}
properties.put(keywordIds.get(i), tags);
} else {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
}
}
}
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data");
@ -197,4 +265,11 @@ public class DatasetRDAMapper {
return entity;
}
private static Tag toTagEntity(String name) {
Tag tag = new Tag();
tag.setId("");
tag.setName(name);
return tag;
}
}

View File

@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.JsonNode;
import eu.eudat.logic.utilities.helpers.MyStringUtils;
import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.rda.Distribution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.util.*;
import java.util.stream.Collectors;
public class DistributionRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class);
@ -50,7 +52,8 @@ public class DistributionRDAMapper {
rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText());
break;
case LICENSE:
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node)));
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("license")).collect(Collectors.toList());
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(licenseNodes)));
break;
case FORMAT:
rda.setFormat(Collections.singletonList(rdaValue));
@ -120,30 +123,128 @@ public class DistributionRDAMapper {
return properties;
}
public static Distribution toRDA(JsonNode node) {
public static Map<String, String> toProperties(Distribution rda, JsonNode root) {
Map<String, String> properties = new HashMap<>();
List<JsonNode> distributionNodes = JsonSearcher.findNodes(root, "rdaProperty", "dataset.distribution");
for (JsonNode distributionNode: distributionNodes) {
for (ExportPropertyName exportPropertyName: ExportPropertyName.values()) {
if (distributionNode.get("rdaProperty").asText().contains(exportPropertyName.getName())) {
switch (exportPropertyName) {
case ACCESS_URL:
properties.put(distributionNode.get("id").asText(), rda.getAccessUrl());
break;
case DESCRIPTION:
properties.put(distributionNode.get("id").asText(), rda.getDescription());
break;
case TITLE:
properties.put(distributionNode.get("id").asText(), rda.getTitle());
break;
case AVAILABLE_UTIL:
properties.put(distributionNode.get("id").asText(), rda.getAvailableUntil());
break;
case DOWNLOAD_URL:
if (rda.getDownloadUrl() != null) {
properties.put(distributionNode.get("id").asText(), rda.getDownloadUrl().toString());
}
break;
case DATA_ACCESS:
properties.put(distributionNode.get("id").asText(), rda.getDataAccess().value());
break;
case BYTE_SIZE:
if (rda.getByteSize() != null) {
properties.put(distributionNode.get("id").asText(), rda.getByteSize().toString());
}
break;
case FORMAT:
if (rda.getFormat() != null && !rda.getFormat().isEmpty()) {
properties.put(distributionNode.get("id").asText(), rda.getFormat().get(0));
}
break;
case LICENSE:
if (rda.getLicense() != null && !rda.getLicense().isEmpty()) {
properties.putAll(LicenseRDAMapper.toProperties(rda.getLicense().get(0), root));
}
break;
case HOST:
if (rda.getHost() != null) {
properties.putAll(HostRDAMapper.toProperties(rda.getHost()));
}
break;
}
}
}
}
return properties;
}
public static Distribution toRDA(List<JsonNode> nodes) {
Distribution rda = new Distribution();
String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText();
if (rdaProperty.contains("access_url")) {
rda.setAccessUrl(rdaValue);
} else if (rdaProperty.contains("available_util")) {
rda.setAvailableUntil(rdaValue);
} else if (rdaProperty.contains("byte_size")) {
rda.setByteSize(Integer.parseInt(rdaValue));
} else if (rdaProperty.contains("data_access")) {
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue));
} else if (rdaProperty.contains("description")) {
rda.setDescription(rdaValue);
} else if (rdaProperty.contains("download_url")) {
rda.setDownloadUrl(URI.create(rdaValue));
} else if (rdaProperty.contains("format")) {
rda.setFormat(Collections.singletonList(rdaValue));
} else if (rdaProperty.contains("host")) {
for (JsonNode node: nodes) {
String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText();
for (ExportPropertyName exportPropertyName: ExportPropertyName.values()) {
if (rdaProperty.contains(exportPropertyName.getName())) {
switch (exportPropertyName) {
case ACCESS_URL:
rda.setAccessUrl(rdaValue);
break;
case DESCRIPTION:
rda.setDescription(rdaValue);
break;
case TITLE:
rda.setTitle(rdaValue);
break;
case AVAILABLE_UTIL:
rda.setAvailableUntil(rdaValue);
break;
case DOWNLOAD_URL:
rda.setDownloadUrl(URI.create(rdaValue));
break;
case DATA_ACCESS:
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue));
break;
case BYTE_SIZE:
rda.setByteSize(Integer.parseInt(rdaValue));
break;
case FORMAT:
rda.setFormat(Collections.singletonList(rdaValue));
break;
case LICENSE:
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("license")).collect(Collectors.toList());
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(licenseNodes)));
break;
case HOST:
List<JsonNode> hostNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("host")).collect(Collectors.toList());
rda.setHost(HostRDAMapper.toRDA(hostNodes, "0"));
break;
}
}
}
/*if (rdaProperty.contains("access_url")) {
rda.setAccessUrl(rdaValue);
} else if (rdaProperty.contains("available_util")) {
rda.setAvailableUntil(rdaValue);
} else if (rdaProperty.contains("byte_size")) {
rda.setByteSize(Integer.parseInt(rdaValue));
} else if (rdaProperty.contains("data_access")) {
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue));
} else if (rdaProperty.contains("description")) {
rda.setDescription(rdaValue);
} else if (rdaProperty.contains("download_url")) {
rda.setDownloadUrl(URI.create(rdaValue));
} else if (rdaProperty.contains("format")) {
rda.setFormat(Collections.singletonList(rdaValue));
} else if (rdaProperty.contains("host")) {
// rda.setHost(HostRDAMapper.toRDA(node));
} else if (rdaProperty.contains("license")) {
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node)));
} else if (rdaProperty.contains("title")) {
rda.setTitle(rdaValue);
} else if (rdaProperty.contains("license")) {
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node)));
} else if (rdaProperty.contains("title")) {
rda.setTitle(rdaValue);
}*/
}

View File

@ -2,12 +2,15 @@ package eu.eudat.models.rda.mapper;
import eu.eudat.data.entities.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.rda.Dmp;
import eu.eudat.models.rda.DmpId;
import net.minidev.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@ -17,10 +20,12 @@ public class DmpRDAMapper {
private DatasetRDAMapper datasetRDAMapper;
private ApiContext apiContext;
@Autowired
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) {
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) throws IOException {
this.datasetRDAMapper = datasetRDAMapper;
this.apiContext = apiContext;
}
@Transactional
@ -36,6 +41,11 @@ public class DmpRDAMapper {
rda.setModified(dmp.getModified());
rda.setTitle(dmp.getLabel());
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
if (!extraProperties.isEmpty()) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
}
UserInfo creator;
if (dmp.getCreator() != null) {
creator = dmp.getCreator();
@ -48,29 +58,47 @@ public class DmpRDAMapper {
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
}
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset, rda.getContributor())).collect(Collectors.toList()));
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
return rda;
}
public DMP toEntity(Dmp rda) {
public DMP toEntity(Dmp rda, String[] profiles) {
DMP entity = new DMP();
entity.setLabel(rda.getTitle());
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
entity.setDoi(rda.getDmpId().getIdentifier());
}
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty()) {
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet()));
}
if (entity.getAssociatedDmps() == null) {
entity.setAssociatedDmps(new HashSet<>());
}
if (profiles != null) {
for (String profile : profiles) {
DatasetProfile exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
entity.getAssociatedDmps().add(exProfile);
}
}
if (rda.getContributor() != null && !rda.getContributor().isEmpty()) {
entity.setResearchers(rda.getContributor().stream().map(ContributorRDAMapper::toEntity).collect(Collectors.toSet()));
entity.setResearchers(rda.getContributor().stream().map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
}
entity.setCreated(rda.getCreated());
entity.setModified(rda.getModified());
entity.setDescription(rda.getDescription());
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet()));
DatasetProfile defaultProfile = ((DatasetProfile)entity.getAssociatedDmps().toArray()[0]);
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
entity.setProject((Project) result.get("project"));
result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet()));
Map<String, Object> extraProperties = new HashMap<>();
extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
return entity;
}

View File

@ -1,10 +1,14 @@
package eu.eudat.models.rda.mapper;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.Grant;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.rda.Funding;
import java.util.Date;
import java.util.UUID;
public class FundingRDAMapper {
public static Funding toRDA(Grant grant) {
@ -27,6 +31,29 @@ public class FundingRDAMapper {
public static Grant toEntity(Funding rda, ApiContext apiContext) {
GrantCriteria criteria = new GrantCriteria();
criteria.setReference(rda.getGrantId().getIdentifier());
return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle();
Grant grant;
try {
grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle();
}catch (Exception e) {
grant = new Grant();
grant.setId(UUID.randomUUID());
grant.setLabel(rda.getGrantId().getIdentifier());
grant.setStatus((short)1);
grant.setCreated(new Date());
grant.setModified(new Date());
grant.setType(0);
grant.setFunder(new Funder());
grant.getFunder().setId(UUID.randomUUID());
grant.getFunder().setLabel(rda.getFunderId().getIdentifier());
grant.getFunder().setStatus((short)1);
grant.getFunder().setCreated(new Date());
grant.getFunder().setModified(new Date());
grant.getFunder().setType(0);
grant.getFunder().setReference(rda.getFunderId().getType().toString()+"::"+rda.getFunderId().getIdentifier());
grant.setReference(rda.getGrantId().getType().toString()+"::"+rda.getGrantId().getIdentifier());
Funder funder = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().createOrUpdate(grant.getFunder());
grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(grant);
}
return grant;
}
}

View File

@ -0,0 +1,25 @@
package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class KeywordRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(KeywordRDAMapper.class);
public static String toRDA(String value) {
ObjectMapper mapper = new ObjectMapper();
try {
Map<String, Object> map = mapper.readValue(value, HashMap.class);
return (String) map.get("name");
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return value;
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.models.rda.mapper;
import eu.eudat.models.rda.Language;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public class LanguageRDAMapper {
private final static Map<String, Object> langMap = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(LanguageRDAMapper.class);
static {
String json = null;
try {
json = new BufferedReader(new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8))
.lines().collect(Collectors.joining("\n"));
langMap.putAll(new org.json.JSONObject(json).toMap());
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
public static Language mapLanguageIsoToRDAIso(String code) {
return langMap.entrySet().stream().map(entry -> {
if (entry.getValue().toString().equals(code)) {
return Language.fromValue(entry.getKey());
} else {
return null;
}
}).filter(Objects::nonNull).findFirst().get();
}
public static String mapRDAIsoToLanguageIso(Language lang) {
return langMap.get(lang.value()).toString();
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.JsonNode;
import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.rda.License;
import java.net.URI;
@ -10,17 +11,32 @@ import java.util.Map;
public class LicenseRDAMapper {
public static License toRDA(JsonNode node) {
public static License toRDA(List<JsonNode> nodes) {
License rda = new License();
String rdaProperty = node.get("rdaProperty").asText();
String value = node.get("value").asText();
for (JsonNode node: nodes) {
String rdaProperty = node.get("rdaProperty").asText();
String value = node.get("value").asText();
if (rdaProperty.contains("license_ref")) {
rda.setLicenseRef(URI.create(value));
rda.setAdditionalProperty("license_refId", node.get("id").asText());
} else if (rdaProperty.contains("start_date")) {
rda.setStartDate(value);
rda.setAdditionalProperty("start_dateId", node.get("id").asText());
for (LicenceProperties licenceProperties: LicenceProperties.values()) {
if (rdaProperty.contains(licenceProperties.getName())) {
switch (licenceProperties) {
case LICENSE_REF:
rda.setLicenseRef(URI.create(value));
break;
case START_DATE:
rda.setStartDate(value);
break;
}
}
}
/*if (rdaProperty.contains("license_ref")) {
rda.setLicenseRef(URI.create(value));
rda.setAdditionalProperty("license_refId", node.get("id").asText());
} else if (rdaProperty.contains("start_date")) {
rda.setStartDate(value);
rda.setAdditionalProperty("start_dateId", node.get("id").asText());
}*/
}
return rda;
@ -45,4 +61,44 @@ public class LicenseRDAMapper {
return properties;
}
public static Map<String, String> toProperties(License rda, JsonNode root) {
Map<String, String> properties = new HashMap<>();
List<JsonNode> licenseNodes = JsonSearcher.findNodes(root, "rdaProperty", "dataset.distribution.license");
for (JsonNode licenseNode: licenseNodes) {
for (LicenceProperties licenceProperty: LicenceProperties.values()) {
if (licenseNode.get("rdaProperty").asText().endsWith(licenceProperty.getName())) {
switch (licenceProperty) {
case LICENSE_REF:
if (rda.getLicenseRef() != null) {
properties.put(licenseNode.get("id").asText(), rda.getLicenseRef().toString());
}
break;
case START_DATE:
properties.put(licenseNode.get("id").asText(), rda.getStartDate());
break;
}
}
}
}
return properties;
}
public enum LicenceProperties {
LICENSE_REF("license_ref"),
START_DATE("start_date");
private String name;
LicenceProperties(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -42,3 +42,4 @@ dataset.issued
dataset.dataset_id
dataset.dataset_id.identifier
dataset.dataset_id.type
dmp.contributor

View File

@ -77,7 +77,7 @@ zenodo.login.redirect_uri=http://localhost:4200/login/external/zenodo
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
language.path=i18n/
language.path=dmp-frontend/src/assets/i18n/
#############LOGGING#########
logging.config=classpath:logging/logback-${spring.profiles.active}.xml

View File

@ -1,9 +1,9 @@
dmp.domain = https://opendmp.eu
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=
database.username=
database.password=
database.url=jdbc:postgresql://dmp-db:5432/dmptool
database.username=dmptool
database.password=CHANGEME
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = tags-elastic-search

View File

@ -11,9 +11,6 @@ elasticsearch.port = 9200
elasticsearch.username=elastic
elasticsearch.password=
####################ELK OVERRIDES CONFIGURATIONS##########
http-logger.server-address = http://logstash:31311
####################PDF OVERRIDES CONFIGURATIONS##########
pdf.converter.url=http://docsbox-web/

View File

@ -127,7 +127,7 @@
<grants>
<urls>
<urlConfig>
<!--<urlConfig>
<key>cristin</key>
<label>Cristin</label>
<ordinal>2</ordinal>
@ -144,7 +144,7 @@
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urlConfig>-->
<urlConfig>
<key>openaire</key>
<label>OpenAIRE</label>
@ -163,7 +163,7 @@
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<!-- <urlConfig>
<!--<urlConfig>
<key>openAire</key>
<label>OpenAIRE</label>
<ordinal>1</ordinal>
@ -180,8 +180,8 @@
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<urlConfig>
</urlConfig>-->
<!--<urlConfig>
<key>internal</key>
<label>Internal</label>
<ordinal>1</ordinal>
@ -497,6 +497,42 @@
<repositories>
<urls>
<urlConfig>
<key>openaire</key>
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<type>External</type>
<url>https://services.openaire.eu/search/v2/api/datasources?q={like}&amp;fq=datasourcetypeuiname%20exact%20%22Data%20Repository%22&amp;page={page}&amp;size={pageSize}&amp;format=json</url>
<firstPage>0</firstPage>
<contenttype>application/json;charset=UTF-8</contenttype>
<data>
<path>$['results'][*]['result']['metadata']['oaf:entity']['oaf:datasource']</path>
<fields>
<id>'originalId'</id>
<name>'officialname'</name>
<count>'count'</count>
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<urlConfig>
<key>openairealt</key>
<label>OpenAIRE Alternative</label>
<ordinal>1</ordinal>
<type>External</type>
<url>https://services.openaire.eu/search/v2/api/resources?query=oaftype%20exact%20datasource%20and%20{like}&amp;page={page}&amp;size={pageSize}&amp;format=json</url>
<firstPage>0</firstPage>
<contenttype>application/json;charset=UTF-8</contenttype>
<data>
<path>$['results'][*]['result']['metadata']['oaf:entity']['oaf:datasource']</path>
<fields>
<id>'originalId'</id>
<name>'officialname'</name>
<count>'count'</count>
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<!--<urlConfig>
<key>cristin</key>
<label>Cristin</label>
<ordinal>1</ordinal>
@ -515,7 +551,7 @@
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
</urlConfig>-->
<!-- <urlConfig>
<key>openAire</key>
<label>OpenAIRE</label>
@ -781,6 +817,24 @@
</data>
<paginationpath>$['number_of_results']</paginationpath>
</urlConfig>
<urlConfig>
<key>openaire</key>
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<type>External</type>
<url>https://services.openaire.eu/search/v2/api/organizations/?q={like}&amp;page={page}&amp;size={pageSize}&amp;format=json</url>
<firstPage>0</firstPage>
<contenttype>application/json; charset=utf-8</contenttype>
<data>
<path>$['results'][*]['result']['metadata']['oaf:entity']['oaf:organization']</path>
<fields>
<id>'originalId'</id>
<name>'legalname'</name>
<count>'count'</count>
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<!-- <urlConfig>
<key>openAire</key>
<label>OpenAIRE</label>
@ -883,6 +937,30 @@
<fetchMode>FIRST</fetchMode> <!-- EITHER 'FIRST' OR 'ALL' -->
</datasets>
<licenses>
<urls>
<urlConfig>
<key>opendefinition</key>
<label>Open Definition</label>
<ordinal>1</ordinal>
<type>External</type>
<url>https://licenses.opendefinition.org/licenses/groups/all.json</url>
<firstPage>1</firstPage>
<contenttype>application/vnd.api+json; charset=utf-8</contenttype>
<data>
<path>$[*]</path>
<fields>
<id>'id'</id>
<name>'title'</name>
<uri>'url'</uri>
<description>'maintainer'</description>
</fields>
</data>
</urlConfig>
</urls>
<fetchMode>FIRST</fetchMode>
</licenses>
</externalUrls>

View File

@ -0,0 +1,13 @@
<fetchConfig>
<configs>
<config>
<type>currency</type>
<fileType>xml</fileType>
<filePath>internal/iso-4217.xml</filePath>
<parseClass>eu.eudat.logic.proxy.fetching.entities.CurrencyModel</parseClass>
<parseField>currencies</parseField>
<name>currency</name>
<value>code</value>
</config>
</configs>
</fetchConfig>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,186 @@
{
"aar": "aa",
"abk": "ab",
"afr": "af",
"aka": "ak",
"amh": "am",
"ara": "ar",
"arg": "an",
"asm": "as",
"ava": "av",
"ave": "ae",
"aym": "ay",
"aze": "az",
"bak": "ba",
"bam": "bm",
"bel": "be",
"ben": "bn",
"bis": "bi",
"bod": "bo",
"bos": "bs",
"bre": "br",
"bul": "bg",
"cat": "ca",
"ces": "cs",
"cha": "ch",
"che": "ce",
"chu": "cu",
"chv": "cv",
"cor": "kw",
"cos": "co",
"cre": "cr",
"cym": "cy",
"dan": "da",
"deu": "de",
"div": "dv",
"dzo": "dz",
"ell": "el",
"eng": "en",
"epo": "eo",
"est": "et",
"eus": "eu",
"ewe": "ee",
"fao": "fo",
"fas": "fa",
"fij": "fj",
"fin": "fi",
"fra": "fr",
"fry": "fy",
"ful": "ff",
"gla": "gd",
"gle": "ga",
"glg": "gl",
"glv": "gv",
"grn": "gn",
"guj": "gu",
"hat": "ht",
"hau": "ha",
"hbs": "sh",
"heb": "he",
"her": "hz",
"hin": "hi",
"hmo": "ho",
"hrv": "hr",
"hun": "hu",
"hye": "hy",
"ibo": "ig",
"ido": "io",
"iii": "ii",
"iku": "iu",
"ile": "ie",
"ina": "ia",
"ind": "id",
"ipk": "ik",
"isl": "is",
"ita": "it",
"jav": "jv",
"jpn": "ja",
"kal": "kl",
"kan": "kn",
"kas": "ks",
"kat": "ka",
"kau": "kr",
"kaz": "kk",
"khm": "km",
"kik": "ki",
"kin": "rw",
"kir": "ky",
"kom": "kv",
"kon": "kg",
"kor": "ko",
"kua": "kj",
"kur": "ku",
"lao": "lo",
"lat": "la",
"lav": "lv",
"lim": "li",
"lin": "ln",
"lit": "lt",
"ltz": "lb",
"lub": "lu",
"lug": "lg",
"mah": "mh",
"mal": "ml",
"mar": "mr",
"mkd": "mk",
"mlg": "mg",
"mlt": "mt",
"mon": "mn",
"mri": "mi",
"msa": "ms",
"mya": "my",
"nau": "na",
"nav": "nv",
"nbl": "nr",
"nde": "nd",
"ndo": "ng",
"nep": "ne",
"nld": "nl",
"nno": "nn",
"nob": "nb",
"nor": "no",
"nya": "ny",
"oci": "oc",
"oji": "oj",
"ori": "or",
"orm": "om",
"oss": "os",
"pan": "pa",
"pli": "pi",
"pol": "pl",
"por": "pt",
"pus": "ps",
"que": "qu",
"roh": "rm",
"ron": "ro",
"run": "rn",
"rus": "ru",
"sag": "sg",
"san": "sa",
"sin": "si",
"slk": "sk",
"slv": "sl",
"sme": "se",
"smo": "sm",
"sna": "sn",
"snd": "sd",
"som": "so",
"sot": "st",
"spa": "es",
"sqi": "sq",
"srd": "sc",
"srp": "sr",
"ssw": "ss",
"sun": "su",
"swa": "sw",
"swe": "sv",
"tah": "ty",
"tam": "ta",
"tat": "tt",
"tel": "te",
"tgk": "tg",
"tgl": "tl",
"tha": "th",
"tir": "ti",
"ton": "to",
"tsn": "tn",
"tso": "ts",
"tuk": "tk",
"tur": "tr",
"twi": "tw",
"uig": "ug",
"ukr": "uk",
"urd": "ur",
"uzb": "uz",
"ven": "ve",
"vie": "vi",
"vol": "vo",
"wln": "wa",
"wol": "wo",
"xho": "xh",
"yid": "yi",
"yor": "yo",
"zha": "za",
"zho": "zh",
"zul": "zu"
}

Some files were not shown because too many files have changed in this diff Show More