Renames "Project" to "Grant on backend. (Issue #145)
This commit is contained in:
parent
37aebb3d8d
commit
feaec87b82
|
@ -2,7 +2,7 @@ package eu.eudat.data.dao.criteria;
|
|||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
|||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private List<eu.eudat.data.entities.Project> projects;
|
||||
private List<eu.eudat.data.entities.Grant> grants;
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
private Integer status;
|
||||
|
@ -35,11 +35,11 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
public List<Grant> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
public void setGrants(List<Grant> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public boolean getAllVersions() {
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
|
||||
private ProjectStateType projectStatus;
|
||||
private List<UUID> projects;
|
||||
private GrantStateType grantStatus;
|
||||
private List<UUID> grants;
|
||||
public List<UUID> datasetProfile;
|
||||
private List<String> dmpOrganisations;
|
||||
|
||||
public ProjectStateType getProjectStatus() {
|
||||
return projectStatus;
|
||||
public GrantStateType getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
public void setProjectStatus(ProjectStateType projectStatus) {
|
||||
this.projectStatus = projectStatus;
|
||||
public void setGrantStatus(GrantStateType grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public List<UUID> getProjects() {
|
||||
return projects;
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setProjects(List<UUID> projects) {
|
||||
this.projects = projects;
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetProfile() {
|
||||
|
|
|
@ -18,7 +18,7 @@ public class DatasetCriteria extends Criteria<Dataset> {
|
|||
private UUID profileDatasetId;
|
||||
private List<String> organisations;
|
||||
private Integer role;
|
||||
private List<UUID> projects;
|
||||
private List<UUID> grants;
|
||||
private List<UUID> collaborators;
|
||||
private List<UUID> datasetTemplates;
|
||||
|
||||
|
@ -85,11 +85,11 @@ public class DatasetCriteria extends Criteria<Dataset> {
|
|||
this.role = role;
|
||||
}
|
||||
|
||||
public List<UUID> getProjects() {
|
||||
return projects;
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setProjects(List<UUID> projects) {
|
||||
this.projects = projects;
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public List<UUID> getCollaborators() {
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.data.dao.criteria;
|
|||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.elastic.entities.Tag;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -11,25 +11,25 @@ import java.util.UUID;
|
|||
* Created by ikalyvas on 10/2/2018.
|
||||
*/
|
||||
public class DatasetPublicCriteria extends Criteria<Dataset>{
|
||||
private ProjectStateType projectStatus;
|
||||
private List<UUID> projects;
|
||||
private GrantStateType grantStatus;
|
||||
private List<UUID> grants;
|
||||
private List<UUID> datasetProfile;
|
||||
private List<String> dmpOrganisations;
|
||||
private List<Tag> tags;
|
||||
private List<UUID> dmpIds;
|
||||
|
||||
public ProjectStateType getProjectStatus() {
|
||||
return projectStatus;
|
||||
public GrantStateType getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
public void setProjectStatus(ProjectStateType projectStatus) {
|
||||
this.projectStatus = projectStatus;
|
||||
public void setGrantStatus(GrantStateType grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public List<UUID> getProjects() {
|
||||
return projects;
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setProjects(List<UUID> projects) {
|
||||
this.projects = projects;
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetProfile() {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ProjectCriteria extends Criteria<Project> {
|
||||
public class GrantCriteria extends Criteria<Grant> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private String reference;
|
||||
private Integer projectStateType;
|
||||
private Integer grantStateType;
|
||||
private boolean isPublic;
|
||||
|
||||
public Date getPeriodStart() {
|
||||
|
@ -33,11 +33,11 @@ public class ProjectCriteria extends Criteria<Project> {
|
|||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Integer getProjectStateType() {
|
||||
return projectStateType;
|
||||
public Integer getGrantStateType() {
|
||||
return grantStateType;
|
||||
}
|
||||
public void setProjectStateType(Integer projectStateType) {
|
||||
this.projectStateType = projectStateType;
|
||||
public void setGrantStateType(Integer grantStateType) {
|
||||
this.grantStateType = grantStateType;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
|
@ -39,8 +39,8 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getProjects() != null && !criteria.getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").in(criteria.getProjects())));
|
||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||
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.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
|
||||
|
|
|
@ -47,8 +47,8 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
query.where((builder, root) -> builder.equal(root.join("dmp").join("users").get("role"), criteria.getRole()));
|
||||
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp").join("organisations").get("reference").in(criteria.getOrganisations()));
|
||||
if (criteria.getProjects() != null && !criteria.getProjects().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp").join("project").get("id").in(criteria.getProjects()));
|
||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp").join("grant").get("id").in(criteria.getGrants()));
|
||||
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty())
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
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, UserInfo principal);
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -17,17 +17,17 @@ import java.util.Date;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("projectDao")
|
||||
public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDao {
|
||||
@Component("grantDao")
|
||||
public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
||||
|
||||
@Autowired
|
||||
public ProjectDaoImpl(DatabaseService<Project> databaseService) {
|
||||
public GrantDaoImpl(DatabaseService<Grant> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
|
||||
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
|
||||
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() + "%"),
|
||||
|
@ -38,10 +38,10 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
|
||||
if (criteria.getReference() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference()));
|
||||
if (criteria.getProjectStateType() != null) {
|
||||
if (criteria.getProjectStateType().equals(ProjectStateType.FINISHED.getValue()))
|
||||
if (criteria.getGrantStateType() != null) {
|
||||
if (criteria.getGrantStateType().equals(GrantStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), new Date()));
|
||||
if (criteria.getProjectStateType().equals(ProjectStateType.ONGOING.getValue()))
|
||||
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"))));
|
||||
|
@ -49,43 +49,43 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
if (criteria.isPublic()) {
|
||||
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DMP.DMPStatus.FINALISED.getValue())).distinct();
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project createOrUpdate(Project item) {
|
||||
return getDatabaseService().createOrUpdate(item, Project.class);
|
||||
public Grant createOrUpdate(Grant item) {
|
||||
return getDatabaseService().createOrUpdate(item, Grant.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project find(UUID id) {
|
||||
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
public Grant find(UUID id) {
|
||||
return getDatabaseService().getQueryable(Grant.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Project item) {
|
||||
public void delete(Grant item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Project.class);
|
||||
public QueryableList<Grant> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Grant.class);
|
||||
}
|
||||
|
||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo 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;
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<Project> createOrUpdateAsync(Project item) {
|
||||
public CompletableFuture<Grant> createOrUpdateAsync(Grant item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project find(UUID id, String hint) {
|
||||
public Grant find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,17 +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.entities.Project;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
|
||||
|
||||
QueryableList<Project> getWithCriteria(ProjectCriteria criteria);
|
||||
|
||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal);
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ import java.util.UUID;
|
|||
public class Content implements DataEntity<Content, UUID> {
|
||||
|
||||
public enum ParentType {
|
||||
PROJECT(0);
|
||||
GRANT(0);
|
||||
|
||||
private int value;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class Content implements DataEntity<Content, UUID> {
|
|||
public static ParentType fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return PROJECT;
|
||||
return GRANT;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Content Parent Type Status");
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.stream.Collectors;
|
|||
@NamedEntityGraph(
|
||||
name = "dataManagementPlanListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
|
||||
@NamedAttributeNode("project"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
|
||||
subgraphs = {
|
||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
|||
@NamedEntityGraph(
|
||||
name = "fullyDetailed",
|
||||
attributeNodes = {
|
||||
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
|
||||
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
|
||||
@NamedEntityGraph(
|
||||
name = "dmpRecentActivity",
|
||||
|
@ -86,8 +86,8 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Project\"")
|
||||
private Project project;
|
||||
@JoinColumn(name = "\"Grant\"")
|
||||
private Grant grant;
|
||||
|
||||
|
||||
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||
|
@ -241,11 +241,11 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
public Grant getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
public void setGrant(Grant grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public Set<DatasetProfile> getAssociatedDmps() {
|
||||
|
@ -333,7 +333,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.status = entity.getStatus();
|
||||
this.created = entity.created;
|
||||
this.properties = entity.getProperties();
|
||||
this.project = entity.getProject();
|
||||
this.grant = entity.getGrant();
|
||||
this.description = entity.getDescription();
|
||||
this.researchers = entity.getResearchers();
|
||||
this.organisations = entity.getOrganisations();
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.stream.Collectors;
|
|||
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
|
||||
subgraphs = {
|
||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"), @NamedAttributeNode("organisations")}),
|
||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
||||
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
||||
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
|
||||
}),
|
||||
|
|
|
@ -13,20 +13,20 @@ import java.util.stream.Collectors;
|
|||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Project\"")
|
||||
@Table(name = "\"Grant\"")
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "projectRecentActivity",
|
||||
name = "grantRecentActivity",
|
||||
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
|
||||
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
|
||||
),
|
||||
@NamedEntityGraph(
|
||||
name = "projectListingItem",
|
||||
name = "grantListingItem",
|
||||
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
|
||||
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("project"), @NamedAttributeNode("users")})
|
||||
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
|
||||
)
|
||||
})
|
||||
public class Project implements DataEntity<Project, UUID> {
|
||||
public class Grant implements DataEntity<Grant, UUID> {
|
||||
|
||||
public enum Status {
|
||||
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
|
||||
|
@ -50,17 +50,17 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
case 99:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
throw new RuntimeException("Unsupported Grant Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ProjectType {
|
||||
public enum GrantType {
|
||||
EXTERNAL(0), INTERNAL(1);
|
||||
|
||||
private Integer value;
|
||||
|
||||
private ProjectType(Integer value) {
|
||||
private GrantType(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -68,14 +68,14 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
return value;
|
||||
}
|
||||
|
||||
public static ProjectType fromInteger(int value) {
|
||||
public static GrantType fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return EXTERNAL;
|
||||
case 1:
|
||||
return INTERNAL;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Type");
|
||||
throw new RuntimeException("Unsupported Grant Type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,10 +87,9 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "project")
|
||||
@OneToMany(mappedBy = "grant")
|
||||
private Set<DMP> dmps;
|
||||
|
||||
|
||||
@Column(name = "\"Label\"")
|
||||
private String label;
|
||||
|
||||
|
@ -108,7 +107,6 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||
private String definition;
|
||||
|
||||
|
||||
@Column(name = "\"StartDate\"", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date startdate = null;
|
||||
|
@ -117,16 +115,13 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
@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 UserInfo creationUser;
|
||||
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
||||
|
@ -143,11 +138,11 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
@JoinColumn(name = "\"Content\"")
|
||||
private Content content;
|
||||
|
||||
public Project() {
|
||||
public Grant() {
|
||||
}
|
||||
|
||||
public Project(Project project) {
|
||||
this.id = project.getId();
|
||||
public Grant(Grant grant) {
|
||||
this.id = grant.getId();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -285,7 +280,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(Project entity) {
|
||||
public void update(Grant entity) {
|
||||
this.description = entity.getDescription();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -305,7 +300,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
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"))
|
|
@ -23,8 +23,8 @@ public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanC
|
|||
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().getProjects() != null && !this.getCriteria().getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").in(this.getCriteria().getProjects())));
|
||||
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())
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.eudat.data.query.items.item.project;
|
||||
package eu.eudat.data.query.items.item.grant;
|
||||
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
public class ProjectCriteriaRequest extends Query<ProjectCriteria, Project> {
|
||||
public class GrantCriteriaRequest extends Query<GrantCriteria, Grant> {
|
||||
private Integer length;
|
||||
|
||||
public Integer getLength() {
|
||||
|
@ -16,12 +16,12 @@ public class ProjectCriteriaRequest extends Query<ProjectCriteria, Project> {
|
|||
this.length = length;
|
||||
}
|
||||
|
||||
private ProjectCriteriaRequest() {
|
||||
private GrantCriteriaRequest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> applyCriteria() {
|
||||
QueryableList<Project> query = this.getQuery();
|
||||
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() + "%"),
|
||||
|
@ -32,7 +32,7 @@ public class ProjectCriteriaRequest extends Query<ProjectCriteria, Project> {
|
|||
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"), Project.Status.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package eu.eudat.data.query.items.table.dataset;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
@ -29,15 +28,15 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
|
|||
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().getProjects() != null && !this.getCriteria().getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("dmp").get("project").get("id").in(this.getCriteria().getProjects())));
|
||||
if (this.getCriteria().getProjectStatus() != null) {
|
||||
if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("project").get("enddate"), new Date()));
|
||||
if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.ONGOING.getValue()))
|
||||
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
|
||||
query.where(((builder, root) -> root.get("dmp").get("grant").get("id").in(this.getCriteria().getGrants())));
|
||||
if (this.getCriteria().getGrantStatus() != null) {
|
||||
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
|
||||
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.greaterThan(root.get("dmp").get("project").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("dmp").get("project").get("enddate"))));
|
||||
builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("dmp").get("grant").get("enddate"))));
|
||||
}
|
||||
if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) {
|
||||
query.where(((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds())));
|
||||
|
|
|
@ -23,8 +23,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().getProjects() != null && !this.getCriteria().getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").in(this.getCriteria().getProjects())));
|
||||
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())
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package eu.eudat.data.query.items.table.dmp;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.types.project.ProjectStateType;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
@ -20,15 +19,15 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManageme
|
|||
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().getProjects() != null && !this.getCriteria().getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").get("id").in(this.getCriteria().getProjects())));
|
||||
if (this.getCriteria().getProjectStatus() != null) {
|
||||
if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("project").get("enddate"), new Date()));
|
||||
if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.ONGOING.getValue()))
|
||||
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
|
||||
query.where(((builder, root) -> root.get("grant").get("id").in(this.getCriteria().getGrants())));
|
||||
if (this.getCriteria().getGrantStatus() != null) {
|
||||
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
|
||||
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.greaterThan(root.get("project").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("project").get("enddate"))));
|
||||
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("grant").get("enddate"))));
|
||||
}
|
||||
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty()) query
|
||||
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package eu.eudat.data.query.items.table.project;
|
||||
package eu.eudat.data.query.items.table.grant;
|
||||
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProjectTableRequest extends TableQuery<ProjectCriteria,Project,UUID> {
|
||||
public class GrantTableRequest extends TableQuery<GrantCriteria,Grant,UUID> {
|
||||
@Override
|
||||
public QueryableList<Project> applyCriteria() {
|
||||
QueryableList<Project> query = this.getQuery();
|
||||
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() + "%"),
|
||||
|
@ -22,12 +21,12 @@ public class ProjectTableRequest extends TableQuery<ProjectCriteria,Project,UUID
|
|||
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"), Project.Status.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> applyPaging(QueryableList<Project> items) {
|
||||
public QueryableList<Grant> applyPaging(QueryableList<Grant> items) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package eu.eudat.query;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
|
@ -20,7 +20,7 @@ public class DMPQuery extends Query<DMP, UUID> {
|
|||
private UUID groupId;
|
||||
private String label;
|
||||
private int version;
|
||||
private ProjectQuery projectQuery;
|
||||
private GrantQuery grantQuery;
|
||||
private UserQuery userQuery;
|
||||
private DatasetQuery datasetQuery;
|
||||
private List<Integer> statuses;
|
||||
|
@ -67,12 +67,12 @@ public class DMPQuery extends Query<DMP, UUID> {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public ProjectQuery getProjectQuery() {
|
||||
return projectQuery;
|
||||
public GrantQuery getGrantQuery() {
|
||||
return grantQuery;
|
||||
}
|
||||
|
||||
public void setProjectQuery(ProjectQuery projectQuery) {
|
||||
this.projectQuery = projectQuery;
|
||||
public void setGrantQuery(GrantQuery grantQuery) {
|
||||
this.grantQuery = grantQuery;
|
||||
}
|
||||
|
||||
public List<Integer> getStatuses() {
|
||||
|
@ -120,9 +120,9 @@ public class DMPQuery extends Query<DMP, UUID> {
|
|||
if (this.id != null) {
|
||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
||||
}
|
||||
if (this.projectQuery != null) {
|
||||
Subquery<Project> projectQuery = this.projectQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
query.where((builder, root) -> root.get("project").get("id").in(projectQuery));
|
||||
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.getStatuses() != null && !this.getStatuses().isEmpty()) {
|
||||
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
|
@ -13,7 +13,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProjectQuery extends Query<Project, UUID> {
|
||||
public class GrantQuery extends Query<Grant, UUID> {
|
||||
|
||||
private UUID id;
|
||||
private List<UUID> ids;
|
||||
|
@ -23,11 +23,11 @@ public class ProjectQuery extends Query<Project, UUID> {
|
|||
private Date modified;
|
||||
private UserQuery userQuery;
|
||||
|
||||
public ProjectQuery(DatabaseAccessLayer<Project, UUID> databaseAccessLayer) {
|
||||
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
|
||||
super(databaseAccessLayer);
|
||||
}
|
||||
|
||||
public ProjectQuery(DatabaseAccessLayer<Project, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||
super(databaseAccessLayer, selectionFields);
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ public class ProjectQuery extends Query<Project, UUID> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> getQuery() {
|
||||
QueryableList<Project> query = this.databaseAccessLayer.asQueryable();
|
||||
public QueryableList<Grant> getQuery() {
|
||||
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())
|
|
@ -1,14 +1,14 @@
|
|||
package eu.eudat.types.project;
|
||||
package eu.eudat.types.grant;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 8/24/2018.
|
||||
*/
|
||||
public enum ProjectStateType {
|
||||
public enum GrantStateType {
|
||||
ONGOING(0), FINISHED(1);
|
||||
|
||||
private Integer value;
|
||||
|
||||
private ProjectStateType(Integer value) {
|
||||
private GrantStateType(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,14 @@ public enum ProjectStateType {
|
|||
return value;
|
||||
}
|
||||
|
||||
public static ProjectStateType fromInteger(Integer value) {
|
||||
public static GrantStateType fromInteger(Integer value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return ONGOING;
|
||||
case 1:
|
||||
return FINISHED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project State Type");
|
||||
throw new RuntimeException("Unsupported Grant State Type");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class ResponsesCache {
|
|||
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
|
||||
List<GuavaCache> caches = new ArrayList<GuavaCache>();
|
||||
caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
caches.add(new GuavaCache("projects", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
caches.add(new GuavaCache("grants", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
caches.add(new GuavaCache("organisations", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
caches.add(new GuavaCache("registries", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.configurations.dynamicproject;
|
||||
package eu.eudat.configurations.dynamicgrant;
|
||||
|
||||
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Configuration;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public interface DynamicProjectConfiguration {
|
||||
public interface DynamicGrantConfiguration {
|
||||
Configuration getConfiguration();
|
||||
|
||||
List<DynamicField> getFields();
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.configurations.dynamicproject;
|
||||
package eu.eudat.configurations.dynamicgrant;
|
||||
|
||||
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Configuration;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||
import eu.eudat.models.data.dynamicfields.Dependency;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -21,9 +21,9 @@ import java.util.List;
|
|||
* Created by ikalyvas on 5/4/2018.
|
||||
*/
|
||||
|
||||
@Service("dynamicProjectConfiguration")
|
||||
@Service("dynamicGrantConfiguration")
|
||||
@Profile("devel")
|
||||
public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfiguration {
|
||||
public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfiguration {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
|
@ -32,14 +32,14 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
|
|||
private Environment environment;
|
||||
|
||||
@Autowired
|
||||
public DynamicProjectConfigurationDevelImpl(Environment environment) {
|
||||
public DynamicGrantConfigurationDevelImpl(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
if (this.configuration != null) return this.configuration;
|
||||
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
|
||||
String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl");
|
||||
System.out.println("Loaded also config file: " + fileUrl);
|
||||
String current = null;
|
||||
InputStream is = null;
|
||||
|
@ -48,7 +48,7 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
|
|||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
is = new URL("file:///"+current + "/web/src/main/resources/ProjectConfiguration.xml").openStream();
|
||||
is = new URL("file:///"+current + "/web/src/main/resources/GrantConfiguration.xml").openStream();
|
||||
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.configurations.dynamicproject;
|
||||
package eu.eudat.configurations.dynamicgrant;
|
||||
|
||||
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Configuration;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||
import eu.eudat.models.data.dynamicfields.Dependency;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -21,9 +21,9 @@ import java.util.List;
|
|||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
@Service("dynamicProjectConfiguration")
|
||||
@Service("dynamicGrantConfiguration")
|
||||
@Profile({ "production", "staging" })
|
||||
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration {
|
||||
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
|
@ -32,14 +32,14 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
|
|||
private Environment environment;
|
||||
|
||||
@Autowired
|
||||
public DynamicProjectConfigurationProdImpl(Environment environment) {
|
||||
public DynamicGrantConfigurationProdImpl(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
if (this.configuration != null) return this.configuration;
|
||||
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
|
||||
String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl");
|
||||
System.out.println("Loaded also config file: " + fileUrl);
|
||||
String current = null;
|
||||
InputStream is = null;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.configurations.dynamicproject.entities;
|
||||
package eu.eudat.configurations.dynamicgrant.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.configurations.dynamicproject.entities;
|
||||
package eu.eudat.configurations.dynamicgrant.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.configurations.dynamicproject.entities;
|
||||
package eu.eudat.configurations.dynamicgrant.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.configurations.dynamicproject.entities;
|
||||
package eu.eudat.configurations.dynamicgrant.entities;
|
||||
|
||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.configurations.dynamicproject.entities;
|
||||
package eu.eudat.configurations.dynamicgrant.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
@ -2,9 +2,7 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.core.logger.Logger;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.LoggerService;
|
||||
import eu.eudat.models.validators.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
|
@ -32,12 +30,12 @@ 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 && ProjectTableRequestValidator.supportsType((binder.getTarget().getClass())))
|
||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("projectTableRequestValidator", ProjectTableRequestValidator.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 && ProjectModelValidator.supportsType((binder.getTarget().getClass())))
|
||||
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("projectModelValidator", ProjectModelValidator.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));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.configurations.dynamicproject.entities.Language;
|
||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Language;
|
||||
import eu.eudat.logic.managers.CommonsManager;
|
||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
||||
|
@ -22,19 +22,19 @@ import java.util.List;
|
|||
@RequestMapping(value = {"/api/common"})
|
||||
public class CommonController {
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
||||
private ConfigLoader configLoader;
|
||||
|
||||
@Autowired
|
||||
public CommonController(DynamicProjectConfiguration dynamicProjectConfiguration, ConfigLoader configLoader) {
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
public CommonController(DynamicGrantConfiguration dynamicGrantConfiguration, ConfigLoader configLoader) {
|
||||
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
||||
this.configLoader = configLoader;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/language"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Language>>> getPaged() {
|
||||
List<Language> language = this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getLanguage();
|
||||
List<Language> language = this.dynamicGrantConfiguration.getConfiguration().getMainExternalField().getLanguage();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Language>>().status(ApiMessageCode.NO_MESSAGE).payload(language));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
|
||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||
import eu.eudat.criteria.DMPCriteria;
|
||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
|
@ -55,16 +55,16 @@ import java.util.UUID;
|
|||
@RequestMapping(value = {"/api/dmps/"})
|
||||
public class DMPs extends BaseController {
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
||||
private Environment environment;
|
||||
private DataManagementPlanManager dataManagementPlanManager;
|
||||
private DatasetManager datasetManager;
|
||||
|
||||
@Autowired
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment,
|
||||
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager) {
|
||||
public DMPs(ApiContext apiContext, DynamicGrantConfiguration dynamicGrantConfiguration, Environment environment,
|
||||
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager) {
|
||||
super(apiContext);
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
||||
this.environment = environment;
|
||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
||||
this.datasetManager = datasetManager;
|
||||
|
@ -92,7 +92,7 @@ public class DMPs extends BaseController {
|
|||
ResponseEntity<byte[]> document = this.dataManagementPlanManager.getDocument(id, contentType);
|
||||
return document;
|
||||
} else {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicProjectConfiguration);
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicGrantConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class DMPs extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity getSinglePublic(@PathVariable String id) {
|
||||
try {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicProjectConfiguration);
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicGrantConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||
|
@ -180,7 +180,7 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration, criteriaRequestItem.getCriteria());
|
||||
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.properties.PropertiesModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.Grant;
|
||||
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.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
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.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import static eu.eudat.types.Authorities.ANONYMOUS;
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/grants/"})
|
||||
public class Grants extends BaseController {
|
||||
private GrantManager grantManager;
|
||||
|
||||
@Autowired
|
||||
public Grants(ApiContext apiContext, GrantManager grantManager) {
|
||||
super(apiContext);
|
||||
this.grantManager = grantManager;
|
||||
}
|
||||
|
||||
@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, Principal principal) throws Exception {
|
||||
DataTableData<eu.eudat.models.data.grant.GrantListingModel> dataTable = this.grantManager.getPaged(grantTableRequest, principal, 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, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
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, Principal principal) throws IOException, ParseException {
|
||||
this.grantManager.createOrUpdate(grant, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.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, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
this.grantManager.inactivate(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.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, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<eu.eudat.models.data.grant.Grant> dataTable = this.grantManager.getCriteriaWithExternal(grantCriteria, principal);
|
||||
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, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,8 +41,8 @@ public class Organisations extends BaseController {
|
|||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
||||
) throws HugeResultSet, NoURLFound {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getOrganisations(query, type);
|
||||
OrganisationsExternalSourcesModel projectsExternalSourcesModel = this.organisationsExternalSourcesModel.fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = this.organisationsExternalSourcesModel.fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(organisationsExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/internal/organisations"}, produces = "application/json")
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
||||
import eu.eudat.exceptions.project.ProjectWithDMPsDeleteException;
|
||||
import eu.eudat.logic.managers.ProjectManager;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.project.ProjectListingModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static eu.eudat.types.Authorities.ANONYMOUS;
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/projects/"})
|
||||
public class Projects extends BaseController {
|
||||
private ProjectManager projectManager;
|
||||
|
||||
@Autowired
|
||||
public Projects(ApiContext apiContext, ProjectManager projectManager) {
|
||||
super(apiContext);
|
||||
this.projectManager = projectManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPaged(projectTableRequest, principal, fieldsGroup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"public/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest) throws Exception {
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPublicPaged(projectTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<eu.eudat.models.data.project.Project>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
eu.eudat.models.data.project.Project project = this.projectManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.project.Project>().payload(project).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Project>> addProject(@Valid @RequestBody eu.eudat.models.data.project.Project project, Principal principal) throws IOException, ParseException {
|
||||
this.projectManager.createOrUpdate(project, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Project>> inactivate(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
this.projectManager.inactivate(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().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.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().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.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteria(projectCriteria);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,17 +26,17 @@ import java.util.UUID;
|
|||
public class QuickWizardController extends BaseController {
|
||||
|
||||
private QuickWizardManager quickWizardManager;
|
||||
private ProjectManager projectManager;
|
||||
private GrantManager grantManager;
|
||||
|
||||
|
||||
private DatasetManager datasetManager;
|
||||
|
||||
@Autowired
|
||||
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager, DatasetManager datasetManager, ProjectManager projectManager) {
|
||||
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager, DatasetManager datasetManager, GrantManager grantManager) {
|
||||
super(apiContext);
|
||||
this.quickWizardManager = quickWizardManager;
|
||||
this.datasetManager = datasetManager;
|
||||
this.projectManager = projectManager;
|
||||
this.grantManager = grantManager;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,24 +44,24 @@ public class QuickWizardController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<QuickWizardModel>> addQuickWizardModel(@Valid @RequestBody QuickWizardModel quickWizard, Principal principal) throws Exception {
|
||||
eu.eudat.data.entities.Project projectEntity;
|
||||
//Create Project
|
||||
if (quickWizard.getProject().getExistProject() == null) {
|
||||
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject(), principal);
|
||||
eu.eudat.data.entities.Grant grantEntity;
|
||||
//Create Grant
|
||||
if (quickWizard.getGrant().getExistGrant() == null) {
|
||||
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
|
||||
} else {
|
||||
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
||||
grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
|
||||
}
|
||||
//Create Dmp
|
||||
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
|
||||
quickWizard.getDmp().toDataDmp(
|
||||
projectEntity,
|
||||
grantEntity,
|
||||
principal),
|
||||
principal);
|
||||
|
||||
//Create Datasets
|
||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
|
||||
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp( projectEntity, principal);
|
||||
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp( grantEntity, principal);
|
||||
UUID uuid = quickWizard.getDmp().getDatasetProfile().getId();
|
||||
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, uuid);
|
||||
this.datasetManager.createOrUpdate(datasetWizardModel, principal);
|
||||
|
|
|
@ -12,7 +12,7 @@ public class DMPCriteria {
|
|||
private Criteria<UUID> groupId;
|
||||
private Criteria<String> label;
|
||||
private Criteria<Integer> version;
|
||||
private ProjectCriteria project;
|
||||
private GrantCriteria grant;
|
||||
private DateCriteria created;
|
||||
private DateCriteria modified;
|
||||
private UserCriteria creator;
|
||||
|
@ -74,12 +74,12 @@ public class DMPCriteria {
|
|||
this.version = criteria;
|
||||
}
|
||||
|
||||
public ProjectCriteria getProject() {
|
||||
return project;
|
||||
public GrantCriteria getGrant() {
|
||||
return grant;
|
||||
}
|
||||
|
||||
public void setProject(ProjectCriteria project) {
|
||||
this.project = project;
|
||||
public void setGrant(GrantCriteria grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public DateCriteria getCreated() {
|
||||
|
@ -131,7 +131,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.project != null) fields.addAll(this.project.buildFields(path + "project"));
|
||||
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 +142,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.project != null) dmpQuery.setProjectQuery(this.project.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;
|
||||
|
|
|
@ -3,10 +3,10 @@ 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.ProjectQuery;
|
||||
import eu.eudat.query.GrantQuery;
|
||||
import java.util.*;
|
||||
|
||||
public class ProjectCriteria {
|
||||
public class GrantCriteria {
|
||||
private Criteria<UUID> id;
|
||||
private List<UUID> ids;
|
||||
private Criteria<String> label;
|
||||
|
@ -99,9 +99,9 @@ public class ProjectCriteria {
|
|||
return new LinkedList<>(fields);
|
||||
}
|
||||
|
||||
public ProjectQuery buildQuery(DatabaseRepository dao) {
|
||||
public GrantQuery buildQuery(DatabaseRepository dao) {
|
||||
List<String> fields = this.buildFields("");
|
||||
ProjectQuery query = new ProjectQuery(dao.getProjectDao(), fields);
|
||||
GrantQuery query = new GrantQuery(dao.getGrantDao(), fields);
|
||||
query.setId(this.id.getValue());
|
||||
if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao));
|
||||
return query;
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.exceptions.grant;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 11/30/2018.
|
||||
*/
|
||||
public class GrantWithDMPsDeleteException extends RuntimeException {
|
||||
public GrantWithDMPsDeleteException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GrantWithDMPsDeleteException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public GrantWithDMPsDeleteException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public GrantWithDMPsDeleteException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package eu.eudat.exceptions.project;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 11/30/2018.
|
||||
*/
|
||||
public class ProjectWithDMPsDeleteException extends RuntimeException {
|
||||
public ProjectWithDMPsDeleteException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectWithDMPsDeleteException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ProjectWithDMPsDeleteException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ProjectWithDMPsDeleteException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ public class BuilderFactoryImpl implements BuilderFactory {
|
|||
if (tClass.equals(DatasetProfileBuilder.class)) return (T) new DatasetProfileBuilder();
|
||||
if (tClass.equals(DataTableDataBuilder.class)) return (T) new DataTableDataBuilder<>();
|
||||
if (tClass.equals(PrincipalBuilder.class)) return (T) new PrincipalBuilder();
|
||||
if (tClass.equals(ProjectBuilder.class)) return (T) new ProjectBuilder();
|
||||
if (tClass.equals(GrantBuilder.class)) return (T) new GrantBuilder();
|
||||
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();
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
package eu.eudat.logic.builders.model.models;
|
||||
|
||||
import eu.eudat.logic.builders.Builder;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
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.entities.Grant.Status status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified;
|
||||
|
||||
private String description;
|
||||
|
||||
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.entities.Grant.Status status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrantBuilder creationUser(UserInfo 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;
|
||||
}
|
||||
|
||||
@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);
|
||||
return grant;
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package eu.eudat.logic.builders.model.models;
|
||||
|
||||
import eu.eudat.logic.builders.Builder;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class ProjectBuilder extends Builder<Project> {
|
||||
|
||||
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.entities.Project.Status status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified;
|
||||
|
||||
private String description;
|
||||
|
||||
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 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.entities.Project.Status status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder creationUser(UserInfo 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;
|
||||
}
|
||||
|
||||
@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);
|
||||
return project;
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@ package eu.eudat.logic.managers;
|
|||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.dao.entities.DMPDao;
|
||||
import eu.eudat.data.dao.entities.DatasetDao;
|
||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||
import eu.eudat.data.dao.entities.ProjectDao;
|
||||
import eu.eudat.data.dao.entities.GrantDao;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
|
@ -51,12 +51,12 @@ public class DashBoardManager {
|
|||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
||||
CompletableFuture datasetFuture = databaseRepository.getDatasetDao().getWithCriteria(datasetCriteria).countAsync()
|
||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||
CompletableFuture projectFuture = databaseRepository.getProjectDao().asQueryable().countAsync()
|
||||
.whenComplete((projectsStats, throwable) -> statistics.setTotalProjectCount(projectsStats));
|
||||
CompletableFuture grantFuture = databaseRepository.getGrantDao().asQueryable().countAsync()
|
||||
.whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats));
|
||||
CompletableFuture organisationFuture = databaseRepository.getOrganisationDao().getWithCriteria(organisationCriteria).countAsync()
|
||||
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
|
||||
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, projectFuture, organisationFuture).join();
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, grantFuture, organisationFuture).join();
|
||||
return statistics;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class DashBoardManager {
|
|||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
OrganisationDao organisationRepository = databaseRepository.getOrganisationDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
|
@ -72,19 +72,19 @@ public class DashBoardManager {
|
|||
datasetCriteria.setAllVersions(false);
|
||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||
dataManagementPlanCriteria.setAllVersions(false);
|
||||
ProjectCriteria projectCriteria = new ProjectCriteria();
|
||||
GrantCriteria grantCriteria = new GrantCriteria();
|
||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
||||
|
||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId()).countAsync()
|
||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
||||
CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user).countAsync()
|
||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||
CompletableFuture projectFuture = projectRepository.getAuthenticated(projectRepository.getWithCriteria(projectCriteria), user).countAsync()
|
||||
.whenComplete((projectsStats, throwable) -> statistics.setTotalProjectCount(projectsStats));
|
||||
CompletableFuture grantFuture = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).countAsync()
|
||||
.whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats));
|
||||
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.asQueryable().withHint("organisationRecentActivity"), user).countAsync()
|
||||
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
|
||||
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, projectFuture, orgnanisationFuture).join();
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, grantFuture, orgnanisationFuture).join();
|
||||
return statistics;
|
||||
}
|
||||
|
||||
|
@ -92,14 +92,14 @@ public class DashBoardManager {
|
|||
RecentActivity activity = new RecentActivity();
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setAllVersions(false);
|
||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||
dataManagementPlanCriteria.setAllVersions(false);
|
||||
ProjectCriteria projectCriteria = new ProjectCriteria();
|
||||
GrantCriteria grantCriteria = new GrantCriteria();
|
||||
RecentActivityDataBuilder recentActivityDataBuilder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(RecentActivityDataBuilder.class);
|
||||
|
||||
CompletableFuture<List<RecentActivityData>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId())
|
||||
|
@ -116,14 +116,14 @@ public class DashBoardManager {
|
|||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
||||
|
||||
CompletableFuture<List<RecentActivityData>> projects = projectRepository.getAuthenticated(projectRepository.getWithCriteria(projectCriteria), user)
|
||||
.withHint("projectRecentActivity")
|
||||
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((projectActivities, throwable) -> activity.setRecentProjectActivities(projectActivities));
|
||||
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));
|
||||
|
||||
CompletableFuture.allOf(projects, dmps, datasets).join();
|
||||
CompletableFuture.allOf(grants, dmps, datasets).join();
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class DashBoardManager {
|
|||
user.setId(principal.getId());
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
|
||||
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), principal.getId())
|
||||
|
@ -150,14 +150,14 @@ public class DashBoardManager {
|
|||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue()))
|
||||
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));
|
||||
|
||||
CompletableFuture<List<SearchBarItem>> projects = projectRepository.getAuthenticated(projectRepository.asQueryable(), user)
|
||||
.withHint("projectRecentActivity")
|
||||
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.PROJECT.getValue()))
|
||||
.whenComplete((projectItems, throwable) -> searchBarItems.addAll(projectItems));
|
||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.GRANT.getValue()))
|
||||
.whenComplete((grantItems, throwable) -> searchBarItems.addAll(grantItems));
|
||||
|
||||
CompletableFuture.allOf(projects, dmps, datasets).join();
|
||||
CompletableFuture.allOf(grants, dmps, datasets).join();
|
||||
return searchBarItems;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||
import eu.eudat.data.dao.criteria.*;
|
||||
import eu.eudat.data.dao.entities.*;
|
||||
import eu.eudat.data.entities.Organisation;
|
||||
|
@ -277,14 +277,14 @@ public class DataManagementPlanManager {
|
|||
return this.datasetManager.convertToPDF(file, environment, fileName);
|
||||
}*/
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, DynamicGrantConfiguration dynamicGrantConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
if (dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
eu.eudat.models.data.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
datamanagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null;
|
||||
datamanagementPlan.setDynamicFields(dynamicProjectConfiguration.getFields().stream().map(item -> {
|
||||
datamanagementPlan.setDynamicFields(dynamicGrantConfiguration.getFields().stream().map(item -> {
|
||||
DynamicFieldWithValue fieldWithValue = new DynamicFieldWithValue();
|
||||
fieldWithValue.setId(item.getId());
|
||||
fieldWithValue.setDependencies(item.getDependencies());
|
||||
|
@ -315,7 +315,7 @@ public class DataManagementPlanManager {
|
|||
return datamanagementPlan;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSinglePublic(String id, DynamicProjectConfiguration dynamicProjectConfiguration) throws Exception {
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSinglePublic(String id, DynamicGrantConfiguration dynamicGrantConfiguration) throws Exception {
|
||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
|
||||
if (dataManagementPlanEntity != null && dataManagementPlanEntity.getStatus() == 1) {
|
||||
|
@ -323,7 +323,7 @@ public class DataManagementPlanManager {
|
|||
datamanagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
|
||||
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null;
|
||||
datamanagementPlan.setDynamicFields(dynamicProjectConfiguration.getFields().stream().map(item -> {
|
||||
datamanagementPlan.setDynamicFields(dynamicGrantConfiguration.getFields().stream().map(item -> {
|
||||
DynamicFieldWithValue fieldWithValue = new DynamicFieldWithValue();
|
||||
fieldWithValue.setId(item.getId());
|
||||
fieldWithValue.setDependencies(item.getDependencies());
|
||||
|
@ -365,7 +365,7 @@ public class DataManagementPlanManager {
|
|||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
public List<Tuple<String, String>> getDynamicFields(String id, DynamicProjectConfiguration dynamicProjectConfiguration, DynamicFieldsCriteria criteria) throws IllegalAccessException, InstantiationException {
|
||||
public List<Tuple<String, String>> getDynamicFields(String id, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicFieldsCriteria criteria) throws IllegalAccessException, InstantiationException {
|
||||
List<Tuple<String, String>> result = new LinkedList<>();
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
@ -373,7 +373,7 @@ public class DataManagementPlanManager {
|
|||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
|
||||
|
||||
Property property = dynamicProjectConfiguration.getConfiguration().getConfigurationProperties().stream()
|
||||
Property property = dynamicGrantConfiguration.getConfiguration().getConfigurationProperties().stream()
|
||||
.filter(item -> item.getId().equals(id)).findFirst().orElse(null);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (criteria.getLike() != null) stringBuilder.append("?search=" + criteria.getLike());
|
||||
|
@ -427,7 +427,7 @@ public class DataManagementPlanManager {
|
|||
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
||||
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao(), user);
|
||||
|
||||
DMP dmp;
|
||||
if (dataManagementPlan.getId() != null) {
|
||||
|
@ -510,7 +510,7 @@ public class DataManagementPlanManager {
|
|||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
||||
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao(), user);
|
||||
|
||||
newDmp.setGroupId(oldDmp.getGroupId());
|
||||
newDmp.setVersion(oldDmp.getVersion() + 1);
|
||||
|
@ -535,7 +535,7 @@ public class DataManagementPlanManager {
|
|||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
||||
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao(), user);
|
||||
|
||||
newDmp.setGroupId(UUID.randomUUID());
|
||||
newDmp.setVersion(0);
|
||||
|
@ -586,16 +586,16 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
|
||||
if (newDmp.getProject() != null) {
|
||||
Project project = newDmp.getProject();
|
||||
ProjectCriteria criteria = new ProjectCriteria();
|
||||
criteria.setReference(project.getReference());
|
||||
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault();
|
||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||
private void createGrantIfItDoesntExist(DMP newDmp, GrantDao grantDao, UserInfo userInfo) {
|
||||
if (newDmp.getGrant() != null) {
|
||||
Grant grant = newDmp.getGrant();
|
||||
GrantCriteria criteria = new GrantCriteria();
|
||||
criteria.setReference(grant.getReference());
|
||||
eu.eudat.data.entities.Grant grantEntity = grantDao.getWithCriteria(criteria).getSingleOrDefault();
|
||||
if (grantEntity != null) grant.setId(grantEntity.getId());
|
||||
else {
|
||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||
projectDao.createOrUpdate(project);
|
||||
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
||||
grantDao.createOrUpdate(grant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -693,14 +693,14 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
dmpElement.appendChild(dmpProfileElement);
|
||||
|
||||
Element project = xmlDoc.createElement("project");
|
||||
Element grant = xmlDoc.createElement("grant");
|
||||
Element label = xmlDoc.createElement("label");
|
||||
label.setTextContent(dmp.getProject().getLabel());
|
||||
project.appendChild(label);
|
||||
Element projectId = xmlDoc.createElement("id");
|
||||
projectId.setTextContent(dmp.getProject().getId().toString());
|
||||
project.appendChild(projectId);
|
||||
dmpElement.appendChild(project);
|
||||
label.setTextContent(dmp.getGrant().getLabel());
|
||||
grant.appendChild(label);
|
||||
Element grantId = xmlDoc.createElement("id");
|
||||
grantId.setTextContent(dmp.getGrant().getId().toString());
|
||||
grant.appendChild(grantId);
|
||||
dmpElement.appendChild(grant);
|
||||
Element organisationsElement = xmlDoc.createElement("organisations");
|
||||
for (Organisation organisation : dmp.getOrganisations()) {
|
||||
Element organisationElement = xmlDoc.createElement("organisation");
|
||||
|
@ -862,12 +862,12 @@ public class DataManagementPlanManager {
|
|||
/*Tuple tuple = new Tuple();
|
||||
tuple.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
||||
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());*/
|
||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImport();
|
||||
project.setId(projectImport.getId());
|
||||
project.setLabel(projectImport.getLabel());
|
||||
project.setAbbreviation(projectImport.getAbbreviation());
|
||||
project.setDescription(projectImport.getDescription());
|
||||
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());
|
||||
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
||||
for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
|
||||
AssociatedProfile associatedProfile = new AssociatedProfile();
|
||||
|
@ -895,7 +895,7 @@ public class DataManagementPlanManager {
|
|||
|
||||
// Sets properties.
|
||||
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
||||
dm.setProject(project); //Sets project property.
|
||||
dm.setGrant(grant); //Sets grant property.
|
||||
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
||||
dm.setProfiles(associatedProfiles);
|
||||
dm.setOrganisations(organisations); // Sets organisations property.
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
||||
import eu.eudat.exceptions.grant.GrantWithDMPsDeleteException;
|
||||
import eu.eudat.logic.builders.entity.ContentBuilder;
|
||||
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
||||
import eu.eudat.data.dao.entities.GrantDao;
|
||||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.exceptions.files.TempFileNotFoundException;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||
import eu.eudat.models.data.external.GrantsExternalSourcesModel;
|
||||
import eu.eudat.models.data.files.ContentFile;
|
||||
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.models.data.security.Principal;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.FileStorageService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
public class GrantManager {
|
||||
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private FileStorageService fileStorageService;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
|
||||
public GrantManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.fileStorageService = apiContext.getOperationsContext().getFileStorageService();
|
||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public DataTableData<eu.eudat.models.data.grant.GrantListingModel> getPaged(GrantTableRequest grantTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
QueryableList<eu.eudat.data.entities.Grant> items = grantRepository.getWithCriteria(grantTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Grant> authItems = grantRepository.getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.data.entities.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.entities.Grant> items = grantRepository.getWithCriteria(grantTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.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 {
|
||||
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.entities.Grant inactivate(String id) throws InstantiationException, IllegalAccessException {
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
eu.eudat.data.entities.Grant grant = grantRepository.find(UUID.fromString(id));
|
||||
grant.setStatus(eu.eudat.data.entities.Grant.Status.DELETED.getValue());
|
||||
grant = grantRepository.createOrUpdate(grant);
|
||||
return grant;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.grant.Grant> getCriteriaWithExternal(GrantCriteriaRequest grantCriteria, Principal principal) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<eu.eudat.data.entities.Grant> items = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(grantCriteria.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.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.getGrants(grantCriteria.getCriteria().getLike());
|
||||
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())
|
||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Grant.Status.fromInteger(0))
|
||||
.build();
|
||||
|
||||
grants.add(grant);
|
||||
}
|
||||
grants.sort(Comparator.comparing(x -> x.getLabel()));
|
||||
return grants;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.grant.Grant> getCriteria(GrantCriteriaRequest grantCriteria) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||
QueryableList<eu.eudat.data.entities.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.entities.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.entities.Grant.GrantType.INTERNAL.getValue());
|
||||
grantEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
databaseRepository.getGrantDao().createOrUpdate(grantEntity);
|
||||
}
|
||||
|
||||
public void delete(UUID uuid) {
|
||||
eu.eudat.data.entities.Grant oldGrant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(uuid);
|
||||
if (oldGrant.getDmps().size() > 0)
|
||||
throw new GrantWithDMPsDeleteException("You cannot Remove Grants with DMPs");
|
||||
oldGrant.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(oldGrant);
|
||||
}
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.exceptions.project.ProjectWithDMPsDeleteException;
|
||||
import eu.eudat.logic.builders.entity.ContentBuilder;
|
||||
import eu.eudat.logic.builders.model.models.ProjectBuilder;
|
||||
import eu.eudat.data.dao.entities.ProjectDao;
|
||||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.exceptions.files.TempFileNotFoundException;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.data.files.ContentFile;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.project.Project;
|
||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||
import eu.eudat.models.data.project.ProjectListingModel;
|
||||
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.FileStorageService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
public class ProjectManager {
|
||||
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private FileStorageService fileStorageService;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
|
||||
public ProjectManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.fileStorageService = apiContext.getOperationsContext().getFileStorageService();
|
||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPaged(ProjectTableRequest projectTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> authItems = projectRepository.getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(authItems, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();
|
||||
CompletableFuture projectsFuture;
|
||||
if (fieldsGroup.equals("listing")) {
|
||||
projectsFuture = pagedItems.selectAsync(item -> new ProjectListingModel().fromDataModelDetails(item))
|
||||
.whenComplete((results, throwable) ->
|
||||
dataTable.setData(results)
|
||||
);
|
||||
} else {
|
||||
projectsFuture = pagedItems.selectAsync(item -> new ProjectListingModel().fromDataModel(item))
|
||||
.whenComplete((results, throwable) ->
|
||||
dataTable.setData(results)
|
||||
);
|
||||
}
|
||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
|
||||
CompletableFuture.allOf(projectsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPublicPaged(ProjectTableRequest projectTableRequest) throws Exception {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
projectTableRequest.getCriteria().setPublic(true);
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(items, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();
|
||||
CompletableFuture projectsFuture;
|
||||
projectsFuture = pagedItems.selectAsync(item -> new ProjectListingModel().fromDataModel(item))
|
||||
.whenComplete((results, throwable) -> {
|
||||
dataTable.setData(results);
|
||||
});
|
||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
|
||||
CompletableFuture.allOf(projectsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.project.Project getSingle(String id) throws InstantiationException, IllegalAccessException {
|
||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||
project.fromDataModel(databaseRepository.getProjectDao().find(UUID.fromString(id)));
|
||||
return project;
|
||||
}
|
||||
|
||||
public eu.eudat.data.entities.Project inactivate(String id) throws InstantiationException, IllegalAccessException {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
eu.eudat.data.entities.Project project = projectRepository.find(UUID.fromString(id));
|
||||
project.setStatus(eu.eudat.data.entities.Project.Status.DELETED.getValue());
|
||||
project = projectRepository.createOrUpdate(project);
|
||||
return project;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.project.Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria, Principal principal) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<eu.eudat.data.entities.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCriteria(projectCriteria.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
||||
List<eu.eudat.models.data.project.Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike());
|
||||
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.entities.Project.Status.fromInteger(0))
|
||||
.build();
|
||||
|
||||
projects.add(project);
|
||||
}
|
||||
projects.sort(Comparator.comparing(x -> x.getLabel()));
|
||||
return projects;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.project.Project> getCriteria(ProjectCriteriaRequest projectCriteria) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
if (projectCriteria.getLength() != null) items.take(projectCriteria.getLength());
|
||||
List<eu.eudat.models.data.project.Project> projects = items.select(item -> new Project().fromDataModel(item));
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
||||
if (project.getFiles() != null) {
|
||||
for (ContentFile file : project.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.PROJECT.getValue())
|
||||
.uri("LOCAL:" + storedFile.getId())
|
||||
.build();
|
||||
projectEntity.setContent(databaseRepository.getContentDao().createOrUpdate(content));
|
||||
} catch (TempFileNotFoundException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||
}
|
||||
|
||||
public void delete(UUID uuid) {
|
||||
eu.eudat.data.entities.Project oldProject = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().find(uuid);
|
||||
if (oldProject.getDmps().size() > 0)
|
||||
throw new ProjectWithDMPsDeleteException("You cannot Remove Projects with DMPs");
|
||||
oldProject.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(oldProject);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,10 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.dao.entities.ContentDao;
|
||||
import eu.eudat.data.dao.entities.ProjectDao;
|
||||
import eu.eudat.data.dao.entities.UserInfoDao;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.FileStorageService;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
|
||||
import eu.eudat.models.data.quickwizard.QuickWizardModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -30,18 +24,18 @@ public class QuickWizardManager {
|
|||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public Project createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||
return projectEntityRet;
|
||||
public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant, Principal principal) throws ParseException, IOException {
|
||||
eu.eudat.data.entities.Grant grantEntity = grant.toDataModel();
|
||||
grantEntity.setType(eu.eudat.data.entities.Grant.GrantType.INTERNAL.getValue());
|
||||
grantEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
Grant grantEntityRet = databaseRepository.getGrantDao().createOrUpdate(grantEntity);
|
||||
return grantEntityRet;
|
||||
}
|
||||
|
||||
public DMP createOrUpdate(DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
createProjectIfItDoesntExist(newDmp, user);
|
||||
createGrantIfItDoesntExist(newDmp, user);
|
||||
//newDmp.setCreator(user);
|
||||
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||
|
@ -57,16 +51,16 @@ public class QuickWizardManager {
|
|||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||
}
|
||||
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
|
||||
if (newDmp.getProject() != null) {
|
||||
Project project = newDmp.getProject();
|
||||
ProjectCriteria criteria = new ProjectCriteria();
|
||||
criteria.setReference(project.getReference());
|
||||
eu.eudat.data.entities.Project projectEntity = databaseRepository.getProjectDao().getWithCriteria(criteria).getSingleOrDefault();
|
||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||
private void createGrantIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
|
||||
if (newDmp.getGrant() != null) {
|
||||
Grant grant = newDmp.getGrant();
|
||||
GrantCriteria criteria = new GrantCriteria();
|
||||
criteria.setReference(grant.getReference());
|
||||
eu.eudat.data.entities.Grant grantEntity = databaseRepository.getGrantDao().getWithCriteria(criteria).getSingleOrDefault();
|
||||
if (grantEntity != null) grant.setId(grantEntity.getId());
|
||||
else {
|
||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||
databaseRepository.getProjectDao().createOrUpdate(project);
|
||||
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
||||
databaseRepository.getGrantDao().createOrUpdate(grant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ExternalUrls implements Serializable {
|
|||
|
||||
Long maxresults;
|
||||
|
||||
ProjectUrls projects;
|
||||
GrantUrls grants;
|
||||
RegistryUrls registries;
|
||||
RepositoryUrls repositories;
|
||||
ServiceUrls services;
|
||||
|
@ -84,13 +84,13 @@ public class ExternalUrls implements Serializable {
|
|||
this.organisations = organisations;
|
||||
}
|
||||
|
||||
public ProjectUrls getProjects() {
|
||||
return projects;
|
||||
public GrantUrls getGrants() {
|
||||
return grants;
|
||||
}
|
||||
|
||||
@XmlElement(name = "projects")
|
||||
public void setProjects(ProjectUrls projects) {
|
||||
this.projects = projects;
|
||||
@XmlElement(name = "grants")
|
||||
public void setGrants(GrantUrls grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public Long getMaxresults() {
|
||||
|
|
|
@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
public class ProjectUrls {
|
||||
public class GrantUrls {
|
||||
|
||||
List<UrlConfiguration> urls;
|
||||
FetchStrategy fetchMode;
|
|
@ -2,7 +2,7 @@ package eu.eudat.logic.proxy.fetching;
|
|||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||
import eu.eudat.logic.proxy.config.DataUrlConfiguration;
|
||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||
|
@ -25,12 +25,12 @@ public class RemoteFetcher {
|
|||
|
||||
private ConfigLoader configLoader;
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
||||
|
||||
@Autowired
|
||||
public RemoteFetcher(ConfigLoader configLoader, DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
public RemoteFetcher(ConfigLoader configLoader, DynamicGrantConfiguration dynamicGrantConfiguration) {
|
||||
this.configLoader = configLoader;
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
||||
}
|
||||
|
||||
@Cacheable("repositories")
|
||||
|
@ -42,10 +42,10 @@ public class RemoteFetcher {
|
|||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
@Cacheable("projects")
|
||||
public List<Map<String, String>> getProjects(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
|
||||
@Cacheable("grants")
|
||||
public List<Map<String, String>> getGrants(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicGrantConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getGrants().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public interface DatabaseRepository {
|
|||
|
||||
OrganisationDao getOrganisationDao();
|
||||
|
||||
ProjectDao getProjectDao();
|
||||
GrantDao getGrantDao();
|
||||
|
||||
RegistryDao getRegistryDao();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
private DatasetProfileDao datasetProfileDao;
|
||||
private DMPDao dmpDao;
|
||||
private OrganisationDao organisationDao;
|
||||
private ProjectDao projectDao;
|
||||
private GrantDao GrantDao;
|
||||
private RegistryDao registryDao;
|
||||
private ResearcherDao researcherDao;
|
||||
private ServiceDao serviceDao;
|
||||
|
@ -62,8 +62,8 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
}
|
||||
|
||||
@Autowired
|
||||
private void setProjectDao(ProjectDao projectDao) {
|
||||
this.projectDao = projectDao;
|
||||
private void setGrantDao(GrantDao GrantDao) {
|
||||
this.GrantDao = GrantDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
@ -112,8 +112,8 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProjectDao getProjectDao() {
|
||||
return projectDao;
|
||||
public GrantDao getGrantDao() {
|
||||
return GrantDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,16 +6,16 @@ import java.util.List;
|
|||
* Created by ikalyvas on 3/14/2018.
|
||||
*/
|
||||
public class RecentActivity {
|
||||
private List<RecentActivityData> recentProjectActivities;
|
||||
private List<RecentActivityData> recentGrantActivities;
|
||||
private List<RecentActivityData> recentDatasetActivities;
|
||||
private List<RecentActivityData> recentDmpActivities;
|
||||
|
||||
public List<RecentActivityData> getRecentProjectActivities() {
|
||||
return recentProjectActivities;
|
||||
public List<RecentActivityData> getRecentGrantActivities() {
|
||||
return recentGrantActivities;
|
||||
}
|
||||
|
||||
public void setRecentProjectActivities(List<RecentActivityData> recentProjectActivities) {
|
||||
this.recentProjectActivities = recentProjectActivities;
|
||||
public void setRecentGrantActivities(List<RecentActivityData> recentGrantActivities) {
|
||||
this.recentGrantActivities = recentGrantActivities;
|
||||
}
|
||||
|
||||
public List<RecentActivityData> getRecentDatasetActivities() {
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.models.data.dashboard.statistics;
|
|||
|
||||
public class DashBoardStatistics {
|
||||
private Long totalDataManagementPlanCount;
|
||||
private Long totalProjectCount;
|
||||
private Long totalGrantCount;
|
||||
private Long totalDataSetCount;
|
||||
private Long totalOrganisationCount;
|
||||
|
||||
|
@ -15,12 +15,12 @@ public class DashBoardStatistics {
|
|||
this.totalDataManagementPlanCount = totalDataManagementPlanCount;
|
||||
}
|
||||
|
||||
public Long getTotalProjectCount() {
|
||||
return totalProjectCount;
|
||||
public Long getTotalGrantCount() {
|
||||
return totalGrantCount;
|
||||
}
|
||||
|
||||
public void setTotalProjectCount(Long totalProjectCount) {
|
||||
this.totalProjectCount = totalProjectCount;
|
||||
public void setTotalGrantCount(Long totalGrantCount) {
|
||||
this.totalGrantCount = totalGrantCount;
|
||||
}
|
||||
|
||||
public Long getTotalDataSetCount() {
|
||||
|
|
|
@ -8,13 +8,9 @@ import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManageme
|
|||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.project.Project;
|
||||
import eu.eudat.models.data.grant.Grant;
|
||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -30,7 +26,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
private String description;
|
||||
private List<DatasetListingModel> datasets;
|
||||
private List<AssociatedProfile> profiles;
|
||||
private eu.eudat.models.data.project.Project project;
|
||||
private eu.eudat.models.data.grant.Grant grant;
|
||||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserListingModel> associatedUsers;
|
||||
|
@ -106,11 +102,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
public Grant getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
public void setGrant(Grant grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.userinfo.UserInfo getCreator() {
|
||||
|
@ -206,9 +202,9 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.version = entity.getVersion();
|
||||
this.groupId = this.groupId == null ? null : this.groupId;
|
||||
this.label = entity.getLabel();
|
||||
this.project = new Project();
|
||||
this.grant = new Grant();
|
||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||
this.project.fromDataModel(entity.getProject());
|
||||
this.grant.fromDataModel(entity.getGrant());
|
||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.lockable = entity.getDataset().stream().findAny().isPresent();
|
||||
|
@ -255,7 +251,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
dataManagementPlanEntity.setVersion(this.version);
|
||||
dataManagementPlanEntity.setLabel(this.label);
|
||||
if (this.project != null) dataManagementPlanEntity.setProject(this.project.toDataModel());
|
||||
if (this.grant != null) dataManagementPlanEntity.setGrant(this.grant.toDataModel());
|
||||
dataManagementPlanEntity.setStatus((short) this.status);
|
||||
dataManagementPlanEntity.setDescription(this.description);
|
||||
if (this.profiles != null) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManageme
|
|||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||
import net.minidev.json.JSONObject;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
private String description;
|
||||
private List<DatasetListingModel> datasets;
|
||||
private List<AssociatedProfile> profiles;
|
||||
private eu.eudat.models.data.project.ProjectDMPEditorModel project;
|
||||
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
|
||||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserListingModel> associatedUsers;
|
||||
|
@ -102,11 +102,11 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public ProjectDMPEditorModel getProject() {
|
||||
return project;
|
||||
public GrantDMPEditorModel getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(ProjectDMPEditorModel project) {
|
||||
this.project = project;
|
||||
public void setGrant(GrantDMPEditorModel grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.userinfo.UserInfo getCreator() {
|
||||
|
@ -202,9 +202,9 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
this.version = entity.getVersion();
|
||||
this.groupId = this.groupId == null ? null : this.groupId;
|
||||
this.label = entity.getLabel();
|
||||
this.project = new ProjectDMPEditorModel();
|
||||
this.grant = new GrantDMPEditorModel();
|
||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||
this.project.getExistProject().fromDataModel(entity.getProject());
|
||||
this.grant.getExistGrant().fromDataModel(entity.getGrant());
|
||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.lockable = entity.getDataset().stream().findAny().isPresent();
|
||||
|
@ -250,23 +250,23 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
dataManagementPlanEntity.setVersion(this.version);
|
||||
dataManagementPlanEntity.setLabel(this.label);
|
||||
if (this.project != null) {
|
||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
||||
if (this.grant != null) {
|
||||
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
||||
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
|
||||
else {
|
||||
Project project = new Project();
|
||||
project.setAbbreviation("");
|
||||
project.setLabel(this.project.getLabel());
|
||||
project.setType(Project.ProjectType.INTERNAL.getValue());
|
||||
project.setReference("dmp:" + this.project.getLabel());
|
||||
project.setUri("");
|
||||
project.setDefinition("");
|
||||
project.setCreated(new Date());
|
||||
project.setStatus(Project.Status.ACTIVE.getValue());
|
||||
project.setModified(new Date());
|
||||
project.setDescription(this.project.getDescription());
|
||||
Grant grant = new Grant();
|
||||
grant.setAbbreviation("");
|
||||
grant.setLabel(this.grant.getLabel());
|
||||
grant.setType(Grant.GrantType.INTERNAL.getValue());
|
||||
grant.setReference("dmp:" + this.grant.getLabel());
|
||||
grant.setUri("");
|
||||
grant.setDefinition("");
|
||||
grant.setCreated(new Date());
|
||||
grant.setStatus(Grant.Status.ACTIVE.getValue());
|
||||
grant.setModified(new Date());
|
||||
grant.setDescription(this.grant.getDescription());
|
||||
|
||||
dataManagementPlanEntity.setProject(project);
|
||||
dataManagementPlanEntity.setGrant(grant);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package eu.eudat.models.data.dmp;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dataset.Dataset;
|
||||
import eu.eudat.models.data.project.Project;
|
||||
import eu.eudat.models.data.grant.Grant;
|
||||
import eu.eudat.models.data.userinfo.UserInfo;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -25,7 +21,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
private int status;
|
||||
private String description;
|
||||
private List<AssociatedProfile> profiles;
|
||||
private eu.eudat.models.data.project.Project project;
|
||||
private eu.eudat.models.data.grant.Grant grant;
|
||||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserDMP> associatedUsers;
|
||||
|
@ -89,12 +85,12 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
this.profiles = profiles;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
public Grant getGrant() {
|
||||
return grant;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
public void setGrant(Grant grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public List<Organisation> getOrganisations() {
|
||||
|
@ -174,7 +170,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.researchers != null && !this.researchers.isEmpty())
|
||||
entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.project != null) entity.setProject(this.project.toDataModel());
|
||||
if (this.grant != null) entity.setGrant(this.grant.toDataModel());
|
||||
if (this.profiles != null)
|
||||
entity.setAssociatedDmps(this.profiles.stream().map(x -> x.toData()).collect(Collectors.toSet()));
|
||||
/*Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
|
|
|
@ -10,7 +10,7 @@ public class DmpImportModel {
|
|||
private String description;
|
||||
private String dmpName;
|
||||
private DmpProfileImportModel profile;
|
||||
private ProjectImportModels projectImportModels;
|
||||
private GrantImportModels grantImportModels;
|
||||
private List<AssociatedProfileImportModels> profilesImportModels;
|
||||
private List<OrganisationImportModel> organisationImportModels;
|
||||
private List<ResearcherImportModels> researchersImportModels;
|
||||
|
@ -38,12 +38,12 @@ public class DmpImportModel {
|
|||
public DmpProfileImportModel getDmpProfile() { return profile; }
|
||||
public void setDmpProfile(DmpProfileImportModel profile) { this.profile = profile; }
|
||||
|
||||
@XmlElement(name = "project")
|
||||
public ProjectImportModels getProjectImport() {
|
||||
return projectImportModels;
|
||||
@XmlElement(name = "grant")
|
||||
public GrantImportModels getGrantImport() {
|
||||
return grantImportModels;
|
||||
}
|
||||
public void setProjectImport(ProjectImportModels projectImportModels) {
|
||||
this.projectImportModels = projectImportModels;
|
||||
public void setGrantImport(GrantImportModels grantImportModels) {
|
||||
this.grantImportModels = grantImportModels;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name="organisations")
|
||||
|
|
|
@ -12,7 +12,7 @@ public class DmpRDAExportModel {
|
|||
private String description;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
//private project;
|
||||
//private grant;
|
||||
private ContactRDAExportModel contact;
|
||||
private String language;
|
||||
private String ethical_issues_exist;
|
||||
|
|
|
@ -3,8 +3,8 @@ package eu.eudat.models.data.dmp;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.UUID;
|
||||
|
||||
@XmlRootElement(name = "project")
|
||||
public class ProjectImportModels {
|
||||
@XmlRootElement(name = "grant")
|
||||
public class GrantImportModels {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
|
@ -4,9 +4,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
|
||||
public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> {
|
||||
public class GrantsExternalSourcesModel extends ExternalListingItem<GrantsExternalSourcesModel> {
|
||||
@Override
|
||||
public ProjectsExternalSourcesModel fromExternalItem(List<Map<String, String>> values) {
|
||||
public GrantsExternalSourcesModel fromExternalItem(List<Map<String, String>> values) {
|
||||
for (Map<String, String> item : values) {
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setRemoteId(item.get("pid"));
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.models.data.project;
|
||||
package eu.eudat.models.data.grant;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class Project implements DataModel<eu.eudat.data.entities.Project, Project> {
|
||||
public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
|
||||
private Date endDate;
|
||||
|
||||
private eu.eudat.data.entities.Project.Status status;
|
||||
private eu.eudat.data.entities.Grant.Status status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = eu.eudat.data.entities.Project.Status.fromInteger(status);
|
||||
this.status = eu.eudat.data.entities.Grant.Status.fromInteger(status);
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
|
@ -175,7 +175,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project fromDataModel(eu.eudat.data.entities.Project entity) {
|
||||
public Grant fromDataModel(eu.eudat.data.entities.Grant entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -194,8 +194,8 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.data.entities.Project toDataModel() {
|
||||
eu.eudat.data.entities.Project entity = new eu.eudat.data.entities.Project();
|
||||
public eu.eudat.data.entities.Grant toDataModel() {
|
||||
eu.eudat.data.entities.Grant entity = new eu.eudat.data.entities.Grant();
|
||||
entity.setId(this.id);
|
||||
entity.setAbbreviation(this.abbreviation);
|
||||
entity.setLabel(this.label);
|
||||
|
@ -206,7 +206,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
entity.setStartdate(this.startDate);
|
||||
entity.setCreated(this.created == null ? new Date() : this.created);
|
||||
entity.setEnddate(this.endDate);
|
||||
entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Project.Status.ACTIVE.getValue());
|
||||
entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue());
|
||||
entity.setModified(new Date());
|
||||
entity.setDescription(this.description);
|
||||
return entity;
|
|
@ -0,0 +1,37 @@
|
|||
package eu.eudat.models.data.grant;
|
||||
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class GrantCriteriaModel implements DataModel<eu.eudat.data.entities.Grant, GrantCriteriaModel> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantCriteriaModel fromDataModel(Grant entity) {
|
||||
this.id = entity.getId();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grant toDataModel() {
|
||||
Grant grant = new Grant();
|
||||
grant.setId(this.id);
|
||||
return grant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package eu.eudat.models.data.project;
|
||||
package eu.eudat.models.data.grant;
|
||||
|
||||
public class ProjectDMPEditorModel {
|
||||
private Project existProject;
|
||||
public class GrantDMPEditorModel {
|
||||
private Grant existGrant;
|
||||
private String label;
|
||||
private String description;
|
||||
|
||||
public Project getExistProject() {
|
||||
return existProject;
|
||||
public Grant getExistGrant() {
|
||||
return existGrant;
|
||||
}
|
||||
public void setExistProject(Project existProject) {
|
||||
this.existProject = existProject;
|
||||
public void setExistGrant(Grant existGrant) {
|
||||
this.existGrant = existGrant;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.models.data.project;
|
||||
package eu.eudat.models.data.grant;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.files.ContentFile;
|
||||
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Project, ProjectListingModel> {
|
||||
public class GrantListingModel implements DataModel<eu.eudat.data.entities.Grant, GrantListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
|
||||
private Date endDate;
|
||||
|
||||
private Project.Status status;
|
||||
private Grant.Status status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = Project.Status.fromInteger(status);
|
||||
this.status = Grant.Status.fromInteger(status);
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
|
@ -134,7 +134,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public void setStatus(Project.Status status) {
|
||||
public void setStatus(Grant.Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
@ -171,13 +171,13 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProjectListingModel fromDataModel(eu.eudat.data.entities.Project entity) {
|
||||
public GrantListingModel fromDataModel(eu.eudat.data.entities.Grant entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectListingModel fromDataModelWIthDmps(eu.eudat.data.entities.Project entity) {
|
||||
public GrantListingModel fromDataModelWIthDmps(eu.eudat.data.entities.Grant entity) {
|
||||
this.fromDataModel(entity);
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
|
@ -194,7 +194,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProjectListingModel fromDataModelDetails(eu.eudat.data.entities.Project entity) {
|
||||
public GrantListingModel fromDataModelDetails(eu.eudat.data.entities.Grant entity) {
|
||||
this.fromDataModel(entity);
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
|
@ -210,12 +210,12 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
|
|||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.data.entities.Project toDataModel() throws Exception {
|
||||
public eu.eudat.data.entities.Grant toDataModel() throws Exception {
|
||||
throw new Exception("Not Implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return "projectListingItem";
|
||||
return "grantListingItem";
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package eu.eudat.models.data.project;
|
||||
package eu.eudat.models.data.grant;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProjectOverviewModel implements DataModel<Project, ProjectOverviewModel> {
|
||||
public class GrantOverviewModel implements DataModel<Grant, GrantOverviewModel> {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
|
@ -65,7 +65,7 @@ public class ProjectOverviewModel implements DataModel<Project, ProjectOverviewM
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProjectOverviewModel fromDataModel(Project entity) {
|
||||
public GrantOverviewModel fromDataModel(Grant entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -77,7 +77,7 @@ public class ProjectOverviewModel implements DataModel<Project, ProjectOverviewM
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project toDataModel() throws Exception {
|
||||
public Grant toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
|
|||
public class DataManagementPlanListingModel implements DataModel<DMP, DataManagementPlanListingModel> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String project;
|
||||
private String grant;
|
||||
private String profile;
|
||||
private Date creationTime;
|
||||
private Date modifiedTime;
|
||||
|
@ -35,8 +35,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
private List<AssociatedProfile> associatedProfiles;
|
||||
private List<UserInfoListingModel> users;
|
||||
private String description;
|
||||
private String projectAbbreviation;
|
||||
private String projectId;
|
||||
private String grantAbbreviation;
|
||||
private String grantId;
|
||||
private Date finalizedAt;
|
||||
private Boolean isPublic;
|
||||
private Date publishedAt;
|
||||
|
@ -56,11 +56,11 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public String getProject() {
|
||||
return project;
|
||||
public String getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(String project) {
|
||||
this.project = project;
|
||||
public void setGrant(String grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
|
@ -140,18 +140,18 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getProjectAbbreviation() {
|
||||
return projectAbbreviation;
|
||||
public String getGrantAbbreviation() {
|
||||
return grantAbbreviation;
|
||||
}
|
||||
public void setProjectAbbreviation(String projectAbbreviation) {
|
||||
this.projectAbbreviation = projectAbbreviation;
|
||||
public void setGrantAbbreviation(String grantAbbreviation) {
|
||||
this.grantAbbreviation = grantAbbreviation;
|
||||
}
|
||||
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
public String getGrantId() {
|
||||
return grantId;
|
||||
}
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
public void setGrantId(String grantId) {
|
||||
this.grantId = grantId;
|
||||
}
|
||||
|
||||
public Date getFinalizedAt() {
|
||||
|
@ -187,7 +187,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.fromDataModel(entity);
|
||||
this.status = entity.getStatus();
|
||||
this.version = entity.getVersion();
|
||||
this.project = entity.getProject().getLabel();
|
||||
this.grant = entity.getGrant().getLabel();
|
||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||
this.creationTime = entity.getCreated();
|
||||
this.modifiedTime = entity.getModified();
|
||||
|
@ -195,8 +195,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
||||
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||
this.description = entity.getDescription();
|
||||
this.projectAbbreviation = entity.getProject().getAbbreviation();
|
||||
this.projectId = entity.getProject().getId().toString();
|
||||
this.grantAbbreviation = entity.getGrant().getAbbreviation();
|
||||
this.grantId = entity.getGrant().getId().toString();
|
||||
this.finalizedAt = entity.getFinalizedAt();
|
||||
this.isPublic = entity.isPublic();
|
||||
this.publishedAt = entity.getPublishedAt();
|
||||
|
|
|
@ -3,18 +3,12 @@ package eu.eudat.models.data.listingmodels;
|
|||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.data.dmp.Organisation;
|
||||
import eu.eudat.models.data.dmp.Researcher;
|
||||
import eu.eudat.models.data.project.ProjectOverviewModel;
|
||||
import eu.eudat.models.data.urls.DatasetUrlListing;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import eu.eudat.models.data.grant.GrantOverviewModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
|
@ -26,7 +20,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
|||
private String id;
|
||||
private String label;
|
||||
private String profile;
|
||||
private ProjectOverviewModel project;
|
||||
private GrantOverviewModel grant;
|
||||
private Date creationTime;
|
||||
private Date modifiedTime;
|
||||
private Date finalizedAt;
|
||||
|
@ -65,11 +59,11 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
|||
this.profile = profile;
|
||||
}
|
||||
|
||||
public ProjectOverviewModel getProject() {
|
||||
return project;
|
||||
public GrantOverviewModel getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(ProjectOverviewModel project) {
|
||||
this.project = project;
|
||||
public void setGrant(GrantOverviewModel grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public Date getCreationTime() {
|
||||
|
@ -189,7 +183,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
|||
this.fromDataModel(entity);
|
||||
this.status = entity.getStatus();
|
||||
this.version = entity.getVersion();
|
||||
this.project = new ProjectOverviewModel().fromDataModel(entity.getProject());
|
||||
this.grant = new GrantOverviewModel().fromDataModel(entity.getGrant());
|
||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||
this.creationTime = entity.getCreated();
|
||||
this.modifiedTime = entity.getModified();
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.stream.Collectors;
|
|||
public class DatasetListingModel implements DataModel<Dataset, DatasetListingModel> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String project;
|
||||
private String grant;
|
||||
private String dmp;
|
||||
private String dmpId;
|
||||
private String profile;
|
||||
|
@ -24,8 +24,8 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
|||
private Date created;
|
||||
private Date modified;
|
||||
private String description;
|
||||
private String projectAbbreviation;
|
||||
private String projectId;
|
||||
private String grantAbbreviation;
|
||||
private String grantId;
|
||||
private Date finalizedAt;
|
||||
|
||||
public String getId() {
|
||||
|
@ -42,11 +42,11 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public String getProject() {
|
||||
return project;
|
||||
public String getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(String project) {
|
||||
this.project = project;
|
||||
public void setGrant(String grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public String getDmp() {
|
||||
|
@ -119,18 +119,18 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getProjectAbbreviation() {
|
||||
return projectAbbreviation;
|
||||
public String getGrantAbbreviation() {
|
||||
return grantAbbreviation;
|
||||
}
|
||||
public void setProjectAbbreviation(String projectAbbreviation) {
|
||||
this.projectAbbreviation = projectAbbreviation;
|
||||
public void setGrantAbbreviation(String grantAbbreviation) {
|
||||
this.grantAbbreviation = grantAbbreviation;
|
||||
}
|
||||
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
public String getGrantId() {
|
||||
return grantId;
|
||||
}
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
public void setGrantId(String grantId) {
|
||||
this.grantId = grantId;
|
||||
}
|
||||
|
||||
public Date getFinalizedAt() {
|
||||
|
@ -146,14 +146,14 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
|||
this.label = entity.getLabel();
|
||||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
this.project = entity.getDmp().getProject().getLabel();
|
||||
this.grant = entity.getDmp().getGrant().getLabel();
|
||||
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
||||
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
||||
this.profile = entity.getProfile() != null ? entity.getProfile().getLabel() : "";
|
||||
this.description = entity.getDescription();
|
||||
this.status = entity.getStatus();
|
||||
this.projectAbbreviation = entity.getDmp().getProject().getAbbreviation();
|
||||
this.projectId = entity.getDmp().getProject().getId().toString();
|
||||
this.grantAbbreviation = entity.getDmp().getGrant().getAbbreviation();
|
||||
this.grantId = entity.getDmp().getGrant().getId().toString();
|
||||
this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.dataRepositories = LabelBuilder.getLabel(entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList()));
|
||||
this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()));
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package eu.eudat.models.data.project;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ProjectCriteriaModel implements DataModel<eu.eudat.data.entities.Project, ProjectCriteriaModel> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectCriteriaModel fromDataModel(Project entity) {
|
||||
this.id = entity.getId();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project toDataModel() {
|
||||
Project project = new Project();
|
||||
project.setId(this.id);
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,8 @@
|
|||
package eu.eudat.models.data.quickwizard;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.models.data.userinfo.UserInfo;
|
||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -19,7 +17,7 @@ public class DmpQuickWizardModel {
|
|||
private int status;
|
||||
private AssociatedProfile datasetProfile;
|
||||
private String description;
|
||||
private eu.eudat.models.data.project.Project project;
|
||||
private eu.eudat.models.data.grant.Grant grant;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -58,24 +56,24 @@ public class DmpQuickWizardModel {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.project.Project getProject() {
|
||||
return project;
|
||||
public eu.eudat.models.data.grant.Grant getGrant() {
|
||||
return grant;
|
||||
}
|
||||
|
||||
public void setProject(eu.eudat.models.data.project.Project project) {
|
||||
this.project = project;
|
||||
public void setGrant(eu.eudat.models.data.grant.Grant grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Project project, Principal principal) {
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Grant grant, Principal principal) {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
|
||||
dataManagementPlanEntity.setId(this.id);
|
||||
dataManagementPlanEntity.setVersion(0);
|
||||
|
||||
dataManagementPlanEntity.setLabel(this.label);
|
||||
if (project != null) {
|
||||
eu.eudat.models.data.project.Project importProject = new eu.eudat.models.data.project.Project();
|
||||
dataManagementPlanEntity.setProject(importProject.fromDataModel(project));
|
||||
if (grant != null) {
|
||||
eu.eudat.models.data.grant.Grant importGrant = new eu.eudat.models.data.grant.Grant();
|
||||
dataManagementPlanEntity.setGrant(importGrant.fromDataModel(grant));
|
||||
}
|
||||
if (this.datasetProfile != null) {
|
||||
List<AssociatedProfile> assProfile = new LinkedList<>();
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package eu.eudat.models.data.quickwizard;
|
||||
|
||||
|
||||
import eu.eudat.models.data.grant.Grant;
|
||||
|
||||
public class GrantQuickWizardModel {
|
||||
private String label;
|
||||
private String description;
|
||||
private Grant existGrant;
|
||||
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Grant getExistGrant() {
|
||||
return existGrant;
|
||||
}
|
||||
|
||||
public void setExistGrant(Grant existGrant) {
|
||||
this.existGrant = existGrant;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.grant.Grant toDataGrant(){
|
||||
eu.eudat.models.data.grant.Grant toGrant = new eu.eudat.models.data.grant.Grant();
|
||||
toGrant.setAbbreviation("");
|
||||
toGrant.setLabel(this.label);
|
||||
toGrant.setReference("dmp:" + this.label);
|
||||
toGrant.setUri("");
|
||||
toGrant.setDefinition("");
|
||||
toGrant.setDescription(this.description);
|
||||
return toGrant;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package eu.eudat.models.data.quickwizard;
|
||||
|
||||
|
||||
import eu.eudat.models.data.project.Project;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProjectQuickWizardModel {
|
||||
private String label;
|
||||
private String description;
|
||||
private Project existProject;
|
||||
|
||||
|
||||
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Project getExistProject() {
|
||||
return existProject;
|
||||
}
|
||||
|
||||
public void setExistProject(Project existProject) {
|
||||
this.existProject = existProject;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.project.Project toDataProject(){
|
||||
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
|
||||
toProject.setAbbreviation("");
|
||||
toProject.setLabel(this.label);
|
||||
toProject.setReference("dmp:" + this.label);
|
||||
toProject.setUri("");
|
||||
toProject.setDefinition("");
|
||||
toProject.setDescription(this.description);
|
||||
return toProject;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,16 +3,16 @@ package eu.eudat.models.data.quickwizard;
|
|||
|
||||
public class QuickWizardModel {
|
||||
|
||||
private ProjectQuickWizardModel project;
|
||||
private GrantQuickWizardModel grant;
|
||||
private DmpQuickWizardModel dmp;
|
||||
private DatasetQuickWizardModel datasets;
|
||||
private int status;
|
||||
|
||||
public ProjectQuickWizardModel getProject() {
|
||||
return project;
|
||||
public GrantQuickWizardModel getGrant() {
|
||||
return grant;
|
||||
}
|
||||
public void setProject(ProjectQuickWizardModel project) {
|
||||
this.project = project;
|
||||
public void setGrant(GrantQuickWizardModel grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public DmpQuickWizardModel getDmp() {
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package eu.eudat.models.validators;
|
||||
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.project.Project;
|
||||
import eu.eudat.models.data.grant.Grant;
|
||||
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
|
||||
@Component("datasetProfileValidator")
|
||||
public class DatasetProfileValidator extends FluentValidator<Project> {
|
||||
public class DatasetProfileValidator extends FluentValidator<Grant> {
|
||||
|
||||
public DatasetProfileValidator() {
|
||||
ruleFor(x -> x.getLabel()).notEmpty()
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package eu.eudat.models.validators;
|
||||
|
||||
import eu.eudat.models.data.grant.Grant;
|
||||
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("grantModelValidator")
|
||||
public class GrantModelValidator extends FluentValidator<Grant> {
|
||||
|
||||
public GrantModelValidator() {
|
||||
ruleFor(x -> x.getType()).compareAs((x -> eu.eudat.data.entities.Grant.GrantType.EXTERNAL.getValue()), (leftItem, rightItem) -> leftItem == rightItem)
|
||||
.withName("type").withMessage("grant.external.edit");
|
||||
ruleFor(x -> x.getStartDate()).compareAs((x -> x.getEndDate()), (leftItem, rightItem) -> leftItem.after(rightItem))
|
||||
.withName("startDate").withMessage("grant.startDate.overlapping")
|
||||
.ruleIf(x -> x.getStartDate() != null && x.getEndDate() != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return Grant.class.equals(aClass);
|
||||
}
|
||||
|
||||
public static boolean supportsType(Class<?> aClass) {
|
||||
return Grant.class.equals(aClass);
|
||||
}
|
||||
}
|
|
@ -1,33 +1,32 @@
|
|||
package eu.eudat.models.validators;
|
||||
|
||||
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
||||
import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
||||
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
|
||||
@Component("projectTableRequestValidator")
|
||||
public class ProjectTableRequestValidator extends FluentValidator<ProjectTableRequest> {
|
||||
@Component("grantTableRequestValidator")
|
||||
public class GrantTableRequestValidator extends FluentValidator<GrantTableRequest> {
|
||||
|
||||
public ProjectTableRequestValidator() {
|
||||
public GrantTableRequestValidator() {
|
||||
ruleFor(x -> x.getOffset()).compareAs(x -> 0, (leftItem, rightItem) -> leftItem < rightItem)
|
||||
.withName("offset").withMessage("projectTableRequest.offset.negative");
|
||||
.withName("offset").withMessage("grantTableRequest.offset.negative");
|
||||
|
||||
ruleFor(x -> x.getLength()).compareAs(x -> 0, (leftItem, rightItem) -> leftItem < rightItem)
|
||||
.withName("length").withMessage("projectTableRequest.length.negative");
|
||||
.withName("length").withMessage("grantTableRequest.length.negative");
|
||||
|
||||
ruleFor(x -> x.getCriteria().getPeriodStart())
|
||||
.compareAs(x -> x.getCriteria().getPeriodEnd(), (leftItem, rightItem) -> rightItem.before(leftItem))
|
||||
.withName("criteria.periodStart").withMessage("projectTableRequest.periodStart.overlapping")
|
||||
.withName("criteria.periodStart").withMessage("grantTableRequest.periodStart.overlapping")
|
||||
.ruleIf(x -> x.getCriteria() != null && x.getCriteria().getPeriodStart() != null && x.getCriteria().getPeriodEnd() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return ProjectTableRequest.class.equals(aClass);
|
||||
return GrantTableRequest.class.equals(aClass);
|
||||
}
|
||||
|
||||
public static boolean supportsType(Class<?> clazz) {
|
||||
return ProjectTableRequest.class.equals(clazz);
|
||||
return GrantTableRequest.class.equals(clazz);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package eu.eudat.models.validators;
|
||||
|
||||
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
||||
import eu.eudat.models.data.project.Project;
|
||||
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
|
||||
@Component("projectModelValidator")
|
||||
public class ProjectModelValidator extends FluentValidator<Project> {
|
||||
|
||||
public ProjectModelValidator() {
|
||||
ruleFor(x -> x.getType()).compareAs((x -> eu.eudat.data.entities.Project.ProjectType.EXTERNAL.getValue()), (leftItem, rightItem) -> leftItem == rightItem)
|
||||
.withName("type").withMessage("project.external.edit");
|
||||
ruleFor(x -> x.getStartDate()).compareAs((x -> x.getEndDate()), (leftItem, rightItem) -> leftItem.after(rightItem))
|
||||
.withName("startDate").withMessage("project.startDate.overlapping")
|
||||
.ruleIf(x -> x.getStartDate() != null && x.getEndDate() != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return Project.class.equals(aClass);
|
||||
}
|
||||
|
||||
public static boolean supportsType(Class<?> aClass) {
|
||||
return Project.class.equals(aClass);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ package eu.eudat.types.searchbar;
|
|||
* Created by ikalyvas on 7/26/2018.
|
||||
*/
|
||||
public enum SearchBarItemType {
|
||||
DATASET(0), DMP(1), PROJECT(2);
|
||||
DATASET(0), DMP(1), GRANT(2);
|
||||
|
||||
private Integer value;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public enum SearchBarItemType {
|
|||
case 1:
|
||||
return DMP;
|
||||
case 2:
|
||||
return PROJECT;
|
||||
return GRANT;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Search bar item Code");
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
datamanagementplanrequest.length.negative=table length cannot be negative
|
||||
datamanagementplanrequest.offset.negative=table offset cannot be negative
|
||||
projectTableRequest.periodStart.overlapping=Period Start cannot overlap Period End
|
||||
projectTableRequest.offset.negative=table offset cannot be negative
|
||||
projectTableRequest.length.negative=table length cannot be negative
|
||||
grantTableRequest.periodStart.overlapping=Period Start cannot overlap Period End
|
||||
grantTableRequest.offset.negative=table offset cannot be negative
|
||||
grantTableRequest.length.negative=table length cannot be negative
|
||||
datasetprofile.label.null=Dataset Profile Label cannot be null
|
||||
project.startDate.overlapping=Period Start cannot overlap Period
|
||||
dataset.public=Dataset Has Been Made Public
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
datamanagementplanrequest.length.negative=Το μέγεθος του table δεν μπορει να ειναι αρνητικο
|
||||
datamanagementplanrequest.offset.negative=Το offset του table δεν μπορει να ειναι αρνητικο
|
||||
projectTableRequest.periodStart.overlapping=Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
|
||||
projectTableRequest.offset.negative=Το offset του table δεν μπορει να ειναι αρνητικο
|
||||
projectTableRequest.length.negative=Το μέγεθος του table δεν μπορει να ειναι αρνητικο
|
||||
grantTableRequest.periodStart.overlapping=Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
|
||||
grantTableRequest.offset.negative=Το offset του table δεν μπορει να ειναι αρνητικο
|
||||
grantTableRequest.length.negative=Το μέγεθος του table δεν μπορει να ειναι αρνητικο
|
||||
datasetprofile.label.null=Το ονομα του ορισμου ενος Dataset δεν μπορει να ειναι κενο
|
||||
project.startDate.overlapping=Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
|
||||
dataset.public=Το Dataset δημοσιοποιηθηκε σε ολους
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE public."DMP"
|
||||
RENAME COLUMN "Project" to "Grant"
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "Project"
|
||||
RENAME TO "Grant";
|
Loading…
Reference in New Issue