remove old refence classes

This commit is contained in:
Efstratios Giannopoulos 2024-01-04 12:55:42 +02:00
parent ccd7d069cb
commit f253fd965c
152 changed files with 422 additions and 10050 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,7 +1,6 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.DataRepository;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.Reference;
import eu.eudat.model.referencedefinition.Field;

View File

@ -1,7 +1,6 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.ExternalDataset;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.Reference;
import eu.eudat.model.referencedefinition.Field;

View File

@ -1,7 +1,6 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.Registry;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.Reference;
import eu.eudat.model.referencedefinition.Field;

View File

@ -1,7 +1,6 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.Service;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.Reference;
import eu.eudat.model.referencedefinition.Field;

View File

@ -1,7 +1,5 @@
package eu.eudat.model.publicapi.funder;
import eu.eudat.data.old.Funder;
import java.util.UUID;
public class FunderPublicOverviewModel {
@ -22,15 +20,15 @@ public class FunderPublicOverviewModel {
this.label = label;
}
public FunderPublicOverviewModel fromDataModel(Funder entity) {
this.id = entity.getId();
this.label = entity.getLabel();
return this;
}
public Funder toDataModel() throws Exception {
return null;
}
// public FunderPublicOverviewModel fromDataModel(Funder entity) {
// this.id = entity.getId();
// this.label = entity.getLabel();
// return this;
// }
//
// public Funder toDataModel() throws Exception {
// return null;
// }
public String getHint() {
return null;

View File

@ -1,7 +1,6 @@
package eu.eudat.model.publicapi.grant;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.Grant;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.DmpReference;
import eu.eudat.model.Reference;

View File

@ -2,7 +2,6 @@ package eu.eudat.data.dao.criteria;
import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.old.Grant;
import java.util.Date;
import java.util.List;
@ -12,7 +11,6 @@ public class DataManagementPlanCriteria extends Criteria<DmpEntity> {
private Date periodStart;
private Date periodEnd;
private DmpBlueprintEntity profile;
private List<Grant> grants;
private boolean allVersions;
private List<UUID> groupIds;
private Integer status;
@ -46,13 +44,6 @@ public class DataManagementPlanCriteria extends Criteria<DmpEntity> {
this.profile = profile;
}
public List<Grant> getGrants() {
return grants;
}
public void setGrants(List<Grant> grants) {
this.grants = grants;
}
public boolean getAllVersions() {
return allVersions;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -47,8 +47,8 @@ public class DMPDaoImpl extends DatabaseAccess<DmpEntity> implements DMPDao {
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
if (criteria.getProfile() != null)
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
// if (criteria.getGrants() != null && !criteria.getGrants().isEmpty()) //TODO
// query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
if (!criteria.getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -24,8 +24,8 @@ public class DataManagementPlanTableRequest extends TableQuery<DataManagementPla
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().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
// query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants()))); //TODO
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())

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -3,8 +3,6 @@ package eu.eudat.query;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
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.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
@ -22,7 +20,6 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
private UUID groupId;
private String label;
private int version;
private GrantQuery grantQuery;
// private UserQueryOld userQuery;
private DatasetQuery datasetQuery;
private List<Integer> statuses;
@ -69,13 +66,6 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
this.version = version;
}
public GrantQuery getGrantQuery() {
return grantQuery;
}
public void setGrantQuery(GrantQuery grantQuery) {
this.grantQuery = grantQuery;
}
public List<Integer> getStatuses() {
return statuses;
@ -122,10 +112,10 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
if (this.grantQuery != null) {
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));
}
// if (this.grantQuery != null) { //TODO
// 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));
// }
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
}

View File

@ -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;
}
}

View File

