Adds the number of Organisation on Dashboard statistcs.

This commit is contained in:
gkolokythas 2019-04-22 17:19:08 +03:00
parent 3e7747455c
commit b52225308d
6 changed files with 34 additions and 28 deletions

View File

@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.OrganisationCriteria; import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; import java.util.UUID;
@ -10,5 +11,6 @@ import java.util.UUID;
public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> { public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> {
QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria); QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria);
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal);
} }

View File

@ -4,6 +4,7 @@ import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.OrganisationCriteria; import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@ -54,6 +55,11 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }
public QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal) {
query.where((builder, root) -> builder.equal(root.join("dmps").get("creator"), principal));
return query;
}
@Override @Override
public Organisation find(UUID id, String hint) { public Organisation find(UUID id, String hint) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -1,6 +1,5 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
@ -13,9 +12,14 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Organisation\"") @Table(name = "\"Organisation\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "organisationRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps")}
)
})
public class Organisation implements Serializable, DataEntity<Organisation,UUID> { public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
@Id @Id
@ -41,19 +45,16 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPOrganisation\"", @JoinTable(name = "\"DMPOrganisation\"",
joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}, joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")} inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
) )
private Set<DMP> dMPs; private Set<DMP> dmps;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class) @Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@ -66,37 +67,27 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
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 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;
} }
@ -104,7 +95,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,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;
} }
@ -112,7 +102,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
@ -120,7 +109,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getReference() { public String getReference() {
return reference; return reference;
} }
public void setReference(String reference) { public void setReference(String reference) {
this.reference = reference; this.reference = reference;
} }
@ -128,7 +116,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getUri() { public String getUri() {
return uri; return uri;
} }
public void setUri(String uri) { public void setUri(String uri) {
this.uri = uri; this.uri = uri;
} }
@ -136,20 +123,17 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getDefinition() { public String getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(String definition) {
this.definition = definition; this.definition = definition;
} }
public Set<DMP> getdMPs() { public Set<DMP> getDmps() {
return dMPs; return dmps;
} }
public void setDmps(Set<DMP> dmps) {
public void setdMPs(Set<DMP> dMPs) { this.dmps = dmps;
this.dMPs = dMPs;
} }
@Override @Override
public void update(Organisation entity) { public void update(Organisation entity) {

View File

@ -2,9 +2,11 @@ package eu.eudat.logic.managers;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetCriteria; 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.ProjectCriteria;
import eu.eudat.data.dao.entities.DMPDao; import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.DatasetDao; 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.ProjectDao;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder; import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
@ -58,6 +60,7 @@ public class DashBoardManager {
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao(); DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
DatasetDao datasetRepository = databaseRepository.getDatasetDao(); DatasetDao datasetRepository = databaseRepository.getDatasetDao();
ProjectDao projectRepository = databaseRepository.getProjectDao(); ProjectDao projectRepository = databaseRepository.getProjectDao();
OrganisationDao organisationRepository = databaseRepository.getOrganisationDao();
UserInfo user = new UserInfo(); UserInfo user = new UserInfo();
user.setId(principal.getId()); user.setId(principal.getId());
DatasetCriteria datasetCriteria = new DatasetCriteria(); DatasetCriteria datasetCriteria = new DatasetCriteria();
@ -65,6 +68,7 @@ public class DashBoardManager {
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria(); DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
dataManagementPlanCriteria.setAllVersions(false); dataManagementPlanCriteria.setAllVersions(false);
ProjectCriteria projectCriteria = new ProjectCriteria(); ProjectCriteria projectCriteria = new ProjectCriteria();
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), user).countAsync() CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), user).countAsync()
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats)); .whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
@ -72,8 +76,10 @@ public class DashBoardManager {
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats)); .whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
CompletableFuture projectFuture = projectRepository.getAuthenticated(projectRepository.getWithCriteria(projectCriteria), user).countAsync() CompletableFuture projectFuture = projectRepository.getAuthenticated(projectRepository.getWithCriteria(projectCriteria), user).countAsync()
.whenComplete((projectsStats, throwable) -> statistics.setTotalProjectCount(projectsStats)); .whenComplete((projectsStats, throwable) -> statistics.setTotalProjectCount(projectsStats));
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.asQueryable().withHint("organisationRecentActivity"), user).countAsync()
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
CompletableFuture.allOf(dmpFuture, datasetFuture, projectFuture).join(); CompletableFuture.allOf(dmpFuture, datasetFuture, projectFuture, orgnanisationFuture).join();
return statistics; return statistics;
} }

View File

@ -4,6 +4,7 @@ public class DashBoardStatistics {
private Long totalDataManagementPlanCount; private Long totalDataManagementPlanCount;
private Long totalProjectCount; private Long totalProjectCount;
private Long totalDataSetCount; private Long totalDataSetCount;
private Long totalOrganisationCount;
public Long getTotalDataManagementPlanCount() { public Long getTotalDataManagementPlanCount() {
@ -30,5 +31,11 @@ public class DashBoardStatistics {
this.totalDataSetCount = totalDataSetCount; this.totalDataSetCount = totalDataSetCount;
} }
public Long getTotalOrganisationCount() {
return totalOrganisationCount;
}
public void setTotalOrganisationCount(Long totalOrganisationCount) {
this.totalOrganisationCount = totalOrganisationCount;
}
} }

View File

@ -4,4 +4,5 @@ export interface DashboardStatisticsModel {
totalDataManagementPlanCount: number; totalDataManagementPlanCount: number;
totalProjectCount: number; totalProjectCount: number;
totalDataSetCount: number; totalDataSetCount: number;
totalOrganisationCount: number;
} }