Commit 1022cb8a authored by Matija Obreza's avatar Matija Obreza
Browse files

Added support for NOT, IS_NULL and IS_NOT_NULL filtering

parent 8d6888b1
...@@ -20,13 +20,14 @@ import static org.genesys.catalog.model.vocab.QControlledVocabulary.controlledVo ...@@ -20,13 +20,14 @@ import static org.genesys.catalog.model.vocab.QControlledVocabulary.controlledVo
import org.genesys.blocks.model.filters.StringFilter; import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter; import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.QPartner; import org.genesys.catalog.model.QPartner;
import org.genesys.catalog.model.vocab.ControlledVocabulary;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.JPAExpressions;
public class ControlledVocabularyFilter extends UuidModelFilter { public class ControlledVocabularyFilter extends UuidModelFilter<ControlledVocabularyFilter, ControlledVocabulary> {
/** The owner. */ /** The owner. */
public PartnerFilter owner; public PartnerFilter owner;
...@@ -47,7 +48,7 @@ public class ControlledVocabularyFilter extends UuidModelFilter { ...@@ -47,7 +48,7 @@ public class ControlledVocabularyFilter extends UuidModelFilter {
*/ */
public Predicate buildQuery() { public Predicate buildQuery() {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(controlledVocabulary._super, and); super.buildQuery(controlledVocabulary, controlledVocabulary._super, and);
if (published != null) { if (published != null) {
and.and(controlledVocabulary.published.eq(published)); and.and(controlledVocabulary.published.eq(published));
......
...@@ -24,6 +24,7 @@ import org.apache.commons.lang3.ArrayUtils; ...@@ -24,6 +24,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.StringFilter; import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter; import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.dataset.Dataset;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
...@@ -35,7 +36,7 @@ import org.genesys2.server.model.PublishState; ...@@ -35,7 +36,7 @@ import org.genesys2.server.model.PublishState;
* @author Andrey Lugovskoy * @author Andrey Lugovskoy
* @author Matija Obreza * @author Matija Obreza
*/ */
public class DatasetFilter extends UuidModelFilter { public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> {
/** Any text. */ /** Any text. */
public String _text; public String _text;
...@@ -70,7 +71,7 @@ public class DatasetFilter extends UuidModelFilter { ...@@ -70,7 +71,7 @@ public class DatasetFilter extends UuidModelFilter {
*/ */
public Predicate buildQuery() { public Predicate buildQuery() {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(dataset._super, and); super.buildQuery(dataset, dataset._super, and);
if (state != null && !state.isEmpty()) { if (state != null && !state.isEmpty()) {
and.and(dataset.state.in(state)); and.and(dataset.state.in(state));
......
...@@ -40,7 +40,7 @@ import org.genesys2.server.model.PublishState; ...@@ -40,7 +40,7 @@ import org.genesys2.server.model.PublishState;
* @author Andrey Lugovskoy * @author Andrey Lugovskoy
* @author Matija Obreza * @author Matija Obreza
*/ */
public class DescriptorFilter extends UuidModelFilter { public class DescriptorFilter extends UuidModelFilter<DescriptorFilter, Descriptor> {
/** Any text. */ /** Any text. */
public String _text; public String _text;
...@@ -101,7 +101,7 @@ public class DescriptorFilter extends UuidModelFilter { ...@@ -101,7 +101,7 @@ public class DescriptorFilter extends UuidModelFilter {
public Predicate buildQuery(final QDescriptor descriptorPath) { public Predicate buildQuery(final QDescriptor descriptorPath) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(descriptorPath._super, and); super.buildQuery(descriptorPath, descriptorPath._super, and);
if (crop != null && !crop.isEmpty()) { if (crop != null && !crop.isEmpty()) {
and.and(descriptorPath.crop.in(crop)); and.and(descriptorPath.crop.in(crop));
......
...@@ -23,6 +23,7 @@ import org.apache.commons.lang3.ArrayUtils; ...@@ -23,6 +23,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.StringFilter; import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter; import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.traits.DescriptorList;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
...@@ -34,7 +35,7 @@ import org.genesys2.server.model.PublishState; ...@@ -34,7 +35,7 @@ import org.genesys2.server.model.PublishState;
* @author Andrey Lugovskoy * @author Andrey Lugovskoy
* @author Matija Obreza * @author Matija Obreza
*/ */
public class DescriptorListFilter extends UuidModelFilter { public class DescriptorListFilter extends UuidModelFilter<DescriptorListFilter, DescriptorList> {
/** Any text. */ /** Any text. */
public String _text; public String _text;
...@@ -67,7 +68,7 @@ public class DescriptorListFilter extends UuidModelFilter { ...@@ -67,7 +68,7 @@ public class DescriptorListFilter extends UuidModelFilter {
*/ */
public Predicate buildQuery() { public Predicate buildQuery() {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(descriptorList._super, and); super.buildQuery(descriptorList, descriptorList._super, and);
if (crop != null && !crop.isEmpty()) { if (crop != null && !crop.isEmpty()) {
and.and(descriptorList.crop.in(crop)); and.and(descriptorList.crop.in(crop));
......
...@@ -22,6 +22,7 @@ import java.util.Set; ...@@ -22,6 +22,7 @@ import java.util.Set;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.StringFilter; import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter; import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.Partner;
import org.genesys.catalog.model.QPartner; import org.genesys.catalog.model.QPartner;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
...@@ -32,7 +33,7 @@ import com.querydsl.core.types.Predicate; ...@@ -32,7 +33,7 @@ import com.querydsl.core.types.Predicate;
* *
* @author Andrey Lugovskoy. * @author Andrey Lugovskoy.
*/ */
public class PartnerFilter extends UuidModelFilter { public class PartnerFilter extends UuidModelFilter<PartnerFilter, Partner> {
/** The short name. */ /** The short name. */
public Set<String> shortName; public Set<String> shortName;
...@@ -57,7 +58,7 @@ public class PartnerFilter extends UuidModelFilter { ...@@ -57,7 +58,7 @@ public class PartnerFilter extends UuidModelFilter {
public Predicate buildQuery(final QPartner partnerPath) { public Predicate buildQuery(final QPartner partnerPath) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(partnerPath._super, and); super.buildQuery(partnerPath, partnerPath._super, and);
if (CollectionUtils.isNotEmpty(shortName)) { if (CollectionUtils.isNotEmpty(shortName)) {
and.and(partnerPath.shortName.in(shortName)); and.and(partnerPath.shortName.in(shortName));
......
...@@ -3,6 +3,7 @@ package org.genesys2.server.component.elastic; ...@@ -3,6 +3,7 @@ package org.genesys2.server.component.elastic;
import static com.google.common.collect.Lists.*; import static com.google.common.collect.Lists.*;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -35,11 +36,15 @@ import com.querydsl.core.types.Visitor; ...@@ -35,11 +36,15 @@ import com.querydsl.core.types.Visitor;
public class ElasticQueryBuilder implements Visitor<Void, Void> { public class ElasticQueryBuilder implements Visitor<Void, Void> {
private static Logger LOG = LoggerFactory.getLogger(ElasticQueryBuilder.class); private static Logger LOG = LoggerFactory.getLogger(ElasticQueryBuilder.class);
private BoolQueryBuilder root = QueryBuilders.boolQuery(); private final List<QueryBuilder> mustClauses = new ArrayList<>();
private final List<QueryBuilder> mustNotClauses = new ArrayList<>();
private final ElasticQueryBuilder self = this; private final ElasticQueryBuilder self = this;
public QueryBuilder getQuery() { public QueryBuilder getQuery() {
BoolQueryBuilder root = QueryBuilders.boolQuery();
mustClauses.forEach(must -> root.filter(must));
mustNotClauses.forEach(mustNot -> root.mustNot(mustNot));
return root; return root;
} }
...@@ -116,6 +121,29 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> { ...@@ -116,6 +121,29 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
Expression<?> a1 = args.get(1); Expression<?> a1 = args.get(1);
handleLike(operator, a0, a1); handleLike(operator, a0, a1);
} else if (operator == Ops.NOT) {
LOG.debug("{}: {}", operator, args);
for (Expression<?> expr : args) {
printExpression(operator + ".. ", expr);
}
Expression<?> notExp = args.get(0);
handleNot(notExp);
} else if (operator == Ops.IS_NOT_NULL) {
LOG.debug("{}: {}", operator, args);
for (Expression<?> expr : args) {
printExpression(operator + ".. ", expr);
}
Path<?> path = (Path<?>) args.get(0);
PathMetadata pmd = path.getMetadata();
mustClauses.add(existsQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName())));
} else if (operator == Ops.IS_NULL) {
LOG.debug("{}: {}", operator, args);
for (Expression<?> expr : args) {
printExpression(operator + ".. ", expr);
}
Path<?> path = (Path<?>) args.get(0);
PathMetadata pmd = path.getMetadata();
mustNotClauses.add(existsQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName())));
} else { } else {
LOG.error("Op {}: {}", operator, args); LOG.error("Op {}: {}", operator, args);
} }
...@@ -124,15 +152,22 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> { ...@@ -124,15 +152,22 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
// printExpression("a1: " + type.getName() + " " + operator, a1); // printExpression("a1: " + type.getName() + " " + operator, a1);
} }
private void handleNot(Expression<?> notExp) {
LOG.debug("NOT expr: {}", notExp);
ElasticQueryBuilder notBuilder = new ElasticQueryBuilder();
notExp.accept(notBuilder, null);
notBuilder.mustClauses.forEach(mustNot -> mustNotClauses.add(mustNot));
}
private void handleLike(Operator operator, Path<?> path, Expression<?> val) { private void handleLike(Operator operator, Path<?> path, Expression<?> val) {
PathMetadata pmd = path.getMetadata(); PathMetadata pmd = path.getMetadata();
// SimpleQueryStringBuilder qsq = simpleQueryStringQuery( +":" + toValue(val)); // SimpleQueryStringBuilder qsq = simpleQueryStringQuery( +":" + toValue(val));
if (operator == Ops.STARTS_WITH) { if (operator == Ops.STARTS_WITH) {
MatchQueryBuilder matchPrefixQuery = matchPhrasePrefixQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName()), toValue(val)); MatchQueryBuilder matchPrefixQuery = matchPhrasePrefixQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName()), toValue(val));
root.filter(matchPrefixQuery); mustClauses.add(matchPrefixQuery);
} else if (operator == Ops.STRING_CONTAINS) { } else if (operator == Ops.STRING_CONTAINS) {
MatchQueryBuilder matchPrefixQuery = matchPhraseQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName()), toValue(val)); MatchQueryBuilder matchPrefixQuery = matchPhraseQuery(customizedPath(pmd.getParent().toString() + "." + pmd.getName()), toValue(val));
root.filter(matchPrefixQuery); mustClauses.add(matchPrefixQuery);
} else { } else {
throw new RuntimeException("Unsupported ES handleLike operator: " + operator); throw new RuntimeException("Unsupported ES handleLike operator: " + operator);
} }
...@@ -155,16 +190,16 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> { ...@@ -155,16 +190,16 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
} else if (operator == Ops.LOE) { } else if (operator == Ops.LOE) {
rq.lte(toValue(val1)); rq.lte(toValue(val1));
} }
root.filter(rq); mustClauses.add(rq);
} }
private void handleEquals(Path<?> path, Expression<?> value) { private void handleEquals(Path<?> path, Expression<?> value) {
PathMetadata pmd = path.getMetadata(); PathMetadata pmd = path.getMetadata();
if (pmd.getPathType() == PathType.COLLECTION_ANY) { if (pmd.getPathType() == PathType.COLLECTION_ANY) {
LOG.error("Path ANY for {}={}", pmd.getParent(), value); LOG.error("Path ANY for {}={}", pmd.getParent(), value);
root.filter(termsQuery(customizedPath(pmd.getParent().toString()), toValues(value))); mustClauses.add(termsQuery(customizedPath(pmd.getParent().toString()), toValues(value)));
} else { } else {
root.filter(termsQuery(customizedPath(getParentPath(pmd.getParent()) + "." + pmd.getName()), toValues(value))); mustClauses.add(termsQuery(customizedPath(getParentPath(pmd.getParent()) + "." + pmd.getName()), toValues(value)));
} }
} }
......
...@@ -30,7 +30,7 @@ import com.querydsl.core.types.Predicate; ...@@ -30,7 +30,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* Filters for {@link AccessionCollect} * Filters for {@link AccessionCollect}
*/ */
public class AccessionCollectFilter extends BasicModelFilter { public class AccessionCollectFilter extends BasicModelFilter<AccessionCollectFilter, AccessionCollect> {
/** The date. */ /** The date. */
public StringFilter date; public StringFilter date;
...@@ -61,7 +61,7 @@ public class AccessionCollectFilter extends BasicModelFilter { ...@@ -61,7 +61,7 @@ public class AccessionCollectFilter extends BasicModelFilter {
*/ */
public Predicate buildQuery(QAccessionCollect collect) { public Predicate buildQuery(QAccessionCollect collect) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(collect._super, and); super.buildQuery(collect, collect._super, and);
if (date != null) { if (date != null) {
and.and(date.buildQuery(collect.collDate)); and.and(date.buildQuery(collect.collDate));
......
...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate; ...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* Filters for {@link Accession} * Filters for {@link Accession}
*/ */
public class AccessionFilter extends UuidModelFilter { public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession> {
/** The historic. */ /** The historic. */
/// Include historic /// Include historic
...@@ -94,7 +94,7 @@ public class AccessionFilter extends UuidModelFilter { ...@@ -94,7 +94,7 @@ public class AccessionFilter extends UuidModelFilter {
*/ */
public Predicate buildQuery() { public Predicate buildQuery() {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(accession._super._super, and); super.buildQuery(accession, accession._super._super, and);
if (taxa != null) { if (taxa != null) {
and.and(taxa.buildQuery(accession.taxonomy)); and.and(taxa.buildQuery(accession.taxonomy));
......
...@@ -19,6 +19,7 @@ import static org.genesys2.server.model.genesys.QAccessionGeo.accessionGeo; ...@@ -19,6 +19,7 @@ import static org.genesys2.server.model.genesys.QAccessionGeo.accessionGeo;
import org.genesys.blocks.model.filters.BasicModelFilter; import org.genesys.blocks.model.filters.BasicModelFilter;
import org.genesys.blocks.model.filters.NumberFilter; import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.QAccessionGeo; import org.genesys2.server.model.genesys.QAccessionGeo;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
...@@ -27,7 +28,7 @@ import com.querydsl.core.types.Predicate; ...@@ -27,7 +28,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* The Class CountryFilter. * The Class CountryFilter.
*/ */
public class AccessionGeoFilter extends BasicModelFilter { public class AccessionGeoFilter extends BasicModelFilter<AccessionGeoFilter, AccessionGeo> {
/** The longitude. */ /** The longitude. */
public NumberFilter<Double> longitude; public NumberFilter<Double> longitude;
...@@ -55,7 +56,7 @@ public class AccessionGeoFilter extends BasicModelFilter { ...@@ -55,7 +56,7 @@ public class AccessionGeoFilter extends BasicModelFilter {
*/ */
public Predicate buildQuery(QAccessionGeo accessiongeo) { public Predicate buildQuery(QAccessionGeo accessiongeo) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(accessiongeo._super, and); super.buildQuery(accessiongeo, accessiongeo._super, and);
if (longitude != null) { if (longitude != null) {
and.and(longitude.buildQuery(accessiongeo.longitude)); and.and(longitude.buildQuery(accessiongeo.longitude));
......
...@@ -20,6 +20,7 @@ import static org.genesys2.server.model.impl.QCountry.country; ...@@ -20,6 +20,7 @@ import static org.genesys2.server.model.impl.QCountry.country;
import java.util.Set; import java.util.Set;
import org.genesys.blocks.model.filters.BasicModelFilter; import org.genesys.blocks.model.filters.BasicModelFilter;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.QCountry; import org.genesys2.server.model.impl.QCountry;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
...@@ -29,7 +30,7 @@ import com.querydsl.core.types.Predicate; ...@@ -29,7 +30,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* The Class CountryFilter. * The Class CountryFilter.
*/ */
public class CountryFilter extends BasicModelFilter { public class CountryFilter extends BasicModelFilter<CountryFilter, Country> {
/** The iso 3. */ /** The iso 3. */
public Set<String> iso3; public Set<String> iso3;
...@@ -51,7 +52,7 @@ public class CountryFilter extends BasicModelFilter { ...@@ -51,7 +52,7 @@ public class CountryFilter extends BasicModelFilter {
*/ */
public Predicate buildQuery(QCountry country) { public Predicate buildQuery(QCountry country) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(country._super, and); super.buildQuery(country, country._super, and);
if (iso3 != null && !iso3.isEmpty()) { if (iso3 != null && !iso3.isEmpty()) {
and.and(country.code3.in(iso3)); and.and(country.code3.in(iso3));
......
...@@ -31,7 +31,7 @@ import com.querydsl.core.types.Predicate; ...@@ -31,7 +31,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* Filter for {@link FaoInstitute}. * Filter for {@link FaoInstitute}.
*/ */
public class InstituteFilter extends BasicModelFilter { public class InstituteFilter extends BasicModelFilter<InstituteFilter, FaoInstitute> {
/** The code. */ /** The code. */
public Set<String> code; public Set<String> code;
...@@ -62,7 +62,7 @@ public class InstituteFilter extends BasicModelFilter { ...@@ -62,7 +62,7 @@ public class InstituteFilter extends BasicModelFilter {
*/ */
public Predicate buildQuery(QFaoInstitute institute) { public Predicate buildQuery(QFaoInstitute institute) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(institute._super, and); super.buildQuery(institute, institute._super, and);
if (code != null && !code.isEmpty()) { if (code != null && !code.isEmpty()) {
and.and(institute.code.in(code)); and.and(institute.code.in(code));
......
...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate; ...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* Filter for {@link MaterialRequest}. * Filter for {@link MaterialRequest}.
*/ */
public class MaterialRequestFilter extends AuditedVersionedModelFilter { public class MaterialRequestFilter extends AuditedVersionedModelFilter<MaterialRequestFilter, MaterialRequest> {
/** The identifiers. */ /** The identifiers. */
public Set<UUID> uuid; public Set<UUID> uuid;
...@@ -64,7 +64,7 @@ public class MaterialRequestFilter extends AuditedVersionedModelFilter { ...@@ -64,7 +64,7 @@ public class MaterialRequestFilter extends AuditedVersionedModelFilter {
*/ */
public Predicate buildQuery(QMaterialRequest materialRequest) { public Predicate buildQuery(QMaterialRequest materialRequest) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(materialRequest._super, and); super.buildQuery(materialRequest, materialRequest._super, and);
if (uuid != null && !uuid.isEmpty()) { if (uuid != null && !uuid.isEmpty()) {
and.and(materialRequest.uuid.in(uuid.stream().map(u -> u== null ? null : u.toString()).collect(Collectors.toSet()))); and.and(materialRequest.uuid.in(uuid.stream().map(u -> u== null ? null : u.toString()).collect(Collectors.toSet())));
......
...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate; ...@@ -33,7 +33,7 @@ import com.querydsl.core.types.Predicate;
/** /**
* Filter for {@link MaterialSubRequest}. * Filter for {@link MaterialSubRequest}.
*/ */
public class MaterialSubRequestFilter extends AuditedVersionedModelFilter { public class MaterialSubRequestFilter extends AuditedVersionedModelFilter<MaterialSubRequestFilter, MaterialSubRequest> {
/** The identifiers. */ /** The identifiers. */
public Set<UUID> uuid; public Set<UUID> uuid;
...@@ -64,7 +64,7 @@ public class MaterialSubRequestFilter extends AuditedVersionedModelFilter { ...@@ -64,7 +64,7 @@ public class MaterialSubRequestFilter extends AuditedVersionedModelFilter {
*/ */
public Predicate buildQuery(QMaterialSubRequest materialSubRequest) { public Predicate buildQuery(QMaterialSubRequest materialSubRequest) {
final BooleanBuilder and = new BooleanBuilder(); final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(materialSubRequest._super, and); super.buildQuery(materialSubRequest, materialSubRequest._super, and);
if (uuid != null && !uuid.isEmpty()) { if (uuid != null && !uuid.isEmpty()) {
and.and(materialSubRequest.uuid.in(uuid.stream().map(u -> u== null ? null : u.toString()).collect(Collectors.toSet()))); and.and(materialSubRequest.uuid.in(uuid.stream().map(u -> u== null ? null : u.toString()).collect(Collectors.toSet())));
......
...@@ -21,6 +21,7 @@ import java.util.Set; ...@@ -21,6 +21,7 @@ import java.util.Set;
import org.genesys.blocks.model.filters.StringFilter; import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter; import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys2.server.model.impl.Subset;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
...@@ -31,7 +32,7 @@ import com.querydsl.core.types.Predicate; ...@@ -31,7 +32,7 @@ import com.querydsl.core.types.Predicate;
* *
* @author Maxym Borodenko * @author Maxym Borodenko
*/ */
public class SubsetFilter extends UuidModelFilter { public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> {