@ -23,12 +23,6 @@ public abstract class BaseController {
protected void initBinder(WebDataBinder binder) {
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass())))
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())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -5,9 +5,6 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateEntity;
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.QuickWizardManager;
import eu.eudat.logic.services.ApiContext;
@ -53,49 +50,49 @@ public class QuickWizardController extends BaseController {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
Funder funderEntity;
//Create Funder
if (quickWizard.getFunder() == null) {
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder());
} else {
funderEntity = quickWizard.getFunder().getExistFunder().toDataModel();
}
// Funder funderEntity;//TODO
// //Create Funder
// if (quickWizard.getFunder() == null) {
// funderEntity = null;
// } else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
// funderEntity = null;
// } else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
// funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder());
// } else {
// funderEntity = quickWizard.getFunder().getExistFunder().toDataModel();
// }
Grant grantEntity;
//Create Grant
if (quickWizard.getGrant() == null) {
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null) {
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant());
} else {
grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
}
// Grant grantEntity; //TODO
// //Create Grant
// if (quickWizard.getGrant() == null) {
// grantEntity = null;
// } else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
// grantEntity = null;
// } else if (quickWizard.getGrant().getExistGrant() == null) {
// grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant());
// } else {
// grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
// }
Project projectEntity;
//Create Project
if (quickWizard.getProject().getExistProject() == null
&& quickWizard.getProject().getLabel() == null) {
projectEntity = null;
} else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null) {
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject());
} else {
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
}
// Project projectEntity; //TODO
// //Create Project
// if (quickWizard.getProject().getExistProject() == null
// && quickWizard.getProject().getLabel() == null) {
// projectEntity = null;
// } else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null) {
// projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject());
// } else {
// projectEntity = quickWizard.getProject().getExistProject().toDataModel();
// }
//Create Dmp
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, userScope);
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan, funderEntity);
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(/*grantEntity,*/ userScope);
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan/*, funderEntity*/);
//Create Datasets
quickWizard.getDmp().setId(dmpEntity.getId());
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();
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
this.datasetManager.createOrUpdate(datasetWizardModel);

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -12,7 +12,6 @@ public class DMPCriteria {
private Criteria<UUID> groupId;
private Criteria<String> label;
private Criteria<Integer> version;
private GrantCriteria grant;
private DateCriteria created;
private DateCriteria modified;
private UserCriteria creator;
@ -74,14 +73,6 @@ public class DMPCriteria {
this.version = criteria;
}
public GrantCriteria getGrant() {
return grant;
}
public void setGrant(GrantCriteria grant) {
this.grant = grant;
}
public DateCriteria getCreated() {
return created;
}
@ -131,7 +122,7 @@ public class DMPCriteria {
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 (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.dataset != null) fields.addAll(this.dataset.buildFields(path + "dataset"));
if (!fields.contains(path + "id")) fields.add(path + "id");
@ -142,7 +133,7 @@ public class DMPCriteria {
List<String> fields = this.buildFields("");
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
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.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
return dmpQuery;

View File

@ -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;
}
}

View File

@ -1,9 +1,6 @@
package eu.eudat.logic.builders;
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 org.springframework.stereotype.Service;
@ -12,19 +9,11 @@ import org.springframework.stereotype.Service;
public class BuilderFactoryImpl implements BuilderFactory {
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(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(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(OrganisationBuilder.class)) return (T) new OrganisationBuilder();
return null;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -46,12 +46,9 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
import eu.eudat.models.data.dmp.*;
import eu.eudat.models.data.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.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.*;
import eu.eudat.models.data.project.ProjectDMPEditorModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList;
import eu.eudat.service.deposit.DepositService;
@ -505,24 +502,24 @@ public class DataManagementPlanManager {
newDmp.setCreatorId(user.getId());
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { //TODO
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
// createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
// }
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
// createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
// } //TODO
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
// createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
// }/TODO
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
// createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { //TODO
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
//// }
//// createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao()); //TODO
// }
// }
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao());
}
}
DmpEntity dmp;
if (dataManagementPlan.getId() != null) {
@ -666,18 +663,18 @@ public class DataManagementPlanManager {
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
}
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
// createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
// }
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
// createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
// }
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
// createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
// }
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
// createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
// }//TODO
DmpEntity result = createOrUpdate(dataManagementPlan);
@ -716,25 +713,25 @@ public class DataManagementPlanManager {
UserEntity user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
newDmp.setCreatorId(user.getId());
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
//TODO
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
// createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
// }
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
}
}
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
// createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
// }//TODO
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
// createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
// }//TODO
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
// createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Project)) {
// //TODO
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
//// }
//// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao()); //TODO
// }
// }//TODO
newDmp.setGroupId(oldDmp.getGroupId());
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();
newDmp.setCreatorId(user.getId());
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
}
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
//TODO
// if(this.dmpBlueprintService.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) {
// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
// createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
// }
// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Researchers)) {
// createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
// }
}
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Funder)) {
// createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
// }
// if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Grant)) {
// createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
// //TODO
//// if(this.dmpBlueprintService.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) {
//// if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
//// }
//// createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
//// }
// }//TODO
newDmp.setGroupId(UUID.randomUUID());
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
// for (eu.eudat.data.old.Researcher researcher : newDmp.getResearchers()) {
// 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
// for (Organisation organisation : newDmp.getOrganisations()) {
// 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
// Grant grant = newDmp.getGrant();
// GrantCriteria criteria = new GrantCriteria();
@ -1004,9 +1001,9 @@ public class DataManagementPlanManager {
// 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
// Funder funder = newDmp.getGrant().getFunder();
// FunderCriteria criteria = new FunderCriteria();
@ -1022,9 +1019,9 @@ public class DataManagementPlanManager {
// 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) {
// Project project = newDmp.getProject();
// ProjectCriteria criteria = new ProjectCriteria();
@ -1040,16 +1037,16 @@ public class DataManagementPlanManager {
// createExternalProject(project, projectDao);
// }
// }
}
private void createExternalProject(Project project, ProjectDao projectDao) {
if (project.getStartdate() == null) project.setStartdate(new Date());
if (project.getEnddate() == null) project.setEnddate(new Date());
project.setType(Project.ProjectType.EXTERNAL.getValue());
if (project.getId() == null) project.setId(UUID.randomUUID());
projectDao.createOrUpdate(project);
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
}
// }
//
// private void createExternalProject(Project project, ProjectDao projectDao) {
// if (project.getStartdate() == null) project.setStartdate(new Date());
// if (project.getEnddate() == null) project.setEnddate(new Date());
// project.setType(Project.ProjectType.EXTERNAL.getValue());
// if (project.getId() == null) project.setId(UUID.randomUUID());
// projectDao.createOrUpdate(project);
// metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
// }
private void copyDatasets(DmpEntity newDmp, DatasetDao datasetDao) throws InvalidApplicationException {
List<CompletableFuture<DescriptionEntity>> futures = new LinkedList<>();
@ -2162,41 +2159,42 @@ public class DataManagementPlanManager {
}
}
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)) {
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);
}
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);
}
//TODO
// 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<>();
// if (profiles != null && profiles.length > 0) {
@ -2220,24 +2218,24 @@ public class DataManagementPlanManager {
}
}
List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
organisation.setName(org.getOrganaisationNameImport());
organisation.setReference(org.getOrganaisationReferenceImport());
organisation.setKey(organisation.getReference().split(":")[0]);
organisations.add(organisation);
}
// List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
// for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
// eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
// organisation.setName(org.getOrganaisationNameImport());
// organisation.setReference(org.getOrganaisationReferenceImport());
// organisation.setKey(organisation.getReference().split(":")[0]);
// organisations.add(organisation);
// }//TODO
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
researcher.setLabel(res.getResearcherImportName());
researcher.setName(res.getResearcherImportName());
researcher.setReference(res.getResearcherImportReference());
researcher.setKey(researcher.getReference().split(":")[0]);
researchers.add(researcher);
}
// List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
// for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
// eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
// researcher.setLabel(res.getResearcherImportName());
// researcher.setName(res.getResearcherImportName());
// researcher.setReference(res.getResearcherImportReference());
// researcher.setKey(researcher.getReference().split(":")[0]);
// researchers.add(researcher);
// } //TODO
//List<UserListingModel> associatedUsers = new LinkedList<>();
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
@ -2246,8 +2244,8 @@ public class DataManagementPlanManager {
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
dm.setProfiles(associatedProfiles);
dm.setOrganisations(organisations); // Sets organisations property.
dm.setResearchers(researchers); // Sets researchers property.
// dm.setOrganisations(organisations); // Sets organisations property.
// dm.setResearchers(researchers); // Sets researchers property.
//dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
//dm.setDefinition(dmpProfile);

View File

@ -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().getReferences(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().getReferences(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().getReferences(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;
}
}

View File

@ -12,9 +12,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.*;
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.RegistryDao;
import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.ContactType;
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();
descriptionEntity.setDmpDescriptionTemplateId(userInfo.getId());
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
// createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);//TODO
createExternalDatasetsIfTheyDontExist(descriptionEntity);
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), descriptionEntity);
// createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), descriptionEntity);
createServicesIfTheyDontExist(descriptionEntity);
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
datasetWizardModel.setId(descriptionEntity1.getId());
if (datasetWizardModel.getDmp().getGrant() == null) {
DmpEntity dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
}
// if (datasetWizardModel.getDmp().getGrant() == null) { //TODO
// DmpEntity dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
//
// datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
// }
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
@ -894,9 +892,9 @@ public class DatasetManager {
}
private void createRegistriesIfTheyDontExist(RegistryDao registryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
//TODO implement it on create
// private void createRegistriesIfTheyDontExist(RegistryDao registryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
//
// if (descriptionEntity.getRegistries() != null && !descriptionEntity.getRegistries().isEmpty()) {
// for (Registry registry : descriptionEntity.getRegistries()) {
// 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
// private void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
//
// if (descriptionEntity.getDatasetDataRepositories() != null && !descriptionEntity.getDatasetDataRepositories().isEmpty()) {
// for (DatasetDataRepository datasetDataRepository : descriptionEntity.getDatasetDataRepositories()) {
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
@ -931,7 +930,7 @@ public class DatasetManager {
// }
// }
// }
}
// }
private void createServicesIfTheyDontExist(DescriptionEntity descriptionEntity) throws InvalidApplicationException {
//TODO implement it on create
@ -1063,8 +1062,8 @@ public class DatasetManager {
entity.setDmpDescriptionTemplateId(userInfo.getId());
updateTagsXmlImportDataset(entity);
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), entity);
// createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
// createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), entity);//TODO
createServicesIfTheyDontExist(entity);
createExternalDatasetsIfTheyDontExist(entity);

View File

@ -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().getReferences(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);
}
}

