From 6ebbb885fbbef44858262470fea153a558978825 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Thu, 22 Feb 2024 17:47:01 +0200 Subject: [PATCH] Adding anchors list on annotation entity lookup / query --- .../annotation/query/AnnotationQuery.java | 23 +++++++++++++++++++ .../query/lookup/AnnotationLookup.java | 12 ++++++++++ .../core/query/annotation.lookup.ts | 1 + 3 files changed, 36 insertions(+) diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java index ae149857f..773fc7af4 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java @@ -35,6 +35,8 @@ public class AnnotationQuery extends QueryBase { private Collection entityTypes; + private Collection anchors; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final UserScope userScope; @@ -126,6 +128,21 @@ public class AnnotationQuery extends QueryBase { return this; } + public AnnotationQuery anchors(String value) { + this.anchors = List.of(value); + return this; + } + + public AnnotationQuery anchors(String... value) { + this.anchors = Arrays.asList(value); + return this; + } + + public AnnotationQuery anchors(Collection values) { + this.anchors = values; + return this; + } + @Override protected Boolean isFalseQuery() { return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.entityIds); @@ -176,6 +193,12 @@ public class AnnotationQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } + if (this.anchors != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(AnnotationEntity._anchor)); + for (String item : this.anchors) + inClause.value(item); + predicates.add(inClause); + } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java index 46d493b94..97680d5b4 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java @@ -22,6 +22,8 @@ public class AnnotationLookup extends Lookup { private List entityTypes; + private List anchors; + public String getLike() { return like; } @@ -70,6 +72,14 @@ public class AnnotationLookup extends Lookup { this.entityTypes = entityTypes; } + public List getAnchors() { + return anchors; + } + + public void setAnchors(List anchors) { + this.anchors = anchors; + } + public AnnotationQuery enrich(QueryFactory queryFactory) { AnnotationQuery query = queryFactory.query(AnnotationQuery.class); if (this.like != null) @@ -84,6 +94,8 @@ public class AnnotationLookup extends Lookup { query.entityIds(this.entityIds); if (this.entityTypes != null) query.entityTypes(this.entityTypes); + if (this.anchors != null) + query.anchors(this.anchors); this.enrichCommon(query); diff --git a/dmp-frontend/src/annotation-service/core/query/annotation.lookup.ts b/dmp-frontend/src/annotation-service/core/query/annotation.lookup.ts index 4d764262b..e58171e5b 100644 --- a/dmp-frontend/src/annotation-service/core/query/annotation.lookup.ts +++ b/dmp-frontend/src/annotation-service/core/query/annotation.lookup.ts @@ -10,6 +10,7 @@ export class AnnotationLookup extends Lookup implements AnnotationFilter { isActive: IsActive; entityIds: Guid[]; entityTypes: string[]; + anchors: string[]; constructor() { super();