From 69f74e48fe31942cb911278229cc670f205951db Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Wed, 26 Jun 2024 12:39:28 +0300 Subject: [PATCH] added description template filter --- .../org/opencdmp/query/DescriptionQuery.java | 12 ++++++++++ .../query/lookup/DescriptionLookup.java | 10 +++++--- .../src/app/core/query/description.lookup.ts | 19 ++++++++------- .../description-listing.component.html | 2 +- .../listing/description-listing.component.ts | 24 +++++++++++++++++-- .../filtering/description-filter.component.ts | 6 ++--- 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java index 6305d70f9..2284e8da2 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java @@ -38,7 +38,10 @@ public class DescriptionQuery extends QueryBase { private DmpQuery dmpQuery; + private DescriptionTemplateQuery descriptionTemplateQuery; + private DescriptionReferenceQuery descriptionReferenceQuery; + private DescriptionTagQuery descriptionTagQuery; private Instant createdAfter; @@ -155,6 +158,11 @@ public class DescriptionQuery extends QueryBase { return this; } + public DescriptionQuery descriptionTemplateSubQuery(DescriptionTemplateQuery subQuery) { + this.descriptionTemplateQuery = subQuery; + return this; + } + public DescriptionQuery descriptionReferenceSubQuery(DescriptionReferenceQuery subQuery) { this.descriptionReferenceQuery = subQuery; return this; @@ -344,6 +352,10 @@ public class DescriptionQuery extends QueryBase { QueryContext subQuery = this.applySubQuery(this.dmpQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(DmpEntity._id)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)).value(subQuery.Query)); } + if (this.descriptionTemplateQuery != null) { + QueryContext subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._id)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._descriptionTemplateId)).value(subQuery.Query)); + } if (this.descriptionReferenceQuery != null) { QueryContext subQuery = this.applySubQuery(this.descriptionReferenceQuery, queryContext, UUID.class, descriptionReferenceEntityRoot -> descriptionReferenceEntityRoot.get(DescriptionReferenceEntity._descriptionId)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(subQuery.Query)); diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java index dd0854229..59867f460 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java @@ -25,6 +25,7 @@ public class DescriptionLookup extends Lookup { private Instant finalizedBefore; private DmpLookup dmpSubQuery; + private DescriptionTemplateLookup descriptionTemplateSubQuery; private DescriptionReferenceLookup descriptionReferenceSubQuery; private DescriptionTagLookup descriptionTagSubQuery; @@ -76,9 +77,11 @@ public class DescriptionLookup extends Lookup { return this.dmpSubQuery; } - public void setDmpSubQuery(DmpLookup dmpSubQuery) { - this.dmpSubQuery = dmpSubQuery; - } + public void setDmpSubQuery(DmpLookup dmpSubQuery) { this.dmpSubQuery = dmpSubQuery; } + + public DescriptionTemplateLookup getDescriptionTemplateSubQuery() { return this.descriptionTemplateSubQuery; } + + public void setDescriptionTemplateSubQuery(DescriptionTemplateLookup dmpSubQuery) { this.descriptionTemplateSubQuery = dmpSubQuery; } public DescriptionReferenceLookup getDescriptionReferenceSubQuery() { return this.descriptionReferenceSubQuery; } @@ -126,6 +129,7 @@ public class DescriptionLookup extends Lookup { if (this.ids != null) query.ids(this.ids); if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.enrich(queryFactory)); + if (this.descriptionTemplateSubQuery != null) query.descriptionTemplateSubQuery(this.descriptionTemplateSubQuery.enrich(queryFactory)); if (this.descriptionReferenceSubQuery != null) query.descriptionReferenceSubQuery(this.descriptionReferenceSubQuery.enrich(queryFactory)); if (this.descriptionTagSubQuery != null) query.descriptionTagSubQuery(this.descriptionTagSubQuery.enrich(queryFactory)); if (this.isActive != null) query.isActive(this.isActive); diff --git a/dmp-frontend/src/app/core/query/description.lookup.ts b/dmp-frontend/src/app/core/query/description.lookup.ts index 5ba9db23e..9220144de 100644 --- a/dmp-frontend/src/app/core/query/description.lookup.ts +++ b/dmp-frontend/src/app/core/query/description.lookup.ts @@ -7,6 +7,7 @@ import { DmpUserRole } from '../common/enum/dmp-user-role'; import { ReferenceType } from '../model/reference-type/reference-type'; import { DescriptionReferenceLookup } from './reference.lookup'; import { DescriptionTagLookup } from './tag.lookup'; +import { DescriptionTemplateLookup } from './description-template.lookup'; export class DescriptionLookup extends Lookup implements DescriptionFilter { ids: Guid[]; @@ -16,16 +17,17 @@ export class DescriptionLookup extends Lookup implements DescriptionFilter { createdBefore: Date; finalizedAfter: Date; finalizedBefore: Date; - dmpSubQuery: DmpLookup; isActive: IsActive[]; statuses: DescriptionStatus[]; - - showAllVersions: boolean; //TODO - descriptionTemplateIds: Guid[]; //TODO - roleInDmp: DmpUserRole[]; //TODO + + dmpSubQuery: DmpLookup; + descriptionTemplateSubQuery: DescriptionTemplateLookup; descriptionTagSubQuery: DescriptionTagLookup; descriptionReferenceSubQuery: DescriptionReferenceLookup; - + + roleInDmp: DmpUserRole[]; //TODO + showAllVersions: boolean; //TODO + constructor() { super(); } @@ -39,12 +41,13 @@ export interface DescriptionFilter { createdBefore: Date; finalizedAfter: Date; finalizedBefore: Date; - dmpSubQuery: DmpLookup; isActive: IsActive[]; statuses: DescriptionStatus[]; showAllVersions: boolean; - descriptionTemplateIds: Guid[]; roleInDmp: DmpUserRole[]; + + dmpSubQuery: DmpLookup; + descriptionTemplateSubQuery: DescriptionTemplateLookup; descriptionTagSubQuery: DescriptionTagLookup; descriptionReferenceSubQuery: DescriptionReferenceLookup; } diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html index 95eefc982..cc1ae9b06 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html @@ -29,7 +29,7 @@ -