diff --git a/dmp-backend/core/pom.xml b/dmp-backend/core/pom.xml
index 09e82047c..2275a1d4f 100644
--- a/dmp-backend/core/pom.xml
+++ b/dmp-backend/core/pom.xml
@@ -35,6 +35,11 @@
oidc-authz
2.1.0
+
+ gr.cite.opendmp
+ repositorydepositbase
+ 1.0.4
+
diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
index 3f4d15035..49607f58f 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
@@ -28,6 +28,11 @@ public final class Permission {
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType";
+ //DescriptionTemplateType
+ public static String BrowseEntityDoi = "BrowseEntityDoi";
+ public static String EditEntityDoi = "EditEntityDoi";
+ public static String DeleteEntityDoi = "DeleteEntityDoi";
+
// UI Pages
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/EntityType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/EntityType.java
index c5c56dbbd..79002fcd7 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/EntityType.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/EntityType.java
@@ -1,4 +1,28 @@
package eu.eudat.commons.enums;
-public enum EntityType {
+import eu.eudat.data.converters.enums.DatabaseEnum;
+
+import java.util.Map;
+
+public enum EntityType implements DatabaseEnum {
+
+ DMP((short) 0);
+
+ private final Short value;
+
+ EntityType(Short value) {
+ this.value = value;
+ }
+
+ @Override
+ public Short getValue() {
+ return value;
+ }
+
+ private static final Map map = EnumUtils.getEnumValueMap(EntityType.class);
+
+ public static EntityType of(Short i) {
+ return map.get(i);
+ }
+
}
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
new file mode 100644
index 000000000..cf208d12b
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositConfiguration.java
@@ -0,0 +1,35 @@
+package eu.eudat.configurations;
+
+import eu.eudat.depositinterface.repository.RepositoryDeposit;
+import eu.eudat.repository.DepositRepository;
+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.util.ArrayList;
+import java.util.List;
+
+@Configuration
+@EnableConfigurationProperties({DepositProperties.class})
+public class DepositConfiguration {
+
+ private final DepositProperties properties;
+
+ @Autowired
+ public DepositConfiguration(DepositProperties properties) {
+ this.properties = properties;
+ }
+
+ @Bean
+ @Qualifier("depositClients")
+ public List depositClients() {
+ List clients = new ArrayList<>();
+ for (String url: properties.getUrls()) {
+ clients.add(new DepositRepository(WebClient.builder().baseUrl(url + "/api/deposit").build()));
+ }
+ return clients;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java
new file mode 100644
index 000000000..aa7a37f40
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/DepositProperties.java
@@ -0,0 +1,25 @@
+package eu.eudat.configurations;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.bind.ConstructorBinding;
+
+import java.util.List;
+
+@ConfigurationProperties(prefix = "deposit")
+public class DepositProperties {
+
+ private List urls;
+
+ @ConstructorBinding
+ public DepositProperties(List urls) {
+ this.urls = urls;
+ }
+
+ public List getUrls() {
+ return urls;
+ }
+
+ public void setUrls(List urls) {
+ this.urls = urls;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/CredentialEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/CredentialEntity.java
index 8c7686853..a95d73200 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/CredentialEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/CredentialEntity.java
@@ -6,7 +6,7 @@ import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.ProviderTypeConverter;
import eu.eudat.data.converters.enums.IsActiveConverter;
-import eu.eudat.data.helpers.EntityBinder;
+import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import jakarta.persistence.*;
import java.util.Date;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java
index bf584c74d..487f07775 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java
@@ -16,30 +16,35 @@ public class DescriptionTemplateTypeEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
- public final static String _id = "id";
+
+ public static final String _id = "id";
@Column(name = "name", length = 500, nullable = false)
private String name;
- public final static String _name = "name";
+
+ public static final String _name = "name";
@Column(name = "created_at", nullable = false)
private Instant createdAt;
- public final static String _createdAt = "createdAt";
+
+ public static final String _createdAt = "createdAt";
@Column(name = "updated_at", nullable = false)
private Instant updatedAt;
- public final static String _updatedAt = "updatedAt";
+
+ public static final String _updatedAt = "updatedAt";
@Column(name = "is_active", nullable = false)
@Convert(converter = IsActiveConverter.class)
private IsActive isActive;
- public final static String _isActive = "isActive";
+
+ public static final String _isActive = "isActive";
@Column(name = "status", nullable = false)
@Convert(converter = DescriptionTemplateTypeStatusConverter.class)
private DescriptionTemplateTypeStatus status;
- public final static String _status = "status";
+ public static final String _status = "status";
public UUID getId() {
return id;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java
new file mode 100644
index 000000000..edb31da6c
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java
@@ -0,0 +1,127 @@
+package eu.eudat.data;
+
+import eu.eudat.commons.enums.EntityType;
+import eu.eudat.commons.enums.IsActive;
+import eu.eudat.data.converters.DateToUTCConverter;
+import eu.eudat.data.converters.enums.IsActiveConverter;
+import jakarta.persistence.*;
+
+import java.time.Instant;
+import java.util.Date;
+import java.util.UUID;
+
+@Entity
+@Table(name = "\"EntityDoi\"")
+public class EntityDoiEntity {
+
+ @Id
+ @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
+ private UUID id;
+
+ public static final String _id = "id";
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "entity_type", nullable = false)
+ private EntityType entityType;
+
+ public static final String _entityType = "entityType";
+
+ @Column(name = "repository_id", nullable = false)
+ private String repositoryId;
+
+ public static final String _repositoryId = "repositoryId";
+
+ @Column(name = "doi", nullable = false)
+ private String doi;
+
+ public static final String _doi = "doi";
+
+ @Column(name = "created_at", nullable = false)
+ @Convert(converter = DateToUTCConverter.class)
+ private Instant createdAt;
+
+ public static final String _createdAt = "createdAt";
+
+ @Column(name = "updated_at", nullable = false)
+ @Convert(converter = DateToUTCConverter.class)
+ private Instant updatedAt;
+
+ public static final String _updatedAt = "updatedAt";
+
+ @Column(name = "is_active", nullable = false)
+ @Convert(converter = IsActiveConverter.class)
+ private IsActive isActive;
+
+ public static final String _isActive = "isActive";
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "entity_id", nullable = false)
+ private UUID entityId;
+
+ public static final String _entityId = "entityId";
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public EntityType getEntityType() {
+ return entityType;
+ }
+
+ public void setEntityType(EntityType entityType) {
+ this.entityType = entityType;
+ }
+
+ 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 Instant getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Instant createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Instant getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public void setUpdatedAt(Instant updatedAt) {
+ this.updatedAt = updatedAt;
+ }
+
+ public IsActive getIsActive() {
+ return isActive;
+ }
+
+ public void setIsActive(IsActive isActive) {
+ this.isActive = isActive;
+ }
+
+ public UUID getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(UUID entityId) {
+ this.entityId = entityId;
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/EntityTypeConverter.java b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/EntityTypeConverter.java
new file mode 100644
index 000000000..c6814bdea
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/EntityTypeConverter.java
@@ -0,0 +1,14 @@
+package eu.eudat.data.converters.enums;
+
+import eu.eudat.commons.enums.EntityType;
+import jakarta.persistence.Converter;
+
+@Converter
+public class EntityTypeConverter extends DatabaseEnumConverter{
+
+ @Override
+ protected EntityType of(Short i) {
+ return EntityType.of(i);
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/helpers/EntityBinder.java b/dmp-backend/core/src/main/java/eu/eudat/data/helpers/EntityBinder.java
deleted file mode 100644
index 39c921317..000000000
--- a/dmp-backend/core/src/main/java/eu/eudat/data/helpers/EntityBinder.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package eu.eudat.data.helpers;
-
-import jakarta.persistence.Tuple;
-
-import java.util.List;
-
-public class EntityBinder {
- public static T fromTuple(List tuple, String path) {
- try {
- return (T) tuple.get(0).get(path);
- }catch (IllegalArgumentException illegalArgument){
- return null;
- }
- }
-}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java
index 1fb54000a..f11b96f13 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java
@@ -1,6 +1,7 @@
package eu.eudat.data.old;
+import eu.eudat.data.EntityDoiEntity;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
@@ -183,7 +184,7 @@ public class DMP implements DataEntity {
private Date publishedAt;
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
- private Set dois;
+ private Set dois;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"")
@@ -340,10 +341,10 @@ public class DMP implements DataEntity {
this.publishedAt = publishedAt;
}
- public Set getDois() {
+ public Set getDois() {
return dois;
}
- public void setDois(Set dois) {
+ public void setDois(Set dois) {
this.dois = dois;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/EntityDoi.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/EntityDoi.java
deleted file mode 100644
index f0df55771..000000000
--- a/dmp-backend/core/src/main/java/eu/eudat/data/old/EntityDoi.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package eu.eudat.data.old;
-
-import eu.eudat.data.converters.DateToUTCConverter;
-import eu.eudat.data.old.helpers.EntityBinder;
-import eu.eudat.queryable.queryableentity.DataEntity;
-
-import jakarta.persistence.*;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-@Entity
-@Table(name = "\"EntityDoi\"")
-public class EntityDoi implements DataEntity {
- public enum EntityType {
- DMP
- }
-
- @Id
- @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
- private UUID id;
-
- @Enumerated(EnumType.STRING)
- @Column(name = "\"EntityType\"", nullable = false)
- private EntityType entityType;
-
- @Column(name = "\"RepositoryId\"", nullable = false)
- private String repositoryId;
-
- @Column(name = "\"Doi\"", nullable = false)
- private String doi;
-
- @Column(name = "\"CreatedAt\"", nullable = false)
- @Convert(converter = DateToUTCConverter.class)
- private Date createdAt;
-
- @Column(name = "\"UpdatedAt\"", nullable = false)
- @Convert(converter = DateToUTCConverter.class)
- private Date updatedAt;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "\"EntityId\"", nullable = false)
- private DMP entityId;
-
- public UUID getId() {
- return id;
- }
- public void setId(UUID id) {
- this.id = id;
- }
-
- public EntityType getEntityType() {
- return entityType;
- }
- public void setEntityType(EntityType entityType) {
- this.entityType = entityType;
- }
-
- 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 getEntityId() {
- return entityId;
- }
- public void setEntityId(DMP entityId) {
- this.entityId = entityId;
- }
-
- @Override
- public void update(EntityDoi doi) {
- this.entityType = doi.getEntityType();
- this.repositoryId = doi.getRepositoryId();
- this.doi = doi.getDoi();
- this.createdAt = doi.getCreatedAt();
- this.updatedAt = doi.getUpdatedAt();
- this.entityId = doi.getEntityId();
- }
-
- @Override
- public UUID getKeys() {
- return this.id;
- }
-
- @Override
- public EntityDoi buildFromTuple(List tuple, List fields, String base) {
- String currentBase = base.isEmpty() ? "" : base + ".";
- if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
- if (fields.contains(currentBase + "entityId"))
- this.entityId = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields , base.isEmpty() ? "entityId" : base + "." + "entityId")).collect(Collectors.toList()).get(0);
- return this;
- }
-}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/EntityDoiTouchedEvent.java b/dmp-backend/core/src/main/java/eu/eudat/event/EntityDoiTouchedEvent.java
new file mode 100644
index 000000000..f211d7dbc
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/event/EntityDoiTouchedEvent.java
@@ -0,0 +1,24 @@
+package eu.eudat.event;
+
+import java.util.UUID;
+
+public class EntityDoiTouchedEvent {
+
+ public EntityDoiTouchedEvent() {
+ }
+
+ public EntityDoiTouchedEvent(UUID id) {
+ this.id = id;
+ }
+
+ private UUID id;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java
index c8fca7df1..f3c40355e 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java
@@ -37,4 +37,8 @@ public class EventBroker {
public void emit(DescriptionTemplateTypeTouchedEvent event) {
this.applicationEventPublisher.publishEvent(event);
}
+
+ public void emit(EntityDoiTouchedEvent event) {
+ this.applicationEventPublisher.publishEvent(event);
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/EntityDoi.java b/dmp-backend/core/src/main/java/eu/eudat/model/EntityDoi.java
new file mode 100644
index 000000000..9c6be1c80
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/EntityDoi.java
@@ -0,0 +1,119 @@
+package eu.eudat.model;
+
+import eu.eudat.commons.enums.EntityType;
+import eu.eudat.commons.enums.IsActive;
+
+import java.time.Instant;
+import java.util.Date;
+import java.util.UUID;
+
+public class EntityDoi {
+
+ private UUID id;
+
+ public static final String _id = "id";
+
+ private EntityType entityType;
+
+ public static final String _entityType = "entityType";
+
+ private String repositoryId;
+
+ public static final String _repositoryId = "repositoryId";
+
+ private String doi;
+
+ public static final String _doi = "doi";
+
+ private Instant createdAt;
+
+ public static final String _createdAt = "createdAt";
+
+ private Instant updatedAt;
+
+ public static final String _updatedAt = "updatedAt";
+
+ private IsActive isActive;
+
+ public static final String _isActive = "isActive";
+
+ private UUID entityId;
+
+ public static final String _entityId = "entityId";
+
+ private String hash;
+
+ public static final String _hash = "hash";
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public EntityType getEntityType() {
+ return entityType;
+ }
+
+ public void setEntityType(EntityType entityType) {
+ this.entityType = entityType;
+ }
+
+ 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 Instant getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Instant createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Instant getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public void setUpdatedAt(Instant updatedAt) {
+ this.updatedAt = updatedAt;
+ }
+
+ public IsActive getIsActive() {
+ return isActive;
+ }
+
+ public void setIsActive(IsActive isActive) {
+ this.isActive = isActive;
+ }
+
+ public UUID getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(UUID entityId) {
+ this.entityId = entityId;
+ }
+
+ public String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java
index 044703435..83053e81e 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java
@@ -1,14 +1,10 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
-import eu.eudat.commons.JsonHandlingService;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.model.DescriptionTemplateType;
-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;
@@ -19,7 +15,6 @@ 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)
@@ -39,21 +34,29 @@ public class DescriptionTemplateTypeBuilder extends BaseBuilder build(FieldSet fields, List datas) throws MyApplicationException {
- this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ public List build(FieldSet fields, List 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 || datas == null || fields.isEmpty()) return new ArrayList<>();
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
List models = new ArrayList<>();
- for (DescriptionTemplateTypeEntity d : datas) {
+ for (DescriptionTemplateTypeEntity d : data) {
DescriptionTemplateType m = new DescriptionTemplateType();
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._id))) m.setId(d.getId());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._name))) m.setName(d.getName());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._isActive))) m.setIsActive(d.getIsActive());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._status))) m.setStatus(d.getStatus());
- if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._id)))
+ m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._name)))
+ m.setName(d.getName());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt)))
+ m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._updatedAt)))
+ m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._isActive)))
+ m.setIsActive(d.getIsActive());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._status)))
+ m.setStatus(d.getStatus());
+ if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash)))
+ m.setHash(this.hashValue(d.getUpdatedAt()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java
new file mode 100644
index 000000000..a4cff8bd7
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java
@@ -0,0 +1,72 @@
+package eu.eudat.model.builder;
+
+import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.convention.ConventionService;
+import eu.eudat.data.EntityDoiEntity;
+import eu.eudat.model.EntityDoi;
+import gr.cite.tools.exception.MyApplicationException;
+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.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class EntityDoiBuilder extends BaseBuilder {
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+
+ @Autowired
+ public EntityDoiBuilder(
+ ConventionService conventionService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(EntityDoiBuilder.class)));
+ }
+
+ public EntityDoiBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List 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 models = new ArrayList<>();
+ for (EntityDoiEntity d : data) {
+ EntityDoi m = new EntityDoi();
+ if (fields.hasField(this.asIndexer(EntityDoi._id)))
+ m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(EntityDoi._doi)))
+ m.setDoi(d.getDoi());
+ if (fields.hasField(this.asIndexer(EntityDoi._entityId)))
+ m.setEntityId(d.getEntityId());
+ if (fields.hasField(this.asIndexer(EntityDoi._entityType)))
+ m.setEntityType(d.getEntityType());
+ if (fields.hasField(this.asIndexer(EntityDoi._repositoryId)))
+ m.setRepositoryId(d.getRepositoryId());
+ if (fields.hasField(this.asIndexer(EntityDoi._createdAt)))
+ m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(EntityDoi._updatedAt)))
+ m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(EntityDoi._isActive)))
+ m.setIsActive(d.getIsActive());
+ if (fields.hasField(this.asIndexer(EntityDoi._hash)))
+ m.setHash(hashValue(d.getUpdatedAt()));
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+
+
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTemplateTypeCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTemplateTypeCensor.java
index b941be7e2..39a1f409c 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTemplateTypeCensor.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTemplateTypeCensor.java
@@ -15,10 +15,12 @@ import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class DescriptionTemplateTypeCensor extends BaseCensor{
+public class DescriptionTemplateTypeCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeCensor.class));
+
protected final AuthorizationService authService;
+
public DescriptionTemplateTypeCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
@@ -26,7 +28,8 @@ public class DescriptionTemplateTypeCensor extends BaseCensor{
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
- if (fields.isEmpty()) return;
+ if (fields.isEmpty())
+ return;
this.authService.authorizeForce(Permission.BrowseDescriptionTemplateType);
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/EntityDoiCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/EntityDoiCensor.java
new file mode 100644
index 000000000..55cfed580
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/EntityDoiCensor.java
@@ -0,0 +1,36 @@
+package eu.eudat.model.censorship;
+
+import eu.eudat.authorization.Permission;
+import eu.eudat.convention.ConventionService;
+import gr.cite.commons.web.authz.service.AuthorizationService;
+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 EntityDoiCensor extends BaseCensor{
+
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiCensor.class));
+
+ protected final AuthorizationService authService;
+
+ public EntityDoiCensor(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.isEmpty())
+ return;
+
+ this.authService.authorizeForce(Permission.BrowseEntityDoi);
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionTemplateTypeDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionTemplateTypeDeleter.java
index 068a2b94a..c27f4e7a8 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionTemplateTypeDeleter.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionTemplateTypeDeleter.java
@@ -28,7 +28,9 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
private final EntityManager entityManager;
+
protected final QueryFactory queryFactory;
+
protected final DeleterFactory deleterFactory;
@Autowired
@@ -59,7 +61,8 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
public void delete(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
- if (data == null || data.isEmpty()) return;
+ if (data == null || data.isEmpty())
+ return;
Instant now = Instant.now();
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/EntityDoiDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/EntityDoiDeleter.java
new file mode 100644
index 000000000..e090d092c
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/EntityDoiDeleter.java
@@ -0,0 +1,79 @@
+package eu.eudat.model.deleter;
+
+import eu.eudat.commons.enums.IsActive;
+import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.query.DescriptionTemplateTypeQuery;
+import gr.cite.tools.data.deleter.Deleter;
+import gr.cite.tools.data.deleter.DeleterFactory;
+import gr.cite.tools.data.query.QueryFactory;
+import gr.cite.tools.logging.LoggerService;
+import gr.cite.tools.logging.MapLogEntry;
+import jakarta.persistence.EntityManager;
+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 javax.management.InvalidApplicationException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class EntityDoiDeleter implements Deleter {
+
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
+
+ private final EntityManager entityManager;
+
+ protected final QueryFactory queryFactory;
+
+ protected final DeleterFactory deleterFactory;
+
+ @Autowired
+ public EntityDoiDeleter(
+ EntityManager entityManager,
+ QueryFactory queryFactory,
+ DeleterFactory deleterFactory
+ ) {
+ this.entityManager = entityManager;
+ this.queryFactory = queryFactory;
+ this.deleterFactory = deleterFactory;
+ }
+
+ public void deleteAndSaveByIds(List ids) throws InvalidApplicationException {
+ logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
+ List data = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(ids).collect();
+ logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
+ this.deleteAndSave(data);
+ }
+
+ public void deleteAndSave(List data) throws InvalidApplicationException {
+ logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
+ this.delete(data);
+ logger.trace("saving changes");
+ this.entityManager.flush();
+ logger.trace("changes saved");
+ }
+
+ public void delete(List data) throws InvalidApplicationException {
+ logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty())
+ return;
+
+ Instant now = Instant.now();
+
+ for (DescriptionTemplateTypeEntity item : data) {
+ logger.trace("deleting item {}", item.getId());
+ item.setIsActive(IsActive.Inactive);
+ item.setUpdatedAt(now);
+ logger.trace("updating item");
+ this.entityManager.merge(item);
+ logger.trace("updated item");
+ }
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/EntityDoiPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/EntityDoiPersist.java
new file mode 100644
index 000000000..96d57d5d9
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/EntityDoiPersist.java
@@ -0,0 +1,61 @@
+package eu.eudat.model.persist;
+
+import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
+import eu.eudat.commons.validation.ValidId;
+
+import java.util.UUID;
+
+@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
+public class EntityDoiPersist {
+
+ @ValidId(message = "{validation.invalidid}")
+ private UUID id;
+
+ private UUID entityId;
+
+ private String repositoryId;
+
+ private String doi;
+
+ private String hash;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public UUID getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(UUID entityId) {
+ this.entityId = entityId;
+ }
+
+ 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 String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java
index 13dbec3ad..059a2470c 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java
@@ -25,10 +25,15 @@ import java.util.*;
public class DescriptionTemplateTypeQuery extends QueryBase {
private String like;
+
private Collection ids;
+
private Collection isActives;
+
private Collection statuses;
+
private Collection excludedIds;
+
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
public DescriptionTemplateTypeQuery like(String value) {
@@ -102,6 +107,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase predicates = new ArrayList<>();
if (this.ids != null) {
CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
- for (UUID item : this.ids) inClause.value(item);
+ for (UUID item : this.ids)
+ inClause.value(item);
predicates.add(inClause);
}
if (this.like != null && !this.like.isEmpty()) {
@@ -135,21 +142,24 @@ public class DescriptionTemplateTypeQuery extends QueryBase inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive));
- for (IsActive item : this.isActives) inClause.value(item);
+ for (IsActive item : this.isActives)
+ inClause.value(item);
predicates.add(inClause);
}
if (this.statuses != null) {
CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
- for (DescriptionTemplateTypeStatus item : this.statuses) inClause.value(item);
+ for (DescriptionTemplateTypeStatus item : this.statuses)
+ inClause.value(item);
predicates.add(inClause);
}
if (this.excludedIds != null) {
CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
- for (UUID item : this.excludedIds) notInClause.value(item);
+ for (UUID item : this.excludedIds)
+ notInClause.value(item);
predicates.add(notInClause.not());
}
- if (predicates.size() > 0) {
+ if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@@ -171,13 +181,20 @@ public class DescriptionTemplateTypeQuery extends QueryBase {
+
+ private Collection ids;
+
+ private Collection isActives;
+
+ private Collection types;
+
+ private Collection excludedIds;
+
+ private Collection dois;
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+
+ public EntityDoiQuery ids(UUID value) {
+ this.ids = List.of(value);
+ return this;
+ }
+
+ public EntityDoiQuery ids(UUID... value) {
+ this.ids = Arrays.asList(value);
+ return this;
+ }
+
+ public EntityDoiQuery ids(Collection values) {
+ this.ids = values;
+ return this;
+ }
+
+ public EntityDoiQuery isActive(IsActive value) {
+ this.isActives = List.of(value);
+ return this;
+ }
+
+ public EntityDoiQuery isActive(IsActive... value) {
+ this.isActives = Arrays.asList(value);
+ return this;
+ }
+
+ public EntityDoiQuery isActive(Collection values) {
+ this.isActives = values;
+ return this;
+ }
+
+ public EntityDoiQuery types(EntityType value) {
+ this.types = List.of(value);
+ return this;
+ }
+
+ public EntityDoiQuery types(EntityType... value) {
+ this.types = Arrays.asList(value);
+ return this;
+ }
+
+ public EntityDoiQuery types(Collection values) {
+ this.types = values;
+ return this;
+ }
+
+ public EntityDoiQuery excludedIds(Collection values) {
+ this.excludedIds = values;
+ return this;
+ }
+
+ public EntityDoiQuery excludedIds(UUID value) {
+ this.excludedIds = List.of(value);
+ return this;
+ }
+
+ public EntityDoiQuery excludedIds(UUID... value) {
+ this.excludedIds = Arrays.asList(value);
+ return this;
+ }
+
+ public EntityDoiQuery dois(Collection values) {
+ this.dois = values;
+ return this;
+ }
+
+ public EntityDoiQuery dois(String value) {
+ this.dois = List.of(value);
+ return this;
+ }
+
+ public EntityDoiQuery dois(String... value) {
+ this.dois = Arrays.asList(value);
+ return this;
+ }
+
+ public EntityDoiQuery authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ private final UserScope userScope;
+
+ private final AuthorizationService authService;
+
+ public EntityDoiQuery(
+ UserScope userScope,
+ AuthorizationService authService
+ ) {
+ this.userScope = userScope;
+ this.authService = authService;
+ }
+
+ @Override
+ protected Class entityClass() {
+ return EntityDoiEntity.class;
+ }
+
+ @Override
+ protected Boolean isFalseQuery() {
+ return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.types);
+ }
+
+ @Override
+ protected Predicate applyFilters(QueryContext queryContext) {
+ List predicates = new ArrayList<>();
+ if (this.ids != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._id));
+ for (UUID item : this.ids)
+ inClause.value(item);
+ predicates.add(inClause);
+ }
+ if (this.isActives != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._isActive));
+ for (IsActive item : this.isActives)
+ inClause.value(item);
+ predicates.add(inClause);
+ }
+
+ if (this.types != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityType));
+ for (EntityType item : this.types)
+ inClause.value(item);
+ predicates.add(inClause);
+ }
+ if (this.excludedIds != null) {
+ CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._id));
+ for (UUID item : this.excludedIds)
+ notInClause.value(item);
+ predicates.add(notInClause.not());
+ }
+ if (this.dois != null) {
+ CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._doi));
+ for (String item : this.dois)
+ notInClause.value(item);
+ predicates.add(notInClause.not());
+ }
+ if (!predicates.isEmpty()) {
+ Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
+ return queryContext.CriteriaBuilder.and(predicatesArray);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected EntityDoiEntity convert(Tuple tuple, Set columns) {
+ EntityDoiEntity item = new EntityDoiEntity();
+ item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class));
+ item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class));
+ item.setRepositoryId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._repositoryId, String.class));
+ item.setEntityId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityId, UUID.class));
+ item.setEntityType(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityType, EntityType.class));
+ item.setCreatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._createdAt, Instant.class));
+ item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._updatedAt, Instant.class));
+ item.setIsActive(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._isActive, IsActive.class));
+ return item;
+ }
+
+ @Override
+ protected String fieldNameOf(FieldResolver item) {
+ if (item.match(EntityDoiEntity._id))
+ return EntityDoiEntity._id;
+ else if (item.match(EntityDoiEntity._doi))
+ return EntityDoiEntity._doi;
+ else if (item.match(EntityDoiEntity._repositoryId))
+ return EntityDoiEntity._repositoryId;
+ else if (item.match(EntityDoiEntity._entityId))
+ return EntityDoiEntity._entityId;
+ else if (item.match(EntityDoiEntity._entityType))
+ return EntityDoiEntity._entityType;
+ else if (item.match(EntityDoiEntity._createdAt))
+ return EntityDoiEntity._createdAt;
+ else if (item.match(EntityDoiEntity._updatedAt))
+ return EntityDoiEntity._updatedAt;
+ else if (item.match(EntityDoiEntity._isActive))
+ return EntityDoiEntity._isActive;
+ else
+ return null;
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java
index 26192428a..f12fe2bf9 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java
@@ -12,9 +12,13 @@ import java.util.UUID;
public class DescriptionTemplateTypeLookup extends Lookup {
private String like;
+
private List isActive;
+
private List statuses;
+
private List ids;
+
private List excludedIds;
public String getLike() {
@@ -51,11 +55,16 @@ public class DescriptionTemplateTypeLookup extends Lookup {
public DescriptionTemplateTypeQuery enrich(QueryFactory queryFactory) {
DescriptionTemplateTypeQuery query = queryFactory.query(DescriptionTemplateTypeQuery.class);
- if (this.like != null) query.like(this.like);
- if (this.isActive != null) query.isActive(this.isActive);
- if (this.statuses != null) query.statuses(this.statuses);
- if (this.ids != null) query.ids(this.ids);
- if (this.excludedIds != null) query.excludedIds(this.excludedIds);
+ if (this.like != null)
+ query.like(this.like);
+ if (this.isActive != null)
+ query.isActive(this.isActive);
+ if (this.statuses != null)
+ query.statuses(this.statuses);
+ if (this.ids != null)
+ query.ids(this.ids);
+ if (this.excludedIds != null)
+ query.excludedIds(this.excludedIds);
this.enrichCommon(query);
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/EntityDoiLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/EntityDoiLookup.java
new file mode 100644
index 000000000..a6c15e357
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/EntityDoiLookup.java
@@ -0,0 +1,43 @@
+package eu.eudat.query.lookup;
+
+import eu.eudat.commons.enums.EntityType;
+import eu.eudat.commons.enums.IsActive;
+import eu.eudat.query.EntityDoiQuery;
+import gr.cite.tools.data.query.Lookup;
+import gr.cite.tools.data.query.QueryFactory;
+
+import java.util.List;
+import java.util.UUID;
+
+public class EntityDoiLookup extends Lookup {
+
+ private List isActive;
+
+ private List types;
+
+ private List ids;
+
+ private List excludedIds;
+
+ private List dois;
+
+ public EntityDoiQuery enrich(QueryFactory queryFactory) {
+ EntityDoiQuery query = queryFactory.query(EntityDoiQuery.class);
+ if (this.isActive != null)
+ query.isActive(this.isActive);
+ if (this.types != null)
+ query.types(this.types);
+ if (this.ids != null)
+ query.ids(this.ids);
+ if (this.excludedIds != null)
+ query.excludedIds(this.excludedIds);
+ if (this.dois != null) {
+ query.dois(this.dois);
+ }
+
+ this.enrichCommon(query);
+
+ return query;
+ }
+
+}
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
new file mode 100644
index 000000000..c0dd332b3
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/repository/DepositRepository.java
@@ -0,0 +1,39 @@
+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.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 getConfiguration() {
+ return depositClient.get().uri("/configuration").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference>() {})).block();
+ }
+
+ @Override
+ public String getLogo(String repositoryId) {
+ return depositClient.get().uri("/logo/" + repositoryId).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
+ }
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java
index 35b8473b2..a95a300d1 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java
@@ -12,7 +12,9 @@ import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface DescriptionTemplateTypeService {
+
DescriptionTemplateType persist(DescriptionTemplateTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
+
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeServiceImpl.java
index 188ff36fb..993021564 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeServiceImpl.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeServiceImpl.java
@@ -41,17 +41,27 @@ import java.util.UUID;
@Service
@RequestScope
public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTypeService {
+
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeServiceImpl.class));
private final EntityManager entityManager;
+
private final AuthorizationService authorizationService;
+
private final DeleterFactory deleterFactory;
+
private final BuilderFactory builderFactory;
+
private final ConventionService conventionService;
+
private final ErrorThesaurusProperties errors;
+
private final MessageSource messageSource;
+
private final EventBroker eventBroker;
+
private final QueryFactory queryFactory;
+
private final JsonHandlingService jsonHandlingService;
@Autowired
@@ -88,7 +98,8 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
DescriptionTemplateTypeEntity data;
if (isUpdate) {
data = this.entityManager.find(DescriptionTemplateTypeEntity.class, model.getId());
- if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
+ if (data == null)
+ throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
} else {
data = new DescriptionTemplateTypeEntity();
data.setId(UUID.randomUUID());
@@ -99,8 +110,10 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
data.setName(model.getName());
data.setStatus(model.getStatus());
data.setUpdatedAt(Instant.now());
- if (isUpdate) this.entityManager.merge(data);
- else this.entityManager.persist(data);
+ if (isUpdate)
+ this.entityManager.merge(data);
+ else
+ this.entityManager.persist(data);
this.entityManager.flush();
@@ -115,5 +128,6 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
this.deleterFactory.deleter(DescriptionTemplateTypeDeleter.class).deleteAndSaveByIds(List.of(id));
}
+
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiService.java b/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiService.java
new file mode 100644
index 000000000..df6211d19
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiService.java
@@ -0,0 +1,22 @@
+package eu.eudat.service;
+
+import eu.eudat.model.DescriptionTemplateType;
+import eu.eudat.model.EntityDoi;
+import eu.eudat.model.persist.DescriptionTemplateTypePersist;
+import eu.eudat.model.persist.EntityDoiPersist;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.exception.MyForbiddenException;
+import gr.cite.tools.exception.MyNotFoundException;
+import gr.cite.tools.exception.MyValidationException;
+import gr.cite.tools.fieldset.FieldSet;
+
+import javax.management.InvalidApplicationException;
+import java.util.UUID;
+
+public interface EntityDoiService {
+
+ EntityDoi persist(EntityDoiPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
+
+ void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiServiceImpl.java
new file mode 100644
index 000000000..cbe47a1b2
--- /dev/null
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/EntityDoiServiceImpl.java
@@ -0,0 +1,138 @@
+package eu.eudat.service;
+
+import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.authorization.Permission;
+import eu.eudat.commons.JsonHandlingService;
+import eu.eudat.commons.enums.EntityType;
+import eu.eudat.commons.enums.IsActive;
+import eu.eudat.convention.ConventionService;
+import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.data.EntityDoiEntity;
+import eu.eudat.errorcode.ErrorThesaurusProperties;
+import eu.eudat.event.DescriptionTemplateTypeTouchedEvent;
+import eu.eudat.event.EntityDoiTouchedEvent;
+import eu.eudat.event.EventBroker;
+import eu.eudat.model.DescriptionTemplateType;
+import eu.eudat.model.EntityDoi;
+import eu.eudat.model.builder.DescriptionTemplateTypeBuilder;
+import eu.eudat.model.builder.EntityDoiBuilder;
+import eu.eudat.model.deleter.DescriptionTemplateTypeDeleter;
+import eu.eudat.model.deleter.EntityDoiDeleter;
+import eu.eudat.model.persist.DescriptionTemplateTypePersist;
+import eu.eudat.model.persist.EntityDoiPersist;
+import gr.cite.commons.web.authz.service.AuthorizationService;
+import gr.cite.tools.data.builder.BuilderFactory;
+import gr.cite.tools.data.deleter.DeleterFactory;
+import gr.cite.tools.data.query.QueryFactory;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.exception.MyForbiddenException;
+import gr.cite.tools.exception.MyNotFoundException;
+import gr.cite.tools.exception.MyValidationException;
+import gr.cite.tools.fieldset.BaseFieldSet;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.LoggerService;
+import gr.cite.tools.logging.MapLogEntry;
+import jakarta.persistence.EntityManager;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
+import org.springframework.context.i18n.LocaleContextHolder;
+
+import javax.management.InvalidApplicationException;
+import java.time.Instant;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class EntityDoiServiceImpl implements EntityDoiService {
+
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiServiceImpl.class));
+
+ private final EntityManager entityManager;
+
+ private final AuthorizationService authorizationService;
+
+ private final DeleterFactory deleterFactory;
+
+ private final BuilderFactory builderFactory;
+
+ private final ConventionService conventionService;
+
+ private final ErrorThesaurusProperties errors;
+
+ private final MessageSource messageSource;
+
+ private final EventBroker eventBroker;
+
+ private final QueryFactory queryFactory;
+
+ private final JsonHandlingService jsonHandlingService;
+
+ @Autowired
+ public EntityDoiServiceImpl(
+ EntityManager entityManager,
+ AuthorizationService authorizationService,
+ DeleterFactory deleterFactory,
+ BuilderFactory builderFactory,
+ ConventionService conventionService,
+ ErrorThesaurusProperties errors,
+ MessageSource messageSource,
+ EventBroker eventBroker,
+ QueryFactory queryFactory,
+ JsonHandlingService jsonHandlingService) {
+ this.entityManager = entityManager;
+ this.authorizationService = authorizationService;
+ this.deleterFactory = deleterFactory;
+ this.builderFactory = builderFactory;
+ this.conventionService = conventionService;
+ this.errors = errors;
+ this.messageSource = messageSource;
+ this.eventBroker = eventBroker;
+ this.queryFactory = queryFactory;
+ this.jsonHandlingService = jsonHandlingService;
+ }
+
+ public EntityDoi persist(EntityDoiPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
+ logger.debug(new MapLogEntry("persisting data EntityDoi").And("model", model).And("fields", fields));
+
+ this.authorizationService.authorizeForce(Permission.EditEntityDoi);
+
+ Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
+
+ EntityDoiEntity data;
+ if (isUpdate) {
+ data = this.entityManager.find(EntityDoiEntity.class, model.getId());
+ if (data == null)
+ throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale()));
+ } else {
+ data = new EntityDoiEntity();
+ data.setId(UUID.randomUUID());
+ data.setIsActive(IsActive.Active);
+ data.setCreatedAt(Instant.now());
+ }
+
+ data.setEntityType(EntityType.DMP);
+ data.setEntityId(model.getEntityId());
+ data.setRepositoryId(model.getRepositoryId());
+ data.setDoi(model.getDoi());
+ data.setUpdatedAt(Instant.now());
+ if (isUpdate)
+ this.entityManager.merge(data);
+ else
+ this.entityManager.persist(data);
+
+ this.entityManager.flush();
+
+ this.eventBroker.emit(new EntityDoiTouchedEvent(data.getId()));
+ return this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, EntityDoi._id), data);
+ }
+
+ public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
+ logger.debug("deleting dataset: {}", id);
+
+ this.authorizationService.authorizeForce(Permission.DeleteEntityDoi);
+
+ this.deleterFactory.deleter(EntityDoiDeleter.class).deleteAndSaveByIds(List.of(id));
+ }
+
+}
diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDao.java
deleted file mode 100644
index 48fc74988..000000000
--- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDao.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package eu.eudat.data.dao.entities;
-
-import eu.eudat.data.dao.DatabaseAccessLayer;
-import eu.eudat.data.old.EntityDoi;
-
-import javax.management.InvalidApplicationException;
-import java.util.UUID;
-
-public interface EntityDoiDao extends DatabaseAccessLayer {
- EntityDoi findFromDoi(String doi) throws InvalidApplicationException;
-}
diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDaoImpl.java
deleted file mode 100644
index 782b4c380..000000000
--- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/EntityDoiDaoImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package eu.eudat.data.dao.entities;
-
-import eu.eudat.data.dao.DatabaseAccess;
-import eu.eudat.data.dao.databaselayer.service.DatabaseService;
-import eu.eudat.data.old.EntityDoi;
-import eu.eudat.queryable.QueryableList;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.management.InvalidApplicationException;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-
-@Component("EntityDoiDao")
-public class EntityDoiDaoImpl extends DatabaseAccess implements EntityDoiDao {
-
- @Autowired
- public EntityDoiDaoImpl(DatabaseService databaseService){
- super(databaseService);
- }
-
-
- @Override
- public EntityDoi createOrUpdate(EntityDoi item) {
- return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
- }
-
- @Override
- public CompletableFuture createOrUpdateAsync(EntityDoi item) {
- return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
- }
-
- @Override
- public EntityDoi find(UUID id) throws InvalidApplicationException {
- return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
- }
-
- @Override
- public EntityDoi findFromDoi(String doi) throws InvalidApplicationException {
- return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("doi"), doi)).getSingle();
- }
-
- @Override
- public EntityDoi find(UUID id, String hint) {
- return null;
- }
-
- @Override
- public void delete(EntityDoi item) {
- this.getDatabaseService().delete(item);
- }
-
- @Override
- public QueryableList asQueryable() {
- return this.getDatabaseService().getQueryable(EntityDoi.class);
- }
-}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ExternalReferencesController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ExternalReferencesController.java
new file mode 100644
index 000000000..9e82644e9
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ExternalReferencesController.java
@@ -0,0 +1,104 @@
+package eu.eudat.controllers.v2;
+
+import eu.eudat.controllers.BaseController;
+import eu.eudat.data.old.DataRepository;
+import eu.eudat.data.old.Registry;
+import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
+import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
+import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
+import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.logic.services.externalreferences.ExternalReferencesService;
+import eu.eudat.logic.services.externalreferences.FunderService;
+import eu.eudat.logic.services.externalreferences.ProjectService;
+import eu.eudat.models.data.ExternalReference;
+import eu.eudat.models.data.ExternalReference2;
+import eu.eudat.models.data.datarepository.DataRepositoryModel;
+import eu.eudat.models.data.funder.Funder;
+import eu.eudat.models.data.helpers.responses.ResponseItem;
+import eu.eudat.models.data.project.Project;
+import eu.eudat.models.data.registries.RegistryModel;
+import eu.eudat.models.data.security.Principal;
+import eu.eudat.types.ApiMessageCode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.management.InvalidApplicationException;
+import java.util.List;
+
+@RestController
+@CrossOrigin
+@RequestMapping(path = {"api/external-references"})
+public class ExternalReferencesController extends BaseController {
+
+ private final FunderService funderService;
+ private final ExternalReferencesService externalReferencesService;
+ private final ProjectService projectService;
+
+ @Autowired
+ public ExternalReferencesController(
+ ApiContext apiContext,
+ FunderService funderService,
+ ExternalReferencesService externalReferencesService,
+ ProjectService projectService
+ ) {
+ super(apiContext);
+ this.funderService = funderService;
+ this.externalReferencesService = externalReferencesService;
+ this.projectService = projectService;
+ }
+
+ @PostMapping(path = {"funders"}, consumes = "application/json", produces = "application/json")
+ public @ResponseBody ResponseEntity>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
+ List dataTable = this.funderService.getCriteriaWithExternal(funderCriteria, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
+ }
+
+ @PostMapping(path = {"projects"}, consumes = "application/json", produces = "application/json")
+ public @ResponseBody
+ ResponseEntity>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
+ List dataTable = this.projectService.getCriteriaWithExternal(projectCriteria, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
+ }
+
+
+
+ @GetMapping(path = {"data-repo/{externalType}"}, produces = "application/json")
+ public @ResponseBody ResponseEntity>> listExternalReferecnes(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
+ @RequestParam(value = "type", required = false) String type, Principal principal
+ ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
+ List externalReferences = this.externalReferencesService.getExternalReference(externalType, query, type, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
+ }
+
+ @Transactional
+ @PostMapping(path = {"data-repo/persist"}, consumes = "application/json", produces = "application/json")
+ public @ResponseBody
+ ResponseEntity> createExternalReferecnes(@RequestBody ExternalReference externalReference, Principal principal) throws Exception {
+ ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
+ }
+
+
+
+
+ @GetMapping(path = {"{externalType}"}, produces = "application/json")
+ public @ResponseBody ResponseEntity>> listExternalReferecnes2(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
+ @RequestParam(value = "type", required = false) String type, Principal principal
+ ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
+ List externalReferences = this.externalReferencesService.getExternalReference2(externalType, query, type, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
+ }
+
+ @Transactional
+ @PostMapping(value = {"{externalType}/persist"}, consumes = "application/json", produces = "application/json")
+ public @ResponseBody
+ ResponseEntity> create(@RequestBody ExternalReference2 externalReference, Principal principal) throws Exception {
+ ExternalReference2 newExternalReference = this.externalReferencesService.create(externalReference, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
+ }
+
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ValidationController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ValidationController.java
new file mode 100644
index 000000000..d61525bd2
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ValidationController.java
@@ -0,0 +1,37 @@
+package eu.eudat.controllers.v2;
+
+import eu.eudat.controllers.BaseController;
+import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
+import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.logic.services.ValidationService;
+import eu.eudat.models.data.helpers.responses.ResponseItem;
+import eu.eudat.models.data.security.Principal;
+import eu.eudat.types.ApiMessageCode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@CrossOrigin
+@RequestMapping(path = {"api/validation"})
+public class ValidationController extends BaseController {
+
+ private ValidationService validationService;
+
+ @Autowired
+ public ValidationController(ApiContext apiContext, ValidationService validationService) {
+ super(apiContext);
+ this.validationService = validationService;
+ }
+
+ @GetMapping(path = {""}, produces = "application/json")
+ public @ResponseBody
+ ResponseEntity> validate(
+ @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
+ ) throws HugeResultSet, NoURLFound {
+ Boolean isValid = this.validationService.validateIdentifier(query, type, principal);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(isValid).status(ApiMessageCode.NO_MESSAGE));
+ }
+}
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 1b6f47e5a..1111f1fe1 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
@@ -4,8 +4,10 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.user.UserScope;
+import eu.eudat.commons.enums.EntityType;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Property;
+import eu.eudat.data.EntityDoiEntity;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.old.DescriptionTemplate;
@@ -1975,6 +1977,7 @@ public class DataManagementPlanManager {
return fileEnvelope;
}
+ @Transactional
public FileEnvelope getRDAJsonDocument(String id) throws Exception {
DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()))
@@ -2470,8 +2473,8 @@ public class DataManagementPlanManager {
for (DMP dmp: dmps) {
if (!dmp.getId().equals(selfId)) {
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
- for (Iterator it = dmp.getDois().iterator(); it.hasNext(); ) {
- EntityDoi entityDoi = it.next();
+ for (Iterator it = dmp.getDois().iterator(); it.hasNext(); ) {
+ EntityDoiEntity entityDoi = it.next();
if(entityDoi.getRepositoryId().equals(repositoryId)){
return entityDoi.getDoi();
}
@@ -2483,6 +2486,8 @@ public class DataManagementPlanManager {
return null;
}
+
+ @Transactional
public Doi createDoi(DepositRequest depositRequest) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId()));
if (!isUserOwnerOfDmp(dmp))
@@ -2526,16 +2531,16 @@ public class DataManagementPlanManager {
Doi doiModel = null;
if (finalDoi != null) {
- EntityDoi doiEntity = new EntityDoi();
+ EntityDoiEntity doiEntity = new EntityDoiEntity();
doiEntity.setId(UUID.randomUUID());
- doiEntity.setEntityType(EntityDoi.EntityType.DMP);
+ doiEntity.setEntityType(EntityType.DMP);
doiEntity.setDoi(finalDoi);
doiEntity.setRepositoryId(depositRequest.getRepositoryId());
- Date now = new Date();
- doiEntity.setCreatedAt(now);
- doiEntity.setUpdatedAt(now);
- doiEntity.setEntityId(dmp);
- apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);
+ doiEntity.setCreatedAt(Instant.now());
+ doiEntity.setUpdatedAt(Instant.now());
+ doiEntity.setEntityId(dmp.getId());
+ //TODO: Save doi
+// apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);
dmp.getDois().add(doiEntity);
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
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 cd6bc439e..b51dd0c47 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
@@ -5,10 +5,15 @@ 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.models.data.security.Principal;
+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;
@@ -18,18 +23,20 @@ import java.util.Optional;
public class DepositManager {
private static final Logger logger = LoggerFactory.getLogger(DepositManager.class);
- private List repositories;
+ //private List repositories;
private DataManagementPlanManager dataManagementPlanManager;
+ private final List depositClients;
@Autowired
- public DepositManager(List repositories, DataManagementPlanManager dataManagementPlanManager){
- this.repositories = repositories;
+ public DepositManager(/*List repositories,*/ DataManagementPlanManager dataManagementPlanManager, @Qualifier("depositClients") List depositClients){
+ //this.repositories = repositories;
this.dataManagementPlanManager = dataManagementPlanManager;
+ this.depositClients = depositClients;
}
public List getAvailableRepos() {
List reposConfigModel = new ArrayList<>();
- for (RepositoryDeposit r: this.repositories) {
+ for (RepositoryDeposit r: this.depositClients) {
List repoConf = r.getConfiguration();
if(repoConf != null) {
for(RepositoryDepositConfiguration cf: repoConf){
@@ -42,7 +49,7 @@ public class DepositManager {
}
public String authenticate(String id, String code) {
- for(RepositoryDeposit r: this.repositories){
+ for(RepositoryDeposit r: this.depositClients){
if(r.getConfiguration().stream().anyMatch(x -> x.getRepositoryId().equals(id))){
return r.authenticate(id, code);
}
@@ -50,12 +57,13 @@ public class DepositManager {
return null;
}
+ @Transactional
public Doi deposit(DepositRequest depositRequest) throws Exception {
return this.dataManagementPlanManager.createDoi(depositRequest);
}
public String getRepositoryLogo(String repositoryId){
- for(RepositoryDeposit r: this.repositories){
+ for(RepositoryDeposit r: this.depositClients){
Optional cf = r.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst();
if(cf.isPresent()){
return cf.get().isHasLogo() ? r.getLogo(repositoryId) : null;
diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java
index 86a9742f9..325720e60 100644
--- a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java
+++ b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java
@@ -50,6 +50,55 @@ public class RemoteFetcher {
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
}
+ public List