Adds the criteria on DMP listing and refactors the backend userInfo.
This commit is contained in:
parent
1b340ac1f7
commit
11c1ac33cf
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Organisation;
|
|
||||||
import eu.eudat.data.entities.Project;
|
import eu.eudat.data.entities.Project;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -15,6 +15,8 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
private boolean allVersions;
|
private boolean allVersions;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
private List<String> organisations;
|
||||||
|
private Integer role;
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
public Date getPeriodStart() {
|
||||||
return periodStart;
|
return periodStart;
|
||||||
|
@ -57,4 +59,18 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
public void setStatus(Integer status) {
|
public void setStatus(Integer status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getOrganisations() {
|
||||||
|
return organisations;
|
||||||
|
}
|
||||||
|
public void setOrganisations(List<String> organisations) {
|
||||||
|
this.organisations = organisations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
public void setRole(Integer role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,12 @@ package eu.eudat.data.dao.criteria;
|
||||||
import eu.eudat.data.entities.Organisation;
|
import eu.eudat.data.entities.Organisation;
|
||||||
|
|
||||||
public class OrganisationCriteria extends Criteria<Organisation> {
|
public class OrganisationCriteria extends Criteria<Organisation> {
|
||||||
|
private String labelLike;
|
||||||
|
|
||||||
|
public String getLabelLike() {
|
||||||
|
return labelLike;
|
||||||
|
}
|
||||||
|
public void setLabelLike(String labelLike) {
|
||||||
|
this.labelLike = labelLike;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
|
@ -15,6 +16,6 @@ public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
||||||
|
|
||||||
QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
||||||
|
|
||||||
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UserInfo principal);
|
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principalId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -46,19 +48,28 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||||
if (criteria.getStatus() != null) {
|
if (criteria.getStatus() != null) {
|
||||||
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()){
|
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||||
}
|
} else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
|
||||||
else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()){
|
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (criteria.getRole() != null) {
|
||||||
|
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())){
|
||||||
|
query.where((builder, root) -> builder.equal(root.join("users").get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
|
||||||
|
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())){
|
||||||
|
query.where((builder, root) -> builder.equal(root.join("users").get("role"), UserDMP.UserDMPRoles.USER.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
|
||||||
|
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
|
||||||
|
}
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UserInfo principal) {
|
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal) {
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creator"), principal), builder.isMember(principal, root.get("users"))));
|
query.where((builder, root) -> builder.or(builder.equal(root.get("creator").get("id"), principal), builder.equal(root.join("users", JoinType.LEFT).get("id"), principal)));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -73,7 +74,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||||
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||||
else {
|
else {
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))));
|
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.equal(root.join("dmp").join("users", JoinType.LEFT).get("id"), principal.getId())));
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
||||||
QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class);
|
QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class);
|
||||||
if (criteria.getLike() != null)
|
if (criteria.getLike() != null)
|
||||||
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
|
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
|
||||||
|
if (criteria.getLabelLike() != null) {
|
||||||
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
||||||
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,8 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps", JoinType.LEFT).get("users")))).distinct();
|
//query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps", JoinType.LEFT).get("users")))).distinct();
|
||||||
|
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps").join("users", JoinType.LEFT).get("id"), principal.getId()))).distinct();
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,10 @@ import java.util.stream.Collectors;
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "dataManagementPlanListingModel",
|
name = "dataManagementPlanListingModel",
|
||||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
|
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
|
||||||
@NamedAttributeNode("project"), @NamedAttributeNode("users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")}
|
@NamedAttributeNode("project"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
|
||||||
|
subgraphs = {
|
||||||
|
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
||||||
|
}
|
||||||
),
|
),
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "fullyDetailed",
|
name = "fullyDetailed",
|
||||||
|
@ -118,12 +121,13 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
private Set<Researcher> researchers;
|
private Set<Researcher> researchers;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
||||||
|
/*@OneToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "\"UserDMP\"",
|
@JoinTable(name = "\"UserDMP\"",
|
||||||
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
|
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
|
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
|
||||||
)
|
)*/
|
||||||
private Set<UserInfo> users;
|
private Set<UserDMP> users;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
|
@ -151,66 +155,48 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UserInfo getCreator() {
|
public UserInfo getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCreator(UserInfo creator) {
|
public void setCreator(UserInfo creator) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Short getStatus() {
|
public Short getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setStatus(Short status) {
|
public void setStatus(Short status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Date created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Date getModified() {
|
public Date getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
public void setModified(Date modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<UserDMP> getUsers() {
|
||||||
public Set<UserInfo> getUsers() {
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
public void setUsers(Set<UserDMP> users) {
|
||||||
public void setUsers(Set<UserInfo> users) {
|
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(UUID id) {
|
public void setId(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +204,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public UUID getGroupId() {
|
public UUID getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupId(UUID groupId) {
|
public void setGroupId(UUID groupId) {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +211,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +218,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public Integer getVersion() {
|
public Integer getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(Integer version) {
|
public void setVersion(Integer version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +225,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public Project getProject() {
|
public Project getProject() {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProject(Project project) {
|
public void setProject(Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +232,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public String getAssociatedDmps() {
|
public String getAssociatedDmps() {
|
||||||
return associatedDmps;
|
return associatedDmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAssociatedDmps(String associatedDmps) {
|
public void setAssociatedDmps(String associatedDmps) {
|
||||||
this.associatedDmps = associatedDmps;
|
this.associatedDmps = associatedDmps;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +239,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public DMPProfile getProfile() {
|
public DMPProfile getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfile(DMPProfile profile) {
|
public void setProfile(DMPProfile profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +246,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public Set<Dataset> getDataset() {
|
public Set<Dataset> getDataset() {
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataset(Set<Dataset> dataset) {
|
public void setDataset(Set<Dataset> dataset) {
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +253,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public Set<Organisation> getOrganisations() {
|
public Set<Organisation> getOrganisations() {
|
||||||
return organisations;
|
return organisations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrganisations(Set<Organisation> organisations) {
|
public void setOrganisations(Set<Organisation> organisations) {
|
||||||
this.organisations = organisations;
|
this.organisations = organisations;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +260,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public Set<Researcher> getResearchers() {
|
public Set<Researcher> getResearchers() {
|
||||||
return researchers;
|
return researchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResearchers(Set<Researcher> researchers) {
|
public void setResearchers(Set<Researcher> researchers) {
|
||||||
this.researchers = researchers;
|
this.researchers = researchers;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +267,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public String getProperties() {
|
public String getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(String properties) {
|
public void setProperties(String properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +274,6 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
public String getDmpProperties() {
|
public String getDmpProperties() {
|
||||||
return dmpProperties;
|
return dmpProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpProperties(String dmpProperties) {
|
public void setDmpProperties(String dmpProperties) {
|
||||||
this.dmpProperties = dmpProperties;
|
this.dmpProperties = dmpProperties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package eu.eudat.data.query.items.table.organisations;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||||
|
import eu.eudat.data.entities.Organisation;
|
||||||
|
import eu.eudat.data.query.PaginationService;
|
||||||
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class OrganisationsTableRequest extends TableQuery<OrganisationCriteria, Organisation, UUID> {
|
||||||
|
@Override
|
||||||
|
public QueryableList<Organisation> applyCriteria() {
|
||||||
|
QueryableList<Organisation> query = this.getQuery();
|
||||||
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
|
||||||
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<Organisation> applyPaging(QueryableList<Organisation> items) {
|
||||||
|
return PaginationService.applyPaging(items, this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,22 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
||||||
|
import eu.eudat.logic.managers.OrganisationsManager;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import eu.eudat.models.data.dmp.Organisation;
|
||||||
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
||||||
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -21,10 +27,12 @@ import java.util.Map;
|
||||||
public class Organisations extends BaseController {
|
public class Organisations extends BaseController {
|
||||||
|
|
||||||
private OrganisationsExternalSourcesModel organisationsExternalSourcesModel;
|
private OrganisationsExternalSourcesModel organisationsExternalSourcesModel;
|
||||||
|
private OrganisationsManager organisationsManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
public Organisations(ApiContext apiContext, OrganisationsExternalSourcesModel organisationsExternalSourcesModel) {
|
public Organisations(ApiContext apiContext, OrganisationsExternalSourcesModel organisationsExternalSourcesModel, OrganisationsManager organisationsManager) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
this.organisationsExternalSourcesModel = organisationsExternalSourcesModel;
|
this.organisationsExternalSourcesModel = organisationsExternalSourcesModel;
|
||||||
|
this.organisationsManager = organisationsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json")
|
||||||
|
@ -37,5 +45,11 @@ public class Organisations extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/internal/organisations"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception{
|
||||||
|
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPagedOrganisations(organisationsTableRequest, principal);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DashBoardManager {
|
||||||
ProjectCriteria projectCriteria = new ProjectCriteria();
|
ProjectCriteria projectCriteria = new ProjectCriteria();
|
||||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
||||||
|
|
||||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), user).countAsync()
|
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId()).countAsync()
|
||||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
||||||
CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user).countAsync()
|
CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user).countAsync()
|
||||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||||
|
@ -97,7 +97,7 @@ public class DashBoardManager {
|
||||||
ProjectCriteria projectCriteria = new ProjectCriteria();
|
ProjectCriteria projectCriteria = new ProjectCriteria();
|
||||||
RecentActivityDataBuilder recentActivityDataBuilder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(RecentActivityDataBuilder.class);
|
RecentActivityDataBuilder recentActivityDataBuilder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(RecentActivityDataBuilder.class);
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), user)
|
CompletableFuture<List<RecentActivityData>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId())
|
||||||
.withHint("dmpRecentActivity")
|
.withHint("dmpRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
|
@ -131,7 +131,7 @@ public class DashBoardManager {
|
||||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||||
|
|
||||||
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
||||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), user)
|
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), principal.getId())
|
||||||
.withHint("dmpRecentActivity")
|
.withHint("dmpRecentActivity")
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
|
|
|
@ -35,6 +35,7 @@ import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -81,10 +82,9 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||||
UserInfo userInfo = new UserInfo();
|
UUID principalID = principal.getId();
|
||||||
userInfo.setId(principal.getId());
|
|
||||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class));
|
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class));
|
||||||
QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userInfo);
|
QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID);
|
||||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||||
|
|
||||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
||||||
|
@ -96,17 +96,17 @@ public class DataManagementPlanManager {
|
||||||
.selectAsync(item -> {
|
.selectAsync(item -> {
|
||||||
item.setDataset(
|
item.setDataset(
|
||||||
item.getDataset().stream()
|
item.getDataset().stream()
|
||||||
.filter(dataset -> dataset.getDmp().getCreator().getId().equals(userInfo.getId())
|
.filter(dataset -> dataset.getDmp().getCreator().getId().equals(principalID)
|
||||||
|| dataset.isPublic()
|
|| dataset.isPublic()
|
||||||
|| dataset.getDmp().getUsers().stream()
|
|| dataset.getDmp().getUsers().stream()
|
||||||
.filter(x -> x.getId().equals(userInfo.getId())).collect(Collectors.toList()).size() > 0).collect(Collectors.toSet()));
|
.filter(x -> x.getUser().getId().equals(principalID)).collect(Collectors.toList()).size() > 0).collect(Collectors.toSet()));
|
||||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||||
})
|
})
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
itemsFuture = pagedItems
|
itemsFuture = pagedItems
|
||||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModel(item) )
|
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModel(item))
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,10 +281,9 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DataManagementPlan> getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria, Principal principal) throws IllegalAccessException, InstantiationException {
|
public List<DataManagementPlan> getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||||
UserInfo userInfo = new UserInfo();
|
UUID principalID = principal.getId();
|
||||||
userInfo.setId(principal.getId());
|
|
||||||
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlan.class));
|
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlan.class));
|
||||||
QueryableList<DMP> authenticatedItems = dmpsRepository.getAuthenticated(items, userInfo);
|
QueryableList<DMP> authenticatedItems = dmpsRepository.getAuthenticated(items, principalID);
|
||||||
List<eu.eudat.models.data.dmp.DataManagementPlan> datamanagementPlans = authenticatedItems.select(item -> new DataManagementPlan().fromDataModel(item));
|
List<eu.eudat.models.data.dmp.DataManagementPlan> datamanagementPlans = authenticatedItems.select(item -> new DataManagementPlan().fromDataModel(item));
|
||||||
return datamanagementPlans;
|
return datamanagementPlans;
|
||||||
}
|
}
|
||||||
|
@ -723,7 +722,7 @@ public class DataManagementPlanManager {
|
||||||
researchers.add(researcher);
|
researchers.add(researcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<eu.eudat.models.data.userinfo.UserInfo> associatedUsers = new LinkedList<>();
|
List<UserListingModel> associatedUsers = new LinkedList<>();
|
||||||
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
|
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
|
||||||
|
|
||||||
// Sets properties.
|
// Sets properties.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.models.data.invitation.Invitation;
|
import eu.eudat.models.data.invitation.Invitation;
|
||||||
|
@ -12,6 +13,7 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -31,9 +33,15 @@ public class InvitationsManager {
|
||||||
principalUser.setId(principal.getId());
|
principalUser.setId(principal.getId());
|
||||||
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
||||||
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList());
|
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList());
|
||||||
|
List<UserDMP> userInfoToUserDmp = new LinkedList<>();
|
||||||
|
for (UserInfo userInfo : alreadySignedInUsersEntities) {
|
||||||
|
UserDMP userDMP = new UserDMP();
|
||||||
|
userDMP.setUser(userInfo);
|
||||||
|
userInfoToUserDmp.add(userDMP);
|
||||||
|
}
|
||||||
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
||||||
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
|
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
|
||||||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
|
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserInfoInvitationModel> getUsers(UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
public List<UserInfoInvitationModel> getUsers(UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||||
|
@ -48,8 +56,10 @@ public class InvitationsManager {
|
||||||
throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
||||||
if (invitation.getAcceptedInvitation()) throw new UnauthorisedException("This Url Has Expired");
|
if (invitation.getAcceptedInvitation()) throw new UnauthorisedException("This Url Has Expired");
|
||||||
UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
|
UserDMP userDMP = new UserDMP();
|
||||||
|
userDMP.setUser(invitedUser);
|
||||||
DMP datamanagementPlan = invitation.getDmp();
|
DMP datamanagementPlan = invitation.getDmp();
|
||||||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), invitedUser, datamanagementPlan);
|
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);
|
||||||
invitation.setAcceptedInvitation(true);
|
invitation.setAcceptedInvitation(true);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
||||||
return datamanagementPlan.getId();
|
return datamanagementPlan.getId();
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||||
|
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||||
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
||||||
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
import eu.eudat.models.data.dmp.Organisation;
|
||||||
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class OrganisationsManager {
|
||||||
|
|
||||||
|
private ApiContext apiContext;
|
||||||
|
private DatabaseRepository databaseRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public OrganisationsManager(ApiContext apiContext) {
|
||||||
|
this.apiContext = apiContext;
|
||||||
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTableData<Organisation> getPagedOrganisations(OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception {
|
||||||
|
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||||
|
userInfo.setId(principal.getId());
|
||||||
|
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
|
||||||
|
|
||||||
|
QueryableList<eu.eudat.data.entities.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
|
||||||
|
QueryableList<eu.eudat.data.entities.Organisation> authItems = organisationDao.getAuthenticated(items, userInfo);
|
||||||
|
QueryableList<eu.eudat.data.entities.Organisation> pagedItems = PaginationManager.applyPaging(authItems, organisationsTableRequest);
|
||||||
|
|
||||||
|
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
||||||
|
organisationDataTableData.setData(org);
|
||||||
|
organisationDataTableData.setTotalCount(pagedItems.count());
|
||||||
|
return organisationDataTableData;
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,7 +64,7 @@ public class ProjectManager {
|
||||||
if (fieldsGroup.equals("listing")) {
|
if (fieldsGroup.equals("listing")) {
|
||||||
projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).selectAsync(item -> {
|
projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).selectAsync(item -> {
|
||||||
item.setDmps(item.getDmps().stream().filter(
|
item.setDmps(item.getDmps().stream().filter(
|
||||||
dmp -> dmp.getCreator().getId().equals(principal.getId()) || dmp.getUsers().stream().filter(user -> user.getId().equals(principal.getId())).collect(Collectors.toList()).size() > 0)
|
dmp -> dmp.getCreator().getId().equals(principal.getId()) || dmp.getUsers().stream().filter(user -> user.getUser().getId().equals(principal.getId())).collect(Collectors.toList()).size() > 0)
|
||||||
.collect(Collectors.groupingBy(DMP::getGroupId))
|
.collect(Collectors.groupingBy(DMP::getGroupId))
|
||||||
.values().stream()
|
.values().stream()
|
||||||
.map(dmps -> dmps.stream().reduce((first, second) -> {
|
.map(dmps -> dmps.stream().reduce((first, second) -> {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class UserManager {
|
||||||
public UserProfile getSingle(UUID userId) throws Exception {
|
public UserProfile getSingle(UUID userId) throws Exception {
|
||||||
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
|
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
|
||||||
UserProfile profile = new UserProfile().fromDataModel(user);
|
UserProfile profile = new UserProfile().fromDataModel(user);
|
||||||
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), user).take(5).toList();
|
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), userId).take(5).toList();
|
||||||
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
|
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
public interface InvitationService {
|
public interface InvitationService {
|
||||||
void assignToDmp(DMPDao dmpDao, List<eu.eudat.data.entities.UserInfo> users, DMP dmp);
|
void assignToDmp(DMPDao dmpDao, List<eu.eudat.data.entities.UserDMP> users, DMP dmp);
|
||||||
|
|
||||||
void assignToDmp(DMPDao dmpDao, eu.eudat.data.entities.UserInfo user, DMP dmp);
|
void assignToDmp(DMPDao dmpDao, eu.eudat.data.entities.UserDMP user, DMP dmp);
|
||||||
|
|
||||||
void createInvitations(InvitationDao invitationDao, MailService mailService, List<eu.eudat.data.entities.UserInfo> users, DMP dmp, eu.eudat.data.entities.UserInfo creator) throws MessagingException;
|
void createInvitations(InvitationDao invitationDao, MailService mailService, List<eu.eudat.data.entities.UserInfo> users, DMP dmp, eu.eudat.data.entities.UserInfo creator) throws MessagingException;
|
||||||
|
|
||||||
|
|
|
@ -36,15 +36,15 @@ public class InvitationServiceImpl implements InvitationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignToDmp(DMPDao dmpDao, List<eu.eudat.data.entities.UserInfo> users, DMP dmp) {
|
public void assignToDmp(DMPDao dmpDao, List<eu.eudat.data.entities.UserDMP> users, DMP dmp) {
|
||||||
for (eu.eudat.data.entities.UserInfo user : users) {
|
for (eu.eudat.data.entities.UserDMP user : users) {
|
||||||
dmp.getUsers().add(user);
|
dmp.getUsers().add(user);
|
||||||
}
|
}
|
||||||
dmpDao.createOrUpdate(dmp);
|
dmpDao.createOrUpdate(dmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignToDmp(DMPDao dmpDao, eu.eudat.data.entities.UserInfo user, DMP dmp) {
|
public void assignToDmp(DMPDao dmpDao, eu.eudat.data.entities.UserDMP user, DMP dmp) {
|
||||||
if (!dmp.getUsers().stream().map(x -> x.getId()).collect(Collectors.toList()).contains(user.getId())) {
|
if (!dmp.getUsers().stream().map(x -> x.getId()).collect(Collectors.toList()).contains(user.getId())) {
|
||||||
dmp.getUsers().add(user);
|
dmp.getUsers().add(user);
|
||||||
dmpDao.createOrUpdate(dmp);
|
dmpDao.createOrUpdate(dmp);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.dmp;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||||
|
@ -11,6 +12,7 @@ import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
import eu.eudat.models.data.userinfo.UserInfo;
|
import eu.eudat.models.data.userinfo.UserInfo;
|
||||||
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -34,7 +36,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
private eu.eudat.models.data.project.Project project;
|
private eu.eudat.models.data.project.Project project;
|
||||||
private List<Organisation> organisations;
|
private List<Organisation> organisations;
|
||||||
private List<Researcher> researchers;
|
private List<Researcher> researchers;
|
||||||
private List<UserInfo> associatedUsers;
|
private List<UserListingModel> associatedUsers;
|
||||||
private DataManagementPlanProfile definition;
|
private DataManagementPlanProfile definition;
|
||||||
private eu.eudat.models.data.userinfo.UserInfo creator;
|
private eu.eudat.models.data.userinfo.UserInfo creator;
|
||||||
private Date created;
|
private Date created;
|
||||||
|
@ -73,11 +75,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserInfo> getAssociatedUsers() {
|
public List<UserListingModel> getAssociatedUsers() {
|
||||||
return associatedUsers;
|
return associatedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAssociatedUsers(List<UserInfo> associatedUsers) {
|
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
|
||||||
this.associatedUsers = associatedUsers;
|
this.associatedUsers = associatedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +236,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserInfo().fromDataModel(item)).collect(Collectors.toList());
|
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +273,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||||
if (this.dynamicFields != null)
|
if (this.dynamicFields != null)
|
||||||
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
||||||
dataManagementPlanEntity.setUsers(new HashSet<>(this.associatedUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
|
||||||
|
List<UserDMP> userDMPList = new LinkedList<>();
|
||||||
|
for(UserListingModel userListingModel: this.associatedUsers) {
|
||||||
|
UserDMP userDMP = new UserDMP();
|
||||||
|
userDMP.setUser(userListingModel.toDataModel());
|
||||||
|
userDMPList.add(userDMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
dataManagementPlanEntity.setUsers((Set<UserDMP>) userDMPList);
|
||||||
return dataManagementPlanEntity;
|
return dataManagementPlanEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.Dataset;
|
import eu.eudat.models.data.dataset.Dataset;
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
|
@ -26,7 +27,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
private eu.eudat.models.data.project.Project project;
|
private eu.eudat.models.data.project.Project project;
|
||||||
private List<Organisation> organisations;
|
private List<Organisation> organisations;
|
||||||
private List<Researcher> researchers;
|
private List<Researcher> researchers;
|
||||||
private List<UserInfo> associatedUsers;
|
private List<UserDMP> associatedUsers;
|
||||||
private eu.eudat.models.data.userinfo.UserInfo creator;
|
private eu.eudat.models.data.userinfo.UserInfo creator;
|
||||||
private Date created;
|
private Date created;
|
||||||
private List<Dataset> datasets;
|
private List<Dataset> datasets;
|
||||||
|
@ -111,11 +112,11 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
this.researchers = researchers;
|
this.researchers = researchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserInfo> getAssociatedUsers() {
|
public List<UserDMP> getAssociatedUsers() {
|
||||||
return associatedUsers;
|
return associatedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAssociatedUsers(List<UserInfo> associatedUsers) {
|
public void setAssociatedUsers(List<UserDMP> associatedUsers) {
|
||||||
this.associatedUsers = associatedUsers;
|
this.associatedUsers = associatedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
public DMP toDataModel() throws Exception {
|
public DMP toDataModel() throws Exception {
|
||||||
DMP entity = new DMP();
|
DMP entity = new DMP();
|
||||||
entity.setId(this.id);
|
entity.setId(this.id);
|
||||||
entity.setUsers(new HashSet<>(this.associatedUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
||||||
entity.setDescription(this.description);
|
entity.setDescription(this.description);
|
||||||
entity.setStatus((short) this.status);
|
entity.setStatus((short) this.status);
|
||||||
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
||||||
|
|
|
@ -14,7 +14,6 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +21,6 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +28,6 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +35,6 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(int status) {
|
public void setStatus(int status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
private List<AssociatedProfile> associatedProfiles;
|
private List<AssociatedProfile> associatedProfiles;
|
||||||
private List<UserInfoListingModel> users;
|
private List<UserInfoListingModel> users;
|
||||||
private String description;
|
private String description;
|
||||||
private String projectabbreviation;
|
private String projectAbbreviation;
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -135,11 +135,11 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectabbreviation() {
|
public String getProjectAbbreviation() {
|
||||||
return projectabbreviation;
|
return projectAbbreviation;
|
||||||
}
|
}
|
||||||
public void setProjectabbreviation(String projectabbreviation) {
|
public void setProjectAbbreviation(String projectAbbreviation) {
|
||||||
this.projectabbreviation = projectabbreviation;
|
this.projectAbbreviation = projectAbbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -162,7 +162,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
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.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.projectabbreviation = entity.getProject().getAbbreviation();
|
this.projectAbbreviation = entity.getProject().getAbbreviation();
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserInfoListingModel implements DataModel<UserInfo, UserInfoListingModel> {
|
public class UserInfoListingModel implements DataModel<UserDMP, UserInfoListingModel> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String name;
|
private String name;
|
||||||
|
private Integer role;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -24,15 +26,23 @@ public class UserInfoListingModel implements DataModel<UserInfo, UserInfoListing
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
public void setRole(Integer role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfoListingModel fromDataModel(UserInfo entity) {
|
public UserInfoListingModel fromDataModel(UserDMP entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getUser().getId();
|
||||||
this.name = entity.getName();
|
this.name = entity.getUser().getName();
|
||||||
|
this.role = entity.getRole();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfo toDataModel() throws Exception {
|
public UserDMP toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package eu.eudat.models.data.quickwizard;
|
package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Project;
|
import eu.eudat.data.entities.Project;
|
||||||
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.models.data.userinfo.UserInfo;
|
import eu.eudat.models.data.userinfo.UserInfo;
|
||||||
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -84,7 +86,7 @@ public class DmpQuickWizardModel {
|
||||||
dataManagementPlanEntity.setDescription(this.description);
|
dataManagementPlanEntity.setDescription(this.description);
|
||||||
dataManagementPlanEntity.setProperties(null);
|
dataManagementPlanEntity.setProperties(null);
|
||||||
dataManagementPlanEntity.setCreated(new Date());
|
dataManagementPlanEntity.setCreated(new Date());
|
||||||
List<UserInfo> user = new LinkedList<UserInfo>();
|
List<UserListingModel> user = new LinkedList<>();
|
||||||
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
|
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
userInfo.setId(principal.getId());
|
userInfo.setId(principal.getId());
|
||||||
dataManagementPlanEntity.setAssociatedUsers(user);
|
dataManagementPlanEntity.setAssociatedUsers(user);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import { UserService } from './services/user/user.service';
|
||||||
import { CollectionUtils } from './services/utilities/collection-utils.service';
|
import { CollectionUtils } from './services/utilities/collection-utils.service';
|
||||||
import { TypeUtils } from './services/utilities/type-utils.service';
|
import { TypeUtils } from './services/utilities/type-utils.service';
|
||||||
import { QuickWizardService } from './services/quick-wizard/quick-wizard.service';
|
import { QuickWizardService } from './services/quick-wizard/quick-wizard.service';
|
||||||
|
import { OrganisationService } from './services/organisation/organisation.service';
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
||||||
|
@ -84,6 +85,7 @@ export class CoreServiceModule {
|
||||||
DmpInvitationService,
|
DmpInvitationService,
|
||||||
DatasetExternalAutocompleteService,
|
DatasetExternalAutocompleteService,
|
||||||
QuickWizardService,
|
QuickWizardService,
|
||||||
|
OrganisationService
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export class BaseCriteria {
|
export class BaseCriteria {
|
||||||
public like: string;
|
public like?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import { ProjectListingModel } from "../../model/project/project-listing";
|
import { ProjectListingModel } from "../../model/project/project-listing";
|
||||||
import { BaseCriteria } from "../base-criteria";
|
import { BaseCriteria } from "../base-criteria";
|
||||||
|
import { OrganizationModel } from "../../model/organisation/organization";
|
||||||
|
|
||||||
export class DmpCriteria extends BaseCriteria {
|
export class DmpCriteria extends BaseCriteria {
|
||||||
public projects: ProjectListingModel[] = [];
|
public organisations?: string[] = [];
|
||||||
public groupIds: string[];
|
public projects?: ProjectListingModel[] = [];
|
||||||
public allVersions: boolean;
|
public groupIds?: string[];
|
||||||
|
public allVersions?: boolean;
|
||||||
public status?: number;
|
public status?: number;
|
||||||
|
public role?: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { BaseCriteria } from "../base-criteria";
|
||||||
|
|
||||||
|
export class OrganisationCriteria extends BaseCriteria {
|
||||||
|
public labelLike: string;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { HttpHeaders } from "@angular/common/http";
|
||||||
|
import { BaseHttpService } from "../http/base-http.service";
|
||||||
|
import { environment } from "../../../../environments/environment";
|
||||||
|
import { Observable } from "rxjs/internal/Observable";
|
||||||
|
import { DataTableData } from "../../model/data-table/data-table-data";
|
||||||
|
import { OrganizationModel } from "../../model/organisation/organization";
|
||||||
|
import { OrganisationCriteria } from "../../query/organisation/organisation-criteria";
|
||||||
|
import { DataTableRequest } from "../../model/data-table/data-table-request";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class OrganisationService {
|
||||||
|
|
||||||
|
private actionUrl: string;
|
||||||
|
private headers: HttpHeaders;
|
||||||
|
|
||||||
|
constructor(private http: BaseHttpService) {
|
||||||
|
|
||||||
|
this.actionUrl = environment.Server;
|
||||||
|
|
||||||
|
this.headers = new HttpHeaders();
|
||||||
|
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||||
|
this.headers = this.headers.set('Accept', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchInternalOrganisations(dataTableRequest: DataTableRequest<OrganisationCriteria>): Observable<DataTableData<OrganizationModel>> {
|
||||||
|
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'internal/organisations', dataTableRequest , { headers: this.headers });
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,16 +54,16 @@ export class DashboardComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if (this.isAuthenticated()) {
|
// if (this.isAuthenticated()) {
|
||||||
this.userService.getRecentActivity()
|
// this.userService.getRecentActivity()
|
||||||
.pipe(takeUntil(this._destroyed))
|
// .pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
// .subscribe(response => {
|
||||||
this.datasetActivities = response['recentDatasetActivities'];
|
// this.datasetActivities = response['recentDatasetActivities'];
|
||||||
this.dmpActivities = response['recentDmpActivities'];
|
// this.dmpActivities = response['recentDmpActivities'];
|
||||||
this.projectActivities = response['recentProjectActivities'];
|
// this.projectActivities = response['recentProjectActivities'];
|
||||||
this.organisationActivities = response['totalOrganisationCount'];
|
// this.organisationActivities = response['totalOrganisationCount'];
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
// this.projectAutoCompleteConfiguration = {
|
// this.projectAutoCompleteConfiguration = {
|
||||||
// filterFn: this.searchProject.bind(this),
|
// filterFn: this.searchProject.bind(this),
|
||||||
|
|
|
@ -53,10 +53,10 @@
|
||||||
<!-- Role Filter -->
|
<!-- Role Filter -->
|
||||||
<div *ngIf="showProject" class="col-10 gray-container">
|
<div *ngIf="showProject" class="col-10 gray-container">
|
||||||
<h6 class="category-title">{{ 'DATASET-PROFILE-LISTING.COLUMNS.ROLE' | translate }}</h6>
|
<h6 class="category-title">{{ 'DATASET-PROFILE-LISTING.COLUMNS.ROLE' | translate }}</h6>
|
||||||
<mat-radio-group aria-label="Select an option">
|
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('role')">
|
||||||
<mat-list-item><mat-radio-button value="1">{{ 'TYPES.DATASET-ROLE.ANY' | translate }}</mat-radio-button></mat-list-item>
|
<mat-list-item><mat-radio-button value="null">{{ 'TYPES.DATASET-ROLE.ANY' | translate }}</mat-radio-button></mat-list-item>
|
||||||
<mat-list-item><mat-radio-button value="2">{{ 'TYPES.DATASET-ROLE.OWNER' | translate }}</mat-radio-button></mat-list-item>
|
<mat-list-item><mat-radio-button value="0">{{ 'TYPES.DATASET-ROLE.OWNER' | translate }}</mat-radio-button></mat-list-item>
|
||||||
<mat-list-item><mat-radio-button value="3">{{ 'TYPES.DATASET-ROLE.MEMBER' | translate }}</mat-radio-button></mat-list-item>
|
<mat-list-item><mat-radio-button value="1">{{ 'TYPES.DATASET-ROLE.MEMBER' | translate }}</mat-radio-button></mat-list-item>
|
||||||
</mat-radio-group>
|
</mat-radio-group>
|
||||||
</div>
|
</div>
|
||||||
<!-- End of Role Filter -->
|
<!-- End of Role Filter -->
|
||||||
|
|
|
@ -17,6 +17,10 @@ import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.compone
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { ExternalSourceItemModel } from '../../../../core/model/external-sources/external-source-item';
|
import { ExternalSourceItemModel } from '../../../../core/model/external-sources/external-source-item';
|
||||||
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
|
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
|
||||||
|
import { OrganisationService } from '../../../../core/services/organisation/organisation.service';
|
||||||
|
import { OrganisationCriteria } from '../../../../core/query/organisation/organisation-criteria';
|
||||||
|
import { OrganizationModel } from '../../../../core/model/organisation/organization';
|
||||||
|
import { DataTableData } from '../../../../core/model/data-table/data-table-data';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-criteria-component',
|
selector: 'app-dmp-criteria-component',
|
||||||
|
@ -37,7 +41,8 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
||||||
like: new FormControl(),
|
like: new FormControl(),
|
||||||
projects: new FormControl(),
|
projects: new FormControl(),
|
||||||
status: new FormControl(),
|
status: new FormControl(),
|
||||||
organisations: new FormControl()
|
organisations: new FormControl(),
|
||||||
|
role: new FormControl
|
||||||
});
|
});
|
||||||
|
|
||||||
projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||||
|
@ -60,17 +65,19 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
||||||
private dmpService: DmpService,
|
private dmpService: DmpService,
|
||||||
public formBuilder: FormBuilder,
|
public formBuilder: FormBuilder,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private externalSourcesService: ExternalSourcesService
|
private organisationService: OrganisationService
|
||||||
) {
|
) {
|
||||||
super(new ValidationErrorModel());
|
super(new ValidationErrorModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
this.formGroup.get('role').valueChanges
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(x => this.controlModified());
|
||||||
this.formGroup.get('organisations').valueChanges
|
this.formGroup.get('organisations').valueChanges
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(x => this.controlModified());
|
.subscribe(x => this.controlModified());
|
||||||
this.formGroup.get('status').valueChanges
|
this.formGroup.get('status').valueChanges
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(x => this.controlModified());
|
.subscribe(x => this.controlModified());
|
||||||
|
@ -111,11 +118,16 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
||||||
return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data);
|
return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
|
filterOrganisations(value: string) {
|
||||||
this.filteredOrganisations = undefined;
|
this.filteredOrganisations = undefined;
|
||||||
this.filteringOrganisationsAsync = true;
|
this.filteringOrganisationsAsync = true;
|
||||||
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
const dataTableRequest: DataTableRequest<OrganisationCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||||
|
dataTableRequest.criteria = new OrganisationCriteria();
|
||||||
|
dataTableRequest.criteria.labelLike = value;
|
||||||
|
|
||||||
return this.externalSourcesService.searchDMPOrganizations(value);
|
return this.organisationService.searchInternalOrganisations(dataTableRequest).map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSave(event) {
|
fileSave(event) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<app-dmp-criteria-component [showProject]="showProject" class="col-auto"></app-dmp-criteria-component>
|
<app-dmp-criteria-component [showProject]="showProject" class="col-auto"></app-dmp-criteria-component>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-9 pt-4">
|
<div class="col-9 pt-4">
|
||||||
<mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]" (page)="pageThisEvent($event)" class="top-paginator"></mat-paginator>
|
<!-- <mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]" (page)="pageThisEvent($event)" class="top-paginator"></mat-paginator> -->
|
||||||
<div *ngFor="let item of listingItems; let i = index">
|
<div *ngFor="let item of listingItems; let i = index">
|
||||||
<app-dmp-listing-item-component [showDivider]="i != (listingItems.length - 1)" [dmp]="item" (onClick)="rowClicked($event)"></app-dmp-listing-item-component>
|
<app-dmp-listing-item-component [showDivider]="i != (listingItems.length - 1)" [dmp]="item" (onClick)="rowClicked($event)"></app-dmp-listing-item-component>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -85,7 +85,6 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
|
@ -94,7 +93,15 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
||||||
let fields: Array<string> = new Array();
|
let fields: Array<string> = new Array();
|
||||||
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
||||||
const request = new DataTableRequest<DmpCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
const request = new DataTableRequest<DmpCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this.criteria.formGroup.value;
|
let value = this.criteria.formGroup.value;
|
||||||
|
request.criteria = {
|
||||||
|
projects: value.projects,
|
||||||
|
status: value.status,
|
||||||
|
role: value.role
|
||||||
|
}
|
||||||
|
if (value.organisations) {
|
||||||
|
request.criteria.organisations = value.organisations.map(x => x.id)
|
||||||
|
}
|
||||||
if (this.itemId) {
|
if (this.itemId) {
|
||||||
request.criteria.groupIds = [this.itemId];
|
request.criteria.groupIds = [this.itemId];
|
||||||
request.criteria.allVersions = true;
|
request.criteria.allVersions = true;
|
||||||
|
@ -115,7 +122,6 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
||||||
}
|
}
|
||||||
|
|
||||||
pageThisEvent(event) {
|
pageThisEvent(event) {
|
||||||
console.log(event);
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue