Compare commits
3 Commits
29022ee1cd
...
73b0272672
Author | SHA1 | Date |
---|---|---|
Efstratios Giannopoulos | 73b0272672 | |
Efstratios Giannopoulos | f253fd965c | |
Efstratios Giannopoulos | ccd7d069cb |
|
@ -50,6 +50,7 @@ public class AuditableAction {
|
||||||
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
|
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
|
||||||
public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist");
|
public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist");
|
||||||
public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete");
|
public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete");
|
||||||
|
public static final EventId Reference_Search = new EventId(7004, "Reference_Search");
|
||||||
|
|
||||||
public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query");
|
public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query");
|
||||||
public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup");
|
public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup");
|
||||||
|
|
|
@ -1,140 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DataRepository\"")
|
|
||||||
public class DataRepository implements Serializable, DataEntity<DataRepository, UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"")
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"")
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"", nullable = false)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"", nullable = false)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"")
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(DataRepository entity) {
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataRepository 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");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"ExternalDataset\"")
|
|
||||||
public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false)
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"", nullable = false)
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = false)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(ExternalDataset entity) {
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.modified = new Date();
|
|
||||||
this.creationUser = entity.getCreationUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDataset 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");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,183 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Funder\"")
|
|
||||||
public class Funder implements DataEntity<Funder, UUID> {
|
|
||||||
|
|
||||||
public enum Status {
|
|
||||||
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
|
|
||||||
|
|
||||||
private short value;
|
|
||||||
|
|
||||||
Status(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Status fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return INACTIVE;
|
|
||||||
case 1:
|
|
||||||
return ACTIVE;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Funder Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum FunderType {
|
|
||||||
EXTERNAL(0), INTERNAL(1);
|
|
||||||
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
FunderType(Integer value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FunderType fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return EXTERNAL;
|
|
||||||
case 1:
|
|
||||||
return INTERNAL;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Grant Type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
//@GeneratedValue
|
|
||||||
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@Column(name = "\"Type\"")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Funder entity) {
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.reference = entity.getReference();
|
|
||||||
this.definition = entity.getDefinition();
|
|
||||||
this.status = entity.getStatus();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.modified = new Date();
|
|
||||||
this.type = entity.getType();
|
|
||||||
this.creationUser = entity.getCreationUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Funder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,299 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Grant\"")
|
|
||||||
//@NamedEntityGraphs({
|
|
||||||
// @NamedEntityGraph(
|
|
||||||
// name = "grantRecentActivity",
|
|
||||||
// attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
|
|
||||||
// subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
|
|
||||||
// ),
|
|
||||||
// @NamedEntityGraph(
|
|
||||||
// name = "grantListingItem",
|
|
||||||
// attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
|
|
||||||
// subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
|
|
||||||
// )
|
|
||||||
//})
|
|
||||||
public class Grant implements DataEntity<Grant, UUID> {
|
|
||||||
|
|
||||||
public enum Status {
|
|
||||||
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
|
|
||||||
|
|
||||||
private short value;
|
|
||||||
|
|
||||||
private Status(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Status fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return INACTIVE;
|
|
||||||
case 1:
|
|
||||||
return ACTIVE;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Grant Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum GrantType {
|
|
||||||
EXTERNAL(0), INTERNAL(1);
|
|
||||||
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
private GrantType(Integer value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GrantType fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return EXTERNAL;
|
|
||||||
case 1:
|
|
||||||
return INTERNAL;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Grant Type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
//@GeneratedValue
|
|
||||||
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
|
|
||||||
// @OneToMany(mappedBy = "grant")
|
|
||||||
// private Set<DMP> dmps;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"StartDate\"", nullable = true)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date startdate = null;
|
|
||||||
|
|
||||||
@Column(name = "\"EndDate\"", nullable = true)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date enddate = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@Column(name = "\"Description\"")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Column(name = "\"Type\"")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Content\"")
|
|
||||||
private Content content;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Funder\"")
|
|
||||||
private Funder funder;
|
|
||||||
|
|
||||||
public Grant() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Grant(Grant grant) {
|
|
||||||
this.id = grant.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getStartdate() {
|
|
||||||
return startdate;
|
|
||||||
}
|
|
||||||
public void setStartdate(Date startdate) {
|
|
||||||
this.startdate = startdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getEnddate() {
|
|
||||||
return enddate;
|
|
||||||
}
|
|
||||||
public void setEnddate(Date enddate) {
|
|
||||||
this.enddate = enddate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Set<DMP> getDmps() {
|
|
||||||
// return dmps;
|
|
||||||
// }
|
|
||||||
// public void setDmps(Set<DMP> dmps) {
|
|
||||||
// this.dmps = dmps;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Content getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
public void setContent(Content content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Funder getFunder() {
|
|
||||||
return funder;
|
|
||||||
}
|
|
||||||
public void setFunder(Funder funder) {
|
|
||||||
this.funder = funder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Grant entity) {
|
|
||||||
this.description = entity.getDescription();
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.definition = entity.getDefinition();
|
|
||||||
// this.dmps = entity.getDmps();
|
|
||||||
this.startdate = entity.getStartdate();
|
|
||||||
this.enddate = entity.getEnddate();
|
|
||||||
this.modified = new Date();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
this.funder = entity.getFunder();
|
|
||||||
if (entity.getContent() != null) this.content = entity.getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Grant 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 + "dmps"))
|
|
||||||
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
|
||||||
// if (fields.contains(currentBase + "creationUser"))
|
|
||||||
// this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,149 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
//@Table(name = "\"Organisation\"")
|
|
||||||
//@NamedEntityGraphs({
|
|
||||||
// @NamedEntityGraph(
|
|
||||||
// name = "organisationRecentActivity",
|
|
||||||
// attributeNodes = {@NamedAttributeNode(value = "dmps")}
|
|
||||||
// )
|
|
||||||
//})
|
|
||||||
public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
// @OneToMany(fetch = FetchType.LAZY)
|
|
||||||
// @JoinTable(name = "\"DMPOrganisation\"",
|
|
||||||
// joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
|
|
||||||
// inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
|
||||||
// )
|
|
||||||
// private Set<DMP> dmps;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Set<DMP> getDmps() {
|
|
||||||
// return dmps;
|
|
||||||
// }
|
|
||||||
// public void setDmps(Set<DMP> dmps) {
|
|
||||||
// this.dmps = dmps;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Organisation entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Organisation 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");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,289 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Project\"")
|
|
||||||
public class Project implements DataEntity<Project, UUID> {
|
|
||||||
|
|
||||||
public enum Status {
|
|
||||||
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
|
|
||||||
|
|
||||||
private short value;
|
|
||||||
|
|
||||||
Status(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Status fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return INACTIVE;
|
|
||||||
case 1:
|
|
||||||
return ACTIVE;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Project Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ProjectType {
|
|
||||||
EXTERNAL(0), INTERNAL(1);
|
|
||||||
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
ProjectType(Integer value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProjectType fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return EXTERNAL;
|
|
||||||
case 1:
|
|
||||||
return INTERNAL;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Project Type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
//@GeneratedValue
|
|
||||||
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
// @OneToMany(mappedBy = "project")
|
|
||||||
// private Set<DMP> dmps;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"StartDate\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date startdate = null;
|
|
||||||
|
|
||||||
@Column(name = "\"EndDate\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date enddate = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@Column(name = "\"Description\"")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Column(name = "\"Type\"")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Content\"")
|
|
||||||
private Content content;
|
|
||||||
|
|
||||||
public Project() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Project(Project project) {this.id = project.getId();}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Set<DMP> getDmps() {
|
|
||||||
// return dmps;
|
|
||||||
// }
|
|
||||||
// public void setDmps(Set<DMP> dmps) {
|
|
||||||
// this.dmps = dmps;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getStartdate() {
|
|
||||||
return startdate;
|
|
||||||
}
|
|
||||||
public void setStartdate(Date startdate) {
|
|
||||||
this.startdate = startdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getEnddate() {
|
|
||||||
return enddate;
|
|
||||||
}
|
|
||||||
public void setEnddate(Date enddate) {
|
|
||||||
this.enddate = enddate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Content getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
public void setContent(Content content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Project entity) {
|
|
||||||
this.description = entity.getDescription();
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.definition = entity.getDefinition();
|
|
||||||
// this.dmps = entity.getDmps();
|
|
||||||
this.startdate = entity.getStartdate();
|
|
||||||
this.enddate = entity.getEnddate();
|
|
||||||
this.modified = new Date();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
if (entity.getContent() != null) this.content = entity.getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Project projectFromGrant(Grant grant) {
|
|
||||||
Project project = new Project();
|
|
||||||
project.setDescription(grant.getDescription());
|
|
||||||
project.setLabel(grant.getLabel());
|
|
||||||
project.setAbbreviation(grant.getAbbreviation());
|
|
||||||
project.setCreated(new Date());
|
|
||||||
project.setDefinition(grant.getDefinition());
|
|
||||||
// project.setDmps(grant.getDmps());
|
|
||||||
project.setStartdate(grant.getStartdate());
|
|
||||||
project.setEnddate(grant.getEnddate());
|
|
||||||
project.setModified(new Date());
|
|
||||||
project.setUri(grant.getUri());
|
|
||||||
project.setContent(grant.getContent());
|
|
||||||
project.setReference(grant.getReference());
|
|
||||||
project.setStatus(grant.getStatus());
|
|
||||||
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project 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 + "dmps"))
|
|
||||||
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
|
||||||
// if (fields.contains(currentBase + "creationUser"))
|
|
||||||
// this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Registry\"")
|
|
||||||
public class Registry implements DataEntity<Registry, UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
private Set<DescriptionEntity> descriptionEntities;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DescriptionEntity> getDatasets() {
|
|
||||||
return descriptionEntities;
|
|
||||||
}
|
|
||||||
public void setDatasets(Set<DescriptionEntity> descriptionEntities) {
|
|
||||||
this.descriptionEntities = descriptionEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Registry entity) {
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Registry 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");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,156 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Researcher\"")
|
|
||||||
public class Researcher implements DataEntity<Researcher, UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false, length = 250)
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"PrimaryEmail\"")
|
|
||||||
private String primaryEmail;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
|
|
||||||
// @OneToMany(fetch = FetchType.LAZY)
|
|
||||||
// @JoinTable(name = "\"DMPResearcher\"",
|
|
||||||
// joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
|
|
||||||
// inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
|
||||||
// )
|
|
||||||
// private Set<DMP> dMPs;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrimaryEmail() {
|
|
||||||
return primaryEmail;
|
|
||||||
}
|
|
||||||
public void setPrimaryEmail(String primaryEmail) {
|
|
||||||
this.primaryEmail = primaryEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Set<DMP> getdMPs() {
|
|
||||||
// return dMPs;
|
|
||||||
// }
|
|
||||||
// public void setdMPs(Set<DMP> dMPs) {
|
|
||||||
// this.dMPs = dMPs;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Researcher entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher 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");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,141 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Service\"")
|
|
||||||
public class Service implements DataEntity<Service, UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Abbreviation\"")
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
@Column(name = "\"Reference\"", nullable = true)
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Column(name = "\"Definition\"", nullable = false)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getCreationUser() {
|
|
||||||
return creationUser;
|
|
||||||
}
|
|
||||||
public void setCreationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Service entity) {
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Service buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
||||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
|
||||||
if (fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.model.publicapi.datasetwizard;
|
package eu.eudat.model.publicapi.datasetwizard;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.referencedefinition.Field;
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.model.publicapi.datasetwizard;
|
package eu.eudat.model.publicapi.datasetwizard;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.referencedefinition.Field;
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.model.publicapi.datasetwizard;
|
package eu.eudat.model.publicapi.datasetwizard;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.referencedefinition.Field;
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.model.publicapi.datasetwizard;
|
package eu.eudat.model.publicapi.datasetwizard;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.referencedefinition.Field;
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.eudat.model.publicapi.funder;
|
package eu.eudat.model.publicapi.funder;
|
||||||
|
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FunderPublicOverviewModel {
|
public class FunderPublicOverviewModel {
|
||||||
|
@ -22,15 +20,15 @@ public class FunderPublicOverviewModel {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunderPublicOverviewModel fromDataModel(Funder entity) {
|
// public FunderPublicOverviewModel fromDataModel(Funder entity) {
|
||||||
this.id = entity.getId();
|
// this.id = entity.getId();
|
||||||
this.label = entity.getLabel();
|
// this.label = entity.getLabel();
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Funder toDataModel() throws Exception {
|
// public Funder toDataModel() throws Exception {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getHint() {
|
public String getHint() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.model.publicapi.grant;
|
package eu.eudat.model.publicapi.grant;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.DmpReference;
|
import eu.eudat.model.DmpReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
|
|
|
@ -197,9 +197,15 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
|
int initialOffset = 0;
|
||||||
|
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){
|
||||||
|
initialOffset = lookup.getPage().getOffset();
|
||||||
|
lookup.getPage().setOffset(0);
|
||||||
|
}
|
||||||
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike());
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike());
|
||||||
|
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.get(lookup.getType(), externalReferenceCriteria, lookup.getKey());
|
List<Map<String, String>> remoteRepos = remoteFetcher.getReferences(lookup.getType(), externalReferenceCriteria, lookup.getKey());
|
||||||
|
|
||||||
List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos);
|
List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos);
|
||||||
List<Reference> models = this.fetchFromDb(lookup);
|
List<Reference> models = this.fetchFromDb(lookup);
|
||||||
|
@ -208,16 +214,15 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
|
||||||
models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList());
|
models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList());
|
||||||
models.sort(Comparator.comparing(Reference::getLabel));
|
models.sort(Comparator.comparing(Reference::getLabel));
|
||||||
|
|
||||||
|
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){
|
||||||
|
models = models.stream().skip(initialOffset).limit(lookup.getPage().getSize()).toList();
|
||||||
|
}
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Reference> fetchFromDb(ReferenceSearchLookup lookup){
|
private List<Reference> fetchFromDb(ReferenceSearchLookup lookup){
|
||||||
|
|
||||||
List<String> fields = Arrays.asList(Reference._id, Reference._label, Reference._description, Reference._abbreviation, Reference._source,
|
|
||||||
Reference._isActive, Reference._createdAt, Reference._updatedAt, Reference._type, Reference._definition, Reference._reference, Reference._sourceType );
|
|
||||||
lookup.setProject(new BaseFieldSet(fields));
|
|
||||||
|
|
||||||
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
||||||
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
||||||
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
||||||
|
|
|
@ -12,14 +12,12 @@ import eu.eudat.service.reference.external.config.entities.GenericUrls;
|
||||||
import eu.eudat.service.reference.external.models.ExternalRefernceResult;
|
import eu.eudat.service.reference.external.models.ExternalRefernceResult;
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
||||||
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
import eu.eudat.service.reference.external.criteria.FetchStrategy;
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import jakarta.xml.bind.JAXBContext;
|
import jakarta.xml.bind.JAXBContext;
|
||||||
import jakarta.xml.bind.Unmarshaller;
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
|
@ -29,7 +27,6 @@ import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import reactor.netty.http.client.HttpClient;
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -41,19 +38,25 @@ import java.util.stream.Collectors;
|
||||||
public class RemoteFetcher {
|
public class RemoteFetcher {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
||||||
|
|
||||||
private final WebClient client;
|
private WebClient webClient;
|
||||||
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||||
@Autowired
|
@Autowired
|
||||||
public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) {
|
public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) {
|
||||||
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||||
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
}
|
||||||
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
|
||||||
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
private WebClient getWebClient(){
|
||||||
}
|
if (this.webClient == null) {
|
||||||
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
this.webClient = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||||
|
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||||
|
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||||
|
}
|
||||||
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
|
}
|
||||||
|
return webClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> get(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
public List<Map<String, String>> getReferences(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
||||||
FetchStrategy fetchStrategy = null;
|
FetchStrategy fetchStrategy = null;
|
||||||
GenericUrls exGenericUrls = this.getExternalUrls(referenceType);
|
GenericUrls exGenericUrls = this.getExternalUrls(referenceType);
|
||||||
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
|
@ -67,26 +70,26 @@ public class RemoteFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericUrls getExternalUrls(ReferenceType referenceType) {
|
public GenericUrls getExternalUrls(ReferenceType referenceType) {
|
||||||
switch (referenceType){
|
return switch (referenceType) {
|
||||||
case Taxonomies: return this.externalUrlConfigProvider.getExternalUrls().getTaxonomies();
|
case Taxonomies -> this.externalUrlConfigProvider.getExternalUrls().getTaxonomies();
|
||||||
case Licenses: return this.externalUrlConfigProvider.getExternalUrls().getLicenses();
|
case Licenses -> this.externalUrlConfigProvider.getExternalUrls().getLicenses();
|
||||||
case Publications: return this.externalUrlConfigProvider.getExternalUrls().getPublications();
|
case Publications -> this.externalUrlConfigProvider.getExternalUrls().getPublications();
|
||||||
case Journals: return this.externalUrlConfigProvider.getExternalUrls().getJournals();
|
case Journals -> this.externalUrlConfigProvider.getExternalUrls().getJournals();
|
||||||
case PubRepositories: return this.externalUrlConfigProvider.getExternalUrls().getPubRepositories();
|
case PubRepositories -> this.externalUrlConfigProvider.getExternalUrls().getPubRepositories();
|
||||||
case DataRepositories: return this.externalUrlConfigProvider.getExternalUrls().getRepositories();
|
case DataRepositories -> this.externalUrlConfigProvider.getExternalUrls().getRepositories();
|
||||||
case Registries: return this.externalUrlConfigProvider.getExternalUrls().getRegistries();
|
case Registries -> this.externalUrlConfigProvider.getExternalUrls().getRegistries();
|
||||||
case Services: return this.externalUrlConfigProvider.getExternalUrls().getServices();
|
case Services -> this.externalUrlConfigProvider.getExternalUrls().getServices();
|
||||||
case Grants: return this.externalUrlConfigProvider.getExternalUrls().getGrants();
|
case Grants -> this.externalUrlConfigProvider.getExternalUrls().getGrants();
|
||||||
case Organizations: return this.externalUrlConfigProvider.getExternalUrls().getOrganisations();
|
case Organizations -> this.externalUrlConfigProvider.getExternalUrls().getOrganisations();
|
||||||
case Datasets: return this.externalUrlConfigProvider.getExternalUrls().getDatasets();
|
case Datasets -> this.externalUrlConfigProvider.getExternalUrls().getDatasets();
|
||||||
case Funder: return this.externalUrlConfigProvider.getExternalUrls().getFunders();
|
case Funder -> this.externalUrlConfigProvider.getExternalUrls().getFunders();
|
||||||
case Project: return this.externalUrlConfigProvider.getExternalUrls().getProjects();
|
case Project -> this.externalUrlConfigProvider.getExternalUrls().getProjects();
|
||||||
case Researcher: return this.externalUrlConfigProvider.getExternalUrls().getResearchers();
|
case Researcher -> this.externalUrlConfigProvider.getExternalUrls().getResearchers();
|
||||||
default: throw new IllegalArgumentException("Type not found" + referenceType);
|
default -> throw new IllegalArgumentException("Type not found" + referenceType);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer findEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
public Integer countEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
|
||||||
List<UrlConfiguration> urlConfigs =
|
List<UrlConfiguration> urlConfigs =
|
||||||
key != null && !key.isEmpty() ? this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
key != null && !key.isEmpty() ? this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
: this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls();
|
: this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls();
|
||||||
|
@ -116,22 +119,22 @@ public class RemoteFetcher {
|
||||||
// throw new MyNotFoundException("No Repository urls found in configuration");
|
// throw new MyNotFoundException("No Repository urls found in configuration");
|
||||||
|
|
||||||
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
||||||
urlConfigs.forEach(urlConfiguration -> {
|
for (UrlConfiguration urlConfiguration : urlConfigs) {
|
||||||
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria);
|
applyFunderQuery(urlConfiguration, externalReferenceCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
String auth = null;
|
String auth = null;
|
||||||
if (urlConfiguration.getAuth() != null) {
|
if (urlConfiguration.getAuth() != null) {
|
||||||
auth = this.getAuthentication(urlConfiguration.getAuth());
|
auth = this.getAuthentication(urlConfiguration.getAuth());
|
||||||
}
|
}
|
||||||
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalReferenceCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalReferenceCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
} else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) {
|
} else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) {
|
||||||
results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalReferenceCriteria.getLike()));
|
results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalReferenceCriteria.getLike()));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
/* for (UrlConfiguration urlConfig : urlConfigs) {
|
/* for (UrlConfiguration urlConfig : urlConfigs) {
|
||||||
ifFunderQueryExist(urlConfig, externalUrlCriteria);
|
ifFunderQueryExist(urlConfig, externalUrlCriteria);
|
||||||
if (urlConfig.getType() == null || urlConfig.getType().equals("External")) {
|
if (urlConfig.getType() == null || urlConfig.getType().equals("External")) {
|
||||||
|
@ -145,7 +148,7 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) {
|
private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) {
|
||||||
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod());
|
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod());
|
||||||
Map<String, Object> reponse = this.client.method(method).uri(authenticationConfiguration.getAuthUrl())
|
Map<String, Object> response = this.getWebClient().method(method).uri(authenticationConfiguration.getAuthUrl())
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
|
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
|
||||||
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
|
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
|
||||||
|
@ -153,7 +156,7 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath());
|
return authenticationConfiguration.getType() + " " + response.get(authenticationConfiguration.getAuthTokenPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalReferenceCriteria externalReferenceCriteria) {
|
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalReferenceCriteria externalReferenceCriteria) {
|
||||||
|
@ -166,7 +169,7 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
||||||
urlConfigs.forEach(urlConfiguration -> {
|
urlConfigs.forEach(urlConfiguration -> {
|
||||||
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria);
|
applyFunderQuery(urlConfiguration, externalReferenceCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalReferenceCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
|
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalReferenceCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
|
||||||
|
@ -179,7 +182,7 @@ public class RemoteFetcher {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalReferenceCriteria externalReferenceCriteria) {
|
private void applyFunderQuery(UrlConfiguration urlConfiguration, ExternalReferenceCriteria externalReferenceCriteria) {
|
||||||
if (urlConfiguration.getFunderQuery() != null) {
|
if (urlConfiguration.getFunderQuery() != null) {
|
||||||
if (externalReferenceCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
if (externalReferenceCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
||||||
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
|
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
|
||||||
|
@ -366,7 +369,7 @@ public class RemoteFetcher {
|
||||||
// entity = new HttpEntity<>(jsonBody, headers);
|
// entity = new HttpEntity<>(jsonBody, headers);
|
||||||
|
|
||||||
|
|
||||||
response = this.client.method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> {
|
response = this.getWebClient().method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> {
|
||||||
if (contentType != null && !contentType.isEmpty()) {
|
if (contentType != null && !contentType.isEmpty()) {
|
||||||
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
httpHeaders.setContentType(MediaType.valueOf(contentType));
|
httpHeaders.setContentType(MediaType.valueOf(contentType));
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -12,7 +11,6 @@ public class DataManagementPlanCriteria extends Criteria<DmpEntity> {
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
private DmpBlueprintEntity profile;
|
private DmpBlueprintEntity profile;
|
||||||
private List<Grant> grants;
|
|
||||||
private boolean allVersions;
|
private boolean allVersions;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
@ -46,13 +44,6 @@ public class DataManagementPlanCriteria extends Criteria<DmpEntity> {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Grant> getGrants() {
|
|
||||||
return grants;
|
|
||||||
}
|
|
||||||
public void setGrants(List<Grant> grants) {
|
|
||||||
this.grants = grants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getAllVersions() {
|
public boolean getAllVersions() {
|
||||||
return allVersions;
|
return allVersions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DataRepositoryCriteria extends Criteria<DataRepository> {
|
|
||||||
|
|
||||||
private UUID creationUserId;
|
|
||||||
|
|
||||||
public UUID getCreationUserId() {
|
|
||||||
return creationUserId;
|
|
||||||
}
|
|
||||||
public void setCreationUserId(UUID creationUserId) {
|
|
||||||
this.creationUserId = creationUserId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ExternalDatasetCriteria extends Criteria<ExternalDataset> {
|
|
||||||
private UUID creationUserId;
|
|
||||||
|
|
||||||
public UUID getCreationUserId() {
|
|
||||||
return creationUserId;
|
|
||||||
}
|
|
||||||
public void setCreationUserId(UUID creationUserId) {
|
|
||||||
this.creationUserId = creationUserId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class FunderCriteria extends Criteria<Funder> {
|
|
||||||
private String reference;
|
|
||||||
private String exactReference;
|
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExactReference() {
|
|
||||||
return exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExactReference(String exactReference) {
|
|
||||||
this.exactReference = exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class GrantCriteria extends Criteria<Grant> {
|
|
||||||
private Date periodStart;
|
|
||||||
private Date periodEnd;
|
|
||||||
private String reference;
|
|
||||||
private Integer grantStateType;
|
|
||||||
private boolean isPublic;
|
|
||||||
private String funderId;
|
|
||||||
private String funderReference;
|
|
||||||
private String exactReference;
|
|
||||||
private boolean isActive;
|
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPeriodEnd() {
|
|
||||||
return periodEnd;
|
|
||||||
}
|
|
||||||
public void setPeriodEnd(Date periodEnd) {
|
|
||||||
this.periodEnd = periodEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getGrantStateType() {
|
|
||||||
return grantStateType;
|
|
||||||
}
|
|
||||||
public void setGrantStateType(Integer grantStateType) {
|
|
||||||
this.grantStateType = grantStateType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPublic() {
|
|
||||||
return isPublic;
|
|
||||||
}
|
|
||||||
public void setPublic(boolean aPublic) {
|
|
||||||
isPublic = aPublic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunderId() {
|
|
||||||
return funderId;
|
|
||||||
}
|
|
||||||
public void setFunderId(String funderId) {
|
|
||||||
this.funderId = funderId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunderReference() {
|
|
||||||
return funderReference;
|
|
||||||
}
|
|
||||||
public void setFunderReference(String funderReference) {
|
|
||||||
this.funderReference = funderReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExactReference() {
|
|
||||||
return exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExactReference(String exactReference) {
|
|
||||||
this.exactReference = exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
return isActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
isActive = active;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Organisation;
|
|
||||||
|
|
||||||
public class OrganisationCriteria extends Criteria<Organisation> {
|
|
||||||
private String labelLike;
|
|
||||||
private Boolean isPublic;
|
|
||||||
private boolean isActive;
|
|
||||||
|
|
||||||
public String getLabelLike() {
|
|
||||||
return labelLike;
|
|
||||||
}
|
|
||||||
public void setLabelLike(String labelLike) {
|
|
||||||
this.labelLike = labelLike;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getPublic() {
|
|
||||||
return isPublic;
|
|
||||||
}
|
|
||||||
public void setPublic(Boolean aPublic) {
|
|
||||||
isPublic = aPublic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
return isActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
isActive = active;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Project;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ProjectCriteria extends Criteria<Project> {
|
|
||||||
private String reference;
|
|
||||||
private String exactReference;
|
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExactReference() {
|
|
||||||
return exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExactReference(String exactReference) {
|
|
||||||
this.exactReference = exactReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class RegistryCriteria extends Criteria<Registry> {
|
|
||||||
|
|
||||||
private UUID creationUserId;
|
|
||||||
|
|
||||||
public UUID getCreationUserId() {
|
|
||||||
return creationUserId;
|
|
||||||
}
|
|
||||||
public void setCreationUserId(UUID creationUserId) {
|
|
||||||
this.creationUserId = creationUserId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Researcher;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ResearcherCriteria extends Criteria<Researcher> {
|
|
||||||
private String name;
|
|
||||||
private String reference;
|
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ServiceCriteria extends Criteria<Service> {
|
|
||||||
|
|
||||||
private UUID creationUserId;
|
|
||||||
|
|
||||||
public UUID getCreationUserId() {
|
|
||||||
return creationUserId;
|
|
||||||
}
|
|
||||||
public void setCreationUserId(UUID creationUserId) {
|
|
||||||
this.creationUserId = creationUserId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -47,8 +47,8 @@ public class DMPDaoImpl extends DatabaseAccess<DmpEntity> implements DMPDao {
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||||
if (criteria.getProfile() != null)
|
if (criteria.getProfile() != null)
|
||||||
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
|
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
|
||||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
// if (criteria.getGrants() != null && !criteria.getGrants().isEmpty()) //TODO
|
||||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
// query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||||
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
|
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface DataRepositoryDao extends DatabaseAccessLayer<DataRepository, UUID> {
|
|
||||||
QueryableList<DataRepository> getWithCriteria(DataRepositoryCriteria criteria);
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("dataRepositoryDao")
|
|
||||||
public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implements DataRepositoryDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DataRepositoryDaoImpl(DatabaseService<DataRepository> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DataRepository> getWithCriteria(DataRepositoryCriteria criteria) {
|
|
||||||
QueryableList<DataRepository> query = this.getDatabaseService().getQueryable(DataRepository.class);
|
|
||||||
if (criteria.getLike() != null)
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
|
||||||
if (criteria.getCreationUserId() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), criteria.getCreationUserId()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataRepository find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(DataRepository.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataRepository createOrUpdate(DataRepository item) {
|
|
||||||
return getDatabaseService().createOrUpdate(item, DataRepository.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataRepository find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(DataRepository item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DataRepository> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(DataRepository.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
public interface ExternalDatasetDao extends DatabaseAccessLayer<ExternalDataset, UUID> {
|
|
||||||
|
|
||||||
QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
|
|
||||||
@Component("externalDatasetDao")
|
|
||||||
public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> implements ExternalDatasetDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ExternalDatasetDaoImpl(DatabaseService<ExternalDataset> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria) {
|
|
||||||
QueryableList<ExternalDataset> query = this.getDatabaseService().getQueryable(ExternalDataset.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
|
||||||
if (criteria.getCreationUserId() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.join("creationUser").get("id"), criteria.getCreationUserId()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDataset createOrUpdate(ExternalDataset item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, ExternalDataset.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDataset find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(ExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(ExternalDataset item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<ExternalDataset> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(ExternalDataset.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDataset find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface FunderDao extends DatabaseAccessLayer<Funder, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Funder> getWithCritetia(FunderCriteria criteria);
|
|
||||||
|
|
||||||
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserEntity principal);
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
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("funderDao")
|
|
||||||
public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public FunderDaoImpl(DatabaseService<Funder> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Funder> getWithCritetia(FunderCriteria criteria) {
|
|
||||||
QueryableList<Funder> query = getDatabaseService().getQueryable(Funder.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) ->
|
|
||||||
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.or(builder.like(builder.upper(root.get("definition")), "%" + criteria.getLike().toUpperCase() + "%"))));
|
|
||||||
if (criteria.getReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), "%" + criteria.getReference().toUpperCase() + "%"));
|
|
||||||
if (criteria.getExactReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), criteria.getExactReference().toUpperCase()));
|
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserEntity principal) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser"), principal));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Funder createOrUpdate(Funder item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Funder.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Funder> createOrUpdateAsync(Funder item) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Funder find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Funder.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Funder find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Funder item) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Funder> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Funder.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface GrantDao extends DatabaseAccessLayer<Grant, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Grant> getWithCriteria(GrantCriteria criteria);
|
|
||||||
|
|
||||||
QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserEntity principal);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpStatus;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import eu.eudat.types.grant.GrantStateType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.JoinType;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("grantDao")
|
|
||||||
public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GrantDaoImpl(DatabaseService<Grant> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> getWithCriteria(GrantCriteria criteria) {
|
|
||||||
QueryableList<Grant> query = getDatabaseService().getQueryable(Grant.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) ->
|
|
||||||
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
|
|
||||||
if (criteria.getPeriodEnd() != null)
|
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd()));
|
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
|
|
||||||
if (criteria.getReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
|
|
||||||
if (criteria.getExactReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), criteria.getExactReference()));
|
|
||||||
if (criteria.getGrantStateType() != null) {
|
|
||||||
if (criteria.getGrantStateType().equals(GrantStateType.FINISHED.getValue()))
|
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), new Date()));
|
|
||||||
if (criteria.getGrantStateType().equals(GrantStateType.ONGOING.getValue()))
|
|
||||||
query.where((builder, root) ->
|
|
||||||
builder.or(builder.greaterThan(root.get("enddate"), new Date())
|
|
||||||
, builder.isNull(root.get("enddate"))));
|
|
||||||
}
|
|
||||||
if (criteria.isPublic()) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DmpStatus.Finalized.getValue())).distinct();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (criteria.isActive()) {
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("isActive"), IsActive.Inactive.getValue())).distinct();
|
|
||||||
}
|
|
||||||
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
|
|
||||||
if (criteria.getFunderReference() != null && !criteria.getFunderReference().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.or(builder.like(root.join("funder", JoinType.LEFT).get("reference"), "%" + criteria.getFunderReference())));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Grant createOrUpdate(Grant item) {
|
|
||||||
return getDatabaseService().createOrUpdate(item, Grant.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Grant find(UUID id) throws InvalidApplicationException {
|
|
||||||
return getDatabaseService().getQueryable(Grant.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Grant item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Grant.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserEntity principal) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())).distinct();
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Grant> createOrUpdateAsync(Grant item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Grant find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
|
||||||
import eu.eudat.data.old.Organisation;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria);
|
|
||||||
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserEntity principal);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpStatus;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Organisation;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.JoinType;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("organisationDao")
|
|
||||||
public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements OrganisationDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public OrganisationDaoImpl(DatabaseService<Organisation> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria) {
|
|
||||||
QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class);
|
|
||||||
if (criteria.getLabelLike() != null && criteria.getLike() != null) {
|
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("reference"), criteria.getLike()), builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%")));
|
|
||||||
} else {
|
|
||||||
if (criteria.getLike() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
|
|
||||||
if (criteria.getLabelLike() != null) {
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
|
||||||
}
|
|
||||||
if (criteria.getPublic() != null && criteria.getPublic()) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DmpStatus.Finalized.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (criteria.isActive()) {
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("isActive"), IsActive.Inactive.getValue())).distinct();
|
|
||||||
}
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Organisation createOrUpdate(Organisation item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Organisation.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Organisation find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Organisation.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Organisation item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Organisation> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Organisation.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Organisation> createOrUpdateAsync(Organisation item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserEntity principal) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps").join("users").get("user"), principal));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Organisation find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
|
||||||
import eu.eudat.data.old.Project;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Project> getWithCritetia(ProjectCriteria criteria);
|
|
||||||
|
|
||||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserEntity principal);
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Project;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.JoinType;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Service("projectDao")
|
|
||||||
public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDao {
|
|
||||||
|
|
||||||
public ProjectDaoImpl(DatabaseService<Project> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Project> getWithCritetia(ProjectCriteria criteria) {
|
|
||||||
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) ->
|
|
||||||
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
|
|
||||||
if (criteria.getReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
|
|
||||||
if (criteria.getExactReference() != null)
|
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), criteria.getExactReference()));
|
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("startdate"), criteria.getPeriodStart()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserEntity principal) {
|
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()))).distinct();
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project createOrUpdate(Project item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Project.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Project> createOrUpdateAsync(Project item) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Project item) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Project> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Project.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface RegistryDao extends DatabaseAccessLayer<Registry, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Registry> getWithCriteria(RegistryCriteria criteria);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("registryDao")
|
|
||||||
public class RegistryDaoImpl extends DatabaseAccess<Registry> implements RegistryDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public RegistryDaoImpl(DatabaseService<Registry> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Registry> getWithCriteria(RegistryCriteria criteria) {
|
|
||||||
QueryableList<Registry> query = this.getDatabaseService().getQueryable(Registry.class);
|
|
||||||
if (criteria.getLike() != null)
|
|
||||||
if (criteria.getLike() != null)
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
|
||||||
if (criteria.getCreationUserId() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), criteria.getCreationUserId()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Registry createOrUpdate(Registry item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Registry.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Registry find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Registry.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Registry item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Registry> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Registry.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Registry> createOrUpdateAsync(Registry item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Registry find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.ResearcherCriteria;
|
|
||||||
import eu.eudat.data.old.Researcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface ResearcherDao extends DatabaseAccessLayer<Researcher, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.ResearcherCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Researcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("researcherDao")
|
|
||||||
public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements ResearcherDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ResearcherDaoImpl(DatabaseService<Researcher> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) {
|
|
||||||
QueryableList<Researcher> query = asQueryable();
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("reference")), "%" + criteria.getLike().toLowerCase() + "%")));
|
|
||||||
if (criteria.getName() != null && !criteria.getName().isEmpty())
|
|
||||||
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%")));
|
|
||||||
if (criteria.getReference() != null && !criteria.getReference().isEmpty())
|
|
||||||
query.where((builder, root) ->builder.or(builder.like(root.get("reference"), criteria.getReference())));
|
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher createOrUpdate(Researcher item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Researcher.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Researcher.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Researcher item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Researcher> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Researcher.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Researcher> createOrUpdateAsync(Researcher item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface ServiceDao extends DatabaseAccessLayer<Service, UUID> {
|
|
||||||
|
|
||||||
QueryableList<Service> getWithCriteria(ServiceCriteria criteria);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
@Component("serviceDao")
|
|
||||||
public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ServiceDaoImpl(DatabaseService<Service> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Service> getWithCriteria(ServiceCriteria criteria) {
|
|
||||||
QueryableList<Service> query = this.getDatabaseService().getQueryable(Service.class);
|
|
||||||
if (criteria.getLike() != null)
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
|
||||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
|
||||||
if (criteria.getCreationUserId() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), criteria.getCreationUserId()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Service createOrUpdate(Service item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, Service.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Service find(UUID id) throws InvalidApplicationException {
|
|
||||||
return this.getDatabaseService().getQueryable(Service.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Service item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Service> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(Service.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Service> createOrUpdateAsync(Service item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Service find(UUID id, String hint) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.dmp;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanCriteria, DmpEntity> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpEntity> applyCriteria() {
|
|
||||||
QueryableList<DmpEntity> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
|
||||||
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
|
|
||||||
if (this.getCriteria().getPeriodEnd() != null)
|
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
|
|
||||||
if (this.getCriteria().getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
|
|
||||||
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
|
|
||||||
query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants())));
|
|
||||||
if (!this.getCriteria().getAllVersions())
|
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
|
||||||
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
|
||||||
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.funder;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
public class FunderCriteriaRequest extends Query<FunderCriteria, Funder> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<Funder> applyCriteria() {
|
|
||||||
QueryableList<Funder> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.grant;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
public class GrantCriteriaRequest extends Query<GrantCriteria, Grant> {
|
|
||||||
private Integer length;
|
|
||||||
|
|
||||||
public Integer getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(Integer length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GrantCriteriaRequest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> applyCriteria() {
|
|
||||||
QueryableList<Grant> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
|
||||||
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
|
|
||||||
if (this.getCriteria().getPeriodEnd() != null)
|
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
|
|
||||||
if (this.getCriteria().getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
|
|
||||||
if (this.getCriteria().getReference() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.project;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
|
||||||
import eu.eudat.data.old.Project;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
public class ProjectCriteriaRequest extends Query<ProjectCriteria, Project> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<Project> applyCriteria() {
|
|
||||||
QueryableList<Project> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.researcher;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.ResearcherCriteria;
|
|
||||||
import eu.eudat.data.old.Researcher;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/6/2018.
|
|
||||||
*/
|
|
||||||
public class ResearcherCriteriaRequest extends Query<ResearcherCriteria,Researcher> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<Researcher> applyCriteria() {
|
|
||||||
QueryableList<Researcher> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getLike()));
|
|
||||||
if (this.getCriteria().getName() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("label"), this.getCriteria().getName()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,8 +24,8 @@ public class DataManagementPlanTableRequest extends TableQuery<DataManagementPla
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
|
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
|
||||||
if (this.getCriteria().getPeriodStart() != null)
|
if (this.getCriteria().getPeriodStart() != null)
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
|
||||||
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
|
// if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
|
||||||
query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants())));
|
// query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants()))); //TODO
|
||||||
if (!this.getCriteria().getAllVersions())
|
if (!this.getCriteria().getAllVersions())
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||||
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package eu.eudat.data.query.items.table.externaldataset;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ExternalDatasetTableRequest extends TableQuery<ExternalDatasetCriteria,ExternalDataset,UUID> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<ExternalDataset> applyCriteria() {
|
|
||||||
QueryableList<ExternalDataset> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<ExternalDataset> applyPaging(QueryableList<ExternalDataset> items) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package eu.eudat.data.query.items.table.grant;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GrantTableRequest extends TableQuery<GrantCriteria,Grant,UUID> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> applyCriteria() {
|
|
||||||
QueryableList<Grant> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.or(
|
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
|
||||||
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
|
|
||||||
if (this.getCriteria().getPeriodEnd() != null)
|
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
|
|
||||||
if (this.getCriteria().getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
|
|
||||||
if (this.getCriteria().getReference() != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> applyPaging(QueryableList<Grant> items) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.eudat.data.query.items.table.organisations;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
|
||||||
import eu.eudat.data.old.Organisation;
|
|
||||||
import eu.eudat.data.query.PaginationService;
|
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class OrganisationsTableRequest extends TableQuery<OrganisationCriteria, Organisation, UUID> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<Organisation> applyCriteria() {
|
|
||||||
QueryableList<Organisation> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Organisation> applyPaging(QueryableList<Organisation> items) {
|
|
||||||
return PaginationService.applyPaging(items, this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,8 +3,6 @@ package eu.eudat.query;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
|
@ -22,7 +20,6 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
private String label;
|
private String label;
|
||||||
private int version;
|
private int version;
|
||||||
private GrantQuery grantQuery;
|
|
||||||
// private UserQueryOld userQuery;
|
// private UserQueryOld userQuery;
|
||||||
private DatasetQuery datasetQuery;
|
private DatasetQuery datasetQuery;
|
||||||
private List<Integer> statuses;
|
private List<Integer> statuses;
|
||||||
|
@ -69,13 +66,6 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GrantQuery getGrantQuery() {
|
|
||||||
return grantQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGrantQuery(GrantQuery grantQuery) {
|
|
||||||
this.grantQuery = grantQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getStatuses() {
|
public List<Integer> getStatuses() {
|
||||||
return statuses;
|
return statuses;
|
||||||
|
@ -122,10 +112,10 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
||||||
if (this.id != null) {
|
if (this.id != null) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
||||||
}
|
}
|
||||||
if (this.grantQuery != null) {
|
// if (this.grantQuery != null) { //TODO
|
||||||
Subquery<Grant> grantQuery = this.grantQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
// Subquery<Grant> grantQuery = this.grantQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||||
query.where((builder, root) -> root.get("grant").get("id").in(grantQuery));
|
// query.where((builder, root) -> root.get("grant").get("id").in(grantQuery));
|
||||||
}
|
// }
|
||||||
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
|
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
|
||||||
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
package eu.eudat.query;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Subquery;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GrantQuery extends Query<Grant, UUID> {
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
private List<UUID> ids;
|
|
||||||
private String label;
|
|
||||||
private List<Integer> statuses;
|
|
||||||
private Date created;
|
|
||||||
private Date modified;
|
|
||||||
// private UserQueryOld userQuery;
|
|
||||||
|
|
||||||
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
|
|
||||||
super(databaseAccessLayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer, List<String> selectionFields) {
|
|
||||||
super(databaseAccessLayer, selectionFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UUID> getIds() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIds(List<UUID> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getStatuses() {
|
|
||||||
return statuses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatuses(List<Integer> statuses) {
|
|
||||||
statuses = statuses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public UserQueryOld getUserQuery() {
|
|
||||||
// return userQuery;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setUserQuery(UserQueryOld userQuery) {
|
|
||||||
// this.userQuery = userQuery;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<Grant> getQuery() throws InvalidApplicationException {
|
|
||||||
QueryableList<Grant> query = this.databaseAccessLayer.asQueryable();
|
|
||||||
if (this.id != null)
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
|
||||||
if (this.ids != null && !this.ids.isEmpty())
|
|
||||||
query.where((builder, root) -> root.get("id").in(this.ids));
|
|
||||||
if (this.getStatuses() != null && !this.getStatuses().isEmpty())
|
|
||||||
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
|
||||||
// if (this.userQuery != null) {
|
|
||||||
// Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
|
||||||
// query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery));
|
|
||||||
// }
|
|
||||||
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
|
|
||||||
query.withFields(this.getSelectionFields());
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -23,12 +23,6 @@ public abstract class BaseController {
|
||||||
protected void initBinder(WebDataBinder binder) {
|
protected void initBinder(WebDataBinder binder) {
|
||||||
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass())))
|
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass())))
|
||||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanTableRequestValidator", DataManagementPlanTableRequestValidator.class));
|
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanTableRequestValidator", DataManagementPlanTableRequestValidator.class));
|
||||||
if (binder.getTarget() != null && GrantTableRequestValidator.supportsType((binder.getTarget().getClass())))
|
|
||||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("grantTableRequestValidator", GrantTableRequestValidator.class));
|
|
||||||
if (binder.getTarget() != null && DatasetProfileValidator.supportsType((binder.getTarget().getClass())))
|
|
||||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("datasetProfileValidator", DatasetProfileValidator.class));
|
|
||||||
if (binder.getTarget() != null && GrantModelValidator.supportsType((binder.getTarget().getClass())))
|
|
||||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("grantModelValidator", GrantModelValidator.class));
|
|
||||||
if (binder.getTarget() != null && DataManagementPlanNewVersionValidator.supportsType((binder.getTarget().getClass())))
|
if (binder.getTarget() != null && DataManagementPlanNewVersionValidator.supportsType((binder.getTarget().getClass())))
|
||||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
|
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.DashBoardManager;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.RecentActivity;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.model.RecentActivityModel;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.tablerequest.RecentActivityTableRequest;
|
|
||||||
import eu.eudat.models.data.dashboard.searchbar.SearchBarItem;
|
|
||||||
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
|
||||||
public class DashBoardController extends BaseController {
|
|
||||||
|
|
||||||
private DashBoardManager dashBoardManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
@Autowired
|
|
||||||
public DashBoardController(ApiContext apiContext, DashBoardManager dashBoardManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.dashBoardManager = dashBoardManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/me/getStatistics"}, produces = "application/json")
|
|
||||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getMyStatistics() throws IOException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.BrowseStatistics);
|
|
||||||
|
|
||||||
DashBoardStatistics statistics = dashBoardManager.getMeStatistics();
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/getStatistics"}, produces = "application/json")
|
|
||||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics() throws InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.BrowsePublicStatistics);
|
|
||||||
|
|
||||||
DashBoardStatistics statistics = dashBoardManager.getStatistics();
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dashboard/recentActivity"}, produces = "application/json")
|
|
||||||
@Transactional
|
|
||||||
public ResponseEntity<ResponseItem<List<RecentActivityModel>>> getNewRecentActivity(@RequestBody RecentActivityTableRequest tableRequest) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
|
|
||||||
List<RecentActivityModel> statistics = dashBoardManager.getNewRecentActivity(tableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RecentActivityModel>>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/user/recentActivity"}, produces = "application/json")
|
|
||||||
public ResponseEntity<ResponseItem<RecentActivity>> getRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities) throws InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
|
|
||||||
RecentActivity statistics = dashBoardManager.getRecentActivity(numberOfActivities);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RecentActivity>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/search"}, produces = "application/json")
|
|
||||||
public ResponseEntity<ResponseItem<List<SearchBarItem>>> search(@RequestParam(name = "like") String like) throws InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
|
||||||
|
|
||||||
List<SearchBarItem> searchBarItemList = dashBoardManager.searchUserData(like);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<SearchBarItem>>().status(ApiMessageCode.NO_MESSAGE).payload(searchBarItemList));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
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(value = {"/api/external/datarepos"})
|
|
||||||
public class DataRepositories extends BaseController {
|
|
||||||
|
|
||||||
private DataRepositoryManager dataRepositoryManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DataRepositories(ApiContext apiContext, DataRepositoryManager dataRepositoryManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.dataRepositoryManager = dataRepositoryManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getDataRepositories(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataRepositoryModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataRepositoryModels));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataRepositoryModel>> create(@RequestBody eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
DataRepository dataRepository = this.dataRepositoryManager.create(dataRepositoryModel);
|
|
||||||
DataRepositoryModel dataRepositoryModel1 = new DataRepositoryModel().fromDataModel(dataRepository);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataRepositoryModel>().payload(dataRepositoryModel1).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
|
||||||
import eu.eudat.logic.managers.ExternalDatasetManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
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;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
|
||||||
public class ExternalDatasets extends BaseController {
|
|
||||||
|
|
||||||
private ExternalDatasetManager externalDatasetManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ExternalDatasets(ApiContext apiContext, ExternalDatasetManager externalDatasetManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.externalDatasetManager = externalDatasetManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<ExternalDatasetListingModel>>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
DataTableData<ExternalDatasetListingModel> dataTable = externalDatasetManager.getPaged(datasetTableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/datasets"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseItem<ExternalDatasetListingModel> getWithExternal(@PathVariable UUID id) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
ExternalDatasetListingModel externalDatasetModel = externalDatasetManager.getSingle(id);
|
|
||||||
return new ResponseItem<ExternalDatasetListingModel>().payload(externalDatasetModel).status(ApiMessageCode.NO_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<ExternalDatasetListingModel>> create(@RequestBody eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
ExternalDataset externalDataset = this.externalDatasetManager.create(externalDatasetModel);
|
|
||||||
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(externalDataset);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalDatasetListingModel>().payload(externalDatasetListingModel).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
|
||||||
import eu.eudat.logic.managers.FunderManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.funder.Funder;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/funders/"})
|
|
||||||
public class Funders extends BaseController {
|
|
||||||
private FunderManager funderManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
public Funders(ApiContext apiContext, FunderManager funderManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.funderManager = funderManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<Funder> dataTable = this.funderManager.getCriteriaWithExternal(funderCriteria);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.funder.Funder>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
|
||||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
|
||||||
import eu.eudat.logic.managers.GrantManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.grant.GrantListingModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/grants/"})
|
|
||||||
public class Grants extends BaseController {
|
|
||||||
private GrantManager grantManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Grants(ApiContext apiContext, GrantManager grantManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.grantManager = grantManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<GrantListingModel>>> getPaged(@Valid @RequestBody GrantTableRequest grantTableRequest, @RequestParam String fieldsGroup) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
DataTableData<eu.eudat.models.data.grant.GrantListingModel> dataTable = this.grantManager.getPaged(grantTableRequest, fieldsGroup);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.grant.GrantListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"public/paged"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<GrantListingModel>>> getPaged(@Valid @RequestBody GrantTableRequest grantTableRequest) throws Exception {
|
|
||||||
DataTableData<eu.eudat.models.data.grant.GrantListingModel> dataTable = this.grantManager.getPublicPaged(grantTableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.grant.GrantListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<eu.eudat.models.data.grant.Grant>> getSingle(@PathVariable String id) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
eu.eudat.models.data.grant.Grant grant = this.grantManager.getSingle(id);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.grant.Grant>().payload(grant).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<Grant>> addGrant(@Valid @RequestBody eu.eudat.models.data.grant.Grant grant) throws IOException, ParseException {
|
|
||||||
this.grantManager.createOrUpdate(grant, principal);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.old.Grant>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<Grant>> inactivate(@PathVariable String id) throws IllegalAccessException, InstantiationException {
|
|
||||||
this.grantManager.inactivate(id);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.old.Grant>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> getWithExternal(@RequestBody GrantCriteriaRequest grantCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteriaWithExternal(grantCriteria);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.grant.Grant>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"get"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.grant.Grant>>> get(@RequestBody GrantCriteriaRequest grantCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AnonymousRole);
|
|
||||||
|
|
||||||
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteria(grantCriteria);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.grant.Grant>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/journals"})
|
|
||||||
public class JournalsController extends BaseController {
|
|
||||||
|
|
||||||
private DataRepositoryManager dataRepositoryManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public JournalsController(ApiContext apiContext, DataRepositoryManager dataRepositoryManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.dataRepositoryManager = dataRepositoryManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getJournals(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataRepositoryModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataRepositoryModels));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.LicenseManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/licenses"})
|
|
||||||
public class Licenses extends BaseController {
|
|
||||||
|
|
||||||
private LicenseManager licenseManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Licenses(ApiContext apiContext, LicenseManager licenseManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.licenseManager = licenseManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<LicenseModel>>> listExternalLicenses(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<LicenseModel> licenseModels = this.licenseManager.getLicenses(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<LicenseModel>>().status(ApiMessageCode.NO_MESSAGE).payload(licenseModels));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
|
||||||
import eu.eudat.logic.managers.OrganisationsManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api"})
|
|
||||||
public class Organisations extends BaseController {
|
|
||||||
|
|
||||||
private OrganisationsManager organisationsManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
private ApiContext apiContext;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Organisations(ApiContext apiContext, OrganisationsManager organisationsManager, AuthorizationService authorizationService, ApiContext apiContext1) {
|
|
||||||
super(apiContext);
|
|
||||||
this.organisationsManager = organisationsManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
this.apiContext = apiContext1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<Organisation>>> listExternalOrganisations(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
List<Organisation> organisations = organisationsManager.getCriteriaWithExternal(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/general/organisations"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<Organisation>>> listGeneralOrganisations(@RequestBody OrganisationsTableRequest organisationsTableRequest) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<Organisation> organisations = organisationsManager.getWithExternal(organisationsTableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/internal/organisations"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest) throws Exception{
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPagedOrganisations(organisationsTableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/public/organisations"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPublicPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest) throws Exception{
|
|
||||||
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPublicPagedOrganisations(organisationsTableRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
|
||||||
import eu.eudat.logic.managers.ProjectManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.project.Project;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/projects/"})
|
|
||||||
public class Projects extends BaseController {
|
|
||||||
private ProjectManager projectManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Projects(ApiContext apiContext, ProjectManager projectManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.projectManager = projectManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws MyNotFoundException, InstantiationException, HugeResultSetException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.DataRepositoryManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/pubrepos"})
|
|
||||||
public class PubRepositoriesController extends BaseController {
|
|
||||||
|
|
||||||
private DataRepositoryManager dataRepositoryManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public PubRepositoriesController(ApiContext apiContext, DataRepositoryManager dataRepositoryManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.dataRepositoryManager = dataRepositoryManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<DataRepositoryModel>>> listExternalDataRepositories(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = this.dataRepositoryManager.getPubRepositories(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataRepositoryModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataRepositoryModels));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.PublicationManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.publication.PublicationModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/publications"})
|
|
||||||
public class PublicationsController extends BaseController {
|
|
||||||
|
|
||||||
private PublicationManager publicationManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public PublicationsController(ApiContext apiContext, PublicationManager publicationManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.publicationManager = publicationManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<PublicationModel>>> listExternalPublications(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<PublicationModel> publicationModels = this.publicationManager.getPublications(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<PublicationModel>>().status(ApiMessageCode.NO_MESSAGE).payload(publicationModels));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,9 +5,6 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Funder;
|
|
||||||
import eu.eudat.data.old.Project;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.managers.QuickWizardManager;
|
import eu.eudat.logic.managers.QuickWizardManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -53,49 +50,49 @@ public class QuickWizardController extends BaseController {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
|
|
||||||
Funder funderEntity;
|
// Funder funderEntity;//TODO
|
||||||
//Create Funder
|
// //Create Funder
|
||||||
if (quickWizard.getFunder() == null) {
|
// if (quickWizard.getFunder() == null) {
|
||||||
funderEntity = null;
|
// funderEntity = null;
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
// } else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
||||||
funderEntity = null;
|
// funderEntity = null;
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
// } else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
||||||
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder());
|
// funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder());
|
||||||
} else {
|
// } else {
|
||||||
funderEntity = quickWizard.getFunder().getExistFunder().toDataModel();
|
// funderEntity = quickWizard.getFunder().getExistFunder().toDataModel();
|
||||||
}
|
// }
|
||||||
|
|
||||||
Grant grantEntity;
|
// Grant grantEntity; //TODO
|
||||||
//Create Grant
|
// //Create Grant
|
||||||
if (quickWizard.getGrant() == null) {
|
// if (quickWizard.getGrant() == null) {
|
||||||
grantEntity = null;
|
// grantEntity = null;
|
||||||
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
|
// } else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
|
||||||
grantEntity = null;
|
// grantEntity = null;
|
||||||
} else if (quickWizard.getGrant().getExistGrant() == null) {
|
// } else if (quickWizard.getGrant().getExistGrant() == null) {
|
||||||
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant());
|
// grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant());
|
||||||
} else {
|
// } else {
|
||||||
grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
|
// grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
|
||||||
}
|
// }
|
||||||
|
|
||||||
Project projectEntity;
|
// Project projectEntity; //TODO
|
||||||
//Create Project
|
// //Create Project
|
||||||
if (quickWizard.getProject().getExistProject() == null
|
// if (quickWizard.getProject().getExistProject() == null
|
||||||
&& quickWizard.getProject().getLabel() == null) {
|
// && quickWizard.getProject().getLabel() == null) {
|
||||||
projectEntity = null;
|
// projectEntity = null;
|
||||||
} else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null) {
|
// } else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null) {
|
||||||
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject());
|
// projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject());
|
||||||
} else {
|
// } else {
|
||||||
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
// projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Create Dmp
|
//Create Dmp
|
||||||
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, userScope);
|
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(/*grantEntity,*/ userScope);
|
||||||
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan, funderEntity);
|
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan/*, funderEntity*/);
|
||||||
|
|
||||||
//Create Datasets
|
//Create Datasets
|
||||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||||
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
|
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
|
||||||
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, userScope);
|
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(/*grantEntity , projectEntity, */ userScope);
|
||||||
DescriptionTemplateEntity profile = quickWizard.getDmp().getDatasetProfile();
|
DescriptionTemplateEntity profile = quickWizard.getDmp().getDatasetProfile();
|
||||||
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
|
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
|
||||||
this.datasetManager.createOrUpdate(datasetWizardModel);
|
this.datasetManager.createOrUpdate(datasetWizardModel);
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.logic.managers.RegistryManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.registries.RegistryModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
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(value = {"/api"})
|
|
||||||
public class Registries extends BaseController {
|
|
||||||
|
|
||||||
private RegistryManager registryManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Registries(ApiContext apiContext, RegistryManager registryManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.registryManager = registryManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<RegistryModel>>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
|
|
||||||
, @RequestParam(value = "type", required = false) String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<RegistryModel> registryModels = this.registryManager.getRegistries(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RegistryModel>>().payload(registryModels).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/registries"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<RegistryModel>> create(@RequestBody RegistryModel registryModel) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
Registry registry = this.registryManager.create(registryModel);
|
|
||||||
RegistryModel registryModel1 = new RegistryModel().fromDataModel(registry);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RegistryModel>().payload(registryModel1).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
|
||||||
import eu.eudat.logic.managers.ResearcherManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.dmp.Researcher;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
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(value = {"/api/researchers"})
|
|
||||||
|
|
||||||
public class Researchers extends BaseController {
|
|
||||||
|
|
||||||
private ResearcherManager researcherManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
@Autowired
|
|
||||||
public Researchers(ApiContext apiContext, ResearcherManager researcherManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.researcherManager = researcherManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Researcher> dataTable = this.researcherManager.getCriteriaWithExternal(researcherCriteriaRequest);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<Researcher>> create(@RequestBody eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
this.researcherManager.create(researcher);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.logic.managers.ServiceManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.services.ServiceModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
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(value = {"/api"})
|
|
||||||
public class Services extends BaseController {
|
|
||||||
|
|
||||||
private ServiceManager serviceManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public Services(ApiContext apiContext, ServiceManager serviceManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.serviceManager = serviceManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/services"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<ServiceModel>>> listExternalServices(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
List<ServiceModel> serviceModels = this.serviceManager.getServices(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ServiceModel>>().payload(serviceModels).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/services"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<ServiceModel>> create(@RequestBody ServiceModel serviceModel) throws Exception {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
Service service = serviceManager.create(serviceModel);
|
|
||||||
ServiceModel serviceModel1 = new ServiceModel().fromDataModel(service);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ServiceModel>().payload(serviceModel1).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package eu.eudat.controllers;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.logic.managers.TaxonomyManager;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping(value = {"/api/external/taxonomies"})
|
|
||||||
public class TaxonomiesController extends BaseController {
|
|
||||||
|
|
||||||
private TaxonomyManager taxonomyManager;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public TaxonomiesController(ApiContext apiContext, TaxonomyManager taxonomyManager, AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.taxonomyManager = taxonomyManager;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<TaxonomyModel>>> listExternalPublications(
|
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
|
|
||||||
List<TaxonomyModel> taxonomyModels = this.taxonomyManager.getTaxonomies(query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<TaxonomyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(taxonomyModels));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -106,23 +106,28 @@ public class ReferenceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("search")
|
@PostMapping("search")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
public List<Reference> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
logger.debug("search {}", Reference.class.getSimpleName());
|
||||||
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
|
||||||
|
|
||||||
if (lookup.getType() != null) {
|
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
|
||||||
List<Reference> references = this.referenceService.searchReference(lookup);
|
List<Reference> references = this.referenceService.searchReference(lookup);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
|
|
||||||
}
|
this.auditService.track(AuditableAction.Reference_Search, "lookup", lookup);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("search-with-db-definition")
|
@PostMapping("search-with-db-definition")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
public List<Reference> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
logger.debug("search with db definition {}", Reference.class.getSimpleName());
|
||||||
|
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
|
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
|
|
||||||
|
this.auditService.track(AuditableAction.Reference_Search, "lookup", lookup);
|
||||||
|
|
||||||
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
|
@ -161,18 +166,6 @@ public class ReferenceController extends BaseController {
|
||||||
return persisted;
|
return persisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping(path = {"search/{externalType}"}, produces = "application/json")
|
|
||||||
// public @ResponseBody ResponseEntity<ResponseItem<List<FetcherReference>>> searchReference(@PathVariable(value = "externalType") int externalType,
|
|
||||||
// @RequestParam(value = "query", required = false) String query,
|
|
||||||
// @RequestParam(value = "type", required = false) String type
|
|
||||||
// ) throws HugeResultSet, MyNotFoundException, InvalidApplicationException {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
|
||||||
//
|
|
||||||
// List<FetcherReference> fetcherReferences = this.referenceService.searchReference(referenceType, query, type);
|
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<FetcherReference>>().status(ApiMessageCode.NO_MESSAGE).payload(fetcherReferences));
|
|
||||||
// }
|
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
|
|
@ -12,7 +12,6 @@ public class DMPCriteria {
|
||||||
private Criteria<UUID> groupId;
|
private Criteria<UUID> groupId;
|
||||||
private Criteria<String> label;
|
private Criteria<String> label;
|
||||||
private Criteria<Integer> version;
|
private Criteria<Integer> version;
|
||||||
private GrantCriteria grant;
|
|
||||||
private DateCriteria created;
|
private DateCriteria created;
|
||||||
private DateCriteria modified;
|
private DateCriteria modified;
|
||||||
private UserCriteria creator;
|
private UserCriteria creator;
|
||||||
|
@ -74,14 +73,6 @@ public class DMPCriteria {
|
||||||
this.version = criteria;
|
this.version = criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GrantCriteria getGrant() {
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGrant(GrantCriteria grant) {
|
|
||||||
this.grant = grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateCriteria getCreated() {
|
public DateCriteria getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +122,7 @@ public class DMPCriteria {
|
||||||
path = path != null && !path.isEmpty() ? path + "." : "";
|
path = path != null && !path.isEmpty() ? path + "." : "";
|
||||||
if (this.id != null) fields.add(path + this.id.getAs());
|
if (this.id != null) fields.add(path + this.id.getAs());
|
||||||
if (this.label != null) fields.add(path + this.label.getAs());
|
if (this.label != null) fields.add(path + this.label.getAs());
|
||||||
if (this.grant != null) fields.addAll(this.grant.buildFields(path + "grant"));
|
// if (this.grant != null) fields.addAll(this.grant.buildFields(path + "grant"));
|
||||||
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creator"));
|
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creator"));
|
||||||
if (this.dataset != null) fields.addAll(this.dataset.buildFields(path + "dataset"));
|
if (this.dataset != null) fields.addAll(this.dataset.buildFields(path + "dataset"));
|
||||||
if (!fields.contains(path + "id")) fields.add(path + "id");
|
if (!fields.contains(path + "id")) fields.add(path + "id");
|
||||||
|
@ -142,7 +133,7 @@ public class DMPCriteria {
|
||||||
List<String> fields = this.buildFields("");
|
List<String> fields = this.buildFields("");
|
||||||
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
|
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
|
||||||
if (this.id != null) dmpQuery.setId(this.id.getValue());
|
if (this.id != null) dmpQuery.setId(this.id.getValue());
|
||||||
if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao));
|
// if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao));
|
||||||
// if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao));
|
// if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao));
|
||||||
if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
|
if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
|
||||||
return dmpQuery;
|
return dmpQuery;
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
package eu.eudat.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.criteria.entities.Criteria;
|
|
||||||
import eu.eudat.criteria.entities.DateCriteria;
|
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
|
||||||
import eu.eudat.query.GrantQuery;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class GrantCriteria {
|
|
||||||
private Criteria<UUID> id;
|
|
||||||
private List<UUID> ids;
|
|
||||||
private Criteria<String> label;
|
|
||||||
private List<Integer> statuses;
|
|
||||||
private DateCriteria created;
|
|
||||||
private DateCriteria modified;
|
|
||||||
private UserCriteria creator;
|
|
||||||
|
|
||||||
public Criteria<UUID> getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Criteria<UUID> id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UUID> getIds() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIds(List<UUID> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria<String> getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(Criteria<String> label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
Criteria<String> criteria = new Criteria<>();
|
|
||||||
criteria.setAs(label);
|
|
||||||
this.label = criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getStatuses() {
|
|
||||||
return statuses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatuses(List<Integer> statuses) {
|
|
||||||
this.statuses = statuses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateCriteria getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(DateCriteria created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(String created) {
|
|
||||||
DateCriteria criteria = new DateCriteria();
|
|
||||||
criteria.setAs(created);
|
|
||||||
this.created = criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateCriteria getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(DateCriteria modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(String modified) {
|
|
||||||
DateCriteria criteria = new DateCriteria();
|
|
||||||
criteria.setAs(modified);
|
|
||||||
this.modified = criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserCriteria getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreator(UserCriteria creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<String> buildFields(String path) {
|
|
||||||
Set<String> fields = new LinkedHashSet<>();
|
|
||||||
path = path != null && !path.isEmpty() ? path + "." : "";
|
|
||||||
if (this.id != null) fields.add(path + this.id.getAs());
|
|
||||||
if (this.label != null) fields.add(path + this.label.getAs());
|
|
||||||
if (!fields.contains(path + "id")) fields.add(path + "id");
|
|
||||||
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creationUser"));
|
|
||||||
return new LinkedList<>(fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantQuery buildQuery(DatabaseRepository dao) {
|
|
||||||
List<String> fields = this.buildFields("");
|
|
||||||
GrantQuery query = new GrantQuery(dao.getGrantDao(), fields);
|
|
||||||
query.setId(this.id.getValue());
|
|
||||||
// if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,6 @@
|
||||||
package eu.eudat.logic.builders;
|
package eu.eudat.logic.builders;
|
||||||
|
|
||||||
import eu.eudat.logic.builders.entity.*;
|
import eu.eudat.logic.builders.entity.*;
|
||||||
import eu.eudat.logic.builders.model.criteria.DataRepositoryCriteriaBuilder;
|
|
||||||
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
|
||||||
import eu.eudat.logic.builders.model.criteria.RegistryCriteriaBuilder;
|
|
||||||
import eu.eudat.logic.builders.model.models.*;
|
import eu.eudat.logic.builders.model.models.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -12,19 +9,11 @@ import org.springframework.stereotype.Service;
|
||||||
public class BuilderFactoryImpl implements BuilderFactory {
|
public class BuilderFactoryImpl implements BuilderFactory {
|
||||||
|
|
||||||
public <T extends Builder> T getBuilder(Class<T> tClass) {
|
public <T extends Builder> T getBuilder(Class<T> tClass) {
|
||||||
if (tClass.equals(DataRepositoryCriteriaBuilder.class)) return (T) new DataRepositoryCriteriaBuilder();
|
|
||||||
if (tClass.equals(DatasetProfileBuilder.class)) return (T) new DatasetProfileBuilder();
|
if (tClass.equals(DatasetProfileBuilder.class)) return (T) new DatasetProfileBuilder();
|
||||||
if (tClass.equals(DataTableDataBuilder.class)) return (T) new DataTableDataBuilder<>();
|
if (tClass.equals(DataTableDataBuilder.class)) return (T) new DataTableDataBuilder<>();
|
||||||
if (tClass.equals(GrantBuilder.class)) return (T) new GrantBuilder();
|
|
||||||
if (tClass.equals(ProjectBuilder.class)) return (T) new ProjectBuilder();
|
|
||||||
if (tClass.equals(FunderBuilder.class)) return (T) new FunderBuilder();
|
|
||||||
if (tClass.equals(RegistryCriteriaBuilder.class)) return (T) new RegistryCriteriaBuilder();
|
|
||||||
if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder();
|
if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder();
|
||||||
if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder();
|
if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder();
|
||||||
if (tClass.equals(ResearcherBuilder.class)) return (T) new ResearcherBuilder();
|
|
||||||
if (tClass.equals(ExternalDatasetCriteriaBuilder.class)) return (T) new ExternalDatasetCriteriaBuilder();
|
|
||||||
if (tClass.equals(RecentActivityDataBuilder.class)) return (T) new RecentActivityDataBuilder();
|
if (tClass.equals(RecentActivityDataBuilder.class)) return (T) new RecentActivityDataBuilder();
|
||||||
if (tClass.equals(OrganisationBuilder.class)) return (T) new OrganisationBuilder();
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 2/15/2018.
|
|
||||||
*/
|
|
||||||
public class DataRepositoryCriteriaBuilder extends Builder<DataRepositoryCriteria> {
|
|
||||||
private String like;
|
|
||||||
|
|
||||||
public DataRepositoryCriteriaBuilder like(String like) {
|
|
||||||
this.like = like;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataRepositoryCriteria build() {
|
|
||||||
DataRepositoryCriteria dataRepositoryCriteria = new DataRepositoryCriteria();
|
|
||||||
dataRepositoryCriteria.setLike(like);
|
|
||||||
return dataRepositoryCriteria;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 2/15/2018.
|
|
||||||
*/
|
|
||||||
public class ExternalDatasetCriteriaBuilder extends Builder<ExternalDatasetCriteria> {
|
|
||||||
private String like;
|
|
||||||
|
|
||||||
public ExternalDatasetCriteriaBuilder like(String like) {
|
|
||||||
this.like = like;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDatasetCriteria build() {
|
|
||||||
ExternalDatasetCriteria externalDatasetCriteria = new ExternalDatasetCriteria();
|
|
||||||
externalDatasetCriteria.setLike(like);
|
|
||||||
return externalDatasetCriteria;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 2/15/2018.
|
|
||||||
*/
|
|
||||||
public class RegistryCriteriaBuilder extends Builder<RegistryCriteria> {
|
|
||||||
private String like;
|
|
||||||
|
|
||||||
public RegistryCriteriaBuilder like(String like) {
|
|
||||||
this.like = like;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RegistryCriteria build() {
|
|
||||||
RegistryCriteria registryCriteria = new RegistryCriteria();
|
|
||||||
registryCriteria.setLike(like);
|
|
||||||
return registryCriteria;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.criteria;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 2/15/2018.
|
|
||||||
*/
|
|
||||||
public class ServiceCriteriaBuilder extends Builder<ServiceCriteria> {
|
|
||||||
private String like;
|
|
||||||
|
|
||||||
public ServiceCriteriaBuilder setLike(String like) {
|
|
||||||
this.like = like;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServiceCriteria build() {
|
|
||||||
ServiceCriteria serviceCriteria = new ServiceCriteria();
|
|
||||||
serviceCriteria.setLike(like);
|
|
||||||
return serviceCriteria;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.models;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.models.data.funder.Funder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class FunderBuilder extends Builder<Funder> {
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
private String label;
|
|
||||||
private String reference;
|
|
||||||
private String definition;
|
|
||||||
private eu.eudat.data.old.Funder.Status status;
|
|
||||||
private Date created;
|
|
||||||
private Date modified;
|
|
||||||
private Integer type;
|
|
||||||
private String source;
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public FunderBuilder id(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder label(String label) {
|
|
||||||
this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder reference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder definition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder status(eu.eudat.data.old.Funder.Status status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder created(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder modified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder type(int type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder source(String source) {
|
|
||||||
this.source = source;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunderBuilder key(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Funder build() {
|
|
||||||
Funder funder = new Funder();
|
|
||||||
funder.setId(id);
|
|
||||||
funder.setLabel(label);
|
|
||||||
funder.setReference(reference);
|
|
||||||
funder.setDefinition(definition);
|
|
||||||
if (status != null) funder.setStatus(status.getValue());
|
|
||||||
funder.setCreated(created);
|
|
||||||
funder.setModified(modified);
|
|
||||||
funder.setType(type);
|
|
||||||
funder.setSource(source);
|
|
||||||
funder.setKey(key);
|
|
||||||
return funder;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,147 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.models;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
|
||||||
import eu.eudat.models.data.grant.Grant;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GrantBuilder extends Builder<Grant> {
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
private List<DataManagementPlan> dmps;
|
|
||||||
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
private String abbreviation;
|
|
||||||
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
private Date startDate;
|
|
||||||
|
|
||||||
private Date endDate;
|
|
||||||
|
|
||||||
private eu.eudat.data.old.Grant.Status status;
|
|
||||||
|
|
||||||
private UserEntity creationUser;
|
|
||||||
|
|
||||||
private Date created;
|
|
||||||
|
|
||||||
private Date modified;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String source;
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public GrantBuilder id(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder dmps(List<DataManagementPlan> dmps) {
|
|
||||||
this.dmps = dmps;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder label(String label) {
|
|
||||||
this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder abbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder reference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder uri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder definition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder startDate(Date startDate) {
|
|
||||||
this.startDate = startDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder endDate(Date endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder status(eu.eudat.data.old.Grant.Status status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder creationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder created(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder modified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder description(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder source(String source) {
|
|
||||||
this.source = source;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GrantBuilder key(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Grant build() {
|
|
||||||
Grant grant = new Grant();
|
|
||||||
grant.setStatus(status.getValue());
|
|
||||||
grant.setAbbreviation(abbreviation);
|
|
||||||
grant.setCreated(created);
|
|
||||||
grant.setCreationUser(creationUser);
|
|
||||||
grant.setDefinition(definition);
|
|
||||||
grant.setDescription(description);
|
|
||||||
grant.setDmps(dmps);
|
|
||||||
grant.setEndDate(endDate);
|
|
||||||
grant.setId(id);
|
|
||||||
grant.setLabel(label);
|
|
||||||
grant.setModified(modified);
|
|
||||||
grant.setReference(reference);
|
|
||||||
grant.setCreationUser(creationUser);
|
|
||||||
grant.setStartDate(startDate);
|
|
||||||
grant.setSource(source);
|
|
||||||
grant.setKey(key);
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.models;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
|
||||||
|
|
||||||
public class OrganisationBuilder extends Builder<Organisation> {
|
|
||||||
private String label;
|
|
||||||
private String name;
|
|
||||||
private String id;
|
|
||||||
private String reference;
|
|
||||||
private int status;
|
|
||||||
private String tag;
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder label(String label) {
|
|
||||||
this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() { return reference; }
|
|
||||||
|
|
||||||
public OrganisationBuilder reference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder status(int status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder tag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganisationBuilder key(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Organisation build() {
|
|
||||||
Organisation Organisation = new Organisation();
|
|
||||||
Organisation.setId(id);
|
|
||||||
Organisation.setReference(reference);
|
|
||||||
Organisation.setLabel(label);
|
|
||||||
Organisation.setName(name);
|
|
||||||
Organisation.setStatus(status);
|
|
||||||
Organisation.setTag(tag);
|
|
||||||
Organisation.setKey(key);
|
|
||||||
return Organisation;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,139 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.models;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
|
||||||
import eu.eudat.models.data.project.Project;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ProjectBuilder extends Builder<Project> {
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
private List<DataManagementPlan> dmps;
|
|
||||||
private String label;
|
|
||||||
private int type;
|
|
||||||
private String abbreviation;
|
|
||||||
private String reference;
|
|
||||||
private String uri;
|
|
||||||
private String definition;
|
|
||||||
private Date startDate;
|
|
||||||
private Date endDate;
|
|
||||||
private eu.eudat.data.old.Project.Status status;
|
|
||||||
private UserEntity creationUser;
|
|
||||||
private Date created;
|
|
||||||
private Date modified;
|
|
||||||
private String description;
|
|
||||||
private String source;
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public ProjectBuilder id(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder dmps(List<DataManagementPlan> dmps) {
|
|
||||||
this.dmps = dmps;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder label(String label) {
|
|
||||||
this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder type(int type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder abbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder reference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder uri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder definition(String definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder startDate(Date startDate) {
|
|
||||||
this.startDate = startDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder endDate(Date endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder status(eu.eudat.data.old.Project.Status status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder creationUser(UserEntity creationUser) {
|
|
||||||
this.creationUser = creationUser;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder created(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder modified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder description(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder source(String source) {
|
|
||||||
this.source = source;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuilder key(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project build() {
|
|
||||||
Project project = new Project();
|
|
||||||
project.setStatus(status.getValue());
|
|
||||||
project.setAbbreviation(abbreviation);
|
|
||||||
project.setCreated(created);
|
|
||||||
project.setCreationUser(creationUser);
|
|
||||||
project.setDefinition(definition);
|
|
||||||
project.setDescription(description);
|
|
||||||
project.setDmps(dmps);
|
|
||||||
project.setEndDate(endDate);
|
|
||||||
project.setId(id);
|
|
||||||
project.setLabel(label);
|
|
||||||
project.setModified(modified);
|
|
||||||
project.setReference(reference);
|
|
||||||
project.setCreationUser(creationUser);
|
|
||||||
project.setStartDate(startDate);
|
|
||||||
project.setSource(source);
|
|
||||||
project.setKey(key);
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
package eu.eudat.logic.builders.model.models;
|
|
||||||
|
|
||||||
import eu.eudat.logic.builders.Builder;
|
|
||||||
import eu.eudat.models.data.dmp.Researcher;
|
|
||||||
|
|
||||||
public class ResearcherBuilder extends Builder<Researcher> {
|
|
||||||
private String label;
|
|
||||||
private String name;
|
|
||||||
private String id;
|
|
||||||
private String reference;
|
|
||||||
private int status;
|
|
||||||
private String tag;
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder label(String label) {
|
|
||||||
this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() { return reference; }
|
|
||||||
|
|
||||||
public ResearcherBuilder reference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder status(int status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder tag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResearcherBuilder key(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher build() {
|
|
||||||
Researcher researcher = new Researcher();
|
|
||||||
researcher.setId(id);
|
|
||||||
researcher.setReference(reference);
|
|
||||||
researcher.setLabel(label);
|
|
||||||
researcher.setName(name);
|
|
||||||
researcher.setStatus(status);
|
|
||||||
researcher.setTag(tag);
|
|
||||||
researcher.setKey(key);
|
|
||||||
return researcher;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,360 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
|
||||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.RecentActivity;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.RecentActivityData;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.model.RecentActivityModel;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.model.RecentDatasetModel;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.model.RecentDmpModel;
|
|
||||||
import eu.eudat.models.data.dashboard.recent.tablerequest.RecentActivityTableRequest;
|
|
||||||
import eu.eudat.models.data.dashboard.searchbar.SearchBarItem;
|
|
||||||
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
|
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
|
||||||
import eu.eudat.types.searchbar.SearchBarItemType;
|
|
||||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class DashBoardManager {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DashBoardManager.class);
|
|
||||||
|
|
||||||
private final Map<String, Comparator<RecentActivityModel>> comparators = Stream.of(new Object[][] {
|
|
||||||
{ "modified", Comparator.comparing(o -> ((RecentActivityModel)o).getModified()).reversed()},
|
|
||||||
{ "created", Comparator.comparing(o -> ((RecentActivityModel)o).getCreated()).reversed()},
|
|
||||||
{ "label", Comparator.comparing(o -> ((RecentActivityModel)o).getTitle())},
|
|
||||||
{ "status", Comparator.comparing(o -> ((RecentActivityModel)o).getStatus()).reversed()},
|
|
||||||
{ "finalizedAt", Comparator.comparing(o -> ((RecentActivityModel)o).getFinalizedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()},
|
|
||||||
{ "publishedAt", Comparator.comparing(o -> ((RecentActivityModel)o).getPublishedAt(), Comparator.nullsLast(Comparator.naturalOrder())).reversed()}
|
|
||||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Comparator<RecentActivityModel>)data[1]));
|
|
||||||
|
|
||||||
private final ApiContext apiContext;
|
|
||||||
private final DatabaseRepository databaseRepository;
|
|
||||||
private final DataManagementPlanManager dataManagementPlanManager;
|
|
||||||
private final DatasetManager datasetManager;
|
|
||||||
private final CurrentPrincipalResolver currentPrincipalResolver;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DashBoardManager(ApiContext apiContext, DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager, CurrentPrincipalResolver currentPrincipalResolver, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
|
||||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
|
||||||
this.datasetManager = datasetManager;
|
|
||||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DashBoardStatistics getStatistics() throws InvalidApplicationException {
|
|
||||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
|
||||||
|
|
||||||
DataManagementPlanCriteria publicCriteria = new DataManagementPlanCriteria();
|
|
||||||
publicCriteria.setIsPublic(true);
|
|
||||||
publicCriteria.setOnlyPublic(true);
|
|
||||||
publicCriteria.setAllVersions(false);
|
|
||||||
|
|
||||||
List<DmpEntity> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(publicCriteria).toList();
|
|
||||||
|
|
||||||
// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
|
||||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
|
||||||
/*dataManagementPlanCriteria.setAllVersions(false);
|
|
||||||
dataManagementPlanCriteria.setIsPublic(true);*/
|
|
||||||
organisationCriteria.setPublic(true);
|
|
||||||
|
|
||||||
// List<DMP> dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList();
|
|
||||||
long numberOfDatasets = 0;
|
|
||||||
LinkedList<Grant> grants = new LinkedList<>();
|
|
||||||
for (DmpEntity dmp : dmps) {
|
|
||||||
// numberOfDatasets = numberOfDatasets + dmp.getDataset().stream() //TODO
|
|
||||||
// .filter(item -> item.getStatus() == DescriptionStatus.Finalized).count();
|
|
||||||
// if (dmp.getGrant() != null) {
|
|
||||||
// grants.add(dmp.getGrant());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
statistics.setTotalDataManagementPlanCount((long) dmps.size());
|
|
||||||
statistics.setTotalDataSetCount(numberOfDatasets);
|
|
||||||
statistics.setTotalGrantCount(grants.stream().distinct().count());
|
|
||||||
statistics.setTotalOrganisationCount(databaseRepository.getOrganisationDao().getWithCriteria(organisationCriteria).count());
|
|
||||||
|
|
||||||
return statistics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DashBoardStatistics getMeStatistics() throws IOException, InvalidApplicationException {
|
|
||||||
Long datasets = 0L;
|
|
||||||
Long dmps = 0L;
|
|
||||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
|
||||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
|
||||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
OrganisationDao organisationRepository = databaseRepository.getOrganisationDao();
|
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
user.setId(this.userScope.getUserId());
|
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
|
||||||
// if (apiContext.getOperationsContext().getElasticRepository().getDatasetRepository() != null) { //TODO
|
|
||||||
// try {
|
|
||||||
// eu.eudat.elastic.criteria.DatasetCriteria datasetElasticCriteria = new eu.eudat.elastic.criteria.DatasetCriteria();
|
|
||||||
// datasetElasticCriteria.setAllowAllVersions(false);
|
|
||||||
// datasetElasticCriteria.setPublic(false);
|
|
||||||
// datasetElasticCriteria.setCollaborators(Collections.singletonList(this.userScope.getUserId()));
|
|
||||||
// datasets = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().count(datasetElasticCriteria);
|
|
||||||
// }catch (Exception e) {
|
|
||||||
// logger.warn(e.getMessage(), e);
|
|
||||||
// datasets = null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
datasetCriteria.setAllVersions(false);
|
|
||||||
datasetCriteria.setIsPublic(false);
|
|
||||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
|
||||||
// if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) { //TODO
|
|
||||||
// try {
|
|
||||||
// eu.eudat.elastic.criteria.DmpCriteria dmpElasticCriteria = new eu.eudat.elastic.criteria.DmpCriteria();
|
|
||||||
// dmpElasticCriteria.setAllowAllVersions(false);
|
|
||||||
// dmpElasticCriteria.setPublic(false);
|
|
||||||
// dmpElasticCriteria.setCollaborators(Collections.singletonList(this.userScope.getUserId()));
|
|
||||||
// dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().count(dmpElasticCriteria);
|
|
||||||
// }catch (Exception e) {
|
|
||||||
// logger.warn(e.getMessage(), e);
|
|
||||||
// dmps = null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
dataManagementPlanCriteria.setAllVersions(false);
|
|
||||||
dataManagementPlanCriteria.setOnlyPublic(false);
|
|
||||||
dataManagementPlanCriteria.setIsPublic(false);
|
|
||||||
|
|
||||||
GrantCriteria grantCriteria = new GrantCriteria();
|
|
||||||
grantCriteria.setActive(true);
|
|
||||||
|
|
||||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
|
||||||
organisationCriteria.setActive(true);
|
|
||||||
|
|
||||||
List<Integer> roles = new LinkedList<>();
|
|
||||||
if ((dmps == null || dmps == 0L) && (datasets == null || datasets == 0L)) {
|
|
||||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), this.userScope.getUserId(), roles).distinct().countAsync()
|
|
||||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
|
||||||
CompletableFuture datasetFuture = datasetRepository.getAuthenticated( datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct().countAsync()
|
|
||||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
|
||||||
CompletableFuture.allOf(dmpFuture, datasetFuture).join();
|
|
||||||
} else {
|
|
||||||
statistics.setTotalDataManagementPlanCount(dmps);
|
|
||||||
statistics.setTotalDataSetCount(datasets);
|
|
||||||
}
|
|
||||||
CompletableFuture grantFuture = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).countAsync()
|
|
||||||
.whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats));
|
|
||||||
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.getWithCriteria(organisationCriteria).withHint("organisationRecentActivity"), user).countAsync()
|
|
||||||
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
|
|
||||||
|
|
||||||
CompletableFuture.allOf( grantFuture, orgnanisationFuture).join();
|
|
||||||
return statistics;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public RecentActivity getRecentActivity(Integer numberofactivities) throws InvalidApplicationException {
|
|
||||||
RecentActivity activity = new RecentActivity();
|
|
||||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
|
||||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
user.setId(this.userScope.getUserId());
|
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
|
||||||
datasetCriteria.setAllVersions(false);
|
|
||||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
|
||||||
dataManagementPlanCriteria.setAllVersions(false);
|
|
||||||
GrantCriteria grantCriteria = new GrantCriteria();
|
|
||||||
RecentActivityDataBuilder recentActivityDataBuilder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(RecentActivityDataBuilder.class);
|
|
||||||
|
|
||||||
List<Integer> roles = new LinkedList<>();
|
|
||||||
CompletableFuture<List<RecentActivityData>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), this.userScope.getUserId(), roles)
|
|
||||||
.withHint("dmpRecentActivity")
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.take(numberofactivities)
|
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(Date.from(item.getUpdatedAt())).id(item.getId().toString()).build())
|
|
||||||
.whenComplete((dmpActivities, throwable) -> activity.setRecentDmpActivities(dmpActivities));
|
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct()
|
|
||||||
.withHint("datasetRecentActivity")
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.take(numberofactivities)
|
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(Date.from(item.getUpdatedAt())).id(item.getId().toString()).build())
|
|
||||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
|
||||||
.withHint("grantRecentActivity")
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.take(numberofactivities)
|
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
|
||||||
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));
|
|
||||||
|
|
||||||
CompletableFuture.allOf(grants, dmps, datasets).join();
|
|
||||||
return activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public List<RecentActivityModel> getNewRecentActivity(RecentActivityTableRequest tableRequest) throws Exception {
|
|
||||||
boolean isAuthenticated = this.currentPrincipalResolver.currentPrincipal().isAuthenticated();
|
|
||||||
List<RecentActivityModel> recentActivityModels = new ArrayList<>();
|
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
if (isAuthenticated) {
|
|
||||||
user.setId(userScope.getUserId());
|
|
||||||
}
|
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
|
||||||
datasetCriteria.setLike(tableRequest.getCriteria().getLike());
|
|
||||||
if(tableRequest.getCriteria().getStatus() != null) {
|
|
||||||
datasetCriteria.setStatus(tableRequest.getCriteria().getStatus());
|
|
||||||
}
|
|
||||||
datasetCriteria.setAllVersions(false);
|
|
||||||
datasetCriteria.setIsPublic(!isAuthenticated);
|
|
||||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
|
||||||
dataManagementPlanCriteria.setAllVersions(false);
|
|
||||||
dataManagementPlanCriteria.setLike(tableRequest.getCriteria().getLike());
|
|
||||||
if(tableRequest.getCriteria().getStatus() != null) {
|
|
||||||
dataManagementPlanCriteria.setStatus(tableRequest.getCriteria().getStatus());
|
|
||||||
}
|
|
||||||
dataManagementPlanCriteria.setIsPublic(!isAuthenticated);
|
|
||||||
dataManagementPlanCriteria.setOnlyPublic(!isAuthenticated);
|
|
||||||
|
|
||||||
//GK: Use the managers to get the data in order to be better synced with other lists
|
|
||||||
DataManagementPlanTableRequest dataManagementPlanTableRequest = new DataManagementPlanTableRequest();
|
|
||||||
dataManagementPlanTableRequest.setCriteria(dataManagementPlanCriteria);
|
|
||||||
dataManagementPlanTableRequest.setOrderings(tableRequest.getOrderings());
|
|
||||||
dataManagementPlanTableRequest.setLength(tableRequest.getLength());
|
|
||||||
dataManagementPlanTableRequest.setOffset(tableRequest.getDmpOffset());
|
|
||||||
DataTableData<DataManagementPlanListingModel> dmps = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, "listing");
|
|
||||||
recentActivityModels.addAll(dmps.getData().stream().map(dataManagementPlanListingModel -> new RecentDmpModel().fromDataModel(dataManagementPlanListingModel.toDataModel())).collect(Collectors.toList()));
|
|
||||||
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
|
|
||||||
datasetCriteria.setCollaborators(new ArrayList<>());
|
|
||||||
datasetTableRequest.setCriteria(datasetCriteria);
|
|
||||||
datasetTableRequest.setOrderings(tableRequest.getOrderings());
|
|
||||||
datasetTableRequest.getOrderings().getFields().addAll(datasetTableRequest.getOrderings().getFields().stream().filter(s -> s.contains("publishedAt")).map(s -> s.charAt(0) + "dmp:" + s.substring(1) + "|join|").collect(Collectors.toList()));
|
|
||||||
datasetTableRequest.getOrderings().getFields().removeIf(s -> s.contains("publishedAt") && !s.endsWith("|join|"));
|
|
||||||
datasetTableRequest.setLength(tableRequest.getLength());
|
|
||||||
datasetTableRequest.setOffset(tableRequest.getDatasetOffset());
|
|
||||||
DataTableData<DatasetListingModel> datasets = this.datasetManager.getPaged(datasetTableRequest);
|
|
||||||
recentActivityModels.addAll(datasets.getData().stream().map(datasetListingModel -> new RecentDatasetModel().fromDataModel(datasetListingModel.toDataModel())).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
//GK: Shuffle the deck otherwise we will summon the DMPodia when sorting with status
|
|
||||||
/*int pos = -1;
|
|
||||||
for (int i = (recentActivityModels.size() / 2); i < recentActivityModels.size(); i++) {
|
|
||||||
RecentActivityModel recentActivityModel = recentActivityModels.remove(i);
|
|
||||||
while (pos < recentActivityModels.size()) {
|
|
||||||
pos++;
|
|
||||||
if (pos % 2 != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
recentActivityModels.add(pos, recentActivityModel);
|
|
||||||
}*/
|
|
||||||
//GK: No one likes to play shuffle with the recent activities. So just re-sort them based on how they have been sorted already
|
|
||||||
|
|
||||||
String order = tableRequest.getOrderings().getFields().get(0).toCharArray()[0] + "";
|
|
||||||
String field = tableRequest.getOrderings().getFields().get(0).substring(1);
|
|
||||||
if (field.contains(":") && field.contains("|")) {
|
|
||||||
field = field.substring(field.lastIndexOf(":") + 1, field.indexOf("|"));
|
|
||||||
}
|
|
||||||
field = field.equals("label") ? "title" : field;
|
|
||||||
field = field.substring(0, 1).toUpperCase() + field.substring(1);
|
|
||||||
String finalField = field;
|
|
||||||
recentActivityModels = recentActivityModels.stream().sorted((o1, o2) -> {
|
|
||||||
try {
|
|
||||||
return (order.equals("+") ? 1 : -1 ) * ((Comparable)o1.getClass().getMethod("get" + finalField).invoke(o1)).compareTo(o2.getClass().getMethod("get" + finalField).invoke(o2));
|
|
||||||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return recentActivityModels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SearchBarItem> searchUserData(String like) throws InvalidApplicationException {
|
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
user.setId(this.userScope.getUserIdSafe());
|
|
||||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
|
||||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
|
|
||||||
List<Integer> roles = new LinkedList<>();
|
|
||||||
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> publicDmps = dataManagementPlanRepository.asQueryable()
|
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
|
||||||
.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))
|
|
||||||
.where((builder, root) -> builder.equal(root.get("isPublic"), true))
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), true))
|
|
||||||
.whenComplete((dmpItems, throwable) -> searchBarItems.addAll(dmpItems));
|
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> publicDatasets = datasetRepository.asQueryable()
|
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
|
||||||
.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized))
|
|
||||||
.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true))
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), true))
|
|
||||||
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));
|
|
||||||
|
|
||||||
if (this.userScope.isSet()) {
|
|
||||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), this.userScope.getUserId(), roles)
|
|
||||||
.withHint("dmpRecentActivity")
|
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
|
||||||
.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), false))
|
|
||||||
.whenComplete((dmpItems, throwable) -> searchBarItems.addAll(dmpItems));
|
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> datasets = datasetRepository.getAuthenticated(datasetRepository.asQueryable(), user, roles)
|
|
||||||
.withHint("datasetRecentActivity")
|
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
|
||||||
.where((builder, root) -> builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive))
|
|
||||||
.where((builder, root) -> builder.notEqual(root.get("status"), DescriptionStatus.Canceled))
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), false))
|
|
||||||
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));
|
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> grants = grantRepository.getAuthenticated(grantRepository.asQueryable(), user)
|
|
||||||
.withHint("grantRecentActivity")
|
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.GRANT.getValue(), false))
|
|
||||||
.whenComplete((grantItems, throwable) -> searchBarItems.addAll(grantItems));
|
|
||||||
|
|
||||||
CompletableFuture.allOf(grants, dmps, datasets, publicDmps, publicDatasets).join();
|
|
||||||
} else {
|
|
||||||
CompletableFuture.allOf(publicDmps, publicDatasets).join();
|
|
||||||
}
|
|
||||||
|
|
||||||
return searchBarItems;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -46,12 +46,9 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
||||||
import eu.eudat.models.data.dmp.*;
|
import eu.eudat.models.data.dmp.*;
|
||||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||||
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
|
||||||
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
|
||||||
import eu.eudat.models.data.helpermodels.Tuple;
|
import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.listingmodels.*;
|
import eu.eudat.models.data.listingmodels.*;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.service.deposit.DepositService;
|
import eu.eudat.service.deposit.DepositService;
|
||||||
|
@ -505,24 +502,24 @@ public class DataManagementPlanManager {
|
||||||
newDmp.setCreatorId(user.getId());
|
newDmp.setCreatorId(user.getId());
|
||||||
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
||||||
|
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
||||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
// createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
||||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
|
// createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
|
||||||
}
|
// } //TODO
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
||||||
createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
|
// createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
|
||||||
}
|
// }/TODO
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
||||||
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
|
// createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
|
||||||
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { //TODO
|
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { //TODO
|
||||||
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
||||||
// }
|
//// }
|
||||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao());
|
//// createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao()); //TODO
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
DmpEntity dmp;
|
DmpEntity dmp;
|
||||||
if (dataManagementPlan.getId() != null) {
|
if (dataManagementPlan.getId() != null) {
|
||||||
|
@ -666,18 +663,18 @@ public class DataManagementPlanManager {
|
||||||
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
|
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
|
||||||
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first();
|
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first();
|
||||||
|
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
||||||
createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
// createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
||||||
createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
|
// createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
||||||
createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
|
// createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
||||||
createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
|
// createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
|
||||||
}
|
// }//TODO
|
||||||
|
|
||||||
DmpEntity result = createOrUpdate(dataManagementPlan);
|
DmpEntity result = createOrUpdate(dataManagementPlan);
|
||||||
|
|
||||||
|
@ -716,25 +713,25 @@ public class DataManagementPlanManager {
|
||||||
UserEntity user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
UserEntity user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
||||||
newDmp.setCreatorId(user.getId());
|
newDmp.setCreatorId(user.getId());
|
||||||
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
||||||
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
|
// createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
||||||
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
|
// createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
|
||||||
}
|
// }//TODO
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
||||||
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
|
// createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
|
||||||
}
|
// }//TODO
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
||||||
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
|
// createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
|
||||||
//TODO
|
// //TODO
|
||||||
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
|
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
|
||||||
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
||||||
// }
|
//// }
|
||||||
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
|
//// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao()); //TODO
|
||||||
}
|
// }
|
||||||
}
|
// }//TODO
|
||||||
|
|
||||||
newDmp.setGroupId(oldDmp.getGroupId());
|
newDmp.setGroupId(oldDmp.getGroupId());
|
||||||
newDmp.setVersion((short)(oldDmp.getVersion() + 1));
|
newDmp.setVersion((short)(oldDmp.getVersion() + 1));
|
||||||
|
@ -811,25 +808,25 @@ public class DataManagementPlanManager {
|
||||||
UserEntity user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
UserEntity user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
||||||
newDmp.setCreatorId(user.getId());
|
newDmp.setCreatorId(user.getId());
|
||||||
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
|
||||||
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
|
// createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
|
||||||
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
|
// createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
|
||||||
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
|
// createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
|
||||||
}
|
// }
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
|
||||||
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
|
// createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
|
||||||
//TODO
|
// //TODO
|
||||||
// if(this.dmpBlueprintService.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) {
|
//// if(this.dmpBlueprintService.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) {
|
||||||
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
|
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
|
||||||
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
||||||
// }
|
//// }
|
||||||
// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
|
//// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
|
||||||
// }
|
//// }
|
||||||
}
|
// }//TODO
|
||||||
|
|
||||||
newDmp.setGroupId(UUID.randomUUID());
|
newDmp.setGroupId(UUID.randomUUID());
|
||||||
newDmp.setVersion((short)0);
|
newDmp.setVersion((short)0);
|
||||||
|
@ -938,7 +935,7 @@ public class DataManagementPlanManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createResearchersIfTheyDontExist(DmpEntity newDmp, ResearcherDao researcherRepository, UserEntity user) throws InvalidApplicationException {
|
// private void createResearchersIfTheyDontExist(DmpEntity newDmp, ResearcherDao researcherRepository, UserEntity user) throws InvalidApplicationException {
|
||||||
// if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) { //TODO
|
// if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) { //TODO
|
||||||
// for (eu.eudat.data.old.Researcher researcher : newDmp.getResearchers()) {
|
// for (eu.eudat.data.old.Researcher researcher : newDmp.getResearchers()) {
|
||||||
// ResearcherCriteria criteria = new ResearcherCriteria();
|
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||||
|
@ -952,9 +949,9 @@ public class DataManagementPlanManager {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createOrganisationsIfTheyDontExist(DmpEntity newDmp, OrganisationDao organisationRepository) throws InvalidApplicationException {
|
// private void createOrganisationsIfTheyDontExist(DmpEntity newDmp, OrganisationDao organisationRepository) throws InvalidApplicationException {
|
||||||
// if (newDmp.getOrganisations() != null && !newDmp.getOrganisations().isEmpty()) { //TODO
|
// if (newDmp.getOrganisations() != null && !newDmp.getOrganisations().isEmpty()) { //TODO
|
||||||
// for (Organisation organisation : newDmp.getOrganisations()) {
|
// for (Organisation organisation : newDmp.getOrganisations()) {
|
||||||
// boolean createNew = false;
|
// boolean createNew = false;
|
||||||
|
@ -976,9 +973,9 @@ public class DataManagementPlanManager {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createGrantIfItDoesntExist(DmpEntity newDmp, GrantDao grantDao) throws InvalidApplicationException {
|
// private void createGrantIfItDoesntExist(DmpEntity newDmp, GrantDao grantDao) throws InvalidApplicationException {
|
||||||
// if (newDmp.getGrant() != null) { //TODO
|
// if (newDmp.getGrant() != null) { //TODO
|
||||||
// Grant grant = newDmp.getGrant();
|
// Grant grant = newDmp.getGrant();
|
||||||
// GrantCriteria criteria = new GrantCriteria();
|
// GrantCriteria criteria = new GrantCriteria();
|
||||||
|
@ -1004,9 +1001,9 @@ public class DataManagementPlanManager {
|
||||||
// grantDao.createOrUpdate(grant);
|
// grantDao.createOrUpdate(grant);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createFunderIfItDoesntExist(DmpEntity newDmp, FunderDao funderDao) throws InvalidApplicationException {
|
// private void createFunderIfItDoesntExist(DmpEntity newDmp, FunderDao funderDao) throws InvalidApplicationException {
|
||||||
// if (newDmp.getGrant() != null && newDmp.getGrant().getFunder() != null) { //TODO
|
// if (newDmp.getGrant() != null && newDmp.getGrant().getFunder() != null) { //TODO
|
||||||
// Funder funder = newDmp.getGrant().getFunder();
|
// Funder funder = newDmp.getGrant().getFunder();
|
||||||
// FunderCriteria criteria = new FunderCriteria();
|
// FunderCriteria criteria = new FunderCriteria();
|
||||||
|
@ -1022,9 +1019,9 @@ public class DataManagementPlanManager {
|
||||||
// funderDao.createOrUpdate(funder);
|
// funderDao.createOrUpdate(funder);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createProjectIfItDoesntExist(DmpEntity newDmp, ProjectDao projectDao) throws InvalidApplicationException { //TODO
|
// private void createProjectIfItDoesntExist(DmpEntity newDmp, ProjectDao projectDao) throws InvalidApplicationException { //TODO
|
||||||
// if (newDmp.getProject() != null) {
|
// if (newDmp.getProject() != null) {
|
||||||
// Project project = newDmp.getProject();
|
// Project project = newDmp.getProject();
|
||||||
// ProjectCriteria criteria = new ProjectCriteria();
|
// ProjectCriteria criteria = new ProjectCriteria();
|
||||||
|
@ -1040,16 +1037,16 @@ public class DataManagementPlanManager {
|
||||||
// createExternalProject(project, projectDao);
|
// createExternalProject(project, projectDao);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void createExternalProject(Project project, ProjectDao projectDao) {
|
// private void createExternalProject(Project project, ProjectDao projectDao) {
|
||||||
if (project.getStartdate() == null) project.setStartdate(new Date());
|
// if (project.getStartdate() == null) project.setStartdate(new Date());
|
||||||
if (project.getEnddate() == null) project.setEnddate(new Date());
|
// if (project.getEnddate() == null) project.setEnddate(new Date());
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
// project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
// if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
projectDao.createOrUpdate(project);
|
// projectDao.createOrUpdate(project);
|
||||||
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
|
// metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void copyDatasets(DmpEntity newDmp, DatasetDao datasetDao) throws InvalidApplicationException {
|
private void copyDatasets(DmpEntity newDmp, DatasetDao datasetDao) throws InvalidApplicationException {
|
||||||
List<CompletableFuture<DescriptionEntity>> futures = new LinkedList<>();
|
List<CompletableFuture<DescriptionEntity>> futures = new LinkedList<>();
|
||||||
|
@ -2162,41 +2159,42 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dm.setProperties(dmpPropertiesMap);
|
dm.setProperties(dmpPropertiesMap);
|
||||||
|
//TODO
|
||||||
|
// if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Funder)) {
|
||||||
|
// eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
||||||
|
// FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
||||||
|
// funder.setId(funderImport.getId());
|
||||||
|
// funder.setLabel(funderImport.getLabel());
|
||||||
|
// FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
||||||
|
// funderEditor.setExistFunder(funder);
|
||||||
|
//
|
||||||
|
// dm.setFunder(funderEditor);
|
||||||
|
// }
|
||||||
|
//TODO
|
||||||
|
// if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Grant)) {
|
||||||
|
// eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
||||||
|
// GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
||||||
|
// grant.setId(grantImport.getId());
|
||||||
|
// grant.setLabel(grantImport.getLabel());
|
||||||
|
// grant.setAbbreviation(grantImport.getAbbreviation());
|
||||||
|
// grant.setDescription(grantImport.getDescription());
|
||||||
|
// GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
||||||
|
// grantEditor.setExistGrant(grant);
|
||||||
|
//
|
||||||
|
// dm.setGrant(grantEditor);
|
||||||
|
// }
|
||||||
|
|
||||||
if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Funder)) {
|
//TODO
|
||||||
eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
// if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Project)) {
|
||||||
FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
// eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||||
funder.setId(funderImport.getId());
|
// ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
||||||
funder.setLabel(funderImport.getLabel());
|
// project.setId(projectImport.getId());
|
||||||
FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
// project.setLabel(projectImport.getLabel());
|
||||||
funderEditor.setExistFunder(funder);
|
// ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
||||||
|
// projectEditor.setExistProject(project);
|
||||||
dm.setFunder(funderEditor);
|
//
|
||||||
}
|
// dm.setProject(projectEditor);
|
||||||
|
// }
|
||||||
if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Grant)) {
|
|
||||||
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
|
||||||
GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
|
||||||
grant.setId(grantImport.getId());
|
|
||||||
grant.setLabel(grantImport.getLabel());
|
|
||||||
grant.setAbbreviation(grantImport.getAbbreviation());
|
|
||||||
grant.setDescription(grantImport.getDescription());
|
|
||||||
GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
|
||||||
grantEditor.setExistGrant(grant);
|
|
||||||
|
|
||||||
dm.setGrant(grantEditor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.dmpBlueprintService.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId(), DmpBlueprintSystemFieldType.Project)) {
|
|
||||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
|
||||||
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
|
||||||
project.setId(projectImport.getId());
|
|
||||||
project.setLabel(projectImport.getLabel());
|
|
||||||
ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
|
||||||
projectEditor.setExistProject(project);
|
|
||||||
|
|
||||||
dm.setProject(projectEditor);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
||||||
// if (profiles != null && profiles.length > 0) {
|
// if (profiles != null && profiles.length > 0) {
|
||||||
|
@ -2220,24 +2218,24 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
// List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
||||||
for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
// for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
||||||
eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
|
// eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
|
||||||
organisation.setName(org.getOrganaisationNameImport());
|
// organisation.setName(org.getOrganaisationNameImport());
|
||||||
organisation.setReference(org.getOrganaisationReferenceImport());
|
// organisation.setReference(org.getOrganaisationReferenceImport());
|
||||||
organisation.setKey(organisation.getReference().split(":")[0]);
|
// organisation.setKey(organisation.getReference().split(":")[0]);
|
||||||
organisations.add(organisation);
|
// organisations.add(organisation);
|
||||||
}
|
// }//TODO
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
|
// List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
|
||||||
for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
|
// for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
|
||||||
eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
|
// eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
|
||||||
researcher.setLabel(res.getResearcherImportName());
|
// researcher.setLabel(res.getResearcherImportName());
|
||||||
researcher.setName(res.getResearcherImportName());
|
// researcher.setName(res.getResearcherImportName());
|
||||||
researcher.setReference(res.getResearcherImportReference());
|
// researcher.setReference(res.getResearcherImportReference());
|
||||||
researcher.setKey(researcher.getReference().split(":")[0]);
|
// researcher.setKey(researcher.getReference().split(":")[0]);
|
||||||
researchers.add(researcher);
|
// researchers.add(researcher);
|
||||||
}
|
// } //TODO
|
||||||
|
|
||||||
//List<UserListingModel> associatedUsers = new LinkedList<>();
|
//List<UserListingModel> associatedUsers = new LinkedList<>();
|
||||||
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
|
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
|
||||||
|
@ -2246,8 +2244,8 @@ public class DataManagementPlanManager {
|
||||||
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
||||||
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
||||||
dm.setProfiles(associatedProfiles);
|
dm.setProfiles(associatedProfiles);
|
||||||
dm.setOrganisations(organisations); // Sets organisations property.
|
// dm.setOrganisations(organisations); // Sets organisations property.
|
||||||
dm.setResearchers(researchers); // Sets researchers property.
|
// dm.setResearchers(researchers); // Sets researchers property.
|
||||||
//dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
|
//dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
|
||||||
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
|
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
|
||||||
//dm.setDefinition(dmpProfile);
|
//dm.setDefinition(dmpProfile);
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 9/3/2018.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class DataRepositoryManager {
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private UserScope userScope;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DataRepositoryManager(ApiContext apiContext, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataRepository create(eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception {
|
|
||||||
DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
|
||||||
dataRepository.getCreationUser().setId(userScope.getUserId());
|
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DataRepositoryModel> getDataRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, type);
|
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
|
||||||
criteria.setCreationUserId(userScope.getUserId());
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = new LinkedList<>();
|
|
||||||
if (type.equals("")) {
|
|
||||||
List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
|
||||||
dataRepositoryModels = dataRepositoryList.stream().map(item -> new DataRepositoryModel().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
dataRepositoryModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, DataRepositoryModel.class)).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
return dataRepositoryModels;
|
|
||||||
}
|
|
||||||
public List<DataRepositoryModel> getPubRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.PubRepositories, externalReferenceCriteria, type);
|
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
|
||||||
criteria.setCreationUserId(userScope.getUserId());
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = new LinkedList<>();
|
|
||||||
if (type.equals("")) {
|
|
||||||
List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
|
||||||
dataRepositoryModels = dataRepositoryList.stream().map(item -> new DataRepositoryModel().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
dataRepositoryModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, DataRepositoryModel.class)).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
return dataRepositoryModels;
|
|
||||||
}
|
|
||||||
public List<DataRepositoryModel> getJournals(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Journals, externalReferenceCriteria, type);
|
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
|
||||||
criteria.setCreationUserId(userScope.getUserId());
|
|
||||||
|
|
||||||
List<DataRepositoryModel> dataRepositoryModels = new LinkedList<>();
|
|
||||||
if (type.equals("")) {
|
|
||||||
List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
|
||||||
dataRepositoryModels = dataRepositoryList.stream().map(item -> new DataRepositoryModel().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
dataRepositoryModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, DataRepositoryModel.class)).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
return dataRepositoryModels;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,9 +12,7 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.*;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
import eu.eudat.data.dao.entities.RegistryDao;
|
|
||||||
import eu.eudat.commons.enums.old.notification.ActiveStatus;
|
import eu.eudat.commons.enums.old.notification.ActiveStatus;
|
||||||
import eu.eudat.commons.enums.old.notification.ContactType;
|
import eu.eudat.commons.enums.old.notification.ContactType;
|
||||||
import eu.eudat.commons.enums.old.notification.NotificationType;
|
import eu.eudat.commons.enums.old.notification.NotificationType;
|
||||||
|
@ -659,17 +657,17 @@ public class DatasetManager {
|
||||||
UserEntity userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
UserEntity userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
||||||
descriptionEntity.setDmpDescriptionTemplateId(userInfo.getId());
|
descriptionEntity.setDmpDescriptionTemplateId(userInfo.getId());
|
||||||
|
|
||||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
|
// createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);//TODO
|
||||||
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), descriptionEntity);
|
// createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), descriptionEntity);
|
||||||
createServicesIfTheyDontExist(descriptionEntity);
|
createServicesIfTheyDontExist(descriptionEntity);
|
||||||
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
datasetWizardModel.setId(descriptionEntity1.getId());
|
datasetWizardModel.setId(descriptionEntity1.getId());
|
||||||
if (datasetWizardModel.getDmp().getGrant() == null) {
|
// if (datasetWizardModel.getDmp().getGrant() == null) { //TODO
|
||||||
DmpEntity dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
// DmpEntity dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
|
//
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
// datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
// }
|
||||||
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
|
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
||||||
|
@ -894,9 +892,9 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO implement it on create
|
||||||
private void createRegistriesIfTheyDontExist(RegistryDao registryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
// private void createRegistriesIfTheyDontExist(RegistryDao registryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
//TODO implement it on create
|
//
|
||||||
// if (descriptionEntity.getRegistries() != null && !descriptionEntity.getRegistries().isEmpty()) {
|
// if (descriptionEntity.getRegistries() != null && !descriptionEntity.getRegistries().isEmpty()) {
|
||||||
// for (Registry registry : descriptionEntity.getRegistries()) {
|
// for (Registry registry : descriptionEntity.getRegistries()) {
|
||||||
// RegistryCriteria criteria = new RegistryCriteria();
|
// RegistryCriteria criteria = new RegistryCriteria();
|
||||||
|
@ -909,10 +907,11 @@ public class DatasetManager {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
//TODO implement it on create
|
||||||
//TODO implement it on create
|
// private void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
|
//
|
||||||
// if (descriptionEntity.getDatasetDataRepositories() != null && !descriptionEntity.getDatasetDataRepositories().isEmpty()) {
|
// if (descriptionEntity.getDatasetDataRepositories() != null && !descriptionEntity.getDatasetDataRepositories().isEmpty()) {
|
||||||
// for (DatasetDataRepository datasetDataRepository : descriptionEntity.getDatasetDataRepositories()) {
|
// for (DatasetDataRepository datasetDataRepository : descriptionEntity.getDatasetDataRepositories()) {
|
||||||
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
|
@ -931,7 +930,7 @@ public class DatasetManager {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createServicesIfTheyDontExist(DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
private void createServicesIfTheyDontExist(DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
//TODO implement it on create
|
//TODO implement it on create
|
||||||
|
@ -1063,8 +1062,8 @@ public class DatasetManager {
|
||||||
entity.setDmpDescriptionTemplateId(userInfo.getId());
|
entity.setDmpDescriptionTemplateId(userInfo.getId());
|
||||||
|
|
||||||
updateTagsXmlImportDataset(entity);
|
updateTagsXmlImportDataset(entity);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
|
// createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
|
||||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), entity);
|
// createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), entity);//TODO
|
||||||
createServicesIfTheyDontExist(entity);
|
createServicesIfTheyDontExist(entity);
|
||||||
createExternalDatasetsIfTheyDontExist(entity);
|
createExternalDatasetsIfTheyDontExist(entity);
|
||||||
|
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
|
||||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.service.reference.external.RemoteFetcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ExternalDatasetManager {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private DatabaseRepository databaseRepository;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private final UserScope userScope;
|
|
||||||
@Autowired
|
|
||||||
public ExternalDatasetManager(ApiContext apiContext, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
|
||||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTableData<ExternalDatasetListingModel> getPaged(ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception {
|
|
||||||
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(externalDatasetTableRequest.getCriteria());
|
|
||||||
QueryableList<ExternalDataset> pagedItems = PaginationManager.applyPaging(items, externalDatasetTableRequest);
|
|
||||||
List<ExternalDatasetListingModel> externalDatasetListingmodels = pagedItems.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
|
||||||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ExternalDatasetListingModel> getWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
// Fetch the local saved external Datasets that belong to the user.
|
|
||||||
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
|
||||||
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
|
||||||
|
|
||||||
// Fetch external Datasets from external sources.
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Datasets, externalReferenceCriteria, type);
|
|
||||||
|
|
||||||
// Parse items from external sources to listing models.
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
List<ExternalDatasetListingModel> externalDatasetModels = remoteRepos.stream()
|
|
||||||
.map(item -> mapper.convertValue(item, ExternalDatasetListingModel.class))
|
|
||||||
.collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
|
||||||
// Merge fetched and local.
|
|
||||||
List<ExternalDatasetListingModel> externalDatasets = items.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
|
||||||
externalDatasets.addAll(externalDatasetModels);
|
|
||||||
|
|
||||||
return externalDatasets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExternalDatasetListingModel getSingle(UUID id) throws HugeResultSetException, MyNotFoundException, InstantiationException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().find(id);
|
|
||||||
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetListingModel();
|
|
||||||
externalDatasetModel.fromDataModel(externalDataset);
|
|
||||||
return externalDatasetModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExternalDataset create(eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception {
|
|
||||||
ExternalDataset externalDataset = externalDatasetModel.toDataModel();
|
|
||||||
externalDataset.getCreationUser().setId(this.userScope.getUserId());
|
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().createOrUpdate(externalDataset);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.service.reference.external.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.models.data.external.FundersExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.funder.Funder;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class FunderManager {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private ListHelper listHelper;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
public FunderManager(ApiContext apiContext, RemoteFetcher remoteFetcher, ListHelper listHelper, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.remoteFetcher = remoteFetcher;
|
|
||||||
this.listHelper = listHelper;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Funder> getCriteriaWithExternal(FunderCriteriaRequest funderCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
funderCriteria.getCriteria().setReference("dmp:");
|
|
||||||
QueryableList<eu.eudat.data.old.Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
|
|
||||||
List<Funder> funders = authItems.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item));
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(funderCriteria.getCriteria().getLike());
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Funder, externalReferenceCriteria, null);
|
|
||||||
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
|
|
||||||
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
|
||||||
.status(eu.eudat.data.old.Funder.Status.fromInteger(0))
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.source(externalListingItem.getTag())
|
|
||||||
.build();
|
|
||||||
if (externalListingItem.getSource() != null) {
|
|
||||||
funder.setSource(externalListingItem.getSource());
|
|
||||||
} else {
|
|
||||||
funder.setSource(externalListingItem.getTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
funders.add(funder);
|
|
||||||
}
|
|
||||||
funders.sort(Comparator.comparing(Funder::getLabel));
|
|
||||||
funders = funders.stream().filter(listHelper.distinctByKey(Funder::getLabel)).collect(Collectors.toList());
|
|
||||||
return funders;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,188 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.models.data.external.GrantsExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.grant.Grant;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.data.query.items.item.grant.GrantCriteriaRequest;
|
|
||||||
import eu.eudat.models.data.grant.GrantListingModel;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.service.reference.external.RemoteFetcher;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class GrantManager {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private DatabaseRepository databaseRepository;
|
|
||||||
// private FileStorageService fileStorageService;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private ListHelper listHelper;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
public GrantManager(ApiContext apiContext, ListHelper listHelper, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
|
||||||
// this.fileStorageService = apiContext.getOperationsContext().getFileStorageService();
|
|
||||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
|
||||||
this.listHelper = listHelper;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTableData<eu.eudat.models.data.grant.GrantListingModel> getPaged(GrantTableRequest grantTableRequest, String fieldsGroup) throws Exception {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> items = grantRepository.getWithCriteria(grantTableRequest.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> authItems = grantRepository.getAuthenticated(items, userInfo);
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> pagedItems = PaginationManager.applyPaging(authItems, grantTableRequest);
|
|
||||||
DataTableData<eu.eudat.models.data.grant.GrantListingModel> dataTable = new DataTableData<>();
|
|
||||||
CompletableFuture grantsFuture;
|
|
||||||
if (fieldsGroup.equals("listing")) {
|
|
||||||
grantsFuture = pagedItems.selectAsync(item -> new GrantListingModel().fromDataModelDetails(item))
|
|
||||||
.whenComplete((results, throwable) ->
|
|
||||||
dataTable.setData(results)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
grantsFuture = pagedItems.selectAsync(item -> new GrantListingModel().fromDataModel(item))
|
|
||||||
.whenComplete((results, throwable) ->
|
|
||||||
dataTable.setData(results)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
|
||||||
|
|
||||||
CompletableFuture.allOf(grantsFuture, countFuture).join();
|
|
||||||
return dataTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTableData<eu.eudat.models.data.grant.GrantListingModel> getPublicPaged(GrantTableRequest grantTableRequest) throws Exception {
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
grantTableRequest.getCriteria().setPublic(true);
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> items = grantRepository.getWithCriteria(grantTableRequest.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> pagedItems = PaginationManager.applyPaging(items, grantTableRequest);
|
|
||||||
DataTableData<eu.eudat.models.data.grant.GrantListingModel> dataTable = new DataTableData<>();
|
|
||||||
CompletableFuture grantsFuture;
|
|
||||||
grantsFuture = pagedItems.selectAsync(item -> new GrantListingModel().fromDataModel(item))
|
|
||||||
.whenComplete((results, throwable) -> {
|
|
||||||
dataTable.setData(results);
|
|
||||||
});
|
|
||||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
|
||||||
|
|
||||||
CompletableFuture.allOf(grantsFuture, countFuture).join();
|
|
||||||
return dataTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public eu.eudat.models.data.grant.Grant getSingle(String id) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
|
||||||
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
|
||||||
grant.fromDataModel(databaseRepository.getGrantDao().find(UUID.fromString(id)));
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public eu.eudat.data.old.Grant inactivate(String id) throws InstantiationException, IllegalAccessException {
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
eu.eudat.data.old.Grant grant = grantRepository.find(UUID.fromString(id));
|
|
||||||
grant.setStatus(eu.eudat.data.old.Grant.Status.DELETED.getValue());
|
|
||||||
grant = grantRepository.createOrUpdate(grant);
|
|
||||||
return grant;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public List<eu.eudat.models.data.grant.Grant> getCriteriaWithExternal(GrantCriteriaRequest grantCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
/*if (grantCriteria.getCriteria().getFunderReference() != null && !grantCriteria.getCriteria().getFunderReference().trim().isEmpty()) {
|
|
||||||
FunderCriteria funderCriteria = new FunderCriteria();
|
|
||||||
funderCriteria.setReference(grantCriteria.getCriteria().getFunderReference());
|
|
||||||
Funder funder = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria).getSingleOrDefault();
|
|
||||||
if (funder != null) {
|
|
||||||
grantCriteria.getCriteria().setFunderId(funder.getId().toString());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(grantCriteria.getCriteria().getLike());
|
|
||||||
if (grantCriteria.getCriteria().getFunderReference() != null) {
|
|
||||||
externalReferenceCriteria.setFunderId(grantCriteria.getCriteria().getFunderReference());
|
|
||||||
grantCriteria.getCriteria().setFunderReference(null);
|
|
||||||
}
|
|
||||||
grantCriteria.getCriteria().setReference("dmp:");
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> items = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(grantCriteria.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo);
|
|
||||||
List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item));
|
|
||||||
|
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.get(ReferenceType.Grants, externalReferenceCriteria, null);
|
|
||||||
|
|
||||||
GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : grantsExternalSourcesModel) {
|
|
||||||
eu.eudat.models.data.grant.Grant grant = apiContext.getOperationsContext().getBuilderFactory().getBuilder(GrantBuilder.class)
|
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
|
||||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.old.Grant.Status.fromInteger(0))
|
|
||||||
.source(externalListingItem.getTag())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
grants.add(grant);
|
|
||||||
}
|
|
||||||
grants.sort(Comparator.comparing(Grant::getLabel));
|
|
||||||
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
|
|
||||||
return grants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<eu.eudat.models.data.grant.Grant> getCriteria(GrantCriteriaRequest grantCriteria) throws IllegalAccessException, InstantiationException, HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
|
||||||
QueryableList<eu.eudat.data.old.Grant> items = grantRepository.getWithCriteria(grantCriteria.getCriteria());
|
|
||||||
if (grantCriteria.getLength() != null) items.take(grantCriteria.getLength());
|
|
||||||
List<eu.eudat.models.data.grant.Grant> grants = items.select(item -> new Grant().fromDataModel(item));
|
|
||||||
return grants;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public void createOrUpdate(eu.eudat.models.data.grant.Grant grant, Principal principal) throws ParseException, IOException {
|
|
||||||
eu.eudat.data.old.Grant grantEntity = grant.toDataModel();
|
|
||||||
if (grant.getFiles() != null) {
|
|
||||||
for (ContentFile file : grant.getFiles()) {
|
|
||||||
try {
|
|
||||||
ContentFile storedFile = fileStorageService.copyFromTempFileSystem(file);
|
|
||||||
Content content = new ContentBuilder().extension(file.getType())
|
|
||||||
.label(file.getFilename())
|
|
||||||
.locationType(Content.LocationType.INTERNAL.getValue())
|
|
||||||
.parentType(Content.ParentType.GRANT.getValue())
|
|
||||||
.uri("LOCAL:" + storedFile.getId())
|
|
||||||
.build();
|
|
||||||
grantEntity.setContent(databaseRepository.getContentDao().createOrUpdate(content));
|
|
||||||
} catch (TempFileNotFoundException e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
grantEntity.setType(eu.eudat.data.old.Grant.GrantType.INTERNAL.getValue());
|
|
||||||
grantEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
|
||||||
databaseRepository.getGrantDao().createOrUpdate(grantEntity);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void delete(UUID uuid) throws InvalidApplicationException {
|
|
||||||
eu.eudat.data.old.Grant oldGrant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(uuid);
|
|
||||||
//TODO
|
|
||||||
// if (oldGrant.getDmps().size() > 0)
|
|
||||||
// throw new GrantWithDMPsDeleteException("You cannot Remove Grants with DMPs");
|
|
||||||
// oldGrant.setStatus(DMP.DMPStatus.DELETED.getValue());
|
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(oldGrant);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 9/3/2018.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class LicenseManager {
|
|
||||||
private ApiContext apiContext;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public LicenseManager(ApiContext apiContext) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Licenses, externalReferenceCriteria, type);
|
|
||||||
|
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
|
||||||
|
|
||||||
List<LicenseModel> licenseModels = new LinkedList<>();
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
licenseModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, LicenseModel.class)).collect(Collectors.toList()));
|
|
||||||
licenseModels = licenseModels.stream().filter(licenseModel -> licenseModel.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
|
||||||
return licenseModels;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -299,9 +299,10 @@ public class MetricsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllResearchers(boolean countNexus) throws InvalidApplicationException {
|
private long countAllResearchers(boolean countNexus) throws InvalidApplicationException {
|
||||||
ResearcherCriteria criteria = new ResearcherCriteria();
|
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||||
if (countNexus) criteria.setPeriodStart(getNexusDate());
|
// if (countNexus) criteria.setPeriodStart(getNexusDate());
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(criteria).count();
|
// return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(criteria).count();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllProjects() throws InvalidApplicationException {
|
private long countAllProjects() throws InvalidApplicationException {
|
||||||
|
@ -309,9 +310,10 @@ public class MetricsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllProjects(boolean countNexus) throws InvalidApplicationException {
|
private long countAllProjects(boolean countNexus) throws InvalidApplicationException {
|
||||||
ProjectCriteria criteria = new ProjectCriteria();
|
// ProjectCriteria criteria = new ProjectCriteria();
|
||||||
if (countNexus) criteria.setPeriodStart(getNexusDate());
|
// if (countNexus) criteria.setPeriodStart(getNexusDate());
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
|
// return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllFunders() throws InvalidApplicationException {
|
private long countAllFunders() throws InvalidApplicationException {
|
||||||
|
@ -319,9 +321,10 @@ public class MetricsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllFunders(boolean countNexus) throws InvalidApplicationException {
|
private long countAllFunders(boolean countNexus) throws InvalidApplicationException {
|
||||||
FunderCriteria criteria = new FunderCriteria();
|
// FunderCriteria criteria = new FunderCriteria();
|
||||||
if (countNexus) criteria.setPeriodStart(getNexusDate());
|
// if (countNexus) criteria.setPeriodStart(getNexusDate());
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
|
// return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllGrants() throws InvalidApplicationException {
|
private long countAllGrants() throws InvalidApplicationException {
|
||||||
|
@ -329,9 +332,10 @@ public class MetricsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countAllGrants(boolean countNexus) throws InvalidApplicationException {
|
private long countAllGrants(boolean countNexus) throws InvalidApplicationException {
|
||||||
GrantCriteria criteria = new GrantCriteria();
|
// GrantCriteria criteria = new GrantCriteria();
|
||||||
if (countNexus) criteria.setPeriodStart(getNexusDate());
|
// if (countNexus) criteria.setPeriodStart(getNexusDate());
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
|
// return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long countAllDraftDatasets() throws InvalidApplicationException {
|
public long countAllDraftDatasets() throws InvalidApplicationException {
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.OrganisationBuilder;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class OrganisationsManager {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private DatabaseRepository databaseRepository;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public OrganisationsManager(ApiContext apiContext, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTableData<Organisation> getPagedOrganisations(OrganisationsTableRequest organisationsTableRequest) throws Exception {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
|
|
||||||
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> authItems = organisationDao.getAuthenticated(items, userInfo);
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> pagedItems = PaginationManager.applyPaging(authItems, organisationsTableRequest);
|
|
||||||
|
|
||||||
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
|
||||||
organisationDataTableData.setData(org);
|
|
||||||
organisationDataTableData.setTotalCount(pagedItems.count());
|
|
||||||
|
|
||||||
return organisationDataTableData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataTableData<Organisation> getPublicPagedOrganisations(OrganisationsTableRequest organisationsTableRequest) throws Exception {
|
|
||||||
organisationsTableRequest.getCriteria().setPublic(true);
|
|
||||||
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
|
|
||||||
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> pagedItems = PaginationManager.applyPaging(items, organisationsTableRequest);
|
|
||||||
|
|
||||||
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
|
||||||
organisationDataTableData.setData(org);
|
|
||||||
organisationDataTableData.setTotalCount(pagedItems.count());
|
|
||||||
|
|
||||||
return organisationDataTableData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Organisation> getWithExternal(OrganisationsTableRequest organisationsTableRequest) throws Exception {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
|
|
||||||
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> authItems = organisationDao.getAuthenticated(items, userInfo);
|
|
||||||
QueryableList<eu.eudat.data.old.Organisation> pagedItems = PaginationManager.applyPaging(authItems, organisationsTableRequest);
|
|
||||||
|
|
||||||
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(organisationsTableRequest.getCriteria().getLabelLike());
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, null);
|
|
||||||
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
|
||||||
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
|
|
||||||
.name(externalListingItem.getName())
|
|
||||||
.reference(externalListingItem.getRemoteId())
|
|
||||||
.tag(externalListingItem.getTag())
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.build();
|
|
||||||
org.add(organisation);
|
|
||||||
}
|
|
||||||
return org;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException {
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, type);
|
|
||||||
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
List<Organisation> organisations = new LinkedList<>();
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
|
|
||||||
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
|
|
||||||
.name(externalListingItem.getName())
|
|
||||||
.reference(externalListingItem.getRemoteId())
|
|
||||||
.tag(externalListingItem.getTag())
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.build();
|
|
||||||
organisations.add(organisation);
|
|
||||||
}
|
|
||||||
return organisations.stream().distinct().collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,18 +35,18 @@ public class PrefillingManager {
|
||||||
private final ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
private final LicenseManager licenseManager;
|
// private final LicenseManager licenseManager;
|
||||||
private final PrefillingMapper prefillingMapper;
|
private final PrefillingMapper prefillingMapper;
|
||||||
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PrefillingManager(ApiContext apiContext, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper, ExternalUrlConfigProvider externalUrlConfigProvider) {
|
public PrefillingManager(ApiContext apiContext, DatasetManager datasetManager /*, LicenseManager licenseManager*/, PrefillingMapper prefillingMapper, ExternalUrlConfigProvider externalUrlConfigProvider) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.prefillingMapper = prefillingMapper;
|
this.prefillingMapper = prefillingMapper;
|
||||||
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||||
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.licenseManager = licenseManager;
|
// this.licenseManager = licenseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Prefilling> getPrefillings(String like) {
|
public List<Prefilling> getPrefillings(String like) {
|
||||||
|
@ -74,14 +74,14 @@ public class PrefillingManager {
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
return prefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager, licenseManager);
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager/*, licenseManager*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
||||||
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(configId);
|
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(configId);
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager, licenseManager);
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplateEntity, datasetManager/*, licenseManager*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getSingle(String url, String id) {
|
private Map<String, Object> getSingle(String url, String id) {
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
package eu.eudat.logic.managers;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.ReferenceType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
|
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
|
||||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.project.Project;
|
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.ProjectBuilder;
|
|
||||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
|
||||||
import eu.eudat.service.reference.external.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ProjectManager {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private ListHelper listHelper;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
public ProjectManager(ApiContext apiContext, ListHelper listHelper, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
|
||||||
this.listHelper = listHelper;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
|
|
||||||
UserEntity userInfo = new UserEntity();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
projectCriteria.getCriteria().setReference("dmp:");
|
|
||||||
QueryableList<eu.eudat.data.old.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
|
||||||
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
|
||||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(projectCriteria.getCriteria().getLike());
|
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, null);
|
|
||||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
|
||||||
eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)
|
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
|
||||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
|
||||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.old.Project.Status.fromInteger(0))
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.source(externalListingItem.getTag())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
projects.add(project);
|
|
||||||
}
|
|
||||||
projects.sort(Comparator.comparing(Project::getLabel));
|
|
||||||
projects = projects.stream().filter(listHelper.distinctByKey(Project::getLabel)).collect(Collectors.toList());
|
|
||||||
return projects;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue