diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java index e5b3a01c2..070845bbe 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java @@ -165,7 +165,8 @@ public class ReferenceQuery extends QueryBase { } if (this.like != null && !this.like.isEmpty()) { predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._label), this.like), - queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like) + queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like), + queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._source), this.like) )); } if (this.isActives != null) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/UserQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/UserQuery.java index 731d91fc1..02019b522 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/UserQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/UserQuery.java @@ -4,13 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.DescriptionReferenceEntity; -import eu.eudat.data.UserContactInfoEntity; -import eu.eudat.data.UserEntity; +import eu.eudat.data.*; import eu.eudat.model.User; import eu.eudat.model.PublicUser; -import eu.eudat.model.UserContactInfo; import eu.eudat.query.utils.BuildSubQueryInput; import eu.eudat.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; @@ -36,6 +32,7 @@ public class UserQuery extends QueryBase { private Collection emails; private Collection excludedIds; private Collection isActives; + private UserRoleQuery userRoleQuery; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -113,6 +110,11 @@ public class UserQuery extends QueryBase { return this; } + public UserQuery userRoleSubQuery(UserRoleQuery userRoleSubQuery) { + this.userRoleQuery = userRoleSubQuery; + return this; + } + public UserQuery authorize(EnumSet values) { this.authorize = values; return this; @@ -124,7 +126,8 @@ public class UserQuery extends QueryBase { this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.emails) || - this.isEmpty(this.excludedIds); + this.isEmpty(this.excludedIds) || + this.isFalseQuery(this.userRoleQuery); } @Override @@ -190,6 +193,11 @@ public class UserQuery extends QueryBase { )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userContactInfoSubquery)); } + if (this.userRoleQuery != null) { + Subquery subQuery = queryContext.Query.subquery(this.userRoleQuery.entityClass()); + this.applySubQuery(this.userRoleQuery, queryContext.CriteriaBuilder, subQuery); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(subQuery)); + } if (!predicates.isEmpty()) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/UserLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/UserLookup.java index a14bad5f1..59660cfc7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/UserLookup.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/UserLookup.java @@ -1,15 +1,10 @@ package eu.eudat.query.lookup; -import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.IsActive; -import eu.eudat.elastic.query.DescriptionElasticQuery; -import eu.eudat.elastic.query.InnerObjectDmpElasticQuery; -import eu.eudat.query.DescriptionQuery; import eu.eudat.query.UserQuery; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; -import java.time.Instant; import java.util.List; import java.util.UUID; @@ -22,6 +17,7 @@ public class UserLookup extends Lookup { private List excludedIds; private List isActive; + private UserRoleLookup userRoleSubQuery; public String getLike() { return like; @@ -55,11 +51,28 @@ public class UserLookup extends Lookup { this.isActive = isActive; } + public List getEmails() { + return emails; + } + + public void setEmails(List emails) { + this.emails = emails; + } + + public UserRoleLookup getUserRoleSubQuery() { + return userRoleSubQuery; + } + + public void setUserRoleSubQuery(UserRoleLookup userRoleSubQuery) { + this.userRoleSubQuery = userRoleSubQuery; + } + public UserQuery enrich(QueryFactory queryFactory) { UserQuery query = queryFactory.query(UserQuery.class); if (this.like != null) query.like(this.like); if (this.ids != null) query.ids(this.ids); if (this.emails != null) query.emails(this.emails); + if (this.userRoleSubQuery != null) query.userRoleSubQuery(this.userRoleSubQuery.enrich(queryFactory)); if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.isActive != null) query.isActive(this.isActive); diff --git a/dmp-frontend/src/app/core/query/user-role.lookup.ts b/dmp-frontend/src/app/core/query/user-role.lookup.ts new file mode 100644 index 000000000..e6fb1f5cc --- /dev/null +++ b/dmp-frontend/src/app/core/query/user-role.lookup.ts @@ -0,0 +1,20 @@ +import { Lookup } from "@common/model/lookup"; +import { Guid } from "@common/types/guid"; + +export class UserRoleLookup extends Lookup implements UserRoleFilter { + ids: Guid[]; + excludedIds: Guid[]; + userIds: Guid[]; + roles: string[] + + constructor() { + super(); + } +} + +export interface UserRoleFilter { + ids: Guid[]; + excludedIds: Guid[]; + userIds: Guid[]; + roles: string[]; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/user.lookup.ts b/dmp-frontend/src/app/core/query/user.lookup.ts index 9ecd59e90..ef7533720 100644 --- a/dmp-frontend/src/app/core/query/user.lookup.ts +++ b/dmp-frontend/src/app/core/query/user.lookup.ts @@ -1,6 +1,7 @@ import { Lookup } from '@common/model/lookup'; import { Guid } from '@common/types/guid'; import { IsActive } from '../common/enum/is-active.enum'; +import { UserRoleLookup } from './user-role.lookup'; export class UserLookup extends Lookup implements UserFilter { ids: Guid[]; @@ -8,6 +9,7 @@ export class UserLookup extends Lookup implements UserFilter { like: string; emails: string[]; isActive: IsActive[]; + userRoleSubQuery: UserRoleLookup; constructor() { super(); @@ -20,4 +22,5 @@ export interface UserFilter { like: string; emails: string[]; isActive: IsActive[]; + userRoleSubQuery: UserRoleLookup; } diff --git a/dmp-frontend/src/app/ui/admin/user/listing/filters/user-listing-filters.component.html b/dmp-frontend/src/app/ui/admin/user/listing/filters/user-listing-filters.component.html index fa1e7d2ce..0e15fb761 100644 --- a/dmp-frontend/src/app/ui/admin/user/listing/filters/user-listing-filters.component.html +++ b/dmp-frontend/src/app/ui/admin/user/listing/filters/user-listing-filters.component.html @@ -20,6 +20,14 @@ {{'USER-LISTING.FILTER.IS-ACTIVE' | translate}} +
+ {{'USER-LISTING.FILTER.ROLES' | translate}} + + {{enumUtils.toAppRoleString(appRole)}} + + +
+