View File

@ -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().getReferences(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;
}
}

View File

@ -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.getReferences(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);
}
}

View File

@ -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().getReferences(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;
}
}

View File

@ -299,9 +299,10 @@ public class MetricsManager {
}
private long countAllResearchers(boolean countNexus) throws InvalidApplicationException {
ResearcherCriteria criteria = new ResearcherCriteria();
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(criteria).count();
// ResearcherCriteria criteria = new ResearcherCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllProjects() throws InvalidApplicationException {
@ -309,9 +310,10 @@ public class MetricsManager {
}
private long countAllProjects(boolean countNexus) throws InvalidApplicationException {
ProjectCriteria criteria = new ProjectCriteria();
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
// ProjectCriteria criteria = new ProjectCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
return 0;
}
private long countAllFunders() throws InvalidApplicationException {
@ -319,9 +321,10 @@ public class MetricsManager {
}
private long countAllFunders(boolean countNexus) throws InvalidApplicationException {
FunderCriteria criteria = new FunderCriteria();
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
// FunderCriteria criteria = new FunderCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
return 0;
}
private long countAllGrants() throws InvalidApplicationException {
@ -329,9 +332,10 @@ public class MetricsManager {
}
private long countAllGrants(boolean countNexus) throws InvalidApplicationException {
GrantCriteria criteria = new GrantCriteria();
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
// GrantCriteria criteria = new GrantCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllDraftDatasets() throws InvalidApplicationException {

View File

@ -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().getReferences(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().getReferences(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());
}
}

View File

@ -35,18 +35,18 @@ public class PrefillingManager {
private final ApiContext apiContext;
private final ObjectMapper objectMapper;
private final DatasetManager datasetManager;
private final LicenseManager licenseManager;
// private final LicenseManager licenseManager;
private final PrefillingMapper prefillingMapper;
private final ExternalUrlConfigProvider externalUrlConfigProvider;
@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.prefillingMapper = prefillingMapper;
this.externalUrlConfigProvider = externalUrlConfigProvider;
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.datasetManager = datasetManager;
this.licenseManager = licenseManager;
// this.licenseManager = licenseManager;
}
public List<Prefilling> getPrefillings(String like) {
@ -74,14 +74,14 @@ public class PrefillingManager {
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
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 {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(configId);
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
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) {

View File

@ -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().getReferences(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;
}
}

View File

@ -1,43 +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.publication.PublicationModel;
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 PublicationManager {
private ApiContext apiContext;
@Autowired
public PublicationManager(ApiContext apiContext) {
this.apiContext = apiContext;
}
public List<PublicationModel> getPublications(String query, String type) throws HugeResultSetException, MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Publications, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query);
List<PublicationModel> publicationModels = new LinkedList<>();
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
publicationModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, PublicationModel.class)).collect(Collectors.toList()));
// publicationModels = publicationModels.stream().filter(publicationModel -> publicationModel.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
return publicationModels;
}
}

