From 7bb8e850e8d536627d202bf056d493c518bc5691 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 3 Nov 2023 17:54:26 +0200 Subject: [PATCH] Add first implementation of the new Repository Deposit Service --- .../RepositoryDepositConfigurationCache.java | 21 ++ .../configurations/DepositConfiguration.java | 50 ----- .../deposit/DepositCacheOptions.java | 9 + .../deposit/DepositConfiguration.java | 9 + .../{ => deposit}/DepositProperties.java | 2 +- .../java/eu/eudat/model}/doi/DepositCode.java | 2 +- .../eu/eudat/model}/doi/DepositRequest.java | 2 +- .../main/java/eu/eudat/model}/doi/Doi.java | 26 +-- .../eu/eudat/model}/doi/RepositoryConfig.java | 24 +- .../eu/eudat/model/doi/RepositoryConfigs.java | 22 ++ .../eu/eudat/model/file}/FileEnvelope.java | 2 +- .../mapper/deposit}/DMPToDepositMapper.java | 2 +- .../deposit/DmpEntityDepositMapper.java | 161 ++++++++++++++ .../eudat/repository/DepositRepository.java | 7 + .../deposit/RepositoryDepositService.java | 207 ++++++++++++++++++ .../eu/eudat/utilities}/pdf/PDFUtils.java | 11 +- .../main/java/eu/eudat/controllers/DMPs.java | 4 +- .../java/eu/eudat/controllers/Datasets.java | 4 +- .../eudat/controllers/DepositController.java | 8 +- .../eu/eudat/controllers/FileController.java | 2 +- .../managers/DataManagementPlanManager.java | 10 +- .../eudat/logic/managers/DatasetManager.java | 2 +- .../eudat/logic/managers/DepositManager.java | 6 +- .../models/data/dmp/DataManagementPlan.java | 2 +- .../DataManagementPlanOverviewModel.java | 2 +- .../web/src/main/resources/config/cache.yml | 13 +- 26 files changed, 509 insertions(+), 101 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/configurations/DepositConfiguration.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositCacheOptions.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositConfiguration.java rename dmp-backend/core/src/main/java/eu/eudat/configurations/{ => deposit}/DepositProperties.java (97%) rename dmp-backend/{web/src/main/java/eu/eudat/models/data => core/src/main/java/eu/eudat/model}/doi/DepositCode.java (92%) rename dmp-backend/{web/src/main/java/eu/eudat/models/data => core/src/main/java/eu/eudat/model}/doi/DepositRequest.java (94%) rename dmp-backend/{web/src/main/java/eu/eudat/models/data => core/src/main/java/eu/eudat/model}/doi/Doi.java (72%) rename dmp-backend/{web/src/main/java/eu/eudat/models/data => core/src/main/java/eu/eudat/model}/doi/RepositoryConfig.java (70%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfigs.java rename dmp-backend/{web/src/main/java/eu/eudat/logic/utilities/documents/helpers => core/src/main/java/eu/eudat/model/file}/FileEnvelope.java (89%) rename dmp-backend/{web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper => core/src/main/java/eu/eudat/model/mapper/deposit}/DMPToDepositMapper.java (99%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java rename dmp-backend/{web/src/main/java/eu/eudat/logic/utilities/documents => core/src/main/java/eu/eudat/utilities}/pdf/PDFUtils.java (81%) diff --git a/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java b/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java new file mode 100644 index 000000000..904bf2e3d --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/cache/deposit/RepositoryDepositConfigurationCache.java @@ -0,0 +1,21 @@ +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 { + @Autowired + public RepositoryDepositConfigurationCache(DepositCacheOptions options) { + super(options); + } + + @Override + protected Class valueClass() { + return RepositoryConfigs.class; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositConfiguration.java deleted file mode 100644 index 23c2dfacc..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositConfiguration.java +++ /dev/null @@ -1,50 +0,0 @@ -package eu.eudat.configurations; - -import eu.eudat.depositinterface.repository.RepositoryDeposit; -import eu.eudat.repository.DepositRepository; -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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.client.WebClient; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -@Configuration -@EnableConfigurationProperties({DepositProperties.class}) -public class DepositConfiguration { - private static final Logger logger = LoggerFactory.getLogger(DepositConfiguration.class); - - private final DepositProperties properties; - - private final ApiKeyCacheService apiKeyCacheService; - - @Autowired - public DepositConfiguration(DepositProperties properties, ApiKeyCacheService apiKeyCacheService) { - this.properties = properties; - this.apiKeyCacheService = apiKeyCacheService; - } - - @Bean - @Qualifier("depositClients") - public List depositClients() { - List clients = new ArrayList<>(); - for (DepositProperties.DepositSource source: properties.getSources()) { - - 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); - - clients.add(new DepositRepository(WebClient.builder().baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build())); - } - return clients; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositCacheOptions.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositCacheOptions.java new file mode 100644 index 000000000..6b673806f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositCacheOptions.java @@ -0,0 +1,9 @@ +package eu.eudat.configurations.deposit; + +import gr.cite.tools.cache.CacheOptions; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@ConfigurationProperties(prefix = "cache.deposit") +public class DepositCacheOptions extends CacheOptions { +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositConfiguration.java new file mode 100644 index 000000000..804107ac8 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositConfiguration.java @@ -0,0 +1,9 @@ +package eu.eudat.configurations.deposit; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties({DepositProperties.class, DepositCacheOptions.class}) +public class DepositConfiguration { +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java similarity index 97% rename from dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java rename to dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java index 162d1fd52..819fb90a7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/deposit/DepositProperties.java @@ -1,4 +1,4 @@ -package eu.eudat.configurations; +package eu.eudat.configurations.deposit; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.bind.ConstructorBinding; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositCode.java b/dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositCode.java similarity index 92% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositCode.java rename to dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositCode.java index a567dc9da..f60742540 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositCode.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositCode.java @@ -1,4 +1,4 @@ -package eu.eudat.models.data.doi; +package eu.eudat.model.doi; public class DepositCode { diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositRequest.java b/dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositRequest.java similarity index 94% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositRequest.java rename to dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositRequest.java index b6ee1f4a3..7502769b3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/DepositRequest.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/doi/DepositRequest.java @@ -1,4 +1,4 @@ -package eu.eudat.models.data.doi; +package eu.eudat.model.doi; public class DepositRequest { diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/Doi.java b/dmp-backend/core/src/main/java/eu/eudat/model/doi/Doi.java similarity index 72% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/doi/Doi.java rename to dmp-backend/core/src/main/java/eu/eudat/model/doi/Doi.java index 58fc97398..878e857c1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/Doi.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/doi/Doi.java @@ -1,8 +1,7 @@ -package eu.eudat.models.data.doi; +package eu.eudat.model.doi; import eu.eudat.data.EntityDoiEntity; -import eu.eudat.models.DataModel; -import eu.eudat.models.data.dmp.DataManagementPlan; +import eu.eudat.model.Dmp; import java.util.Date; import java.util.UUID; @@ -13,7 +12,7 @@ public class Doi { private String doi; private Date createdAt; private Date updatedAt; - private DataManagementPlan dmp; + private Dmp dmp; public UUID getId() { return id; @@ -50,20 +49,21 @@ public class Doi { this.updatedAt = updatedAt; } - public DataManagementPlan getDmp() { + public Dmp getDmp() { return dmp; } - public void setDmp(DataManagementPlan dmp) { + public void setDmp(Dmp dmp) { this.dmp = dmp; } - public Doi fromDataModel(EntityDoiEntity entity) { - this.id = entity.getId(); - this.repositoryId = entity.getRepositoryId(); - this.doi = entity.getDoi(); - this.createdAt = Date.from(entity.getCreatedAt()); - this.updatedAt = Date.from(entity.getUpdatedAt()); - return this; + 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 { diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/RepositoryConfig.java b/dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfig.java similarity index 70% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/doi/RepositoryConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfig.java index 1c45346a0..ec62f7f09 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/doi/RepositoryConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfig.java @@ -1,7 +1,9 @@ -package eu.eudat.models.data.doi; +package eu.eudat.model.doi; import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration; +import java.util.List; + public class RepositoryConfig { private int depositType; @@ -61,14 +63,16 @@ public class RepositoryConfig { this.hasLogo = hasLogo; } - public RepositoryConfig toModel(RepositoryDepositConfiguration r){ - this.setDepositType(r.getDepositType()); - this.setRepositoryId(r.getRepositoryId()); - this.setRepositoryAuthorizationUrl(r.getRepositoryAuthorizationUrl()); - this.setRepositoryRecordUrl(r.getRepositoryRecordUrl()); - this.setRepositoryClientId(r.getRepositoryClientId()); - this.setRedirectUri(r.getRedirectUri()); - this.setHasLogo(r.isHasLogo()); - return this; + 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; } } + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfigs.java b/dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfigs.java new file mode 100644 index 000000000..b414bcb0e --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/doi/RepositoryConfigs.java @@ -0,0 +1,22 @@ +package eu.eudat.model.doi; + +import java.util.List; + +public class RepositoryConfigs { + private List repositoryConfigs; + + public RepositoryConfigs() { + } + + public RepositoryConfigs(List repositoryConfigs) { + this.repositoryConfigs = repositoryConfigs; + } + + public List getRepositoryConfigs() { + return repositoryConfigs; + } + + public void setRepositoryConfigs(List repositoryConfigs) { + this.repositoryConfigs = repositoryConfigs; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/helpers/FileEnvelope.java b/dmp-backend/core/src/main/java/eu/eudat/model/file/FileEnvelope.java similarity index 89% rename from dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/helpers/FileEnvelope.java rename to dmp-backend/core/src/main/java/eu/eudat/model/file/FileEnvelope.java index 899b4a3b6..3b5b25e39 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/helpers/FileEnvelope.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/file/FileEnvelope.java @@ -1,4 +1,4 @@ -package eu.eudat.logic.utilities.documents.helpers; +package eu.eudat.model.file; import java.io.File; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DMPToDepositMapper.java similarity index 99% rename from dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java rename to dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DMPToDepositMapper.java index e26ffbfdf..a1e3f9bb9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DMPToDepositMapper.java @@ -1,4 +1,4 @@ -package eu.eudat.logic.security.repositorydeposit.mapper; +package eu.eudat.model.mapper.deposit; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java new file mode 100644 index 000000000..e9d360f16 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java @@ -0,0 +1,161 @@ +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.DescriptionEntity; +import eu.eudat.data.DescriptionTemplateEntity; +import eu.eudat.data.DmpEntity; +import eu.eudat.data.old.UserDMP; +import eu.eudat.data.old.UserInfo; +import eu.eudat.depositinterface.models.*; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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 EntityManager entityManager; + + public DmpEntityDepositMapper(EntityManager entityManager) { + this.entityManager = entityManager; + 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 desciptions = this.getDescriptions(dmpEntity.getId()); + List 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 getDescriptions(UUID dmpId) { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(DescriptionEntity.class); + Root root = query.from(DescriptionEntity.class); + query = query.where(builder.and(builder.equal(root.get("dmp"), dmpId), builder.equal(root.get("isActive"), IsActive.Active))); + return entityManager.createQuery(query).getResultList(); + + } + + 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.getProfile()); + model.setProfileDefinition(descriptionTemplateEntity.getDefinition()); + model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties())); + return model; + } + + private DescriptionTemplateEntity getDescriptionTemplate(UUID descId) { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(DescriptionTemplateEntity.class); + Root root = query.from(DescriptionTemplateEntity.class); + query = query.where(builder.and(builder.equal(root.get("id"), descId), builder.equal(root.get("isActive"), IsActive.Active))); + return entityManager.createQuery(query).getSingleResult(); + } + + private List fromDefinitionAndProperties(String definition, String properties){ + List deposit = new ArrayList<>(); + try { + + Map 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 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 getUsers(UUID dmpId) { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(UserDMP.class); + Root root = query.from(UserDMP.class); + Join join = root.join("user").join("id"); + query = query.multiselect(root.get("user"), root.get("role")); + return entityManager.createQuery(query).getResultList(); + } + + private UserDMPDepositModel toUserDeposit(UserDMP user) { + UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel(); + userDMPDepositModel.setUser(new UserInfoDepositModel()); + userDMPDepositModel.getUser().setName(user.getUser().getName()); + userDMPDepositModel.getUser().setEmail(user.getUser().getEmail()); + userDMPDepositModel.setRole(user.getRole()); + + return userDMPDepositModel; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/repository/DepositRepository.java b/dmp-backend/core/src/main/java/eu/eudat/repository/DepositRepository.java index c0dd332b3..9bfb21bca 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/repository/DepositRepository.java +++ b/dmp-backend/core/src/main/java/eu/eudat/repository/DepositRepository.java @@ -6,14 +6,17 @@ 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; + private final List configurationIds; public DepositRepository(WebClient depositClient) { this.depositClient = depositClient; + this.configurationIds = new ArrayList<>(); } @@ -36,4 +39,8 @@ public class DepositRepository implements RepositoryDeposit { public String getLogo(String repositoryId) { return depositClient.get().uri("/logo/" + repositoryId).exchangeToMono(mono -> mono.bodyToMono(String.class)).block(); } + + public List getConfigurationIds() { + return configurationIds; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java new file mode 100644 index 000000000..19f95fe43 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java @@ -0,0 +1,207 @@ +package eu.eudat.service.deposit; + +import eu.eudat.authorization.Permission; +import eu.eudat.cache.deposit.RepositoryDepositConfigurationCache; +import eu.eudat.commons.enums.EntityType; +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.data.old.DMP; +import eu.eudat.depositinterface.models.DMPDepositModel; +import eu.eudat.depositinterface.models.FileEnvelope; +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 eu.eudat.model.doi.RepositoryConfigs; +import eu.eudat.model.mapper.deposit.DmpEntityDepositMapper; +import eu.eudat.repository.DepositRepository; +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 jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Root; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +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 java.io.File; +import java.io.IOException; +import java.net.URI; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Service +public class RepositoryDepositService { + private static final Logger logger = LoggerFactory.getLogger(RepositoryDepositService.class); + + private final DepositProperties depositProperties; + private final List clients; + private final ApiKeyCacheService apiKeyCacheService; + private final RepositoryDepositConfigurationCache repositoryDepositConfigurationCache; + private final EntityManager entityManager; + private final AuthorizationService authorizationService; + private final ConventionService conventionService; + private final Environment environment; + private final DmpEntityDepositMapper depositMapper; + + @Autowired + public RepositoryDepositService(DepositProperties depositProperties, ApiKeyCacheService apiKeyCacheService, RepositoryDepositConfigurationCache repositoryDepositConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, Environment environment, DmpEntityDepositMapper depositMapper) { + this.depositProperties = depositProperties; + this.apiKeyCacheService = apiKeyCacheService; + this.repositoryDepositConfigurationCache = repositoryDepositConfigurationCache; + this.clients = depositRepositories(builder); + this.entityManager = entityManager; + this.authorizationService = authorizationService; + this.conventionService = conventionService; + this.environment = environment; + this.depositMapper = depositMapper; + //GK: I don't like this but that way you can both cache the available configurations and set Configuration Ids for each client + getAvailableConfigurations(); + } + + + public List getAvailableConfigurations() { + RepositoryConfigs configs = repositoryDepositConfigurationCache.lookup("base"); + if (configs == null) { + List configurations = new ArrayList<>(); + + clients.forEach((client) -> { + List repositoryConfigs = client.getConfiguration(); + if (repositoryConfigs != null && !repositoryConfigs.isEmpty()) { + client.getConfigurationIds().addAll(repositoryConfigs.stream().map(RepositoryDepositConfiguration::getRepositoryId).toList()); + configurations.addAll(repositoryConfigs.stream().map(RepositoryConfig::toModel).toList()); + } + }); + + configs = new RepositoryConfigs(configurations); + this.repositoryDepositConfigurationCache.put("base", configs); + } + + return configs.getRepositoryConfigs(); + } + + public Doi deposit(DepositRequest dmpDepositModel) { + 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 = clients.stream().filter(client -> client.getConfigurationIds().contains(dmpDepositModel.getRepositoryId())).findFirst().orElseThrow(); + //GK: Second get the Target Data Management Plan + DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, UUID.fromString(dmpDepositModel.getDmpId())); + + //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("coniguration.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 + EntityDoiEntity doiEntity = new EntityDoiEntity(); + doiEntity.setId(UUID.randomUUID()); + doiEntity.setDoi(doi); + doiEntity.setEntityType(EntityType.DMP); + DMP dmp = new DMP(); + dmp.setId(dmpEntity.getId()); + doiEntity.setEntityId(dmp); + doiEntity.setCreatedAt(Instant.now()); + doiEntity.setIsActive(IsActive.Active); + entityManager.persist(doiEntity); + + + return Doi.fromDataModel(doiEntity); + } + + private List depositRepositories(WebClient.Builder builder) { + List tclients = new ArrayList<>(); + for (DepositProperties.DepositSource source: depositProperties.getSources()) { + + 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); + + tclients.add(new DepositRepository(builder.baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build())); + } + return tclients; + } + + private String getPreviousDOI(UUID groupId, UUID currentId, String repoId) { + CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); + EntityDoiEntity doiEntity = null; + + //GK: Step one get the previous version of the Data management plan + CriteriaQuery query = builder.createQuery(DmpEntity.class); + Root root = query.from(DmpEntity.class); + query = query.select(root.get("id")); + query = query.where(builder.and(builder.equal(root.get("groupId"), groupId), builder.equal(root.get("isActive"), IsActive.Active))); + query = query.orderBy(builder.desc(root.get("version"))); + List dmpIds = this.entityManager.createQuery(query).getResultList().stream().map(DmpEntity::getId).toList(); + + //GK: Step two get it's doiEntity + CriteriaQuery doiQuery = builder.createQuery(EntityDoiEntity.class); + Root doiRoot = doiQuery.from(EntityDoiEntity.class); + doiQuery = doiQuery.multiselect(doiRoot.get("entityId").get("id"), doiRoot.get("doi"), doiRoot.get("repositoryId")); + doiQuery = doiQuery.where(builder.and(doiRoot.get("entityId").get("id").in(dmpIds), builder.equal(doiRoot.get("isActive"), IsActive.Active))); + List dois = this.entityManager.createQuery(doiQuery).getResultList(); + + for(UUID uuid: dmpIds) + { + if (uuid.equals(currentId)) + continue; + doiEntity = dois.stream() + .filter(entityDoiEntity -> entityDoiEntity.getEntityId().getId().equals(uuid) && entityDoiEntity.getRepositoryId().equals(repoId)).findFirst().orElse(null); + if (doiEntity != null) + break; + } + return doiEntity != null ? doiEntity.getDoi() : null; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/pdf/PDFUtils.java b/dmp-backend/core/src/main/java/eu/eudat/utilities/pdf/PDFUtils.java similarity index 81% rename from dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/pdf/PDFUtils.java rename to dmp-backend/core/src/main/java/eu/eudat/utilities/pdf/PDFUtils.java index 6f842b1f3..8e2170c65 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/pdf/PDFUtils.java +++ b/dmp-backend/core/src/main/java/eu/eudat/utilities/pdf/PDFUtils.java @@ -1,6 +1,6 @@ -package eu.eudat.logic.utilities.documents.pdf; +package eu.eudat.utilities.pdf; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; +import eu.eudat.model.file.FileEnvelope; import org.apache.commons.io.IOUtils; import org.springframework.core.env.Environment; import org.springframework.core.io.FileSystemResource; @@ -18,6 +18,13 @@ import java.util.UUID; public class PDFUtils { + public static File convertToPDF(eu.eudat.depositinterface.models.FileEnvelope file, Environment environment) throws IOException { + FileEnvelope envelope = new FileEnvelope(); + envelope.setFilename(file.getFilename()); + envelope.setFile(file.getFile()); + return convertToPDF(envelope, environment); + } + public static File convertToPDF(FileEnvelope file, Environment environment) throws IOException { LinkedMultiValueMap map = new LinkedMultiValueMap<>(); String uuid = UUID.randomUUID().toString(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index dd31b1823..a005768ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -17,8 +17,8 @@ import eu.eudat.logic.managers.DataManagementPlanManager; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; -import eu.eudat.logic.utilities.documents.pdf.PDFUtils; +import eu.eudat.model.file.FileEnvelope; +import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized; import eu.eudat.models.data.dmp.DataManagementPlan; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java index 9bdec08b6..6b8bfcf28 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java @@ -19,8 +19,8 @@ import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; -import eu.eudat.logic.utilities.documents.pdf.PDFUtils; +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.DataManagentPlanListingModel; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DepositController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DepositController.java index 390b1f96c..9c7111631 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DepositController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DepositController.java @@ -3,10 +3,10 @@ package eu.eudat.controllers; import eu.eudat.authorization.Permission; import eu.eudat.logic.managers.DepositManager; import eu.eudat.logic.services.ApiContext; -import eu.eudat.models.data.doi.DepositCode; -import eu.eudat.models.data.doi.DepositRequest; -import eu.eudat.models.data.doi.Doi; -import eu.eudat.models.data.doi.RepositoryConfig; +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.types.ApiMessageCode; import gr.cite.commons.web.authz.service.AuthorizationService; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/FileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/FileController.java index 25c93c066..26cfda795 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/FileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/FileController.java @@ -20,7 +20,7 @@ import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; +import eu.eudat.model.file.FileEnvelope; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 73f512fde..699ce2bbe 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -39,25 +39,25 @@ import eu.eudat.logic.builders.entity.UserInfoBuilder; import eu.eudat.logic.mapper.elastic.DmpMapper; import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; -import eu.eudat.logic.security.repositorydeposit.mapper.DMPToDepositMapper; +import eu.eudat.model.mapper.deposit.DMPToDepositMapper; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; -import eu.eudat.logic.utilities.documents.pdf.PDFUtils; +import eu.eudat.model.file.FileEnvelope; +import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder; +import eu.eudat.model.doi.DepositRequest; +import eu.eudat.model.doi.Doi; import eu.eudat.models.HintedModelFactory; 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.DatasetsToBeFinalized; import eu.eudat.models.data.dmp.*; -import eu.eudat.models.data.doi.DepositRequest; -import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.commons.enums.DmpBlueprintFieldCategory; import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 55c6af695..311a30c43 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -33,7 +33,7 @@ import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; +import eu.eudat.model.file.FileEnvelope; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DepositManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DepositManager.java index 10061375c..75ec14229 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DepositManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DepositManager.java @@ -2,9 +2,9 @@ package eu.eudat.logic.managers; import eu.eudat.depositinterface.repository.RepositoryDeposit; import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration; -import eu.eudat.models.data.doi.DepositRequest; -import eu.eudat.models.data.doi.Doi; -import eu.eudat.models.data.doi.RepositoryConfig; +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; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index b3382f65d..8f1b8ce43 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -4,9 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.*; +import eu.eudat.model.doi.Doi; import eu.eudat.models.DataModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; -import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.funder.Funder; import eu.eudat.models.data.helpermodels.Tuple; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java index 8c0911773..b76801e2d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java @@ -5,12 +5,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.old.DMP; import eu.eudat.data.old.DMPDatasetProfile; import eu.eudat.data.old.Dataset; +import eu.eudat.model.doi.Doi; import eu.eudat.models.DataModel; import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.dmp.Organisation; import eu.eudat.models.data.dmp.Researcher; -import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.grant.GrantOverviewModel; import java.util.*; diff --git a/dmp-backend/web/src/main/resources/config/cache.yml b/dmp-backend/web/src/main/resources/config/cache.yml index 637bb3033..0464d8c83 100644 --- a/dmp-backend/web/src/main/resources/config/cache.yml +++ b/dmp-backend/web/src/main/resources/config/cache.yml @@ -34,6 +34,14 @@ cache: expireAfterWriteMinutes: 10 expireAfterAccessMinutes: 10 refreshAfterWriteMinutes: 10 + - names: [ "deposit" ] + allowNullValues: true + initialCapacity: 100 + maximumSize: 500 + enableRecordStats: false + expireAfterWriteMinutes: 10 + expireAfterAccessMinutes: 10 + refreshAfterWriteMinutes: 10 mapCaches: apiKey: name: apikey @@ -46,4 +54,7 @@ cache: keyPattern: supportive_material_$material$:v0 Reference: name: Reference - keyPattern: reference_$type$_$criteria$:v0 \ No newline at end of file + keyPattern: reference_$type$_$criteria$:v0 + deposit: + name: deposit + keyPattern: base:v0 \ No newline at end of file