Adding anchors list on annotation entity lookup / query

This commit is contained in:
Thomas Georgios Giannos 2024-02-22 17:47:01 +02:00
parent 40f56986b4
commit 6ebbb885fb
3 changed files with 36 additions and 0 deletions

View File

@ -35,6 +35,8 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
private Collection<String> entityTypes; private Collection<String> entityTypes;
private Collection<String> anchors;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final UserScope userScope; private final UserScope userScope;
@ -126,6 +128,21 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
return this; 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<String> values) {
this.anchors = values;
return this;
}
@Override @Override
protected Boolean isFalseQuery() { protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.entityIds); 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<AnnotationEntity> {
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
if (this.anchors != null) {
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(AnnotationEntity._anchor));
for (String item : this.anchors)
inClause.value(item);
predicates.add(inClause);
}
if (!predicates.isEmpty()) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);

View File

@ -22,6 +22,8 @@ public class AnnotationLookup extends Lookup {
private List<String> entityTypes; private List<String> entityTypes;
private List<String> anchors;
public String getLike() { public String getLike() {
return like; return like;
} }
@ -70,6 +72,14 @@ public class AnnotationLookup extends Lookup {
this.entityTypes = entityTypes; this.entityTypes = entityTypes;
} }
public List<String> getAnchors() {
return anchors;
}
public void setAnchors(List<String> anchors) {
this.anchors = anchors;
}
public AnnotationQuery enrich(QueryFactory queryFactory) { public AnnotationQuery enrich(QueryFactory queryFactory) {
AnnotationQuery query = queryFactory.query(AnnotationQuery.class); AnnotationQuery query = queryFactory.query(AnnotationQuery.class);
if (this.like != null) if (this.like != null)
@ -84,6 +94,8 @@ public class AnnotationLookup extends Lookup {
query.entityIds(this.entityIds); query.entityIds(this.entityIds);
if (this.entityTypes != null) if (this.entityTypes != null)
query.entityTypes(this.entityTypes); query.entityTypes(this.entityTypes);
if (this.anchors != null)
query.anchors(this.anchors);
this.enrichCommon(query); this.enrichCommon(query);

View File

@ -10,6 +10,7 @@ export class AnnotationLookup extends Lookup implements AnnotationFilter {
isActive: IsActive; isActive: IsActive;
entityIds: Guid[]; entityIds: Guid[];
entityTypes: string[]; entityTypes: string[];
anchors: string[];
constructor() { constructor() {
super(); super();