Removed EntityDao logic, added template stack, controller not yet implemented, db script not yet run
This commit is contained in:
parent
8574f33e56
commit
a38342e534
|
@ -15,6 +15,11 @@ public final class Permission {
|
||||||
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
|
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
|
||||||
public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType";
|
public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType";
|
||||||
|
|
||||||
|
//DescriptionTemplateType
|
||||||
|
public static String BrowseEntityDoi = "BrowseEntityDoi";
|
||||||
|
public static String EditEntityDoi = "EditEntityDoi";
|
||||||
|
public static String DeleteEntityDoi = "DeleteEntityDoi";
|
||||||
|
|
||||||
// UI Pages
|
// UI Pages
|
||||||
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
|
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,28 @@
|
||||||
package eu.eudat.commons.enums;
|
package eu.eudat.commons.enums;
|
||||||
|
|
||||||
public enum EntityType {
|
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum EntityType implements DatabaseEnum<Short> {
|
||||||
|
|
||||||
|
DMP((short) 0);
|
||||||
|
|
||||||
|
private final Short value;
|
||||||
|
|
||||||
|
EntityType(Short value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Short getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Short, EntityType> map = EnumUtils.getEnumValueMap(EntityType.class);
|
||||||
|
|
||||||
|
public static EntityType of(Short i) {
|
||||||
|
return map.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
|
|
||||||
import eu.eudat.data.converters.enums.ProviderTypeConverter;
|
import eu.eudat.data.converters.enums.ProviderTypeConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
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 eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -16,30 +16,35 @@ public class DescriptionTemplateTypeEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
private UUID id;
|
private UUID id;
|
||||||
public final static String _id = "id";
|
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Column(name = "name", length = 500, nullable = false)
|
@Column(name = "name", length = 500, nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
public final static String _name = "name";
|
|
||||||
|
public static final String _name = "name";
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false)
|
@Column(name = "created_at", nullable = false)
|
||||||
private Instant createdAt;
|
private Instant createdAt;
|
||||||
public final static String _createdAt = "createdAt";
|
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
@Column(name = "updated_at", nullable = false)
|
@Column(name = "updated_at", nullable = false)
|
||||||
private Instant updatedAt;
|
private Instant updatedAt;
|
||||||
public final static String _updatedAt = "updatedAt";
|
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "is_active", nullable = false)
|
||||||
@Convert(converter = IsActiveConverter.class)
|
@Convert(converter = IsActiveConverter.class)
|
||||||
private IsActive isActive;
|
private IsActive isActive;
|
||||||
public final static String _isActive = "isActive";
|
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = DescriptionTemplateTypeStatusConverter.class)
|
@Convert(converter = DescriptionTemplateTypeStatusConverter.class)
|
||||||
private DescriptionTemplateTypeStatus status;
|
private DescriptionTemplateTypeStatus status;
|
||||||
public final static String _status = "status";
|
|
||||||
|
|
||||||
|
public static final String _status = "status";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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<EntityType, Short>{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EntityType of(Short i) {
|
||||||
|
return EntityType.of(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
package eu.eudat.data.helpers;
|
|
||||||
|
|
||||||
import jakarta.persistence.Tuple;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class EntityBinder {
|
|
||||||
public static <T> T fromTuple(List<Tuple> tuple, String path) {
|
|
||||||
try {
|
|
||||||
return (T) tuple.get(0).get(path);
|
|
||||||
}catch (IllegalArgumentException illegalArgument){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
@ -183,7 +184,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
||||||
private Set<EntityDoi> dois;
|
private Set<EntityDoiEntity> dois;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"Project\"")
|
@JoinColumn(name = "\"Project\"")
|
||||||
|
@ -340,10 +341,10 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<EntityDoi> getDois() {
|
public Set<EntityDoiEntity> getDois() {
|
||||||
return dois;
|
return dois;
|
||||||
}
|
}
|
||||||
public void setDois(Set<EntityDoi> dois) {
|
public void setDois(Set<EntityDoiEntity> dois) {
|
||||||
this.dois = dois;
|
this.dois = dois;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<EntityDoi, UUID> {
|
|
||||||
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> tuple, List<String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,4 +37,8 @@ public class EventBroker {
|
||||||
public void emit(DescriptionTemplateTypeTouchedEvent event) {
|
public void emit(DescriptionTemplateTypeTouchedEvent event) {
|
||||||
this.applicationEventPublisher.publishEvent(event);
|
this.applicationEventPublisher.publishEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void emit(EntityDoiTouchedEvent event) {
|
||||||
|
this.applicationEventPublisher.publishEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,10 @@
|
||||||
package eu.eudat.model.builder;
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||||
import eu.eudat.model.DescriptionTemplateType;
|
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.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
@ -19,7 +15,6 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
@ -39,21 +34,29 @@ public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTempl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DescriptionTemplateType> build(FieldSet fields, List<DescriptionTemplateTypeEntity> datas) throws MyApplicationException {
|
public List<DescriptionTemplateType> build(FieldSet fields, List<DescriptionTemplateTypeEntity> data) 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));
|
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));
|
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<DescriptionTemplateType> models = new ArrayList<>();
|
List<DescriptionTemplateType> models = new ArrayList<>();
|
||||||
for (DescriptionTemplateTypeEntity d : datas) {
|
for (DescriptionTemplateTypeEntity d : data) {
|
||||||
DescriptionTemplateType m = new DescriptionTemplateType();
|
DescriptionTemplateType m = new DescriptionTemplateType();
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._id))) m.setId(d.getId());
|
if (fields.hasField(this.asIndexer(DescriptionTemplateType._id)))
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._name))) m.setName(d.getName());
|
m.setId(d.getId());
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
if (fields.hasField(this.asIndexer(DescriptionTemplateType._name)))
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
m.setName(d.getName());
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._isActive))) m.setIsActive(d.getIsActive());
|
if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt)))
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._status))) m.setStatus(d.getStatus());
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
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);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
|
@ -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<EntityDoi, EntityDoiEntity> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public EntityDoiBuilder(
|
||||||
|
ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(EntityDoiBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityDoiBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EntityDoi> build(FieldSet fields, List<EntityDoiEntity> 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<EntityDoi> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -15,10 +15,12 @@ import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@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));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeCensor.class));
|
||||||
|
|
||||||
protected final AuthorizationService authService;
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
public DescriptionTemplateTypeCensor(ConventionService conventionService, AuthorizationService authService) {
|
public DescriptionTemplateTypeCensor(ConventionService conventionService, AuthorizationService authService) {
|
||||||
super(conventionService);
|
super(conventionService);
|
||||||
this.authService = authService;
|
this.authService = authService;
|
||||||
|
@ -26,7 +28,8 @@ public class DescriptionTemplateTypeCensor extends BaseCensor{
|
||||||
|
|
||||||
public void censor(FieldSet fields, UUID userId) {
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
if (fields.isEmpty()) return;
|
if (fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescriptionTemplateType);
|
this.authService.authorizeForce(Permission.BrowseDescriptionTemplateType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,9 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeDeleter.class));
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
protected final QueryFactory queryFactory;
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
protected final DeleterFactory deleterFactory;
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -59,7 +61,8 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
|
||||||
|
|
||||||
public void delete(List<DescriptionTemplateTypeEntity> data) throws InvalidApplicationException {
|
public void delete(List<DescriptionTemplateTypeEntity> data) throws InvalidApplicationException {
|
||||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
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();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
|
|
|
@ -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<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<DescriptionTemplateTypeEntity> 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<DescriptionTemplateTypeEntity> 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<DescriptionTemplateTypeEntity> 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,10 +25,15 @@ import java.util.*;
|
||||||
public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateTypeEntity> {
|
public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateTypeEntity> {
|
||||||
|
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
private Collection<UUID> ids;
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
private Collection<IsActive> isActives;
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
private Collection<DescriptionTemplateTypeStatus> statuses;
|
private Collection<DescriptionTemplateTypeStatus> statuses;
|
||||||
|
|
||||||
private Collection<UUID> excludedIds;
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery like(String value) {
|
public DescriptionTemplateTypeQuery like(String value) {
|
||||||
|
@ -102,6 +107,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
private final AuthorizationService authService;
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery(
|
public DescriptionTemplateTypeQuery(
|
||||||
|
@ -127,7 +133,8 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
if (this.ids != null) {
|
if (this.ids != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
|
CriteriaBuilder.In<UUID> 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);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.like != null && !this.like.isEmpty()) {
|
if (this.like != null && !this.like.isEmpty()) {
|
||||||
|
@ -135,21 +142,24 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
}
|
}
|
||||||
if (this.isActives != null) {
|
if (this.isActives != null) {
|
||||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive));
|
CriteriaBuilder.In<IsActive> 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);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.statuses != null) {
|
if (this.statuses != null) {
|
||||||
CriteriaBuilder.In<DescriptionTemplateTypeStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
|
CriteriaBuilder.In<DescriptionTemplateTypeStatus> 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);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.excludedIds != null) {
|
if (this.excludedIds != null) {
|
||||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
|
CriteriaBuilder.In<UUID> 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());
|
predicates.add(notInClause.not());
|
||||||
}
|
}
|
||||||
if (predicates.size() > 0) {
|
if (!predicates.isEmpty()) {
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,13 +181,20 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(DescriptionTemplateType._id)) return DescriptionTemplateType._id;
|
if (item.match(DescriptionTemplateType._id))
|
||||||
else if (item.match(DescriptionTemplateType._name)) return DescriptionTemplateType._name;
|
return DescriptionTemplateType._id;
|
||||||
else if (item.match(DescriptionTemplateType._createdAt)) return DescriptionTemplateType._createdAt;
|
else if (item.match(DescriptionTemplateType._name))
|
||||||
else if (item.match(DescriptionTemplateType._updatedAt)) return DescriptionTemplateType._updatedAt;
|
return DescriptionTemplateType._name;
|
||||||
else if (item.match(DescriptionTemplateType._isActive)) return DescriptionTemplateType._isActive;
|
else if (item.match(DescriptionTemplateType._createdAt))
|
||||||
else if (item.match(DescriptionTemplateType._status)) return DescriptionTemplateType._status;
|
return DescriptionTemplateType._createdAt;
|
||||||
else return null;
|
else if (item.match(DescriptionTemplateType._updatedAt))
|
||||||
|
return DescriptionTemplateType._updatedAt;
|
||||||
|
else if (item.match(DescriptionTemplateType._isActive))
|
||||||
|
return DescriptionTemplateType._isActive;
|
||||||
|
else if (item.match(DescriptionTemplateType._status))
|
||||||
|
return DescriptionTemplateType._status;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.EntityType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
import jakarta.persistence.Tuple;
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<EntityType> types;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<String> dois;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> 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<UUID> 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<IsActive> 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<EntityType> values) {
|
||||||
|
this.types = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityDoiQuery excludedIds(Collection<UUID> 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<String> 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<AuthorizationFlags> 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<EntityDoiEntity> 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 <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> 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<IsActive> 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<EntityType> 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<UUID> 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<String> 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<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,9 +12,13 @@ import java.util.UUID;
|
||||||
public class DescriptionTemplateTypeLookup extends Lookup {
|
public class DescriptionTemplateTypeLookup extends Lookup {
|
||||||
|
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
private List<IsActive> isActive;
|
private List<IsActive> isActive;
|
||||||
|
|
||||||
private List<DescriptionTemplateTypeStatus> statuses;
|
private List<DescriptionTemplateTypeStatus> statuses;
|
||||||
|
|
||||||
private List<UUID> ids;
|
private List<UUID> ids;
|
||||||
|
|
||||||
private List<UUID> excludedIds;
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
public String getLike() {
|
public String getLike() {
|
||||||
|
@ -51,11 +55,16 @@ public class DescriptionTemplateTypeLookup extends Lookup {
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery enrich(QueryFactory queryFactory) {
|
public DescriptionTemplateTypeQuery enrich(QueryFactory queryFactory) {
|
||||||
DescriptionTemplateTypeQuery query = queryFactory.query(DescriptionTemplateTypeQuery.class);
|
DescriptionTemplateTypeQuery query = queryFactory.query(DescriptionTemplateTypeQuery.class);
|
||||||
if (this.like != null) query.like(this.like);
|
if (this.like != null)
|
||||||
if (this.isActive != null) query.isActive(this.isActive);
|
query.like(this.like);
|
||||||
if (this.statuses != null) query.statuses(this.statuses);
|
if (this.isActive != null)
|
||||||
if (this.ids != null) query.ids(this.ids);
|
query.isActive(this.isActive);
|
||||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
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);
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
|
|
@ -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> isActive;
|
||||||
|
|
||||||
|
private List<EntityType> types;
|
||||||
|
|
||||||
|
private List<UUID> ids;
|
||||||
|
|
||||||
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
|
private List<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,7 +12,9 @@ import javax.management.InvalidApplicationException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DescriptionTemplateTypeService {
|
public interface DescriptionTemplateTypeService {
|
||||||
|
|
||||||
DescriptionTemplateType persist(DescriptionTemplateTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
DescriptionTemplateType persist(DescriptionTemplateTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
||||||
|
|
||||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,17 +41,27 @@ import java.util.UUID;
|
||||||
@Service
|
@Service
|
||||||
@RequestScope
|
@RequestScope
|
||||||
public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTypeService {
|
public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTypeService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeServiceImpl.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeServiceImpl.class));
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
private final DeleterFactory deleterFactory;
|
private final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
|
|
||||||
private final ErrorThesaurusProperties errors;
|
private final ErrorThesaurusProperties errors;
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
private final EventBroker eventBroker;
|
private final EventBroker eventBroker;
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -88,7 +98,8 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
|
||||||
DescriptionTemplateTypeEntity data;
|
DescriptionTemplateTypeEntity data;
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
data = this.entityManager.find(DescriptionTemplateTypeEntity.class, model.getId());
|
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 {
|
} else {
|
||||||
data = new DescriptionTemplateTypeEntity();
|
data = new DescriptionTemplateTypeEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
|
@ -99,8 +110,10 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
|
||||||
data.setName(model.getName());
|
data.setName(model.getName());
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
if (isUpdate) this.entityManager.merge(data);
|
if (isUpdate)
|
||||||
else this.entityManager.persist(data);
|
this.entityManager.merge(data);
|
||||||
|
else
|
||||||
|
this.entityManager.persist(data);
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
|
@ -115,5 +128,6 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
|
||||||
|
|
||||||
this.deleterFactory.deleter(DescriptionTemplateTypeDeleter.class).deleteAndSaveByIds(List.of(id));
|
this.deleterFactory.deleter(DescriptionTemplateTypeDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.old.EntityDoi;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface EntityDoiDao extends DatabaseAccessLayer<EntityDoi, UUID> {
|
|
||||||
EntityDoi findFromDoi(String doi);
|
|
||||||
}
|
|
|
@ -1,56 +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 java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("EntityDoiDao")
|
|
||||||
public class EntityDoiDaoImpl extends DatabaseAccess<EntityDoi> implements EntityDoiDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public EntityDoiDaoImpl(DatabaseService<EntityDoi> databaseService){
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityDoi createOrUpdate(EntityDoi item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<EntityDoi> createOrUpdateAsync(EntityDoi item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityDoi find(UUID id) {
|
|
||||||
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityDoi findFromDoi(String doi) {
|
|
||||||
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<EntityDoi> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(EntityDoi.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,10 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.entities.*;
|
import eu.eudat.data.dao.entities.*;
|
||||||
import eu.eudat.data.old.DescriptionTemplate;
|
import eu.eudat.data.old.DescriptionTemplate;
|
||||||
|
@ -2449,8 +2451,8 @@ public class DataManagementPlanManager {
|
||||||
for (DMP dmp: dmps) {
|
for (DMP dmp: dmps) {
|
||||||
if (!dmp.getId().equals(selfId)) {
|
if (!dmp.getId().equals(selfId)) {
|
||||||
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
||||||
for (Iterator<EntityDoi> it = dmp.getDois().iterator(); it.hasNext(); ) {
|
for (Iterator<EntityDoiEntity> it = dmp.getDois().iterator(); it.hasNext(); ) {
|
||||||
EntityDoi entityDoi = it.next();
|
EntityDoiEntity entityDoi = it.next();
|
||||||
if(entityDoi.getRepositoryId().equals(repositoryId)){
|
if(entityDoi.getRepositoryId().equals(repositoryId)){
|
||||||
return entityDoi.getDoi();
|
return entityDoi.getDoi();
|
||||||
}
|
}
|
||||||
|
@ -2505,16 +2507,16 @@ public class DataManagementPlanManager {
|
||||||
Doi doiModel = null;
|
Doi doiModel = null;
|
||||||
if (finalDoi != null) {
|
if (finalDoi != null) {
|
||||||
|
|
||||||
EntityDoi doiEntity = new EntityDoi();
|
EntityDoiEntity doiEntity = new EntityDoiEntity();
|
||||||
doiEntity.setId(UUID.randomUUID());
|
doiEntity.setId(UUID.randomUUID());
|
||||||
doiEntity.setEntityType(EntityDoi.EntityType.DMP);
|
doiEntity.setEntityType(EntityType.DMP);
|
||||||
doiEntity.setDoi(finalDoi);
|
doiEntity.setDoi(finalDoi);
|
||||||
doiEntity.setRepositoryId(depositRequest.getRepositoryId());
|
doiEntity.setRepositoryId(depositRequest.getRepositoryId());
|
||||||
Date now = new Date();
|
doiEntity.setCreatedAt(Instant.now());
|
||||||
doiEntity.setCreatedAt(now);
|
doiEntity.setUpdatedAt(Instant.now());
|
||||||
doiEntity.setUpdatedAt(now);
|
doiEntity.setEntityId(dmp.getId());
|
||||||
doiEntity.setEntityId(dmp);
|
//TODO: Save doi
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);
|
// apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);
|
||||||
|
|
||||||
dmp.getDois().add(doiEntity);
|
dmp.getDois().add(doiEntity);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||||
|
|
|
@ -3,8 +3,8 @@ package eu.eudat.logic.services.operations;
|
||||||
import eu.eudat.data.dao.entities.*;
|
import eu.eudat.data.dao.entities.*;
|
||||||
import eu.eudat.data.dao.entities.security.CredentialDao;
|
import eu.eudat.data.dao.entities.security.CredentialDao;
|
||||||
|
|
||||||
|
|
||||||
public interface DatabaseRepository {
|
public interface DatabaseRepository {
|
||||||
|
|
||||||
DataRepositoryDao getDataRepositoryDao();
|
DataRepositoryDao getDataRepositoryDao();
|
||||||
|
|
||||||
DatasetDao getDatasetDao();
|
DatasetDao getDatasetDao();
|
||||||
|
@ -59,7 +59,5 @@ public interface DatabaseRepository {
|
||||||
|
|
||||||
FileUploadDao getFileUploadDao();
|
FileUploadDao getFileUploadDao();
|
||||||
|
|
||||||
EntityDoiDao getEntityDoiDao();
|
|
||||||
|
|
||||||
<T> void detachEntity(T entity);
|
<T> void detachEntity(T entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,43 +2,66 @@ package eu.eudat.logic.services.operations;
|
||||||
|
|
||||||
import eu.eudat.data.dao.entities.*;
|
import eu.eudat.data.dao.entities.*;
|
||||||
import eu.eudat.data.dao.entities.security.CredentialDao;
|
import eu.eudat.data.dao.entities.security.CredentialDao;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
|
|
||||||
|
|
||||||
@Service("databaseRepository")
|
@Service("databaseRepository")
|
||||||
public class DatabaseRepositoryImpl implements DatabaseRepository {
|
public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
|
|
||||||
private DataRepositoryDao dataRepositoryDao;
|
private DataRepositoryDao dataRepositoryDao;
|
||||||
|
|
||||||
private DatasetDao datasetDao;
|
private DatasetDao datasetDao;
|
||||||
|
|
||||||
private DatasetProfileDao datasetProfileDao;
|
private DatasetProfileDao datasetProfileDao;
|
||||||
|
|
||||||
private DMPDao dmpDao;
|
private DMPDao dmpDao;
|
||||||
|
|
||||||
private DmpDatasetProfileDao dmpDatasetProfileDao;
|
private DmpDatasetProfileDao dmpDatasetProfileDao;
|
||||||
|
|
||||||
private OrganisationDao organisationDao;
|
private OrganisationDao organisationDao;
|
||||||
|
|
||||||
private GrantDao GrantDao;
|
private GrantDao GrantDao;
|
||||||
|
|
||||||
private RegistryDao registryDao;
|
private RegistryDao registryDao;
|
||||||
|
|
||||||
private ResearcherDao researcherDao;
|
private ResearcherDao researcherDao;
|
||||||
|
|
||||||
private ServiceDao serviceDao;
|
private ServiceDao serviceDao;
|
||||||
|
|
||||||
private UserInfoDao userInfoDao;
|
private UserInfoDao userInfoDao;
|
||||||
|
|
||||||
private InvitationDao invitationDao;
|
private InvitationDao invitationDao;
|
||||||
|
|
||||||
private CredentialDao credentialDao;
|
private CredentialDao credentialDao;
|
||||||
|
|
||||||
private ExternalDatasetDao externalDatasetDao;
|
private ExternalDatasetDao externalDatasetDao;
|
||||||
|
|
||||||
private UserRoleDao userRoleDao;
|
private UserRoleDao userRoleDao;
|
||||||
|
|
||||||
private UserDatasetProfileDao userDatasetProfileDao;
|
private UserDatasetProfileDao userDatasetProfileDao;
|
||||||
|
|
||||||
private UserDmpDao userDmpDao;
|
private UserDmpDao userDmpDao;
|
||||||
|
|
||||||
private ContentDao contentDao;
|
private ContentDao contentDao;
|
||||||
|
|
||||||
private DMPProfileDao dmpProfileDao;
|
private DMPProfileDao dmpProfileDao;
|
||||||
|
|
||||||
private DatasetExternalDatasetDao datasetExternalDatasetDao;
|
private DatasetExternalDatasetDao datasetExternalDatasetDao;
|
||||||
|
|
||||||
private DatasetServiceDao datasetServiceDao;
|
private DatasetServiceDao datasetServiceDao;
|
||||||
|
|
||||||
private EmailConfirmationDao loginConfirmationEmailDao;
|
private EmailConfirmationDao loginConfirmationEmailDao;
|
||||||
|
|
||||||
private ProjectDao projectDao;
|
private ProjectDao projectDao;
|
||||||
|
|
||||||
private FunderDao funderDao;
|
private FunderDao funderDao;
|
||||||
|
|
||||||
private LockDao lockDao;
|
private LockDao lockDao;
|
||||||
|
|
||||||
private NotificationDao notificationDao;
|
private NotificationDao notificationDao;
|
||||||
|
|
||||||
private FileUploadDao fileUploadDao;
|
private FileUploadDao fileUploadDao;
|
||||||
private EntityDoiDao entityDoiDao;
|
|
||||||
|
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@ -317,16 +340,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
this.fileUploadDao = fileUploadDao;
|
this.fileUploadDao = fileUploadDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityDoiDao getEntityDoiDao() {
|
|
||||||
return entityDoiDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public void setEntityDoiDao(EntityDoiDao entityDoiDao) {
|
|
||||||
this.entityDoiDao = entityDoiDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> void detachEntity(T entity) {
|
public <T> void detachEntity(T entity) {
|
||||||
this.entityManager.detach(entity);
|
this.entityManager.detach(entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.models.data.doi;
|
package eu.eudat.models.data.doi;
|
||||||
|
|
||||||
import eu.eudat.data.old.EntityDoi;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Doi implements DataModel<EntityDoi, Doi> {
|
public class Doi {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
private String doi;
|
private String doi;
|
||||||
|
@ -57,28 +57,25 @@ public class Doi implements DataModel<EntityDoi, Doi> {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Doi fromDataModel(EntityDoiEntity entity) {
|
||||||
public Doi fromDataModel(EntityDoi entity) {
|
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.repositoryId = entity.getRepositoryId();
|
this.repositoryId = entity.getRepositoryId();
|
||||||
this.doi = entity.getDoi();
|
this.doi = entity.getDoi();
|
||||||
this.createdAt = entity.getCreatedAt();
|
this.createdAt = Date.from(entity.getCreatedAt());
|
||||||
this.updatedAt = entity.getUpdatedAt();
|
this.updatedAt = Date.from(entity.getUpdatedAt());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public EntityDoiEntity toDataModel() throws Exception {
|
||||||
public EntityDoi toDataModel() throws Exception {
|
EntityDoiEntity entityDoi = new EntityDoiEntity();
|
||||||
EntityDoi entityDoi = new EntityDoi();
|
|
||||||
entityDoi.setId(this.id);
|
entityDoi.setId(this.id);
|
||||||
entityDoi.setRepositoryId(this.repositoryId);
|
entityDoi.setRepositoryId(this.repositoryId);
|
||||||
entityDoi.setDoi(this.doi);
|
entityDoi.setDoi(this.doi);
|
||||||
entityDoi.setCreatedAt(this.createdAt);
|
entityDoi.setCreatedAt(this.createdAt.toInstant());
|
||||||
entityDoi.setUpdatedAt(this.updatedAt);
|
entityDoi.setUpdatedAt(this.updatedAt.toInstant());
|
||||||
return entityDoi;
|
return entityDoi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHint() {
|
public String getHint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.eudat.models.data.rda;
|
package eu.eudat.models.data.rda;
|
||||||
|
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.old.Dataset;
|
||||||
import eu.eudat.data.old.EntityDoi;
|
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.data.old.UserDMP;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -147,7 +147,7 @@ public class DmpRDAExportModel {
|
||||||
dmpRda.description = entity.getDescription().replace("\n", " ");
|
dmpRda.description = entity.getDescription().replace("\n", " ");
|
||||||
if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
||||||
boolean zenodoDoi = false;
|
boolean zenodoDoi = false;
|
||||||
for(EntityDoi doi: entity.getDois()){
|
for(EntityDoiEntity doi: entity.getDois()){
|
||||||
if(doi.getRepositoryId().equals("Zenodo")){
|
if(doi.getRepositoryId().equals("Zenodo")){
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(doi.getDoi(), "zenodo");
|
dmpRda.dmp_id = new IdRDAExportModel(doi.getDoi(), "zenodo");
|
||||||
zenodoDoi = true;
|
zenodoDoi = true;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.models.rda.mapper;
|
package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
|
@ -52,7 +53,7 @@ public class DmpRDAMapper {
|
||||||
}
|
}
|
||||||
Dmp rda = new Dmp();
|
Dmp rda = new Dmp();
|
||||||
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
||||||
for(EntityDoi doi: dmp.getDois()){
|
for(EntityDoiEntity doi: dmp.getDois()){
|
||||||
if(doi.getRepositoryId().equals("Zenodo")){
|
if(doi.getRepositoryId().equals("Zenodo")){
|
||||||
rda.setDmpId(DmpIdRDAMapper.toRDA(doi.getDoi()));
|
rda.setDmpId(DmpIdRDAMapper.toRDA(doi.getDoi()));
|
||||||
}
|
}
|
||||||
|
@ -128,8 +129,9 @@ public class DmpRDAMapper {
|
||||||
entity.setLabel(rda.getTitle());
|
entity.setLabel(rda.getTitle());
|
||||||
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
|
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
|
||||||
try {
|
try {
|
||||||
EntityDoi doi = apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().findFromDoi(rda.getDmpId().getIdentifier());
|
//TODO: Find from doi = rda.getDmpId().getIdentifier()
|
||||||
Set<EntityDoi> dois = new HashSet<>();
|
EntityDoiEntity doi = new EntityDoiEntity();
|
||||||
|
Set<EntityDoiEntity> dois = new HashSet<>();
|
||||||
dois.add(doi);
|
dois.add(doi);
|
||||||
entity.setDois(dois);
|
entity.setDois(dois);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.publicapi.models.doi;
|
package eu.eudat.publicapi.models.doi;
|
||||||
|
|
||||||
import eu.eudat.data.old.EntityDoi;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DoiPublicModel implements DataModel<EntityDoi, DoiPublicModel>, LabelGenerator {
|
public class DoiPublicModel implements LabelGenerator {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
private String doi;
|
private String doi;
|
||||||
|
@ -32,17 +32,15 @@ public class DoiPublicModel implements DataModel<EntityDoi, DoiPublicModel>, Lab
|
||||||
this.doi = doi;
|
this.doi = doi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public DoiPublicModel fromDataModel(EntityDoiEntity entity) {
|
||||||
public DoiPublicModel fromDataModel(EntityDoi entity) {
|
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.repositoryId = entity.getRepositoryId();
|
this.repositoryId = entity.getRepositoryId();
|
||||||
this.doi = entity.getDoi();
|
this.doi = entity.getDoi();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public EntityDoiEntity toDataModel() throws Exception {
|
||||||
public EntityDoi toDataModel() throws Exception {
|
EntityDoiEntity entity = new EntityDoiEntity();
|
||||||
EntityDoi entity = new EntityDoi();
|
|
||||||
entity.setId(this.getId());
|
entity.setId(this.getId());
|
||||||
entity.setRepositoryId(this.getRepositoryId());
|
entity.setRepositoryId(this.getRepositoryId());
|
||||||
entity.setDoi(this.getDoi());
|
entity.setDoi(this.getDoi());
|
||||||
|
@ -54,7 +52,6 @@ public class DoiPublicModel implements DataModel<EntityDoi, DoiPublicModel>, Lab
|
||||||
return this.getDoi();
|
return this.getDoi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHint() {
|
public String getHint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "ID" TO id;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "EntityType" TO entity_type;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "RepositoryId" TO repository_id;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "Doi" TO doi;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "CreatedAt" TO created_at;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "UpdatedAt" TO updated_at;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
RENAME "EntityId" TO entity_id;
|
||||||
|
|
||||||
|
ALTER TABLE public."EntityDoi"
|
||||||
|
ADD COLUMN is_active smallint NOT NULL DEFAULT 1
|
Loading…
Reference in New Issue