Fixes bug on DMP's filter Role.
This commit is contained in:
parent
ebd53e9513
commit
ccb96aeb13
|
@ -8,6 +8,7 @@ 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 java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
||||||
|
@ -16,6 +17,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, UUID principalId);
|
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principalId, List<Integer> roles);
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,7 +5,6 @@ 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;
|
||||||
|
@ -14,110 +13,119 @@ 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.Join;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("dMPDao")
|
@Component("dMPDao")
|
||||||
public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DMPDaoImpl(DatabaseService<DMP> databaseService) {
|
||||||
|
super(databaseService);
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Override
|
||||||
public DMPDaoImpl(DatabaseService<DMP> databaseService) {
|
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
||||||
super(databaseService);
|
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
|
||||||
}
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||||
|
query.where((builder, root) -> builder.or(
|
||||||
@Override
|
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||||
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
|
||||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
|
if (criteria.getPeriodEnd() != null)
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||||
query.where((builder, root) -> builder.or(
|
if (criteria.getPeriodStart() != null)
|
||||||
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||||
builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
|
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||||
if (criteria.getPeriodEnd() != null)
|
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
if (!criteria.getAllVersions())
|
||||||
if (criteria.getPeriodStart() != null)
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
|
||||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||||
if (!criteria.getAllVersions())
|
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
if (criteria.getStatus() != null) {
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
|
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
query.where((builder, root) -> builder.and(builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()), builder.notEqual(root.get("isPublic"), true)));
|
||||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
} else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
|
||||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||||
if (criteria.getStatus() != null) {
|
}
|
||||||
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
}
|
||||||
query.where((builder, root) -> builder.and(builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()), builder.notEqual(root.get("isPublic"), true)));
|
if (criteria.getIsPublic())
|
||||||
} else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
|
query.where(((builder, root) -> builder.equal(root.get("isPublic"), true)));
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
/*if (criteria.getRole() != null) {
|
||||||
}
|
|
||||||
}
|
|
||||||
if (criteria.getIsPublic())
|
|
||||||
query.where(((builder, root) -> builder.equal(root.get("isPublic"), true)));
|
|
||||||
if (criteria.getRole() != null) {
|
|
||||||
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
|
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
|
||||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
|
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
|
||||||
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
|
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
|
||||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
|
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
|
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
|
||||||
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
|
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
|
||||||
}
|
}
|
||||||
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
|
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
|
||||||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||||
}
|
}
|
||||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
||||||
}
|
}
|
||||||
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, UUID principal) {
|
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal, List<Integer> roles) {
|
||||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
|
if (roles != null && !roles.isEmpty()) {
|
||||||
return query;
|
query.where((builder, root) -> {
|
||||||
}
|
Join userJoin = root.join("users", JoinType.LEFT);
|
||||||
|
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal), userJoin.get("role").in(roles));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
return query;
|
||||||
public DMP createOrUpdate(DMP item) {
|
}
|
||||||
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP find(UUID id) {
|
public DMP createOrUpdate(DMP item) {
|
||||||
return getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
public DMP find(UUID id) {
|
||||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
return getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||||
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
}
|
||||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(DMP item) {
|
public QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
||||||
this.getDatabaseService().delete(item);
|
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
||||||
}
|
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
||||||
|
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> asQueryable() {
|
public void delete(DMP item) {
|
||||||
return this.getDatabaseService().getQueryable(DMP.class);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Override
|
||||||
@Override
|
public QueryableList<DMP> asQueryable() {
|
||||||
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
|
return this.getDatabaseService().getQueryable(DMP.class);
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Async
|
||||||
public DMP find(UUID id, String hint) {
|
@Override
|
||||||
throw new UnsupportedOperationException();
|
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
|
||||||
}
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DMP find(UUID id, String hint) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,7 @@ 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.OrganisationDao;
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
import eu.eudat.data.dao.entities.GrantDao;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.data.entities.Dataset;
|
|
||||||
import eu.eudat.data.entities.Grant;
|
|
||||||
import eu.eudat.data.entities.UserInfo;
|
|
||||||
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
@ -79,9 +76,9 @@ public class DashBoardManager {
|
||||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||||
dataManagementPlanCriteria.setAllVersions(false);
|
dataManagementPlanCriteria.setAllVersions(false);
|
||||||
GrantCriteria grantCriteria = new GrantCriteria();
|
GrantCriteria grantCriteria = new GrantCriteria();
|
||||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
|
||||||
|
|
||||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId()).countAsync()
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).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));
|
||||||
|
@ -108,7 +105,8 @@ public class DashBoardManager {
|
||||||
GrantCriteria grantCriteria = new GrantCriteria();
|
GrantCriteria grantCriteria = new GrantCriteria();
|
||||||
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), principal.getId())
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
CompletableFuture<List<RecentActivityData>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles)
|
||||||
.withHint("dmpRecentActivity")
|
.withHint("dmpRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
|
@ -141,8 +139,9 @@ public class DashBoardManager {
|
||||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||||
GrantDao grantRepository = databaseRepository.getGrantDao();
|
GrantDao grantRepository = databaseRepository.getGrantDao();
|
||||||
|
|
||||||
|
List<Integer> roles = new LinkedList<>();
|
||||||
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
||||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), principal.getId())
|
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), principal.getId(), roles)
|
||||||
.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")))
|
||||||
|
|
|
@ -92,7 +92,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 {
|
||||||
UUID principalID = principal.getId();
|
UUID principalID = principal.getId();
|
||||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||||
QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID);
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
if (dataManagementPlanTableRequest.getCriteria().getRole() != null) roles.add(dataManagementPlanTableRequest.getCriteria().getRole());
|
||||||
|
QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID, roles);
|
||||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||||
|
|
||||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
||||||
|
@ -363,7 +365,8 @@ 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 {
|
||||||
UUID principalID = principal.getId();
|
UUID principalID = 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, principalID);
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
QueryableList<DMP> authenticatedItems = dmpsRepository.getAuthenticated(items, principalID, roles);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.dao.entities.UserInfoDao;
|
import eu.eudat.data.dao.entities.UserInfoDao;
|
||||||
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.data.entities.UserRole;
|
import eu.eudat.data.entities.UserRole;
|
||||||
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
||||||
|
@ -28,10 +29,7 @@ import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -66,7 +64,8 @@ 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(), userId).take(5).toList();
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), userId, roles).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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue