zenodo model changes
This commit is contained in:
parent
aa8c73b6ed
commit
048980ac39
|
@ -37,7 +37,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>2.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite</groupId>
|
<groupId>gr.cite</groupId>
|
||||||
|
|
|
@ -104,4 +104,8 @@ public class AuditableAction {
|
||||||
public static final EventId Lock_Persist = new EventId(17002, "Lock_Persist");
|
public static final EventId Lock_Persist = new EventId(17002, "Lock_Persist");
|
||||||
public static final EventId Lock_Delete = new EventId(17003, "Lock_Delete");
|
public static final EventId Lock_Delete = new EventId(17003, "Lock_Delete");
|
||||||
|
|
||||||
|
public static final EventId Deposit_GetAvailableRepositories = new EventId(18000, "Deposit_GetAvailableRepositories");
|
||||||
|
public static final EventId Deposit_GetAccessToken = new EventId(18001, "Deposit_GetAccessToken");
|
||||||
|
public static final EventId Deposit_Deposit = new EventId(18002, "Deposit_Deposit");
|
||||||
|
public static final EventId Deposit_GetLogo = new EventId(18003, "Deposit_GetLogo");
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ public final class Permission {
|
||||||
//Elastic
|
//Elastic
|
||||||
public static String ManageElastic = "ManageElastic";
|
public static String ManageElastic = "ManageElastic";
|
||||||
|
|
||||||
|
//Deposit
|
||||||
|
public static String BrowseDeposit = "BrowseDeposit";
|
||||||
|
public static String EditDeposit = "BrowseDeposit";
|
||||||
|
|
||||||
|
|
||||||
//Language
|
//Language
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
package eu.eudat.cache.deposit;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.configurations.deposit.DepositCacheOptions;
|
|
||||||
import eu.eudat.model.doi.RepositoryConfigs;
|
|
||||||
import gr.cite.tools.cache.CacheService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class RepositoryDepositConfigurationCache extends CacheService<RepositoryConfigs> {
|
|
||||||
@Autowired
|
|
||||||
public RepositoryDepositConfigurationCache(DepositCacheOptions options) {
|
|
||||||
super(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<RepositoryConfigs> valueClass() {
|
|
||||||
return RepositoryConfigs.class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,58 +8,71 @@ import java.util.List;
|
||||||
@ConfigurationProperties(prefix = "deposit")
|
@ConfigurationProperties(prefix = "deposit")
|
||||||
public class DepositProperties {
|
public class DepositProperties {
|
||||||
|
|
||||||
private final List<DepositSource> sources;
|
private List<DepositSource> sources;
|
||||||
|
|
||||||
@ConstructorBinding
|
|
||||||
public DepositProperties(List<DepositSource> sources) {
|
|
||||||
this.sources = sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DepositSource> getSources() {
|
public List<DepositSource> getSources() {
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSources(List<DepositSource> sources) {
|
||||||
|
this.sources = sources;
|
||||||
|
}
|
||||||
|
|
||||||
public static class DepositSource {
|
public static class DepositSource {
|
||||||
|
|
||||||
private final String url;
|
private String repositoryId;
|
||||||
private final List<String> codes;
|
private String url;
|
||||||
private final String issuerUrl;
|
private String issuerUrl;
|
||||||
private final String clientId;
|
private String clientId;
|
||||||
private final String clientSecret;
|
private String clientSecret;
|
||||||
private final String scope;
|
private String scope;
|
||||||
|
|
||||||
@ConstructorBinding
|
public String getRepositoryId() {
|
||||||
public DepositSource(String url, List<String> codes, String issuerUrl, String clientId, String clientSecret, String scope) {
|
return repositoryId;
|
||||||
this.url = url;
|
}
|
||||||
this.codes = codes;
|
|
||||||
this.issuerUrl = issuerUrl;
|
public void setRepositoryId(String repositoryId) {
|
||||||
this.clientId = clientId;
|
this.repositoryId = repositoryId;
|
||||||
this.clientSecret = clientSecret;
|
|
||||||
this.scope = scope;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
public String getIssuerUrl() {
|
public String getIssuerUrl() {
|
||||||
return issuerUrl;
|
return issuerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIssuerUrl(String issuerUrl) {
|
||||||
|
this.issuerUrl = issuerUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClientId() {
|
public String getClientId() {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClientSecret() {
|
public String getClientSecret() {
|
||||||
return clientSecret;
|
return clientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClientSecret(String clientSecret) {
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
public String getScope() {
|
public String getScope() {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCodes() {
|
public void setScope(String scope) {
|
||||||
return codes;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import gr.cite.tools.data.builder.Builder;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class BaseDepositBuilder<M, D> implements Builder {
|
||||||
|
protected final LoggerService logger;
|
||||||
|
protected final ConventionService conventionService;
|
||||||
|
|
||||||
|
public BaseDepositBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
LoggerService logger
|
||||||
|
) {
|
||||||
|
this.conventionService = conventionService;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public M build(D data) throws MyApplicationException {
|
||||||
|
if (data == null) {
|
||||||
|
//this.logger.Debug(new MapLogEntry("requested build for null item requesting fields").And("fields", directives));
|
||||||
|
// return default(M);
|
||||||
|
M model = null;
|
||||||
|
return null; //TODO
|
||||||
|
}
|
||||||
|
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
||||||
|
return models.stream().map(DepositBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<M> build(List<D> data) throws MyApplicationException{
|
||||||
|
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
|
return models == null ? null : models.stream().map(DepositBuilderItemResponse::getModel).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<DepositBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
||||||
|
|
||||||
|
public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
|
this.logger.trace("Building references from query");
|
||||||
|
List<D> data = query.collect();
|
||||||
|
this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
return this.asForeignKey(data, keySelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
|
this.logger.trace("building references");
|
||||||
|
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
|
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), DepositBuilderItemResponse::getModel));
|
||||||
|
}
|
||||||
|
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
||||||
|
this.logger.trace("Building details from query");
|
||||||
|
List<D> data = query.collect();
|
||||||
|
this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
return this.asMasterKey(data, keySelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
|
this.logger.trace("building details");
|
||||||
|
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
|
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
Map<K, List<M>> map = new HashMap<>();
|
||||||
|
if (models == null) return map;
|
||||||
|
for (DepositBuilderItemResponse<M, D> model : models) {
|
||||||
|
K key = keySelector.apply(model.getData());
|
||||||
|
if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
||||||
|
map.get(key).add(model.getModel());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
public class DepositBuilderItemResponse<M, D>{
|
||||||
|
private final M model;
|
||||||
|
private final D data;
|
||||||
|
|
||||||
|
public DepositBuilderItemResponse(M model, D data) {
|
||||||
|
this.model = model;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public D getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public M getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.TagEntity;
|
||||||
|
import eu.eudat.model.Tag;
|
||||||
|
import eu.eudat.model.User;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.builder.UserBuilder;
|
||||||
|
import eu.eudat.model.deposit.DepositConfiguration;
|
||||||
|
import eu.eudat.query.UserQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DepositConfigurationBuilder extends BaseBuilder<DepositConfiguration, eu.eudat.depositinterface.repository.DepositConfiguration> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DepositConfigurationBuilder(
|
||||||
|
ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DepositConfigurationBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DepositConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DepositConfiguration> build(FieldSet fields, List<eu.eudat.depositinterface.repository.DepositConfiguration> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositConfiguration> models = new ArrayList<>();
|
||||||
|
for (eu.eudat.depositinterface.repository.DepositConfiguration d : data) {
|
||||||
|
DepositConfiguration m = new DepositConfiguration();
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._depositType))) m.setDepositType(d.getDepositType());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._redirectUri))) m.setRedirectUri(d.getRedirectUri());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryId))) m.setRepositoryId(d.getRepositoryId());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryAuthorizationUrl))) m.setRepositoryAuthorizationUrl(d.getRepositoryAuthorizationUrl());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryRecordUrl))) m.setRepositoryRecordUrl(d.getRepositoryRecordUrl());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._repositoryClientId))) m.setRepositoryClientId(d.getRepositoryClientId());
|
||||||
|
if (fields.hasField(this.asIndexer(DepositConfiguration._hasLogo))) m.setHasLogo(d.isHasLogo());
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.depositinterface.models.DescriptionDepositModel;
|
||||||
|
import eu.eudat.model.*;
|
||||||
|
import eu.eudat.model.builder.*;
|
||||||
|
import eu.eudat.model.builder.descriptionpropertiesdefinition.PropertyDefinitionBuilder;
|
||||||
|
import eu.eudat.query.*;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionDepositBuilder extends BaseDepositBuilder<DescriptionDepositModel, DescriptionEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionDepositBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionDepositBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<DescriptionDepositModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity> definitionMap = this.collectDescriptionTemplates(data);
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<DescriptionDepositModel, DescriptionEntity>> models = new ArrayList<>();
|
||||||
|
for (DescriptionEntity d : data) {
|
||||||
|
DescriptionDepositModel m = new DescriptionDepositModel();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
if (d.getProperties() != null){
|
||||||
|
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
|
if (definitionMap != null && definitionMap.containsKey(d.getDescriptionTemplateId()) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setFields(this.builderFactory.builder(DescriptionFieldDepositBuilder.class).authorize(this.authorize).setDefinition(definitionMap.get(d.getDescriptionTemplateId())).build(propertyDefinition.getFields()));
|
||||||
|
}
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||||
|
|
||||||
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
|
||||||
|
Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity>itemMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (DescriptionTemplateEntity descriptionTemplateEntity : descriptionTemplateEntities){
|
||||||
|
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
||||||
|
itemMap.put(descriptionTemplateEntity.getId(), definition);
|
||||||
|
}
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.depositinterface.enums.FieldType;
|
||||||
|
import eu.eudat.depositinterface.models.DescriptionFieldDepositModel;
|
||||||
|
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionFieldDepositBuilder extends BaseDepositBuilder<DescriptionFieldDepositModel, FieldEntity> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition;
|
||||||
|
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
||||||
|
@Autowired
|
||||||
|
public DescriptionFieldDepositBuilder(
|
||||||
|
ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldDepositBuilder.class)));
|
||||||
|
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionFieldDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionFieldDepositBuilder setDefinition(DefinitionEntity definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
||||||
|
if (definition != null){
|
||||||
|
List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = definition.getFieldById(d.getKey());
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(fieldEntities)){
|
||||||
|
eu.eudat.commons.types.descriptiontemplate.FieldEntity field = fieldEntities.getFirst();
|
||||||
|
m.setSchematics(field.getSchematics());
|
||||||
|
if (field.getData() != null) {
|
||||||
|
boolean isMultiValue = fieldDataHelperServiceProvider.get(field.getData().getFieldType()).isMultiValue(field.getData());
|
||||||
|
if (!isMultiValue) m.setValues(List.of(d.getValue()));
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
//TODO: Find better Solution
|
||||||
|
List<Object> values = objectMapper.readValue(d.getValue(), new TypeReference<List<Object>>() {});
|
||||||
|
m.setValues(values);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (field.getData().getFieldType()) {
|
||||||
|
case AUTO_COMPLETE -> m.setFieldType(FieldType.AUTO_COMPLETE);
|
||||||
|
case WORD_LIST -> m.setFieldType(FieldType.WORD_LIST);
|
||||||
|
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
||||||
|
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
||||||
|
case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
|
||||||
|
case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
|
||||||
|
case INTERNAL_DMP_ENTRIES_DATASETS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
|
||||||
|
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
||||||
|
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
||||||
|
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);
|
||||||
|
case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA);
|
||||||
|
case UPLOAD -> m.setFieldType(FieldType.UPLOAD);
|
||||||
|
case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER);
|
||||||
|
case EXTERNAL_DATASETS -> m.setFieldType(FieldType.EXTERNAL_DATASETS);
|
||||||
|
case DATA_REPOSITORIES -> m.setFieldType(FieldType.DATA_REPOSITORIES);
|
||||||
|
case JOURNAL_REPOSITORIES -> m.setFieldType(FieldType.JOURNAL_REPOSITORIES);
|
||||||
|
case PUB_REPOSITORIES -> m.setFieldType(FieldType.PUB_REPOSITORIES);
|
||||||
|
case LICENSES -> m.setFieldType(FieldType.LICENSES);
|
||||||
|
case PUBLICATIONS -> m.setFieldType(FieldType.PUBLICATIONS);
|
||||||
|
case REGISTRIES -> m.setFieldType(FieldType.REGISTRIES);
|
||||||
|
case SERVICES -> m.setFieldType(FieldType.SERVICES);
|
||||||
|
case TAGS -> m.setFieldType(FieldType.TAGS);
|
||||||
|
case RESEARCHERS -> m.setFieldType(FieldType.RESEARCHERS);
|
||||||
|
case ORGANIZATIONS -> m.setFieldType(FieldType.ORGANIZATIONS);
|
||||||
|
case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER);
|
||||||
|
case CURRENCY -> m.setFieldType(FieldType.CURRENCY);
|
||||||
|
case VALIDATION -> m.setFieldType(FieldType.VALIDATION);
|
||||||
|
case TAXONOMIES -> m.setFieldType(FieldType.TAXONOMIES);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + field.getData().getFieldType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,173 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.*;
|
||||||
|
import eu.eudat.depositinterface.enums.DmpAccessType;
|
||||||
|
import eu.eudat.depositinterface.models.*;
|
||||||
|
import eu.eudat.model.*;
|
||||||
|
import eu.eudat.query.*;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.Ordering;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpDepositBuilder extends BaseDepositBuilder<DmpDepositModel, DmpEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private FileEnvelope pdfFile;
|
||||||
|
private FileEnvelope rdaJsonFile;
|
||||||
|
private FileEnvelope supportingFilesZip;
|
||||||
|
private String repositoryId;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DmpDepositBuilder(ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpDepositBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDepositBuilder setPdfFile(FileEnvelope pdfFile) {
|
||||||
|
this.pdfFile = pdfFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDepositBuilder setRdaJsonFile(FileEnvelope rdaJsonFile) {
|
||||||
|
this.rdaJsonFile = rdaJsonFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDepositBuilder setSupportingFilesZip(FileEnvelope supportingFilesZip) {
|
||||||
|
this.supportingFilesZip = supportingFilesZip;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDepositBuilder setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<DmpDepositModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<DmpDepositModel, DmpEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<UUID, List<ReferenceDepositModel>> dmpReferencesMap = this.collectReferences(data);
|
||||||
|
|
||||||
|
Map<UUID, List<DmpUserDepositModel>> dmpUsersMap = this.collectDmpUsers(data);
|
||||||
|
|
||||||
|
Map<UUID, List<DescriptionDepositModel>> descriptionsMap = this.collectDmpDescriptions(data);
|
||||||
|
|
||||||
|
for (DmpEntity d : data) {
|
||||||
|
DmpDepositModel m = new DmpDepositModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setVersion(d.getVersion());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setFinalizedAt(d.getFinalizedAt());
|
||||||
|
m.setPdfFile(this.pdfFile);
|
||||||
|
m.setRdaJsonFile(this.rdaJsonFile);
|
||||||
|
m.setSupportingFilesZip(this.supportingFilesZip);
|
||||||
|
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
|
||||||
|
switch (d.getAccessType()){
|
||||||
|
case Public -> m.setAccessType(DmpAccessType.Public);
|
||||||
|
case Restricted -> m.setAccessType(DmpAccessType.Restricted);
|
||||||
|
case null -> m.setAccessType(null);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getAccessType().getValue());
|
||||||
|
}
|
||||||
|
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setReferences(dmpReferencesMap.get(d.getId()));
|
||||||
|
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setUsers(dmpUsersMap.get(d.getId()));
|
||||||
|
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
||||||
|
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPreviousDOI(UUID dmpGroup, UUID currentDmpId) {
|
||||||
|
if (repositoryId == null || repositoryId.isEmpty()) throw new MyApplicationException("repositoryId required");
|
||||||
|
|
||||||
|
//GK: Step one get the previous version of the Data management plan
|
||||||
|
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class);
|
||||||
|
dmpQuery.setOrder(new Ordering().addDescending(Dmp._version));
|
||||||
|
List<UUID> dmpIds = dmpQuery.groupIds(dmpGroup).excludedIds(currentDmpId).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).toList();
|
||||||
|
|
||||||
|
//GK: Step two get it's doiEntity
|
||||||
|
List<EntityDoiEntity> dois = this.queryFactory.query(EntityDoiQuery.class).repositoryIds(repositoryId).entityIds(dmpIds).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(EntityDoi._entityId, EntityDoi._doi));
|
||||||
|
for(UUID uuid: dmpIds) {
|
||||||
|
EntityDoiEntity doiEntity = dois.stream().filter(x -> x.getEntityId().equals(uuid)).findFirst().orElse(null);
|
||||||
|
if (doiEntity != null) return doiEntity.getDoi();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<ReferenceDepositModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
||||||
|
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference));
|
||||||
|
|
||||||
|
Map<UUID, List<ReferenceDepositModel>> itemMap = new HashMap<>();
|
||||||
|
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||||
|
Map<UUID, ReferenceDepositModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceDepositBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
||||||
|
if (referenceDepositModelMap == null) return null;
|
||||||
|
for (DmpReferenceEntity dmpReference : dmpReferences) {
|
||||||
|
ReferenceDepositModel model =referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null);
|
||||||
|
if (model == null) continue;;
|
||||||
|
UUID key = dmpReference.getDmpId();
|
||||||
|
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
||||||
|
itemMap.get(key).add(model);
|
||||||
|
}
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<UUID, List<DmpUserDepositModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DmpUserDepositModel>> itemMap;
|
||||||
|
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DmpUserDepositBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId);
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DescriptionDepositModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DescriptionDepositModel>> itemMap;
|
||||||
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionDepositBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
|
import eu.eudat.data.UserEntity;
|
||||||
|
import eu.eudat.depositinterface.enums.DmpUserRole;
|
||||||
|
import eu.eudat.depositinterface.models.DmpUserDepositModel;
|
||||||
|
import eu.eudat.depositinterface.models.UserDepositModel;
|
||||||
|
import eu.eudat.query.UserQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpUserDepositBuilder extends BaseDepositBuilder<DmpUserDepositModel, DmpUserEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DmpUserDepositBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserDepositBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpUserDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<DmpUserDepositModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
Map<UUID, UserDepositModel> userItemsMap = this.collectUsers(data);
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<DmpUserDepositModel, DmpUserEntity>> models = new ArrayList<>();
|
||||||
|
for (DmpUserEntity d : data) {
|
||||||
|
DmpUserDepositModel m = new DmpUserDepositModel();
|
||||||
|
switch (d.getRole()){
|
||||||
|
case User -> m.setRole(DmpUserRole.User);
|
||||||
|
case Owner -> m.setRole(DmpUserRole.Owner);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
||||||
|
}
|
||||||
|
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, UserDepositModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", UserDepositModel.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, UserDepositModel> itemMap;
|
||||||
|
UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(UserDepositBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.depositinterface.models.reference.DefinitionDepositModel;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceDefinitionDepositBuilder extends BaseDepositBuilder<DefinitionDepositModel, DefinitionEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceDefinitionDepositBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionDepositBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceDefinitionDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<DefinitionDepositModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<DefinitionDepositModel, DefinitionEntity>> models = new ArrayList<>();
|
||||||
|
for (DefinitionEntity d : data) {
|
||||||
|
DefinitionDepositModel m = new DefinitionDepositModel();
|
||||||
|
if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldDepositBuilder.class).authorize(this.authorize).build(d.getFields()));
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.depositinterface.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.depositinterface.enums.ReferenceType;
|
||||||
|
import eu.eudat.depositinterface.models.ReferenceDepositModel;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceDepositBuilder extends BaseDepositBuilder<ReferenceDepositModel, ReferenceEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceDepositBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDepositBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<ReferenceDepositModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<ReferenceDepositModel, ReferenceEntity>> models = new ArrayList<>();
|
||||||
|
for (ReferenceEntity d : data) {
|
||||||
|
ReferenceDepositModel m = new ReferenceDepositModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
if (d.getDefinition() != null){
|
||||||
|
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
||||||
|
m.setDefinition(this.builderFactory.builder(ReferenceDefinitionDepositBuilder.class).authorize(this.authorize).build(definition));
|
||||||
|
}
|
||||||
|
m.setReference(d.getReference());
|
||||||
|
m.setAbbreviation(d.getAbbreviation());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setSource(d.getSource());
|
||||||
|
switch (d.getSourceType()){
|
||||||
|
case Internal -> m.setSourceType(ReferenceSourceType.Internal);
|
||||||
|
case External -> m.setSourceType(ReferenceSourceType.External);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue());
|
||||||
|
}
|
||||||
|
switch (d.getType()){
|
||||||
|
case Taxonomies -> m.setType(ReferenceType.Taxonomies);
|
||||||
|
case Licenses -> m.setType(ReferenceType.Licenses);
|
||||||
|
case Publications -> m.setType(ReferenceType.Publications);
|
||||||
|
case Journals -> m.setType(ReferenceType.Journals);
|
||||||
|
case PubRepositories -> m.setType(ReferenceType.PubRepositories);
|
||||||
|
case DataRepositories -> m.setType(ReferenceType.DataRepositories);
|
||||||
|
case Registries -> m.setType(ReferenceType.Registries);
|
||||||
|
case Services -> m.setType(ReferenceType.Services);
|
||||||
|
case Project -> m.setType(ReferenceType.Project);
|
||||||
|
case Funder -> m.setType(ReferenceType.Funder);
|
||||||
|
case Datasets -> m.setType(ReferenceType.Datasets);
|
||||||
|
case Organizations -> m.setType(ReferenceType.Organizations);
|
||||||
|
case Grants -> m.setType(ReferenceType.Grants);
|
||||||
|
case Researcher -> m.setType(ReferenceType.Researcher);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getType().getValue());
|
||||||
|
}
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.depositinterface.models.reference.FieldDepositModel;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceFieldDepositBuilder extends BaseDepositBuilder<FieldDepositModel, FieldEntity> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceFieldDepositBuilder(
|
||||||
|
ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldDepositBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceFieldDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<FieldDepositModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<FieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
FieldDepositModel m = new FieldDepositModel();
|
||||||
|
m.setCode(d.getCode());
|
||||||
|
m.setValue(d.getValue());
|
||||||
|
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package eu.eudat.model.builder.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.UserEntity;
|
||||||
|
import eu.eudat.depositinterface.models.UserDepositModel;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class UserDepositBuilder extends BaseDepositBuilder<UserDepositModel, UserEntity> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UserDepositBuilder(ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserDepositBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<DepositBuilderItemResponse<UserDepositModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
List<DepositBuilderItemResponse<UserDepositModel, UserEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
|
for (UserEntity d : data) {
|
||||||
|
UserDepositModel m = new UserDepositModel();
|
||||||
|
m.setName(d.getName());
|
||||||
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package eu.eudat.model.censorship.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.censorship.*;
|
||||||
|
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DepositConfigurationCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositConfigurationCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
|
|
||||||
|
public DepositConfigurationCensor(ConventionService conventionService, AuthorizationService authService) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDeposit);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,23 +1,28 @@
|
||||||
package eu.eudat.model.doi;
|
package eu.eudat.model.deposit;
|
||||||
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
import eu.eudat.depositinterface.enums.DepositType;
|
||||||
|
|
||||||
import java.util.List;
|
public class DepositConfiguration {
|
||||||
|
|
||||||
public class RepositoryConfig {
|
private DepositType depositType;
|
||||||
|
public static final String _depositType = "depositType";
|
||||||
private int depositType;
|
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
|
public static final String _repositoryId = "repositoryId";
|
||||||
private String repositoryAuthorizationUrl;
|
private String repositoryAuthorizationUrl;
|
||||||
|
public static final String _repositoryAuthorizationUrl = "repositoryAuthorizationUrl";
|
||||||
private String repositoryRecordUrl;
|
private String repositoryRecordUrl;
|
||||||
|
public static final String _repositoryRecordUrl = "repositoryRecordUrl";
|
||||||
private String repositoryClientId;
|
private String repositoryClientId;
|
||||||
|
public static final String _repositoryClientId = "repositoryClientId";
|
||||||
private String redirectUri;
|
private String redirectUri;
|
||||||
|
public static final String _redirectUri = "redirectUri";
|
||||||
private boolean hasLogo;
|
private boolean hasLogo;
|
||||||
|
public static final String _hasLogo = "hasLogo";
|
||||||
|
|
||||||
public int getDepositType() {
|
public DepositType getDepositType() {
|
||||||
return depositType;
|
return depositType;
|
||||||
}
|
}
|
||||||
public void setDepositType(int depositType) {
|
public void setDepositType(DepositType depositType) {
|
||||||
this.depositType = depositType;
|
this.depositType = depositType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,17 +67,5 @@ public class RepositoryConfig {
|
||||||
public void setHasLogo(boolean hasLogo) {
|
public void setHasLogo(boolean hasLogo) {
|
||||||
this.hasLogo = hasLogo;
|
this.hasLogo = hasLogo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RepositoryConfig toModel(RepositoryDepositConfiguration r){
|
|
||||||
RepositoryConfig repositoryConfig = new RepositoryConfig();
|
|
||||||
repositoryConfig.setDepositType(r.getDepositType());
|
|
||||||
repositoryConfig.setRepositoryId(r.getRepositoryId());
|
|
||||||
repositoryConfig.setRepositoryAuthorizationUrl(r.getRepositoryAuthorizationUrl());
|
|
||||||
repositoryConfig.setRepositoryRecordUrl(r.getRepositoryRecordUrl());
|
|
||||||
repositoryConfig.setRepositoryClientId(r.getRepositoryClientId());
|
|
||||||
repositoryConfig.setRedirectUri(r.getRedirectUri());
|
|
||||||
repositoryConfig.setHasLogo(r.isHasLogo());
|
|
||||||
return repositoryConfig;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package eu.eudat.model.doi;
|
|
||||||
|
|
||||||
public class DepositRequest {
|
|
||||||
|
|
||||||
private String repositoryId;
|
|
||||||
private String dmpId;
|
|
||||||
private String accessToken;
|
|
||||||
|
|
||||||
public String getRepositoryId() {
|
|
||||||
return repositoryId;
|
|
||||||
}
|
|
||||||
public void setRepositoryId(String repositoryId) {
|
|
||||||
this.repositoryId = repositoryId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDmpId() {
|
|
||||||
return dmpId;
|
|
||||||
}
|
|
||||||
public void setDmpId(String dmpId) {
|
|
||||||
this.dmpId = dmpId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessToken() {
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package eu.eudat.model.doi;
|
|
||||||
|
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
|
||||||
import eu.eudat.model.Dmp;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Doi {
|
|
||||||
private UUID id;
|
|
||||||
private String repositoryId;
|
|
||||||
private String doi;
|
|
||||||
private Date createdAt;
|
|
||||||
private Date updatedAt;
|
|
||||||
private Dmp dmp;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRepositoryId() {
|
|
||||||
return repositoryId;
|
|
||||||
}
|
|
||||||
public void setRepositoryId(String repositoryId) {
|
|
||||||
this.repositoryId = repositoryId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDoi() {
|
|
||||||
return doi;
|
|
||||||
}
|
|
||||||
public void setDoi(String doi) {
|
|
||||||
this.doi = doi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
public void setCreatedAt(Date createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdatedAt() {
|
|
||||||
return updatedAt;
|
|
||||||
}
|
|
||||||
public void setUpdatedAt(Date updatedAt) {
|
|
||||||
this.updatedAt = updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dmp getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
public void setDmp(Dmp dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Doi fromDataModel(EntityDoiEntity entity) {
|
|
||||||
Doi doi1 = new Doi();
|
|
||||||
doi1.id = entity.getId();
|
|
||||||
doi1.repositoryId = entity.getRepositoryId();
|
|
||||||
doi1.doi = entity.getDoi();
|
|
||||||
doi1.createdAt = Date.from(entity.getCreatedAt());
|
|
||||||
doi1.updatedAt = Date.from(entity.getUpdatedAt());
|
|
||||||
return doi1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityDoiEntity toDataModel() throws Exception {
|
|
||||||
EntityDoiEntity entityDoi = new EntityDoiEntity();
|
|
||||||
entityDoi.setId(this.id);
|
|
||||||
entityDoi.setRepositoryId(this.repositoryId);
|
|
||||||
entityDoi.setDoi(this.doi);
|
|
||||||
entityDoi.setCreatedAt(this.createdAt.toInstant());
|
|
||||||
entityDoi.setUpdatedAt(this.updatedAt.toInstant());
|
|
||||||
return entityDoi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHint() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package eu.eudat.model.doi;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RepositoryConfigs {
|
|
||||||
private List<RepositoryConfig> repositoryConfigs;
|
|
||||||
|
|
||||||
public RepositoryConfigs() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public RepositoryConfigs(List<RepositoryConfig> repositoryConfigs) {
|
|
||||||
this.repositoryConfigs = repositoryConfigs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RepositoryConfig> getRepositoryConfigs() {
|
|
||||||
return repositoryConfigs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositoryConfigs(List<RepositoryConfig> repositoryConfigs) {
|
|
||||||
this.repositoryConfigs = repositoryConfigs;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
package eu.eudat.model.mapper.deposit;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.old.*;
|
|
||||||
import eu.eudat.depositinterface.models.*;
|
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import javax.xml.xpath.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DMPToDepositMapper {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DMPToDepositMapper.class);
|
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public static DMPDepositModel fromDMP(DmpEntity entity, FileEnvelope pdfFile, FileEnvelope jsonFile, File supportingFilesZip, String previousDOI) {
|
|
||||||
DMPDepositModel deposit = new DMPDepositModel();
|
|
||||||
// deposit.setId(entity.getId());
|
|
||||||
// deposit.setVersion(entity.getVersion());
|
|
||||||
// deposit.setLabel(entity.getLabel());
|
|
||||||
// deposit.setDescription(entity.getDescription());
|
|
||||||
// deposit.setPublic(entity.isPublic());
|
|
||||||
// deposit.setDatasets(entity.getDataset().stream().map(DMPToDepositMapper::fromDataset).collect(Collectors.toList()));
|
|
||||||
// deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
|
|
||||||
// deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
|
|
||||||
// deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
|
|
||||||
// if (entity.getGrant() != null) {
|
|
||||||
// deposit.setGrant(fromGrant(entity.getGrant()));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// deposit.setPdfFile(pdfFile);
|
|
||||||
// deposit.setRdaJsonFile(jsonFile);
|
|
||||||
// deposit.setSupportingFilesZip(supportingFilesZip);
|
|
||||||
// deposit.setPreviousDOI(previousDOI);
|
|
||||||
//
|
|
||||||
// deposit.setExtraProperties(entity.getExtraProperties());
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
private static DatasetDepositModel fromDataset(DescriptionEntity entity){
|
|
||||||
DatasetDepositModel deposit = new DatasetDepositModel();
|
|
||||||
deposit.setLabel(entity.getLabel());
|
|
||||||
deposit.setDescription(entity.getDescription());
|
|
||||||
//TODO
|
|
||||||
//deposit.setProfileDefinition(entity.getProfile().getDefinition());
|
|
||||||
deposit.setProperties(entity.getProperties());
|
|
||||||
deposit.setFields(fromDefinitionAndProperties(deposit.getProfileDefinition(), deposit.getProperties()));
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<DatasetFieldsDepositModel> fromDefinitionAndProperties(String definition, String properties){
|
|
||||||
List<DatasetFieldsDepositModel> deposit = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
|
|
||||||
Map<String, Object> datasetAnswers = mapper.readValue(properties, HashMap.class);
|
|
||||||
|
|
||||||
Document document = XmlBuilder.fromXml(definition);
|
|
||||||
XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
||||||
XPath xpath = xpathFactory.newXPath();
|
|
||||||
XPathExpression expr = xpath.compile("//schematics");
|
|
||||||
NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
|
||||||
for (int i = 0; i < schematics.getLength(); i++) {
|
|
||||||
Node schematicsNode = schematics.item(i);
|
|
||||||
NodeList schematicsList = schematicsNode.getChildNodes();
|
|
||||||
DatasetFieldsDepositModel fieldDeposit = new DatasetFieldsDepositModel();
|
|
||||||
List<String> schematicsDeposit = new ArrayList<>();
|
|
||||||
if(schematicsList != null){
|
|
||||||
for(int j = 0; j < schematicsList.getLength(); j++){
|
|
||||||
Node schematic = schematicsList.item(j);
|
|
||||||
if(schematic.getTextContent().matches(".*\\w+.*")) {
|
|
||||||
schematicsDeposit.add(schematic.getTextContent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldDeposit.setSchematics(schematicsDeposit);
|
|
||||||
String fieldId = schematicsNode.getParentNode().getAttributes().getNamedItem("id").getNodeValue();
|
|
||||||
Object value = datasetAnswers.get(fieldId);
|
|
||||||
fieldDeposit.setValue(value);
|
|
||||||
Element field = (Element) schematicsNode.getParentNode();
|
|
||||||
Element viewStyle = (Element) field.getElementsByTagName("viewStyle").item(0);
|
|
||||||
String renderStyle = viewStyle.getAttribute("renderstyle");
|
|
||||||
fieldDeposit.setRenderStyleType(renderStyle);
|
|
||||||
Element data = (Element) field.getElementsByTagName("data").item(0);
|
|
||||||
String multipleSelection = data.getAttribute("multiList");
|
|
||||||
String multipleAutoComplete = data.getAttribute("multiAutoComplete");
|
|
||||||
if(!multipleSelection.isEmpty()){
|
|
||||||
fieldDeposit.setMultiple(Boolean.parseBoolean(multipleSelection));
|
|
||||||
}
|
|
||||||
else if(!multipleAutoComplete.isEmpty()){
|
|
||||||
fieldDeposit.setMultiple(Boolean.parseBoolean(multipleAutoComplete));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
fieldDeposit.setMultiple(false);
|
|
||||||
}
|
|
||||||
deposit.add(fieldDeposit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (XPathExpressionException | JsonProcessingException ex){
|
|
||||||
logger.error(ex.getMessage(), ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private static UserDMPDepositModel fromUserDMP(DmpUserEntity entity){
|
|
||||||
// UserDMPDepositModel deposit = new UserDMPDepositModel();
|
|
||||||
// deposit.setUser(fromUserInfo(entity.getUser()));
|
|
||||||
// deposit.setRole(entity.getRole().getValue().intValue());
|
|
||||||
// return deposit;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static UserInfoDepositModel fromUserInfo(UserEntity entity){
|
|
||||||
UserInfoDepositModel deposit = new UserInfoDepositModel();
|
|
||||||
deposit.setName(entity.getName());
|
|
||||||
//deposit.setEmail(entity.getEmail());//TODO: GetEmail
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OrganisationDepositModel fromOrganisation(Organisation entity){
|
|
||||||
OrganisationDepositModel deposit = new OrganisationDepositModel();
|
|
||||||
deposit.setLabel(entity.getLabel());
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResearcherDepositModel fromResearcher(Researcher entity){
|
|
||||||
ResearcherDepositModel deposit = new ResearcherDepositModel();
|
|
||||||
deposit.setLabel(entity.getLabel());
|
|
||||||
deposit.setReference(entity.getReference());
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GrantDepositModel fromGrant(Grant entity){
|
|
||||||
GrantDepositModel deposit = new GrantDepositModel();
|
|
||||||
deposit.setId(entity.getId());
|
|
||||||
deposit.setReference(entity.getReference());
|
|
||||||
deposit.setFunder(fromFunder(entity.getFunder()));
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FunderDepositModel fromFunder(Funder entity){
|
|
||||||
FunderDepositModel deposit = new FunderDepositModel();
|
|
||||||
deposit.setLabel(entity.getLabel());
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,158 +0,0 @@
|
||||||
package eu.eudat.model.mapper.deposit;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
import eu.eudat.data.*;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.depositinterface.models.*;
|
|
||||||
import eu.eudat.model.UserContactInfo;
|
|
||||||
import eu.eudat.query.*;
|
|
||||||
import gr.cite.tools.data.query.Ordering;
|
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import javax.xml.xpath.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class DmpEntityDepositMapper {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DmpEntityDepositMapper.class);
|
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
private final ApplicationContext applicationContext;
|
|
||||||
private final EntityManager entityManager;
|
|
||||||
private final QueryFactory queryFactory;
|
|
||||||
|
|
||||||
public DmpEntityDepositMapper(ApplicationContext applicationContext, EntityManager entityManager, QueryFactory queryFactory) {
|
|
||||||
this.applicationContext = applicationContext;
|
|
||||||
this.entityManager = entityManager;
|
|
||||||
this.queryFactory = queryFactory;
|
|
||||||
|
|
||||||
this.mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: WIP, missing some things like researchers, organizations etc. Must check Blueprint properties and check if those have some standard way to be identified
|
|
||||||
public DMPDepositModel toDeposit(DmpEntity dmpEntity, File zip, FileEnvelope pdf, FileEnvelope json, String previousDOI) {
|
|
||||||
DMPDepositModel model = new DMPDepositModel();
|
|
||||||
List<DescriptionEntity> desciptions = this.getDescriptions(dmpEntity.getId());
|
|
||||||
List<DmpUserEntity> users = getUsers(dmpEntity.getId());
|
|
||||||
model.setId(dmpEntity.getId());
|
|
||||||
model.setLabel(dmpEntity.getLabel());
|
|
||||||
model.setDescription(dmpEntity.getDescription());
|
|
||||||
model.setVersion(dmpEntity.getVersion());
|
|
||||||
model.setPdfFile(pdf);
|
|
||||||
model.setRdaJsonFile(json);
|
|
||||||
model.setSupportingFilesZip(zip);
|
|
||||||
model.setDatasets(desciptions.stream().map(this::toDatasetDeposit).toList());
|
|
||||||
model.setExtraProperties(dmpEntity.getProperties());
|
|
||||||
model.setUsers(users.stream().map(this::toUserDeposit).collect(Collectors.toSet()));
|
|
||||||
model.setPreviousDOI(previousDOI);
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DescriptionEntity> getDescriptions(UUID dmpId) {
|
|
||||||
DescriptionQuery descriptionQuery = this.queryFactory.query(DescriptionQuery.class);
|
|
||||||
return descriptionQuery.dmpDescriptionTemplateSubQuery(this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).isActive(IsActive.Active)).isActive(IsActive.Active).collect();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private DatasetDepositModel toDatasetDeposit(DescriptionEntity entity) {
|
|
||||||
DatasetDepositModel model = new DatasetDepositModel();
|
|
||||||
model.setLabel(entity.getLabel());
|
|
||||||
model.setDescription(entity.getDescription());
|
|
||||||
model.setProperties(entity.getProperties());
|
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplateId());
|
|
||||||
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
|
||||||
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DescriptionTemplateEntity getDescriptionTemplate(UUID descriptionTemplateId) {
|
|
||||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class);
|
|
||||||
return descriptionTemplateQuery.ids(descriptionTemplateId).isActive(IsActive.Active).first();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DatasetFieldsDepositModel> fromDefinitionAndProperties(String definition, String properties){
|
|
||||||
List<DatasetFieldsDepositModel> deposit = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
|
|
||||||
Map<String, Object> datasetAnswers = mapper.readValue(properties, HashMap.class);
|
|
||||||
|
|
||||||
Document document = XmlBuilder.fromXml(definition);
|
|
||||||
XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
||||||
XPath xpath = xpathFactory.newXPath();
|
|
||||||
XPathExpression expr = xpath.compile("//schematics");
|
|
||||||
NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
|
||||||
for (int i = 0; i < schematics.getLength(); i++) {
|
|
||||||
Node schematicsNode = schematics.item(i);
|
|
||||||
NodeList schematicsList = schematicsNode.getChildNodes();
|
|
||||||
DatasetFieldsDepositModel fieldDeposit = new DatasetFieldsDepositModel();
|
|
||||||
List<String> schematicsDeposit = new ArrayList<>();
|
|
||||||
if(schematicsList != null){
|
|
||||||
for(int j = 0; j < schematicsList.getLength(); j++){
|
|
||||||
Node schematic = schematicsList.item(j);
|
|
||||||
if(schematic.getTextContent().matches(".*\\w+.*")) {
|
|
||||||
schematicsDeposit.add(schematic.getTextContent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldDeposit.setSchematics(schematicsDeposit);
|
|
||||||
String fieldId = schematicsNode.getParentNode().getAttributes().getNamedItem("id").getNodeValue();
|
|
||||||
Object value = datasetAnswers.get(fieldId);
|
|
||||||
fieldDeposit.setValue(value);
|
|
||||||
Element field = (Element) schematicsNode.getParentNode();
|
|
||||||
Element viewStyle = (Element) field.getElementsByTagName("viewStyle").item(0);
|
|
||||||
String renderStyle = viewStyle.getAttribute("renderstyle");
|
|
||||||
fieldDeposit.setRenderStyleType(renderStyle);
|
|
||||||
Element data = (Element) field.getElementsByTagName("data").item(0);
|
|
||||||
String multipleSelection = data.getAttribute("multiList");
|
|
||||||
String multipleAutoComplete = data.getAttribute("multiAutoComplete");
|
|
||||||
if(!multipleSelection.isEmpty()){
|
|
||||||
fieldDeposit.setMultiple(Boolean.parseBoolean(multipleSelection));
|
|
||||||
}
|
|
||||||
else if(!multipleAutoComplete.isEmpty()){
|
|
||||||
fieldDeposit.setMultiple(Boolean.parseBoolean(multipleAutoComplete));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
fieldDeposit.setMultiple(false);
|
|
||||||
}
|
|
||||||
deposit.add(fieldDeposit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (XPathExpressionException | JsonProcessingException ex){
|
|
||||||
logger.error(ex.getMessage(), ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return deposit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DmpUserEntity> getUsers(UUID dmpId) {
|
|
||||||
return this.queryFactory.query(DmpUserQuery.class).userIds(dmpId).collect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private UserDMPDepositModel toUserDeposit(DmpUserEntity user) {
|
|
||||||
UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel();
|
|
||||||
userDMPDepositModel.setUser(new UserInfoDepositModel());
|
|
||||||
UserEntity userInfo = this.entityManager.find(UserEntity.class, user.getUserId());
|
|
||||||
userDMPDepositModel.getUser().setName(userInfo.getName());
|
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userInfo.getId());
|
|
||||||
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
|
||||||
userDMPDepositModel.getUser().setEmail(query.first().getValue());
|
|
||||||
userDMPDepositModel.setRole(user.getRole().getValue().intValue());
|
|
||||||
|
|
||||||
return userDMPDepositModel;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,16 @@
|
||||||
package eu.eudat.model.doi;
|
package eu.eudat.model.persist.deposit;
|
||||||
|
|
||||||
public class DepositCode {
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
public class DepositAuthenticateRequest {
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
public String getRepositoryId() {
|
public String getRepositoryId() {
|
|
@ -0,0 +1,49 @@
|
||||||
|
package eu.eudat.model.persist.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.commons.validation.ValidId;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DepositRequest {
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
private String repositoryId;
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@ValidId(message = "{validation.invalidid}")
|
||||||
|
private UUID dmpId;
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
private BaseFieldSet project;
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getDmpId() {
|
||||||
|
return dmpId;
|
||||||
|
}
|
||||||
|
public void setDmpId(UUID dmpId) {
|
||||||
|
this.dmpId = dmpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseFieldSet getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProject(BaseFieldSet project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
}
|
|
@ -222,6 +222,8 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
||||||
if (item.match(DmpReference._id) || item.match(PublicDmpReference._id)) return DmpReferenceEntity._id;
|
if (item.match(DmpReference._id) || item.match(PublicDmpReference._id)) return DmpReferenceEntity._id;
|
||||||
else if (item.prefix(DmpReference._dmp) || item.prefix(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
else if (item.prefix(DmpReference._dmp) || item.prefix(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||||
else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||||
|
else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||||
|
else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||||
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
|
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
|
||||||
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
||||||
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
private Collection<EntityType> types;
|
private Collection<EntityType> types;
|
||||||
|
|
||||||
private Collection<UUID> excludedIds;
|
private Collection<UUID> excludedIds;
|
||||||
|
private Collection<String> repositoryIds;
|
||||||
|
|
||||||
private Collection<String> dois;
|
private Collection<String> dois;
|
||||||
|
|
||||||
|
@ -115,6 +116,21 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntityDoiQuery repositoryIds(Collection<String> values) {
|
||||||
|
this.repositoryIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityDoiQuery repositoryIds(String value) {
|
||||||
|
this.repositoryIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityDoiQuery repositoryIds(String... value) {
|
||||||
|
this.repositoryIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityDoiQuery entityIds(Collection<UUID> values) {
|
public EntityDoiQuery entityIds(Collection<UUID> values) {
|
||||||
this.entityIds = values;
|
this.entityIds = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -135,16 +151,10 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public EntityDoiQuery(
|
public EntityDoiQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,7 +164,7 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean isFalseQuery() {
|
protected Boolean isFalseQuery() {
|
||||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.types);
|
return this.isEmpty(this.ids) || this.isEmpty(this.isActives)|| this.isEmpty(this.repositoryIds) || this.isEmpty(this.excludedIds) || this.isEmpty(this.types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,6 +201,12 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
|
if (this.repositoryIds != null) {
|
||||||
|
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._repositoryId));
|
||||||
|
for (String item : this.repositoryIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.entityIds != null) {
|
if (this.entityIds != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityId));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityId));
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
package eu.eudat.repository;
|
|
||||||
|
|
||||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DepositRepository implements RepositoryDeposit {
|
|
||||||
|
|
||||||
private final WebClient depositClient;
|
|
||||||
|
|
||||||
public DepositRepository(WebClient depositClient) {
|
|
||||||
this.depositClient = depositClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String deposit(String repositoryId, DMPDepositModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
|
||||||
return depositClient.post().uri("/" + repositoryId, uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String authenticate(String repositoryId, String code) {
|
|
||||||
return depositClient.get().uri("/authenticate/" + repositoryId, uriBuilder -> uriBuilder.queryParam("authToken", code).build()).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<RepositoryDepositConfiguration> getConfiguration() {
|
|
||||||
return depositClient.get().uri("/configuration").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<List<RepositoryDepositConfiguration>>() {})).block();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLogo(String repositoryId) {
|
|
||||||
return depositClient.get().uri("/logo/" + repositoryId).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.depositinterface.models.DmpDepositModel;
|
||||||
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
public class DepositClientImpl implements DepositClient {
|
||||||
|
|
||||||
|
private final WebClient depositClient;
|
||||||
|
|
||||||
|
public DepositClientImpl(WebClient depositClient) {
|
||||||
|
this.depositClient = depositClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String deposit(DmpDepositModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
||||||
|
return depositClient.post().uri("/", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String authenticate(String code) {
|
||||||
|
return depositClient.get().uri("/authenticate/", uriBuilder -> uriBuilder.queryParam("authToken", code).build()).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DepositConfiguration getConfiguration() {
|
||||||
|
return depositClient.get().uri("/configuration").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<DepositConfiguration>() {})).block();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLogo() {
|
||||||
|
return depositClient.get().uri("/logo/").exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
|
import gr.cite.tools.cache.CacheOptions;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "cache.deposit-config-by-id")
|
||||||
|
public class DepositConfigurationCacheOptions extends CacheOptions {
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
|
import gr.cite.tools.cache.CacheService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DepositConfigurationCacheService extends CacheService<DepositConfigurationCacheService.DepositConfigurationCacheValue> {
|
||||||
|
|
||||||
|
public static class DepositConfigurationCacheValue {
|
||||||
|
|
||||||
|
public DepositConfigurationCacheValue() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DepositConfigurationCacheValue(String repositoryId, DepositConfiguration configuration) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String repositoryId;
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DepositConfiguration configuration;
|
||||||
|
|
||||||
|
public DepositConfiguration getConfiguration() {
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfiguration(DepositConfiguration configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DepositConfigurationCacheService(DepositConfigurationCacheOptions options) {
|
||||||
|
super(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<DepositConfigurationCacheValue> valueClass() {
|
||||||
|
return DepositConfigurationCacheValue.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyOf(DepositConfigurationCacheValue value) {
|
||||||
|
return this.buildKey(value.getRepositoryId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String buildKey(String subject) {
|
||||||
|
HashMap<String, String> keyParts = new HashMap<>();
|
||||||
|
keyParts.put("$repositoryId$", subject);
|
||||||
|
return this.generateKey(keyParts);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.model.EntityDoi;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
|
import eu.eudat.model.deposit.DepositConfiguration;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DepositService {
|
||||||
|
List<eu.eudat.model.deposit.DepositConfiguration> getAvailableConfigurations(FieldSet fieldSet);
|
||||||
|
|
||||||
|
EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception;
|
||||||
|
|
||||||
|
String getLogo(String repositoryId);
|
||||||
|
|
||||||
|
String authenticate(DepositAuthenticateRequest model);
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.configurations.deposit.DepositProperties;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.depositinterface.models.DmpDepositModel;
|
||||||
|
import eu.eudat.depositinterface.models.FileEnvelope;
|
||||||
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
|
import eu.eudat.model.EntityDoi;
|
||||||
|
import eu.eudat.model.builder.deposit.DepositConfigurationBuilder;
|
||||||
|
import eu.eudat.model.builder.deposit.DmpDepositBuilder;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
|
import eu.eudat.model.persist.EntityDoiPersist;
|
||||||
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.service.entitydoi.EntityDoiService;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DepositServiceImpl implements DepositService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DepositServiceImpl.class);
|
||||||
|
|
||||||
|
private final DepositProperties depositProperties;
|
||||||
|
private final Map<String, DepositClient> clients;
|
||||||
|
private final TokenExchangeCacheService tokenExchangeCacheService;
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
private final WebClient.Builder webClientBuilder;
|
||||||
|
private final EntityDoiService doiService;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final DepositConfigurationCacheService depositConfigurationCacheService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DepositServiceImpl(DepositProperties depositProperties,
|
||||||
|
TokenExchangeCacheService tokenExchangeCacheService,
|
||||||
|
WebClient.Builder builder,
|
||||||
|
AuthorizationService authorizationService,
|
||||||
|
EntityDoiService doiService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
MessageSource messageSource,
|
||||||
|
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService) {
|
||||||
|
this.depositProperties = depositProperties;
|
||||||
|
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
this.webClientBuilder = builder;
|
||||||
|
this.doiService = doiService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.depositConfigurationCacheService = depositConfigurationCacheService;
|
||||||
|
this.clients = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private DepositClient getDepositClient(String repositoryId) {
|
||||||
|
if (this.clients.containsKey(repositoryId)) return this.clients.get(repositoryId);
|
||||||
|
|
||||||
|
//GK: It's register time
|
||||||
|
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
|
||||||
|
if (source != null) {
|
||||||
|
String host = URI.create(source.getUrl()).getHost();
|
||||||
|
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel("deposit:" + source.getRepositoryId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
|
||||||
|
TokenExchangeFilterFunction apiKeyExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel);
|
||||||
|
WebClient webClient = webClientBuilder.baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build();
|
||||||
|
DepositClientImpl repository = new DepositClientImpl(webClient);
|
||||||
|
this.clients.put(source.getRepositoryId(), repository);
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<eu.eudat.model.deposit.DepositConfiguration> getAvailableConfigurations(FieldSet fieldSet) {
|
||||||
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit);
|
||||||
|
|
||||||
|
List<eu.eudat.model.deposit.DepositConfiguration> configurations = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DepositProperties.DepositSource depositSource : depositProperties.getSources()) {
|
||||||
|
DepositConfigurationCacheService.DepositConfigurationCacheValue cacheValue = this.depositConfigurationCacheService.lookup(this.depositConfigurationCacheService.buildKey(depositSource.getRepositoryId()));
|
||||||
|
if (cacheValue == null){
|
||||||
|
DepositClient depositClient = getDepositClient(depositSource.getRepositoryId());
|
||||||
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{depositSource.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
DepositConfiguration configuration = depositClient.getConfiguration();
|
||||||
|
cacheValue = new DepositConfigurationCacheService.DepositConfigurationCacheValue(depositSource.getRepositoryId(), configuration);
|
||||||
|
this.depositConfigurationCacheService.put(cacheValue);
|
||||||
|
}
|
||||||
|
eu.eudat.model.deposit.DepositConfiguration depositConfiguration = this.builderFactory.builder(DepositConfigurationBuilder.class).build(fieldSet, cacheValue.getConfiguration());
|
||||||
|
configurations.add(depositConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configurations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception {
|
||||||
|
this.authorizationService.authorizeForce(Permission.EditDeposit);
|
||||||
|
|
||||||
|
this.authorizationService.authorize(Permission.EditDmp);
|
||||||
|
//GK: First get the right client
|
||||||
|
DepositClient depositClient = getDepositClient(dmpDepositModel.getRepositoryId());
|
||||||
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
//GK: Second get the Target Data Management Plan
|
||||||
|
DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDepositModel.getDmpId()).first();
|
||||||
|
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
//GK: Forth make the required files to be uploaded with the deposit
|
||||||
|
//TODO: Properly create required files
|
||||||
|
FileEnvelope docEnvelope = new FileEnvelope();
|
||||||
|
FileEnvelope pdfEnvelope = new FileEnvelope();
|
||||||
|
FileEnvelope jsonEnvelope = new FileEnvelope();
|
||||||
|
FileEnvelope zip = new FileEnvelope();
|
||||||
|
//TODO: Create Files
|
||||||
|
// File zip = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".zip");
|
||||||
|
// try {
|
||||||
|
// docEnvelope.setFilename("test.docx");
|
||||||
|
// docEnvelope.setFile(this.storageFileService.getH2020TemplateFile());
|
||||||
|
// File pdfFile = PDFUtils.convertToPDF(docEnvelope, environment);
|
||||||
|
// pdfEnvelope.setFilename("test.pdf");
|
||||||
|
// pdfEnvelope.setFile(pdfFile);
|
||||||
|
// File jsonFile = new File(this.environment.getProperty("temp.temp") + UUID.randomUUID() + ".json");
|
||||||
|
// jsonEnvelope.setFilename("test.json");
|
||||||
|
// jsonEnvelope.setFile(jsonFile);
|
||||||
|
//
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// logger.error(e.getMessage(), e);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//GK: Fifth Transform them to the DepositModel
|
||||||
|
DmpDepositModel depositModel = this.builderFactory.builder(DmpDepositBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic)
|
||||||
|
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).setSupportingFilesZip(zip).build(dmpEntity);
|
||||||
|
|
||||||
|
//GK: Sixth Perform the deposit
|
||||||
|
String doi = depositClient.deposit(depositModel, dmpDepositModel.getAccessToken());
|
||||||
|
//GK: Something has gone wrong return null
|
||||||
|
if (doi.isEmpty()) return null;
|
||||||
|
//GK: doi is fine store it in database
|
||||||
|
EntityDoiPersist doiPersist = new EntityDoiPersist();
|
||||||
|
doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId());
|
||||||
|
doiPersist.setDoi(doi);
|
||||||
|
doiPersist.setEntityId(dmpEntity.getId());
|
||||||
|
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLogo(String repositoryId) {
|
||||||
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit);
|
||||||
|
|
||||||
|
DepositClient depositClient = getDepositClient(repositoryId);
|
||||||
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{repositoryId, DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
return depositClient.getLogo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String authenticate(DepositAuthenticateRequest model) {
|
||||||
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit);
|
||||||
|
|
||||||
|
DepositClient depositClient = getDepositClient(model.getRepositoryId());
|
||||||
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
return depositClient.authenticate(model.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,213 +0,0 @@
|
||||||
package eu.eudat.service.deposit;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.cache.deposit.RepositoryDepositConfigurationCache;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.configurations.deposit.DepositProperties;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
|
||||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
|
||||||
import eu.eudat.depositinterface.models.FileEnvelope;
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
|
||||||
import eu.eudat.model.EntityDoi;
|
|
||||||
import eu.eudat.model.doi.DepositRequest;
|
|
||||||
import eu.eudat.model.doi.RepositoryConfig;
|
|
||||||
import eu.eudat.model.doi.RepositoryConfigs;
|
|
||||||
import eu.eudat.model.mapper.deposit.DmpEntityDepositMapper;
|
|
||||||
import eu.eudat.model.persist.EntityDoiPersist;
|
|
||||||
import eu.eudat.query.DmpQuery;
|
|
||||||
import eu.eudat.query.EntityDoiQuery;
|
|
||||||
import eu.eudat.repository.DepositRepository;
|
|
||||||
import eu.eudat.service.entitydoi.EntityDoiService;
|
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.commons.web.oidc.apikey.ApiKeyCacheService;
|
|
||||||
//import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyExchangeFilterFunction;
|
|
||||||
//import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyWebfluxModel;
|
|
||||||
import gr.cite.tools.data.query.Ordering;
|
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.ResourceUtils;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class RepositoryDepositService {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RepositoryDepositService.class);
|
|
||||||
|
|
||||||
private final DepositProperties depositProperties;
|
|
||||||
private final Map<String, DepositRepository> clients;
|
|
||||||
private final ApiKeyCacheService apiKeyCacheService;
|
|
||||||
private final RepositoryDepositConfigurationCache repositoryDepositConfigurationCache;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
private final ConventionService conventionService;
|
|
||||||
private final Environment environment;
|
|
||||||
private final DmpEntityDepositMapper depositMapper;
|
|
||||||
private final WebClient.Builder webClientBuilder;
|
|
||||||
private final EntityDoiService doiService;
|
|
||||||
private final ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public RepositoryDepositService(DepositProperties depositProperties, ApiKeyCacheService apiKeyCacheService, RepositoryDepositConfigurationCache repositoryDepositConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, Environment environment, DmpEntityDepositMapper depositMapper, DmpQuery dmpQuery, EntityDoiQuery doiQuery, EntityDoiService doiService, ApplicationContext applicationContext) {
|
|
||||||
this.depositProperties = depositProperties;
|
|
||||||
this.apiKeyCacheService = apiKeyCacheService;
|
|
||||||
this.repositoryDepositConfigurationCache = repositoryDepositConfigurationCache;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
this.conventionService = conventionService;
|
|
||||||
this.environment = environment;
|
|
||||||
this.depositMapper = depositMapper;
|
|
||||||
this.webClientBuilder = builder;
|
|
||||||
this.doiService = doiService;
|
|
||||||
this.applicationContext = applicationContext;
|
|
||||||
this.clients = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DepositRepository getRepository(String repoId) {
|
|
||||||
if (this.clients.containsKey(repoId)) return this.clients.get(repoId);
|
|
||||||
|
|
||||||
//GK: It's register time
|
|
||||||
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getCodes().contains(repoId)).findFirst().orElse(null);
|
|
||||||
if (source != null) {
|
|
||||||
String host = URI.create(source.getUrl()).getHost();
|
|
||||||
// ApiKeyWebfluxModel apiKeyWebfluxModel = new ApiKeyWebfluxModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
|
|
||||||
// ApiKeyExchangeFilterFunction apiKeyExchangeFilterFunction = new ApiKeyExchangeFilterFunction(this.apiKeyCacheService, apiKeyWebfluxModel);
|
|
||||||
// DepositRepository repository = new DepositRepository(webClientBuilder.baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build());
|
|
||||||
// source.getCodes().forEach(code -> this.clients.put(code, repository));
|
|
||||||
// return repository;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<RepositoryConfig> getAvailableConfigurations() {
|
|
||||||
RepositoryConfigs configs = repositoryDepositConfigurationCache.lookup("base");
|
|
||||||
if (configs == null) {
|
|
||||||
List<RepositoryConfig> configurations = new ArrayList<>();
|
|
||||||
//GK: So much for lazy loading
|
|
||||||
List<DepositRepository> repositories = depositProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().get(0))).toList();
|
|
||||||
|
|
||||||
repositories.forEach((client) -> {
|
|
||||||
List<RepositoryDepositConfiguration> repositoryConfigs = client.getConfiguration();
|
|
||||||
if (repositoryConfigs != null && !repositoryConfigs.isEmpty()) {
|
|
||||||
configurations.addAll(repositoryConfigs.stream().map(RepositoryConfig::toModel).toList());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
configs = new RepositoryConfigs(configurations);
|
|
||||||
this.repositoryDepositConfigurationCache.put("base", configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configs.getRepositoryConfigs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityDoi deposit(DepositRequest dmpDepositModel) throws InvalidApplicationException {
|
|
||||||
this.authorizationService.authorize(Permission.EditDmp);
|
|
||||||
//GK: Why it is in that service, and why it's not static?
|
|
||||||
this.conventionService.isValidGuid(UUID.fromString(dmpDepositModel.getDmpId()));
|
|
||||||
//GK: First get the right client
|
|
||||||
DepositRepository repository = getRepository(dmpDepositModel.getRepositoryId());
|
|
||||||
//GK: Second get the Target Data Management Plan
|
|
||||||
DmpQuery dmpQuery = applicationContext.getBean(DmpQuery.class);
|
|
||||||
DmpEntity dmpEntity = dmpQuery.ids(UUID.fromString(dmpDepositModel.getDmpId())).first();
|
|
||||||
|
|
||||||
//GK: Third get the DOI from the previous Data Management Plan (if it exists)
|
|
||||||
String previousDOI = null;
|
|
||||||
if (dmpEntity.getVersion() > 1) { //TODO: Will it start from 1 or 0?
|
|
||||||
previousDOI = this.getPreviousDOI(dmpEntity.getGroupId(), dmpEntity.getId(), dmpDepositModel.getRepositoryId());
|
|
||||||
}
|
|
||||||
|
|
||||||
//GK: Forth make the required files to be uploaded with the deposit
|
|
||||||
//TODO: Properly create required files
|
|
||||||
FileEnvelope docEnvelope = new FileEnvelope();
|
|
||||||
FileEnvelope pdfEnvelope = new FileEnvelope();
|
|
||||||
FileEnvelope jsonEnvelope = new FileEnvelope();
|
|
||||||
File zip = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".zip");
|
|
||||||
try {
|
|
||||||
File documentFile = ResourceUtils.getFile(this.environment.getProperty("configuration.h2020template"));
|
|
||||||
docEnvelope.setFilename("test.docx");
|
|
||||||
docEnvelope.setFile(documentFile);
|
|
||||||
File pdfFile = PDFUtils.convertToPDF(docEnvelope, environment);
|
|
||||||
pdfEnvelope.setFilename("test.pdf");
|
|
||||||
pdfEnvelope.setFile(pdfFile);
|
|
||||||
File jsonFile = new File(this.environment.getProperty("temp.temp") + UUID.randomUUID() + ".json");
|
|
||||||
jsonEnvelope.setFilename("test.json");
|
|
||||||
jsonEnvelope.setFile(jsonFile);
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//GK: Fifth Transform them to the DepositModel
|
|
||||||
DMPDepositModel depositModel = depositMapper.toDeposit(dmpEntity, zip, pdfEnvelope, jsonEnvelope, previousDOI);
|
|
||||||
|
|
||||||
//GK: Sixth Perform the deposit
|
|
||||||
String doi = "";
|
|
||||||
try {
|
|
||||||
doi = repository.deposit(dmpDepositModel.getRepositoryId(), depositModel, "");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
//GK: Something has gone wrong return null
|
|
||||||
if (doi.isEmpty())
|
|
||||||
return null;
|
|
||||||
//GK: doi is fine store it in database
|
|
||||||
EntityDoiPersist doiPersist = new EntityDoiPersist();
|
|
||||||
doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId());
|
|
||||||
doiPersist.setDoi(doi);
|
|
||||||
doiPersist.setEntityId(dmpEntity.getId());
|
|
||||||
FieldSet fieldSet = new BaseFieldSet();
|
|
||||||
return doiService.persist(doiPersist, fieldSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogo(String repoId) {
|
|
||||||
//GK: First get the right client
|
|
||||||
DepositRepository repository = getRepository(repoId);
|
|
||||||
if (repository != null) {
|
|
||||||
return repository.getLogo(repoId);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getPreviousDOI(UUID groupId, UUID currentId, String repoId) {
|
|
||||||
EntityDoiEntity doiEntity = null;
|
|
||||||
|
|
||||||
//GK: Step one get the previous version of the Data management plan
|
|
||||||
DmpQuery dmpQuery = this.applicationContext.getBean(DmpQuery.class);
|
|
||||||
Ordering ordering = new Ordering();
|
|
||||||
ordering.setItems(List.of("-version"));
|
|
||||||
dmpQuery.setOrder(ordering);
|
|
||||||
FieldSet fieldSet = new BaseFieldSet();
|
|
||||||
fieldSet.ensure("id");
|
|
||||||
List<UUID> dmpIds = dmpQuery.groupIds(groupId).isActive(IsActive.Active).collectAs(fieldSet).stream().map(DmpEntity::getId).toList();
|
|
||||||
|
|
||||||
//GK: Step two get it's doiEntity
|
|
||||||
EntityDoiQuery doiQuery = this.applicationContext.getBean(EntityDoiQuery.class);
|
|
||||||
List<EntityDoiEntity> dois = doiQuery.entityIds(dmpIds).isActive(IsActive.Active).collect();
|
|
||||||
|
|
||||||
for(UUID uuid: dmpIds)
|
|
||||||
{
|
|
||||||
if (uuid.equals(currentId))
|
|
||||||
continue;
|
|
||||||
doiEntity = dois.stream()
|
|
||||||
.filter(entityDoiEntity -> entityDoiEntity.getEntityId().equals(uuid)).findFirst().orElse(null);
|
|
||||||
if (doiEntity != null)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return doiEntity != null ? doiEntity.getDoi() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,6 +11,8 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.description.FieldEntity;
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.*;
|
import eu.eudat.data.*;
|
||||||
|
@ -181,12 +183,33 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void descriptionForce(DescriptionEntity description) throws Exception {
|
// public List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> getFieldById(String id){
|
||||||
|
// List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = new ArrayList<>();
|
||||||
|
// if (id == null || id.isBlank()) return fieldEntities;
|
||||||
|
// if (this.getFieldSets() != null){
|
||||||
|
// for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
|
||||||
|
// fieldEntities.addAll(fieldSetEntity.getFieldById(id));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (this.getSections() != null){
|
||||||
|
// for (SectionEntity sectionEntity: this.getSections()) {
|
||||||
|
// fieldEntities.addAll(sectionEntity.getFieldById(id));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return fieldEntities;
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void descriptionForce(DescriptionEntity description) throws Exception {
|
||||||
List<String> datasetProfileValidators = new LinkedList<>();
|
List<String> datasetProfileValidators = new LinkedList<>();
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, description.getDescriptionTemplateId());
|
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, description.getDescriptionTemplateId());
|
||||||
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
||||||
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||||
// DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
// DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
||||||
// Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
// Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
||||||
//
|
//
|
||||||
|
|
|
@ -202,6 +202,11 @@ public class AutoCompleteFieldDataHelperService extends BaseFieldDataHelperServi
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(AutoCompleteDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
|
|
||||||
private @NotNull AutoCompleteSingleData buildAutoCompleteSingleData(AutoCompleteDataEntity.AutoCompleteSingleData data){
|
private @NotNull AutoCompleteSingleData buildAutoCompleteSingleData(AutoCompleteDataEntity.AutoCompleteSingleData data){
|
||||||
AutoCompleteSingleData xml = new AutoCompleteSingleData();
|
AutoCompleteSingleData xml = new AutoCompleteSingleData();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
|
@ -25,6 +25,7 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
||||||
protected abstract D applyPersistInternal(PM persist, D data);
|
protected abstract D applyPersistInternal(PM persist, D data);
|
||||||
protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist);
|
protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist);
|
||||||
protected abstract IE dataToImportExportXmlInternal(D data, IE xml);
|
protected abstract IE dataToImportExportXmlInternal(D data, IE xml);
|
||||||
|
protected abstract boolean isMultiValueInternal(D data);
|
||||||
@Override
|
@Override
|
||||||
public BaseFieldDataEntity<?> newDataInstance() {
|
public BaseFieldDataEntity<?> newDataInstance() {
|
||||||
return this.newDataInstanceInternal();
|
return this.newDataInstanceInternal();
|
||||||
|
@ -59,6 +60,11 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
||||||
xml.setLabel(data.getLabel());
|
xml.setLabel(data.getLabel());
|
||||||
return this.dataToImportExportXmlInternal((D)data, xml);
|
return this.dataToImportExportXmlInternal((D)data, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMultiValue(BaseFieldDataEntity<?> data){
|
||||||
|
return this.isMultiValueInternal((D)data);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist){
|
public BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist){
|
||||||
BaseFieldDataEntity<?> instance = this.newDataInstance();
|
BaseFieldDataEntity<?> instance = this.newDataInstance();
|
||||||
|
|
|
@ -93,4 +93,9 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(BooleanDecisionDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,9 @@ public class CheckBoxFieldDataHelperService extends BaseFieldDataHelperService<C
|
||||||
protected CheckBoxDataImportExport dataToImportExportXmlInternal(CheckBoxDataEntity data, CheckBoxDataImportExport xml) {
|
protected CheckBoxDataImportExport dataToImportExportXmlInternal(CheckBoxDataEntity data, CheckBoxDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(CheckBoxDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,4 +93,9 @@ public class CurrencyFieldDataHelperService extends BaseFieldDataHelperService<C
|
||||||
protected CurrencyDataImportExport dataToImportExportXmlInternal(CurrencyDataEntity data, CurrencyDataImportExport xml) {
|
protected CurrencyDataImportExport dataToImportExportXmlInternal(CurrencyDataEntity data, CurrencyDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(CurrencyDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,9 @@ public class DataRepositoryFieldDataHelperService extends BaseFieldDataHelperSer
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(DataRepositoryDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,4 +99,9 @@ public class DatasetAutoCompleteFieldDataHelperService extends BaseFieldDataHelp
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(DatasetAutoCompleteDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,4 +94,9 @@ public class DatasetIdentifierFieldDataHelperService extends BaseFieldDataHelper
|
||||||
protected DatasetIdentifierDataImportExport dataToImportExportXmlInternal(DatasetIdentifierDataEntity data, DatasetIdentifierDataImportExport xml) {
|
protected DatasetIdentifierDataImportExport dataToImportExportXmlInternal(DatasetIdentifierDataEntity data, DatasetIdentifierDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(DatasetIdentifierDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,4 +94,9 @@ public class DatePickerFieldDataHelperService extends BaseFieldDataHelperService
|
||||||
protected DatePickerDataImportExport dataToImportExportXmlInternal(DatePickerDataEntity data, DatePickerDataImportExport xml) {
|
protected DatePickerDataImportExport dataToImportExportXmlInternal(DatePickerDataEntity data, DatePickerDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(DatePickerDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,4 +99,9 @@ public class DmpAutoCompleteFieldDataHelperService extends BaseFieldDataHelperSe
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(DmpAutoCompleteDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,4 +101,9 @@ public class ExternalDatasetFieldDataHelperService extends BaseFieldDataHelperSe
|
||||||
xml.setType(data.getType());
|
xml.setType(data.getType());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(ExternalDatasetDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,5 @@ public interface FieldDataHelperService {
|
||||||
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity<?> data);
|
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity<?> data);
|
||||||
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml);
|
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml);
|
||||||
BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data);
|
BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data);
|
||||||
|
boolean isMultiValue(BaseFieldDataEntity<?> data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,9 @@ public class FreeTextFieldDataHelperService extends BaseFieldDataHelperService<F
|
||||||
protected FreeTextDataImportExport dataToImportExportXmlInternal(FreeTextDataEntity data, FreeTextDataImportExport xml) {
|
protected FreeTextDataImportExport dataToImportExportXmlInternal(FreeTextDataEntity data, FreeTextDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(FreeTextDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,4 +100,9 @@ public class JournalRepositoryFieldDataHelperService extends BaseFieldDataHelper
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(JournalRepositoryDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class LicenseFieldDataHelperService extends BaseFieldDataHelperService<Li
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(LicenseDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class OrganizationFieldDataHelperService extends BaseFieldDataHelperServi
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(OrganizationDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,11 @@ public class PublicationFieldDataHelperService extends BaseFieldDataHelperServic
|
||||||
return PublicationDataImportExport.class;
|
return PublicationDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(PublicationDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PublicationData> buildInternal(FieldSet fieldSet, List<PublicationDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags){
|
public List<PublicationData> buildInternal(FieldSet fieldSet, List<PublicationDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags){
|
||||||
return this.builderFactory.builder(PublicationDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(PublicationDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
|
|
|
@ -100,4 +100,9 @@ public class PublicationRepositoryFieldDataHelperService extends BaseFieldDataHe
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(PublicationRepositoryDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,11 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(RadioBoxDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.Option data){
|
private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.Option data){
|
||||||
RadioBoxOption xml = new RadioBoxOption();
|
RadioBoxOption xml = new RadioBoxOption();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class RegistryFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(RegistryDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class ResearcherAutoCompleteFieldDataHelperService extends BaseFieldDataH
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(ResearcherAutoCompleteDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class ResearcherFieldDataHelperService extends BaseFieldDataHelperService
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(ResearcherDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,9 @@ public class RichTextAreaDataFieldDataHelperService extends BaseFieldDataHelperS
|
||||||
protected RichTextAreaDataImportExport dataToImportExportXmlInternal(RichTextAreaDataEntity data, RichTextAreaDataImportExport xml) {
|
protected RichTextAreaDataImportExport dataToImportExportXmlInternal(RichTextAreaDataEntity data, RichTextAreaDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(RichTextAreaDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class ServiceFieldDataHelperService extends BaseFieldDataHelperService<Se
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(ServiceDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,9 @@ public class TagFieldDataHelperService extends BaseFieldDataHelperService<TagDat
|
||||||
protected TagDataImportExport dataToImportExportXmlInternal(TagDataEntity data, TagDataImportExport xml) {
|
protected TagDataImportExport dataToImportExportXmlInternal(TagDataEntity data, TagDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(TagDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,9 @@ public class TaxonomyFieldDataHelperService extends BaseFieldDataHelperService<T
|
||||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(TaxonomyDataEntity data) {
|
||||||
|
return data.getMultiAutoComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,4 +95,9 @@ public class TextAreaFieldDataHelperService extends BaseFieldDataHelperService<T
|
||||||
protected TextAreaDataImportExport dataToImportExportXmlInternal(TextAreaDataEntity data, TextAreaDataImportExport xml) {
|
protected TextAreaDataImportExport dataToImportExportXmlInternal(TextAreaDataEntity data, TextAreaDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(TextAreaDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,11 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(UploadDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private @NotNull UploadDataOption buildOption(UploadDataEntity.Option data){
|
private @NotNull UploadDataOption buildOption(UploadDataEntity.Option data){
|
||||||
UploadDataOption xml = new UploadDataOption();
|
UploadDataOption xml = new UploadDataOption();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
|
@ -95,4 +95,9 @@ public class ValidationFieldDataHelperService extends BaseFieldDataHelperService
|
||||||
protected ValidationDataImportExport dataToImportExportXmlInternal(ValidationDataEntity data, ValidationDataImportExport xml) {
|
protected ValidationDataImportExport dataToImportExportXmlInternal(ValidationDataEntity data, ValidationDataImportExport xml) {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(ValidationDataEntity data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,12 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService<W
|
||||||
}
|
}
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMultiValueInternal(WordListDataEntity data) {
|
||||||
|
return data.getMultiList();
|
||||||
|
}
|
||||||
|
|
||||||
private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){
|
private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){
|
||||||
ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity();
|
ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
package eu.eudat.utilities.pdf;
|
//package eu.eudat.utilities.pdf;
|
||||||
|
//
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
//import eu.eudat.model.file.FileEnvelope;
|
||||||
import org.apache.commons.io.IOUtils;
|
//import org.apache.commons.io.IOUtils;
|
||||||
import org.springframework.core.env.Environment;
|
//import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
//import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.HttpEntity;
|
//import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
//import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
//import org.springframework.http.MediaType;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
//import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
//import org.springframework.web.client.RestTemplate;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
//import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
//import java.nio.file.Files;
|
||||||
import java.util.UUID;
|
//import java.util.UUID;
|
||||||
|
//
|
||||||
public class PDFUtils {
|
//public class PDFUtils {
|
||||||
|
//
|
||||||
public static File convertToPDF(eu.eudat.depositinterface.models.FileEnvelope file, Environment environment) throws IOException {
|
// public static File convertToPDF(eu.eudat.depositinterface.models.FileEnvelope file, Environment environment) throws IOException {
|
||||||
FileEnvelope envelope = new FileEnvelope();
|
// FileEnvelope envelope = new FileEnvelope();
|
||||||
envelope.setFilename(file.getFilename());
|
// envelope.setFilename(file.getFilename());
|
||||||
envelope.setFile(file.getFile());
|
//// envelope.setFile(file.getFile());
|
||||||
return convertToPDF(envelope, environment);
|
// return convertToPDF(envelope, environment);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static File convertToPDF(FileEnvelope file, Environment environment) throws IOException {
|
// public static File convertToPDF(FileEnvelope file, Environment environment) throws IOException {
|
||||||
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
// LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||||
String uuid = UUID.randomUUID().toString();
|
// String uuid = UUID.randomUUID().toString();
|
||||||
map.add("files", new FileSystemResource(file.getFile()));
|
// map.add("files", new FileSystemResource(file.getFile()));
|
||||||
map.add("filename", uuid + ".pdf");
|
// map.add("filename", uuid + ".pdf");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
// HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||||
headers.add("Content-disposition", "attachment; filename=" + uuid + ".pdf");
|
// headers.add("Content-disposition", "attachment; filename=" + uuid + ".pdf");
|
||||||
headers.add("Content-type", "application/pdf");
|
// headers.add("Content-type", "application/pdf");
|
||||||
|
//
|
||||||
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
|
// HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
|
||||||
map, headers);
|
// map, headers);
|
||||||
|
//
|
||||||
byte[] queueResult = new RestTemplate().postForObject(environment.getProperty("pdf.converter.url") + "forms/libreoffice/convert"
|
// byte[] queueResult = new RestTemplate().postForObject(environment.getProperty("pdf.converter.url") + "forms/libreoffice/convert"
|
||||||
, requestEntity, byte[].class);
|
// , requestEntity, byte[].class);
|
||||||
|
//
|
||||||
File resultPdf = new File(environment.getProperty("temp.temp") + uuid + ".pdf");
|
// File resultPdf = new File(environment.getProperty("temp.temp") + uuid + ".pdf");
|
||||||
FileOutputStream output = new FileOutputStream(resultPdf);
|
// FileOutputStream output = new FileOutputStream(resultPdf);
|
||||||
IOUtils.write(queueResult, output);
|
// IOUtils.write(queueResult, output);
|
||||||
output.close();
|
// output.close();
|
||||||
Files.deleteIfExists(file.getFile().toPath());
|
// Files.deleteIfExists(file.getFile().toPath());
|
||||||
|
//
|
||||||
return resultPdf;
|
// return resultPdf;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>2.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
import eu.eudat.model.file.FileEnvelope;
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
@ -221,7 +220,7 @@ public class DMPs extends BaseController {
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
||||||
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, configLoader);
|
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, configLoader);
|
||||||
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replace(" ", "_").replace(",", "_");
|
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replace(" ", "_").replace(",", "_");
|
||||||
File pdffile = PDFUtils.convertToPDF(file, environment);
|
File pdffile = null; //PDFUtils.convertToPDF(file, environment); //TODO
|
||||||
InputStream resource = new FileInputStream(pdffile);
|
InputStream resource = new FileInputStream(pdffile);
|
||||||
logger.info("Mime Type of " + name + " is " +
|
logger.info("Mime Type of " + name + " is " +
|
||||||
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
||||||
|
|
|
@ -3,11 +3,7 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
|
||||||
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
|
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
@ -19,19 +15,15 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
import eu.eudat.model.file.FileEnvelope;
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
|
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import jakarta.persistence.NoResultException;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -44,9 +36,6 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.persistence.NoResultException;
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -244,7 +233,7 @@ public class Datasets extends BaseController {
|
||||||
if (fileName.endsWith(".docx")){
|
if (fileName.endsWith(".docx")){
|
||||||
fileName = fileName.substring(0, fileName.length() - 5);
|
fileName = fileName.substring(0, fileName.length() - 5);
|
||||||
}
|
}
|
||||||
File pdffile = PDFUtils.convertToPDF(file, environment);
|
File pdffile = null; // PDFUtils.convertToPDF(file, environment); //TODO
|
||||||
InputStream resource = new FileInputStream(pdffile);
|
InputStream resource = new FileInputStream(pdffile);
|
||||||
|
|
||||||
HttpHeaders responseHeaders = new HttpHeaders();
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.DepositManager;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.model.EntityDoi;
|
|
||||||
import eu.eudat.model.doi.DepositCode;
|
|
||||||
import eu.eudat.model.doi.DepositRequest;
|
|
||||||
import eu.eudat.model.doi.Doi;
|
|
||||||
import eu.eudat.model.doi.RepositoryConfig;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.service.deposit.RepositoryDepositService;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
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/deposit/"})
|
|
||||||
public class DepositController extends BaseController {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DepositController.class);
|
|
||||||
|
|
||||||
private final DepositManager depositManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
private final RepositoryDepositService repositoryDepositService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DepositController(ApiContext apiContext, DepositManager depositManager, AuthorizationService authorizationService, RepositoryDepositService repositoryDepositService){
|
|
||||||
super(apiContext);
|
|
||||||
this.depositManager = depositManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
this.repositoryDepositService = repositoryDepositService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/repos"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<RepositoryConfig>>> getAvailableRepos() {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
|
|
||||||
List<RepositoryConfig> ids = this.repositoryDepositService.getAvailableConfigurations();
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RepositoryConfig>>().status(ApiMessageCode.NO_MESSAGE).payload(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAccessToken"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<String>> getAccessToken(@RequestBody DepositCode depositCode) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
|
|
||||||
String accessToken = this.depositManager.authenticate(depositCode.getRepositoryId(), depositCode.getCode());
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE).payload(accessToken));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/createDoi"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<EntityDoi>> createDoi(@RequestBody DepositRequest depositRequest) {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
try {
|
|
||||||
EntityDoi doi = this.repositoryDepositService.deposit(depositRequest);
|
|
||||||
if(doi != null){
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<EntityDoi>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(doi));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<EntityDoi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan"));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<EntityDoi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/logo/{repositoryId}"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<String>> getLogo(@PathVariable("repositoryId") String repositoryId) {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
try {
|
|
||||||
String encodedLogo = this.repositoryDepositService.getLogo(repositoryId);
|
|
||||||
if(encodedLogo != null){
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully loaded " + repositoryId + "'s logo.").payload(encodedLogo));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(repositoryId + " has no logo").payload(null));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to load " + repositoryId + "'s logo: " + e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
|
import eu.eudat.audit.AuditableAction;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.controllers.BaseController;
|
||||||
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import eu.eudat.model.EntityDoi;
|
||||||
|
import eu.eudat.model.censorship.EntityDoiCensor;
|
||||||
|
import eu.eudat.model.censorship.deposit.DepositConfigurationCensor;
|
||||||
|
import eu.eudat.model.deposit.DepositConfiguration;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
|
import eu.eudat.service.deposit.DepositService;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import gr.cite.tools.validation.MyValidate;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping(value = {"/api/deposit/"})
|
||||||
|
public class DepositController extends BaseController {
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositController.class));
|
||||||
|
|
||||||
|
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
private final DepositService depositService;
|
||||||
|
private final CensorFactory censorFactory;
|
||||||
|
private final AuditService auditService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DepositController(ApiContext apiContext, AuthorizationService authorizationService, DepositService depositService, CensorFactory censorFactory, AuditService auditService){
|
||||||
|
super(apiContext);
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
this.depositService = depositService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
this.auditService = auditService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/repositories/available")
|
||||||
|
public List<eu.eudat.model.deposit.DepositConfiguration> getAvailableRepos(FieldSet fieldSet) {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + DepositConfiguration.class.getSimpleName()).And("fields", fieldSet));
|
||||||
|
|
||||||
|
this.censorFactory.censor(DepositConfigurationCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
List<DepositConfiguration> model = this.depositService.getAvailableConfigurations(fieldSet);
|
||||||
|
this.auditService.track(AuditableAction.Deposit_GetAvailableRepositories, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/get-access-token")
|
||||||
|
public String getAccessToken(@MyValidate @RequestBody DepositAuthenticateRequest model) throws Exception {
|
||||||
|
logger.debug(new MapLogEntry("get access token" + DepositAuthenticateRequest.class.getSimpleName()).And("model", model));
|
||||||
|
|
||||||
|
String accessToken = this.depositService.authenticate(model);
|
||||||
|
this.auditService.track(AuditableAction.Deposit_GetAccessToken, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
||||||
|
));
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deposit")
|
||||||
|
@Transactional
|
||||||
|
public EntityDoi deposit(@MyValidate @RequestBody DepositRequest model) throws Exception {
|
||||||
|
logger.debug(new MapLogEntry("persisting" + DepositRequest.class.getSimpleName()).And("model", model).And("fieldSet", model.getProject()));
|
||||||
|
this.censorFactory.censor(EntityDoiCensor.class).censor(model.getProject(), null);
|
||||||
|
|
||||||
|
EntityDoi persisted = this.depositService.deposit(model);
|
||||||
|
this.auditService.track(AuditableAction.Deposit_Deposit, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
||||||
|
));
|
||||||
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
|
return persisted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/repositories/{repositoryId}/logo")
|
||||||
|
public String getLogo(@PathVariable("repositoryId") String repositoryId) {
|
||||||
|
logger.debug(new MapLogEntry("get logo" + DepositConfiguration.class.getSimpleName()).And("repositoryId", repositoryId));
|
||||||
|
|
||||||
|
String logo = this.depositService.getLogo(repositoryId);
|
||||||
|
this.auditService.track(AuditableAction.Deposit_GetLogo, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("repositoryId", repositoryId)
|
||||||
|
));
|
||||||
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
|
return logo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -94,7 +94,7 @@ public class DescriptionTemplateController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
public DescriptionTemplate get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
public DescriptionTemplate get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
logger.debug(new MapLogEntry("retrieving" + DescriptionTemplate.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
logger.debug(new MapLogEntry("retrieving" + DescriptionTemplate.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null);
|
||||||
|
|
|
@ -19,8 +19,7 @@ import eu.eudat.commons.enums.old.notification.NotifyState;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
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.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
import eu.eudat.depositinterface.models.DmpDepositModel;
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
||||||
import eu.eudat.exceptions.security.ForbiddenException;
|
import eu.eudat.exceptions.security.ForbiddenException;
|
||||||
|
@ -28,20 +27,18 @@ import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.mapper.deposit.DMPToDepositMapper;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
import eu.eudat.model.EntityDoi;
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
import eu.eudat.model.file.FileEnvelope;
|
||||||
import eu.eudat.query.*;
|
import eu.eudat.query.*;
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
|
||||||
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
||||||
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
||||||
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
|
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
|
||||||
import eu.eudat.model.doi.DepositRequest;
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
import eu.eudat.model.doi.Doi;
|
|
||||||
import eu.eudat.models.HintedModelFactory;
|
import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
@ -57,6 +54,7 @@ import eu.eudat.models.data.listingmodels.*;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import eu.eudat.service.deposit.DepositService;
|
||||||
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
@ -114,7 +112,7 @@ public class DataManagementPlanManager {
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private final MetricsManager metricsManager;
|
private final MetricsManager metricsManager;
|
||||||
private final ConfigLoader configLoader;
|
private final ConfigLoader configLoader;
|
||||||
private List<RepositoryDeposit> repositoriesDeposit;
|
private DepositService repositoriesDeposit;
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final DmpBlueprintService dmpBlueprintService;
|
private final DmpBlueprintService dmpBlueprintService;
|
||||||
|
@ -123,7 +121,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DataManagementPlanManager(XmlHandlingService xmlHandlingService, ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager,
|
public DataManagementPlanManager(XmlHandlingService xmlHandlingService, ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager,
|
||||||
MetricsManager metricsManager, ConfigLoader configLoader, List<RepositoryDeposit> repositoriesDeposit, UserScope userScope, AuthorizationService authorizationService, DmpBlueprintService dmpBlueprintService, QueryFactory queryFactory) {
|
MetricsManager metricsManager, ConfigLoader configLoader, DepositService repositoriesDeposit, UserScope userScope, AuthorizationService authorizationService, DmpBlueprintService dmpBlueprintService, QueryFactory queryFactory) {
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
|
@ -2573,8 +2571,8 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Doi createDoi(DepositRequest depositRequest) throws Exception {
|
public EntityDoi createDoi(DepositRequest depositRequest) throws Exception {
|
||||||
DmpEntity dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId()));
|
DmpEntity dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(depositRequest.getDmpId());
|
||||||
if (!isUserOwnerOfDmp(dmp))
|
if (!isUserOwnerOfDmp(dmp))
|
||||||
throw new Exception("User is not authorized to invoke this action");
|
throw new Exception("User is not authorized to invoke this action");
|
||||||
if (!dmp.getStatus().equals(DmpStatus.Finalized))
|
if (!dmp.getStatus().equals(DmpStatus.Finalized))
|
||||||
|
@ -2582,16 +2580,16 @@ public class DataManagementPlanManager {
|
||||||
/*if (dmp.getDoi() != null)
|
/*if (dmp.getDoi() != null)
|
||||||
throw new Exception("DMP already has a DOI");*/
|
throw new Exception("DMP already has a DOI");*/
|
||||||
|
|
||||||
FileEnvelope file = getWordDocument(depositRequest.getDmpId(), configLoader);
|
FileEnvelope file = getWordDocument(depositRequest.getDmpId().toString(), configLoader);
|
||||||
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replaceAll("[^a-zA-Z0-9_+ ]", "").replace(" ", "_").replace(",", "_");
|
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replaceAll("[^a-zA-Z0-9_+ ]", "").replace(" ", "_").replace(",", "_");
|
||||||
File pdfFile = PDFUtils.convertToPDF(file, environment);
|
byte[] pdfFile = null; //PDFUtils.convertToPDF(file, environment); //TODO
|
||||||
eu.eudat.depositinterface.models.FileEnvelope pdfEnvelope = new eu.eudat.depositinterface.models.FileEnvelope();
|
eu.eudat.depositinterface.models.FileEnvelope pdfEnvelope = new eu.eudat.depositinterface.models.FileEnvelope();
|
||||||
pdfEnvelope.setFile(pdfFile);
|
pdfEnvelope.setFile(pdfFile);
|
||||||
pdfEnvelope.setFilename(name + ".pdf");
|
pdfEnvelope.setFilename(name + ".pdf");
|
||||||
eu.eudat.depositinterface.models.FileEnvelope rdaJsonFile = new eu.eudat.depositinterface.models.FileEnvelope();
|
eu.eudat.depositinterface.models.FileEnvelope rdaJsonFile = new eu.eudat.depositinterface.models.FileEnvelope();
|
||||||
try {
|
try {
|
||||||
FileEnvelope rdaJsonDocument = getRDAJsonDocument(depositRequest.getDmpId());
|
FileEnvelope rdaJsonDocument = getRDAJsonDocument(depositRequest.getDmpId().toString());
|
||||||
rdaJsonFile.setFile(rdaJsonDocument.getFile());
|
//rdaJsonFile.setFile(rdaJsonDocument.getFile()); //TODO
|
||||||
rdaJsonFile.setFilename(rdaJsonDocument.getFilename());
|
rdaJsonFile.setFilename(rdaJsonDocument.getFilename());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
@ -2600,20 +2598,16 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
File supportingFilesZip = this.createSupportingFilesZip(dmp);
|
File supportingFilesZip = this.createSupportingFilesZip(dmp);
|
||||||
|
|
||||||
DMPDepositModel dmpDepositModel = DMPToDepositMapper.fromDMP(dmp, pdfEnvelope, rdaJsonFile, supportingFilesZip, previousDOI);
|
DmpDepositModel dmpDepositModel = new DmpDepositModel(); // DMPToDepositMapper.fromDMP(dmp, pdfEnvelope, rdaJsonFile, supportingFilesZip, previousDOI);//TODO
|
||||||
|
|
||||||
String finalDoi = null;
|
String finalDoi = null;
|
||||||
for(RepositoryDeposit repo: this.repositoriesDeposit){
|
|
||||||
if(repo.getConfiguration().stream().anyMatch(x-> x.getRepositoryId().equals(depositRequest.getRepositoryId()))){
|
|
||||||
try {
|
try {
|
||||||
finalDoi = repo.deposit(depositRequest.getRepositoryId(), dmpDepositModel, depositRequest.getAccessToken());
|
finalDoi = this.repositoriesDeposit.deposit(depositRequest).getDoi();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
EntityDoi doiModel = null;
|
||||||
}
|
|
||||||
Doi doiModel = null;
|
|
||||||
if (finalDoi != null) {
|
if (finalDoi != null) {
|
||||||
|
|
||||||
EntityDoiEntity doiEntity = new EntityDoiEntity();
|
EntityDoiEntity doiEntity = new EntityDoiEntity();
|
||||||
|
@ -2630,15 +2624,15 @@ public class DataManagementPlanManager {
|
||||||
// dmp.getDois().add(doiEntity);
|
// dmp.getDois().add(doiEntity);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||||
|
|
||||||
doiModel = new Doi().fromDataModel(doiEntity);
|
doiModel = new EntityDoi();//.fromDataModel(doiEntity); //TODO
|
||||||
|
|
||||||
}
|
}
|
||||||
if(supportingFilesZip != null) {
|
if(supportingFilesZip != null) {
|
||||||
Files.deleteIfExists(supportingFilesZip.toPath());
|
Files.deleteIfExists(supportingFilesZip.toPath());
|
||||||
}
|
}
|
||||||
Files.deleteIfExists(rdaJsonFile.getFile().toPath());
|
// Files.deleteIfExists(rdaJsonFile.getFile().toPath()); //TODO
|
||||||
Files.deleteIfExists(pdfFile.toPath());
|
// Files.deleteIfExists(pdfFile.toPath());
|
||||||
Files.deleteIfExists(file.getFile().toPath());
|
// Files.deleteIfExists(file.getFile().toPath());
|
||||||
|
|
||||||
return doiModel;
|
return doiModel;
|
||||||
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
|
||||||
import eu.eudat.model.doi.DepositRequest;
|
|
||||||
import eu.eudat.model.doi.Doi;
|
|
||||||
import eu.eudat.model.doi.RepositoryConfig;
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class DepositManager {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DepositManager.class);
|
|
||||||
|
|
||||||
//private List<RepositoryDeposit> repositories;
|
|
||||||
private DataManagementPlanManager dataManagementPlanManager;
|
|
||||||
private final List<RepositoryDeposit> depositClients;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DepositManager(/*List<RepositoryDeposit> repositories,*/ DataManagementPlanManager dataManagementPlanManager, @Qualifier("depositClients") List<RepositoryDeposit> depositClients){
|
|
||||||
//this.repositories = repositories;
|
|
||||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
|
||||||
this.depositClients = depositClients;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RepositoryConfig> getAvailableRepos() {
|
|
||||||
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
|
|
||||||
for (RepositoryDeposit r: this.depositClients) {
|
|
||||||
List<RepositoryDepositConfiguration> repoConf = r.getConfiguration();
|
|
||||||
if(repoConf != null) {
|
|
||||||
for(RepositoryDepositConfiguration cf: repoConf){
|
|
||||||
RepositoryConfig repoModel = new RepositoryConfig();
|
|
||||||
reposConfigModel.add(repoModel.toModel(cf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return reposConfigModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String authenticate(String id, String code) {
|
|
||||||
for(RepositoryDeposit r: this.depositClients){
|
|
||||||
if(r.getConfiguration().stream().anyMatch(x -> x.getRepositoryId().equals(id))){
|
|
||||||
return r.authenticate(id, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Doi deposit(DepositRequest depositRequest) throws Exception {
|
|
||||||
return this.dataManagementPlanManager.createDoi(depositRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRepositoryLogo(String repositoryId){
|
|
||||||
for(RepositoryDeposit r: this.depositClients){
|
|
||||||
Optional<RepositoryDepositConfiguration> cf = r.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst();
|
|
||||||
if(cf.isPresent()){
|
|
||||||
return cf.get().isHasLogo() ? r.getLogo(repositoryId) : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.doi.Doi;
|
import eu.eudat.model.EntityDoi;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||||
|
@ -33,7 +33,7 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
|
||||||
private List<DynamicFieldWithValue> dynamicFields;
|
private List<DynamicFieldWithValue> dynamicFields;
|
||||||
private Map<String, Object> properties;
|
private Map<String, Object> properties;
|
||||||
private List<DmpUser> users;
|
private List<DmpUser> users;
|
||||||
private List<Doi> dois;
|
private List<EntityDoi> dois;
|
||||||
private Project project;
|
private Project project;
|
||||||
private Funder funder;
|
private Funder funder;
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
|
@ -173,10 +173,10 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Doi> getDois() {
|
public List<EntityDoi> getDois() {
|
||||||
return dois;
|
return dois;
|
||||||
}
|
}
|
||||||
public void setDois(List<Doi> dois) {
|
public void setDois(List<EntityDoi> dois) {
|
||||||
this.dois = dois;
|
this.dois = dois;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.doi.Doi;
|
import eu.eudat.model.EntityDoi;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
|
@ -14,9 +10,9 @@ import eu.eudat.models.data.dmp.Organisation;
|
||||||
import eu.eudat.models.data.dmp.Researcher;
|
import eu.eudat.models.data.dmp.Researcher;
|
||||||
import eu.eudat.models.data.grant.GrantOverviewModel;
|
import eu.eudat.models.data.grant.GrantOverviewModel;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, DataManagementPlanOverviewModel> {
|
public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, DataManagementPlanOverviewModel> {
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -37,7 +33,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
|
||||||
private String description;
|
private String description;
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
private List<Doi> dois;
|
private List<EntityDoi> dois;
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -166,10 +162,10 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Doi> getDois() {
|
public List<EntityDoi> getDois() {
|
||||||
return dois;
|
return dois;
|
||||||
}
|
}
|
||||||
public void setDois(List<Doi> dois) {
|
public void setDois(List<EntityDoi> dois) {
|
||||||
this.dois = dois;
|
this.dois = dois;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,6 @@ cache:
|
||||||
manager:
|
manager:
|
||||||
fallbackToNoOpCache: true
|
fallbackToNoOpCache: true
|
||||||
caffeineCaches:
|
caffeineCaches:
|
||||||
- names: [ "apikey" ]
|
|
||||||
allowNullValues: true
|
|
||||||
initialCapacity: 100
|
|
||||||
maximumSize: 500
|
|
||||||
enableRecordStats: false
|
|
||||||
expireAfterWriteMinutes: 10
|
|
||||||
expireAfterAccessMinutes: 10
|
|
||||||
refreshAfterWriteMinutes: 10
|
|
||||||
- names: [ "userBySubjectId" ]
|
- names: [ "userBySubjectId" ]
|
||||||
allowNullValues: true
|
allowNullValues: true
|
||||||
initialCapacity: 100
|
initialCapacity: 100
|
||||||
|
@ -34,7 +26,7 @@ cache:
|
||||||
expireAfterWriteMinutes: 10
|
expireAfterWriteMinutes: 10
|
||||||
expireAfterAccessMinutes: 10
|
expireAfterAccessMinutes: 10
|
||||||
refreshAfterWriteMinutes: 10
|
refreshAfterWriteMinutes: 10
|
||||||
- names: [ "deposit" ]
|
- names: [ "depositConfigById" ]
|
||||||
allowNullValues: true
|
allowNullValues: true
|
||||||
initialCapacity: 100
|
initialCapacity: 100
|
||||||
maximumSize: 500
|
maximumSize: 500
|
||||||
|
@ -51,9 +43,6 @@ cache:
|
||||||
expireAfterAccessMinutes: 1
|
expireAfterAccessMinutes: 1
|
||||||
refreshAfterWriteMinutes: 1
|
refreshAfterWriteMinutes: 1
|
||||||
mapCaches:
|
mapCaches:
|
||||||
apiKey:
|
|
||||||
name: apikey
|
|
||||||
keyPattern: resolve_$keyhash$:v0
|
|
||||||
userBySubjectId:
|
userBySubjectId:
|
||||||
name: userBySubjectId
|
name: userBySubjectId
|
||||||
keyPattern: user_by_subject_$subject$:v0
|
keyPattern: user_by_subject_$subject$:v0
|
||||||
|
@ -66,6 +55,6 @@ cache:
|
||||||
dashboardStatisticsByUserId:
|
dashboardStatisticsByUserId:
|
||||||
name: dashboardStatisticsByUserId
|
name: dashboardStatisticsByUserId
|
||||||
keyPattern: dashboard_stats_by_usr_$key$:v0
|
keyPattern: dashboard_stats_by_usr_$key$:v0
|
||||||
deposit:
|
depositConfigById:
|
||||||
name: deposit
|
name: depositConfigById
|
||||||
keyPattern: base:v0
|
keyPattern: deposit_config_by_id_$repositoryId$:v0
|
|
@ -94,6 +94,20 @@ permissions:
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# Deposit
|
||||||
|
BrowseDeposit:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditDeposit:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
# Language
|
# Language
|
||||||
BrowseLanguage:
|
BrowseLanguage:
|
||||||
roles: [ ]
|
roles: [ ]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
dmp.domain = http://localhost:4200
|
dmp.domain = http://localhost:4200
|
||||||
|
|
||||||
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
|
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
|
||||||
database.url=jdbc:postgresql://dbserver02.local.cite.gr:5432/dmptool
|
database.url=jdbc:postgresql://dbserver05.local.cite.gr/opendmp-prod-anonym
|
||||||
database.username=dmtadm
|
database.username=opendmp-psql
|
||||||
database.password=t00L4DM@18!
|
database.password=EG$NCKq&mARNFCtFfM
|
||||||
spring.datasource.maxIdle=10
|
spring.datasource.maxIdle=10
|
||||||
spring.datasource.minIdle=5
|
spring.datasource.minIdle=5
|
||||||
spring.datasource.maxActive=10
|
spring.datasource.maxActive=10
|
||||||
|
|
Loading…
Reference in New Issue