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 f1751f2e9..6305d70f9 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java @@ -14,8 +14,6 @@ import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.data.*; -import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; -import org.opencdmp.elastic.elasticbuilder.nested.NestedTagElasticBuilder; import org.opencdmp.model.PublicDescription; import org.opencdmp.model.description.Description; import org.opencdmp.query.utils.QueryUtilsService; @@ -25,7 +23,6 @@ import org.springframework.stereotype.Component; import java.time.Instant; import java.util.*; -import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @@ -42,6 +39,7 @@ public class DescriptionQuery extends QueryBase { private DmpQuery dmpQuery; private DescriptionReferenceQuery descriptionReferenceQuery; + private DescriptionTagQuery descriptionTagQuery; private Instant createdAfter; @@ -162,6 +160,11 @@ public class DescriptionQuery extends QueryBase { return this; } + public DescriptionQuery descriptionTagSubQuery(DescriptionTagQuery subQuery) { + this.descriptionTagQuery = subQuery; + return this; + } + public DescriptionQuery excludedIds(Collection values) { this.excludedIds = values; return this; @@ -345,6 +348,10 @@ public class DescriptionQuery extends QueryBase { 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)); } + if (this.descriptionTagQuery != null) { + QueryContext subQuery = this.applySubQuery(this.descriptionTagQuery, queryContext, UUID.class, descriptionTagEntityRoot -> descriptionTagEntityRoot.get(DescriptionTagEntity._descriptionId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(subQuery.Query)); + } if (this.dmpDescriptionTemplateIds != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)); for (UUID item : this.dmpDescriptionTemplateIds) 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 de6efa589..dd0854229 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 @@ -6,7 +6,6 @@ import org.apache.commons.lang3.StringUtils; import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.elastic.query.DescriptionElasticQuery; -import org.opencdmp.model.reference.Reference; import org.opencdmp.query.DescriptionQuery; import java.time.Instant; @@ -27,6 +26,7 @@ public class DescriptionLookup extends Lookup { private DmpLookup dmpSubQuery; private DescriptionReferenceLookup descriptionReferenceSubQuery; + private DescriptionTagLookup descriptionTagSubQuery; private List isActive; @@ -84,6 +84,10 @@ public class DescriptionLookup extends Lookup { public void setDescriptionReferenceSubQuery(DescriptionReferenceLookup descriptionReferenceSubQuery) { this.descriptionReferenceSubQuery = descriptionReferenceSubQuery; } + public DescriptionTagLookup getDescriptionTagSubQuery() { return this.descriptionTagSubQuery; } + + public void setDescriptionTagSubQuery(DescriptionTagLookup descriptionTagSubQuery) { this.descriptionTagSubQuery = descriptionTagSubQuery; } + public Instant getCreatedAfter() { return this.createdAfter; } @@ -123,6 +127,7 @@ public class DescriptionLookup extends Lookup { if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.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); if (this.statuses != null) query.statuses(this.statuses); if (this.createdAfter != null) query.createdAfter(this.createdAfter); diff --git a/dmp-frontend/src/app/core/query/description.lookup.ts b/dmp-frontend/src/app/core/query/description.lookup.ts index cfdd72cd9..178f7d168 100644 --- a/dmp-frontend/src/app/core/query/description.lookup.ts +++ b/dmp-frontend/src/app/core/query/description.lookup.ts @@ -4,9 +4,9 @@ import { IsActive } from '../common/enum/is-active.enum'; import { DescriptionStatus } from '../common/enum/description-status'; import { DmpLookup } from './dmp.lookup'; import { DmpUserRole } from '../common/enum/dmp-user-role'; -import { DescriptionTag } from '../model/description/description'; import { ReferenceType } from '../model/reference-type/reference-type'; -import { DescriptionReferenceLookup, ReferenceLookup } from './reference.lookup'; +import { DescriptionReferenceLookup } from './reference.lookup'; +import { DescriptionTagLookup } from './tag.lookup'; export class DescriptionLookup extends Lookup implements DescriptionFilter { ids: Guid[]; @@ -24,7 +24,7 @@ export class DescriptionLookup extends Lookup implements DescriptionFilter { descriptionTemplateIds: Guid[]; //TODO associatedDmpIds: Guid[]; //TODO roleInDmp: DmpUserRole[]; //TODO - tags: DescriptionTag[]; //TODO + descriptionTagSubQuery: DescriptionTagLookup; descriptionReferenceSubQuery: DescriptionReferenceLookup; constructor() { @@ -47,7 +47,7 @@ export interface DescriptionFilter { descriptionTemplateIds: Guid[]; associatedDmpIds: Guid[]; roleInDmp: DmpUserRole[]; - tags: DescriptionTag[]; + descriptionTagSubQuery: DescriptionTagLookup; descriptionReferenceSubQuery: DescriptionReferenceLookup; } diff --git a/dmp-frontend/src/app/core/query/tag.lookup.ts b/dmp-frontend/src/app/core/query/tag.lookup.ts index 28627e99d..cc610b87d 100644 --- a/dmp-frontend/src/app/core/query/tag.lookup.ts +++ b/dmp-frontend/src/app/core/query/tag.lookup.ts @@ -14,6 +14,17 @@ export class TagLookup extends Lookup implements TagFilter { } } +export class DescriptionTagLookup extends Lookup { + tagIds: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + + constructor() { + super(); + } +} + export interface TagFilter { ids: Guid[]; excludedIds: Guid[]; 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 d8427e6fc..b6e520bd3 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 @@ -16,20 +16,20 @@
-
+
-
+
-