Adds the number of Organisation on Dashboard statistcs.
This commit is contained in:
parent
3e7747455c
commit
b52225308d
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.entities.Organisation;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -10,5 +11,6 @@ import java.util.UUID;
|
|||
public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> {
|
||||
|
||||
QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria);
|
||||
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal);
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Organisation;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
@ -54,6 +55,11 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
|||
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
|
||||
public Organisation find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
@ -13,9 +12,14 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Organisation\"")
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "organisationRecentActivity",
|
||||
attributeNodes = {@NamedAttributeNode(value = "dmps")}
|
||||
)
|
||||
})
|
||||
public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
|
||||
|
||||
@Id
|
||||
|
@ -41,19 +45,16 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||
private String definition;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DMPOrganisation\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<DMP> dMPs;
|
||||
|
||||
private Set<DMP> dmps;
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date created = null;
|
||||
|
@ -66,37 +67,27 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -104,7 +95,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
@ -112,7 +102,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
@ -120,7 +109,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
@ -128,7 +116,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
@ -136,20 +123,17 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
|||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Set<DMP> getdMPs() {
|
||||
return dMPs;
|
||||
public Set<DMP> getDmps() {
|
||||
return dmps;
|
||||
}
|
||||
|
||||
public void setdMPs(Set<DMP> dMPs) {
|
||||
this.dMPs = dMPs;
|
||||
public void setDmps(Set<DMP> dmps) {
|
||||
this.dmps = dmps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(Organisation entity) {
|
||||
|
||||
|
|
|
@ -2,9 +2,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.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.entities.UserInfo;
|
||||
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
||||
|
@ -58,6 +60,7 @@ public class DashBoardManager {
|
|||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
OrganisationDao organisationRepository = databaseRepository.getOrganisationDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
|
@ -65,6 +68,7 @@ public class DashBoardManager {
|
|||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||
dataManagementPlanCriteria.setAllVersions(false);
|
||||
ProjectCriteria projectCriteria = new ProjectCriteria();
|
||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
||||
|
||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), user).countAsync()
|
||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
||||
|
@ -72,8 +76,10 @@ public class DashBoardManager {
|
|||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||
CompletableFuture projectFuture = projectRepository.getAuthenticated(projectRepository.getWithCriteria(projectCriteria), user).countAsync()
|
||||
.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;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ public class DashBoardStatistics {
|
|||
private Long totalDataManagementPlanCount;
|
||||
private Long totalProjectCount;
|
||||
private Long totalDataSetCount;
|
||||
private Long totalOrganisationCount;
|
||||
|
||||
|
||||
public Long getTotalDataManagementPlanCount() {
|
||||
|
@ -30,5 +31,11 @@ public class DashBoardStatistics {
|
|||
this.totalDataSetCount = totalDataSetCount;
|
||||
}
|
||||
|
||||
|
||||
public Long getTotalOrganisationCount() {
|
||||
return totalOrganisationCount;
|
||||
}
|
||||
|
||||
public void setTotalOrganisationCount(Long totalOrganisationCount) {
|
||||
this.totalOrganisationCount = totalOrganisationCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,5 @@ export interface DashboardStatisticsModel {
|
|||
totalDataManagementPlanCount: number;
|
||||
totalProjectCount: number;
|
||||
totalDataSetCount: number;
|
||||
totalOrganisationCount: number;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue