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/description-template-type.lookup.ts b/dmp-frontend/src/app/core/query/description-template-type.lookup.ts index 51f263c12..014358572 100644 --- a/dmp-frontend/src/app/core/query/description-template-type.lookup.ts +++ b/dmp-frontend/src/app/core/query/description-template-type.lookup.ts @@ -1,12 +1,14 @@ import { Lookup } from "@common/model/lookup"; import { Guid } from "@common/types/guid"; import { IsActive } from "../common/enum/is-active.enum"; +import { DescriptionTemplateTypeStatus } from "../common/enum/description-template-type-status"; export class DescriptionTemplateTypeLookup extends Lookup implements DescriptionTemplateTypeFilter { ids: Guid[]; excludedIds: Guid[]; like: string; isActive: IsActive[]; + statuses: DescriptionTemplateTypeStatus[]; constructor() { super(); @@ -18,4 +20,5 @@ export interface DescriptionTemplateTypeFilter { excludedIds: Guid[]; like: string; isActive: IsActive[]; + statuses: DescriptionTemplateTypeStatus[]; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/reference.lookup.ts b/dmp-frontend/src/app/core/query/reference.lookup.ts index d721b390a..36d30aef8 100644 --- a/dmp-frontend/src/app/core/query/reference.lookup.ts +++ b/dmp-frontend/src/app/core/query/reference.lookup.ts @@ -10,7 +10,7 @@ export class ReferenceLookup extends Lookup implements ReferenceFilter { like: string; isActive: IsActive[]; sourceTypes: ReferenceSourceType[]; - referenceTypes: ReferenceType[]; + types: ReferenceType[]; constructor() { super(); @@ -23,5 +23,5 @@ export interface ReferenceFilter { like: string; isActive: IsActive[]; sourceTypes: ReferenceSourceType[]; - referenceTypes: ReferenceType[]; + types: ReferenceType[]; } 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/core/services/description-template-type/description-template-type.service.ts b/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts index fc1ce6762..4b8666439 100644 --- a/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts +++ b/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { DescriptionTemplateType, DescriptionTemplateTypePersist } from '@app/core/model/description-template-type/description-template-type'; import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup'; -import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { QueryResult } from '@common/model/query-result'; @@ -80,8 +79,8 @@ export class DescriptionTemplateTypeService { valueAssign: (item: DescriptionTemplateType) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DmpBlueprintLookup { - const lookup: DmpBlueprintLookup = new DmpBlueprintLookup(); + private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateTypeLookup { + const lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } if (ids && ids.length > 0) { lookup.ids = ids; } diff --git a/dmp-frontend/src/app/core/services/reference/reference.service.ts b/dmp-frontend/src/app/core/services/reference/reference.service.ts index 53354fe39..889a44569 100644 --- a/dmp-frontend/src/app/core/services/reference/reference.service.ts +++ b/dmp-frontend/src/app/core/services/reference/reference.service.ts @@ -72,29 +72,29 @@ export class ReferenceService { // // Autocomplete Commons // - public getSingleAutocompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration { + public getSingleAutocompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration { return { - initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes)).pipe(map(x => x.items)), - filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery)).pipe(map(x => x.items)), - getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), + initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, valueAssign: (item: Reference) => item.id, }; }; - public getMultipleAutoCompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration { + public getMultipleAutoCompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration { return { - initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), - filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), - getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, valueAssign: (item: Reference) => item.id, }; } - private buildAutocompleteLookup(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { + private buildAutocompleteLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { const lookup: ReferenceLookup = new ReferenceLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } @@ -106,7 +106,7 @@ export class ReferenceService { nameof(x => x.label) ] }; - if (referenceTypes && referenceTypes.length > 0) { lookup.referenceTypes = referenceTypes; } + if (types && types.length > 0) { lookup.types = types; } if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; } lookup.order = { items: [nameof(x => x.label)] }; if (like) { lookup.like = this.filterService.transformLike(like); } diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts index 0ac92ca54..27f0be56f 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts @@ -27,6 +27,7 @@ import { ImportDescriptionTemplateDialogComponent } from './import-description-t import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status'; import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup'; +import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe'; @Component({ @@ -127,6 +128,12 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent(DataTableDateTimeFormatPipe).withFormat('short') }, + { + prop: nameof(x => x.isActive), + sortable: true, + languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.IS-ACTIVE', + pipe: this.pipeService.getPipe(IsActiveTypePipe) + }, { alwaysShown: true, cellTemplate: this.actions, diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/filters/description-template-listing-filters.component.html b/dmp-frontend/src/app/ui/admin/description-template/listing/filters/description-template-listing-filters.component.html index 8f4029f50..f8931ff0d 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/filters/description-template-listing-filters.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/filters/description-template-listing-filters.component.html @@ -20,6 +20,14 @@ {{'DESCRIPTION-TEMPLATE-LISTING.FILTER.IS-ACTIVE' | translate}} +
+ {{'DESCRIPTION-TEMPLATE-LISTING.FILTER.STATUS' | translate}} + + {{enumUtils.toDescriptionTemplateTypeStatusString(descriptionTemplateStatus)}} + + +
+