View File

@ -36,31 +36,31 @@ public class QuickWizardManager {
this.queryFactory = queryFactory;
this.userScope = userScope;
}
public Funder createOrUpdate(eu.eudat.models.data.funder.Funder funder) {
Funder funderEntity = funder.toDataModel();
return databaseRepository.getFunderDao().createOrUpdate(funderEntity);
}
public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException {
Grant grantEntity = grant.toDataModel();
grantEntity.setType(Grant.GrantType.INTERNAL.getValue());
grantEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return databaseRepository.getGrantDao().createOrUpdate(grantEntity);
}
public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException {
Project projectEntity = project.toDataModel();
projectEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
}
public DmpEntity createOrUpdate(DataManagementPlan dataManagementPlan, Funder funderEntity) throws Exception {
DmpEntity newDmp = dataManagementPlan.toDataModel();
if (funderEntity != null) {
//TODO
//newDmp.getGrant().setFunder(funderEntity);
}
// public Funder createOrUpdate(eu.eudat.models.data.funder.Funder funder) {
// Funder funderEntity = funder.toDataModel();
// return databaseRepository.getFunderDao().createOrUpdate(funderEntity);
// }
//TODO
// public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException {
// Grant grantEntity = grant.toDataModel();
// grantEntity.setType(Grant.GrantType.INTERNAL.getValue());
// grantEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
// return databaseRepository.getGrantDao().createOrUpdate(grantEntity);
// }
//TODO
// public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException {
// Project projectEntity = project.toDataModel();
// projectEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
// return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
// }
public DmpEntity createOrUpdate(DataManagementPlan dataManagementPlan/*, Funder funderEntity*/) throws Exception {
DmpEntity newDmp = dataManagementPlan.toDataModel();
// if (funderEntity != null) {
// //TODO
// //newDmp.getGrant().setFunder(funderEntity);
// }
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
createFunderIfItDoesntExist(newDmp, user);
createGrantIfItDoesntExist(newDmp, user);

View File

@ -1,61 +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.RegistryCriteria;
import eu.eudat.data.old.Registry;
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.registries.RegistryModel;
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;
@Component
public class RegistryManager {
private ApiContext apiContext;
private final UserScope userScope;
@Autowired
public RegistryManager(ApiContext apiContext, UserScope userScope) {
this.apiContext = apiContext;
this.userScope = userScope;
}
public Registry create(RegistryModel registryModel) throws Exception {
if (registryModel.getLabel() == null || registryModel.getAbbreviation() == null || registryModel.getUri() == null) {
throw new Exception("Missing mandatory entity.");
}
Registry registry = registryModel.toDataModel();
registry.getCreationUser().setId(this.userScope.getUserId());
return apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
}
public List<RegistryModel> getRegistries(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Registries, externalReferenceCriteria, type);
RegistryCriteria criteria = new RegistryCriteria();
if (!query.isEmpty()) criteria.setLike(query);
criteria.setCreationUserId(this.userScope.getUserId());
List<RegistryModel> registryModels = new LinkedList<>();
if (type.equals("")) {
List<Registry> registryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().getWithCriteria(criteria)).toList();
registryModels = registryList.stream().map(item -> new RegistryModel().fromDataModel(item)).collect(Collectors.toList());
}
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
registryModels.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, RegistryModel.class)).collect(Collectors.toList()));
return registryModels;
}
}

