Adding 'dmp' query option on 'description' query

This commit is contained in:
Thomas Georgios Giannos 2023-10-24 17:24:51 +03:00
parent 1e733cf704
commit e149b61b58
2 changed files with 76 additions and 18 deletions

View File

@ -34,6 +34,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
private Collection<DescriptionStatus> statuses; private Collection<DescriptionStatus> statuses;
private Collection<UUID> dmpIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final UserScope userScope; private final UserScope userScope;
@ -110,6 +112,21 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
return this; return this;
} }
public DescriptionQuery dmpIds(UUID value) {
this.dmpIds = List.of(value);
return this;
}
public DescriptionQuery dmpIds(UUID... value) {
this.dmpIds = Arrays.asList(value);
return this;
}
public DescriptionQuery dmpIds(Collection<UUID> values) {
this.dmpIds = values;
return this;
}
public DescriptionQuery authorize(EnumSet<AuthorizationFlags> values) { public DescriptionQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values; this.authorize = values;
return this; return this;
@ -117,7 +134,12 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
@Override @Override
protected Boolean isFalseQuery() { protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses); return
this.isEmpty(this.ids) ||
this.isEmpty(this.isActives) ||
this.isEmpty(this.excludedIds) ||
this.isEmpty(this.statuses) ||
this.isEmpty(this.dmpIds);
} }
@Override @Override
@ -136,7 +158,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
for (UUID item : this.ids) for (UUID item : this.ids)
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
}if (this.excludedIds != null) { }
if (this.excludedIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)); CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id));
for (UUID item : this.excludedIds) for (UUID item : this.excludedIds)
notInClause.value(item); notInClause.value(item);
@ -154,6 +177,12 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
if (this.dmpIds != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmp));
for (UUID item : this.dmpIds)
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]);
return queryContext.CriteriaBuilder.and(predicatesArray); return queryContext.CriteriaBuilder.and(predicatesArray);
@ -164,22 +193,40 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
@Override @Override
protected String fieldNameOf(FieldResolver item) { protected String fieldNameOf(FieldResolver item) {
if (item.match(Description._id)) return DescriptionEntity._id; if (item.match(Description._id))
else if (item.match(Description._label)) return DescriptionEntity._label; return DescriptionEntity._id;
else if (item.match(Description._dmp)) return DescriptionEntity._dmp; else if (item.match(Description._label))
else if (item.match(Description._uri)) return DescriptionEntity._uri; return DescriptionEntity._label;
else if (item.match(Description._properties)) return DescriptionEntity._properties; else if (item.prefix(Description._dmp))
else if (item.match(Description._profile)) return DescriptionEntity._profile; return DescriptionEntity._dmp;
else if (item.match(Description._reference)) return DescriptionEntity._reference; else if (item.match(Description._dmp))
else if (item.match(Description._status)) return DescriptionEntity._status; return DescriptionEntity._dmp;
else if (item.match(Description._description)) return DescriptionEntity._description; else if (item.match(Description._uri))
else if (item.match(Description._dmpSectionIndex)) return DescriptionEntity._dmpSectionIndex; return DescriptionEntity._uri;
else if (item.match(Description._creator)) return DescriptionEntity._creator; else if (item.match(Description._properties))
else if (item.match(Description._createdAt)) return DescriptionEntity._createdAt; return DescriptionEntity._properties;
else if (item.match(Description._updatedAt)) return DescriptionEntity._updatedAt; else if (item.match(Description._profile))
else if (item.match(Description._isActive)) return DescriptionEntity._isActive; return DescriptionEntity._profile;
else if (item.match(Description._finalizedAt)) return DescriptionEntity._finalizedAt; else if (item.match(Description._reference))
else return null; return DescriptionEntity._reference;
else if (item.match(Description._status))
return DescriptionEntity._status;
else if (item.match(Description._description))
return DescriptionEntity._description;
else if (item.match(Description._dmpSectionIndex))
return DescriptionEntity._dmpSectionIndex;
else if (item.match(Description._creator))
return DescriptionEntity._creator;
else if (item.match(Description._createdAt))
return DescriptionEntity._createdAt;
else if (item.match(Description._updatedAt))
return DescriptionEntity._updatedAt;
else if (item.match(Description._isActive))
return DescriptionEntity._isActive;
else if (item.match(Description._finalizedAt))
return DescriptionEntity._finalizedAt;
else
return null;
} }
@Override @Override

View File

@ -22,6 +22,8 @@ public class DescriptionLookup extends Lookup {
private List<DescriptionStatus> statuses; private List<DescriptionStatus> statuses;
private List<UUID> dmpIds;
public String getLike() { public String getLike() {
return like; return like;
} }
@ -62,6 +64,14 @@ public class DescriptionLookup extends Lookup {
this.statuses = statuses; this.statuses = statuses;
} }
public List<UUID> getDmpIds() {
return dmpIds;
}
public void setDmpIds(List<UUID> dmpIds) {
this.dmpIds = dmpIds;
}
public DescriptionQuery enrich(QueryFactory queryFactory) { public DescriptionQuery enrich(QueryFactory queryFactory) {
DescriptionQuery query = queryFactory.query(DescriptionQuery.class); DescriptionQuery query = queryFactory.query(DescriptionQuery.class);
if (this.like != null) query.like(this.like); if (this.like != null) query.like(this.like);
@ -69,6 +79,7 @@ public class DescriptionLookup extends Lookup {
if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.excludedIds != null) query.excludedIds(this.excludedIds);
if (this.isActive != null) query.isActive(this.isActive); if (this.isActive != null) query.isActive(this.isActive);
if (this.statuses != null) query.statuses(this.statuses); if (this.statuses != null) query.statuses(this.statuses);
if (this.dmpIds != null) query.dmpIds(this.dmpIds);
this.enrichCommon(query); this.enrichCommon(query);