View File

@ -1,83 +0,0 @@
package eu.eudat.logic.managers;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.logic.builders.model.models.ResearcherBuilder;
import eu.eudat.data.old.Researcher;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.models.data.external.ExternalSourcesItemModel;
import eu.eudat.models.data.external.ResearchersExternalSourcesModel;
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.RemoteFetcher;
import eu.eudat.query.UserQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext;
import gr.cite.tools.data.query.QueryFactory;
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.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by ikalyvas on 2/5/2018.
*/
@Component
public class ResearcherManager {
private ApiContext apiContext;
private RemoteFetcher remoteFetcher;
private ConfigLoader configLoader;
private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired
public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext;
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
this.configLoader = configLoader;
this.userScope = userScope;
this.queryFactory = queryFactory;
}
public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
Researcher researcherEntity = researcher.toDataModel();
researcherEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
}
public List<eu.eudat.models.data.dmp.Researcher> getCriteriaWithExternal(ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
QueryableList<Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
items.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), this.userScope.getUserId()));
List<eu.eudat.models.data.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.data.dmp.Researcher().fromDataModel(item));
researchers = researchers.stream().filter(item -> item.getKey().equals("Internal")).collect(Collectors.toList());
Map<String, String> keyToSourceMap = configLoader.getKeyToSourceMap();
for (eu.eudat.models.data.dmp.Researcher item : researchers) {
if (item.getKey().equals("Internal"))
item.setTag(item.getKey());
else
item.setTag(keyToSourceMap.get(item.getKey()));
}
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(researcherCriteriaRequest.getCriteria().getName());
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Researcher, externalReferenceCriteria, null);
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)
.label(externalListingItem.getAbbreviation())
.id(externalListingItem.getId())
.reference(externalListingItem.getRemoteId())
.name(externalListingItem.getName())
.tag(externalListingItem.getTag())
.key(externalListingItem.getKey())
.build();
researchers.add(researcher);
}
return researchers.stream().distinct().collect(Collectors.toList());
}
}

Some files were not shown because too many files have changed in this diff Show More