Commit 66081cd9 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '143-extend-filters-with-general-text-search' into 'master'

Resolve "Extend filters with general text search"

Closes #143

See merge request !134
parents 0ad10bad 2c43dc94
......@@ -37,6 +37,14 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -20,6 +20,7 @@ import static org.genesys.catalog.model.dataset.QDataset.dataset;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.AuditedVersionedModelFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.common.model.QPartner;
......@@ -31,10 +32,14 @@ import com.querydsl.jpa.JPAExpressions;
/**
* The Class DatasetFilter.
*
* @author Andrey Lugovskoy.
* @author Andrey Lugovskoy
* @author Matija Obreza
*/
public class DatasetFilter extends AuditedVersionedModelFilter {
/** Any text. */
public String _text;
/** The owner. */
public PartnerFilter owner;
......@@ -80,6 +85,30 @@ public class DatasetFilter extends AuditedVersionedModelFilter {
if (CollectionUtils.isNotEmpty(language)) {
and.and(dataset.language.in(language));
}
if (StringUtils.isNotBlank(_text)) {
/*@formatter:off*/
and.andAnyOf(
dataset.title.containsIgnoreCase(_text),
dataset.description.containsIgnoreCase(_text),
dataset.versionTag.equalsIgnoreCase(_text),
// dataset.crop.equalsIgnoreCase(_text),
// owner
dataset.owner.shortName.equalsIgnoreCase(_text),
dataset.owner.name.containsIgnoreCase(_text),
// descriptor lists
dataset.descriptors.any().title.containsIgnoreCase(_text),
dataset.descriptors.any().crop.equalsIgnoreCase(_text),
// accessions
dataset.accessionIdentifiers.any().genus.equalsIgnoreCase(_text),
dataset.accessionIdentifiers.any().instCode.equalsIgnoreCase(_text),
dataset.accessionIdentifiers.any().acceNumb.equalsIgnoreCase(_text)
);
/*@formatter:on*/
}
return and;
}
}
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,10 +19,12 @@ import static org.genesys.catalog.model.traits.QDescriptor.descriptor;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.AuditedVersionedModelFilter;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.catalog.model.traits.Descriptor.Category;
import org.genesys.catalog.model.traits.QDescriptorList;
import org.genesys.common.model.QPartner;
import com.querydsl.core.BooleanBuilder;
......@@ -32,10 +34,14 @@ import com.querydsl.jpa.JPAExpressions;
/**
* The Class DescriptorFilter.
*
* @author Andrey Lugovskoy.
* @author Andrey Lugovskoy
* @author Matija Obreza
*/
public class DescriptorFilter extends AuditedVersionedModelFilter {
/** Any text. */
public String _text;
/** The owner. */
public PartnerFilter owner;
......@@ -78,6 +84,9 @@ public class DescriptorFilter extends AuditedVersionedModelFilter {
/** The max value. */
public NumberFilter<Double> maxValue;
/** Descriptor list filter */
public DescriptorListFilter list;
/**
* Builds the query.
*
......@@ -129,6 +138,31 @@ public class DescriptorFilter extends AuditedVersionedModelFilter {
if (maxValue != null) {
and.and(maxValue.buildQuery(descriptor.maxValue));
}
if (list != null) {
and.and(descriptor.descriptorLists.any().in(JPAExpressions.selectFrom(QDescriptorList.descriptorList).where(list.buildQuery())));
}
if (StringUtils.isNotBlank(_text)) {
/*@formatter:off*/
and.andAnyOf(
descriptor.title.containsIgnoreCase(_text),
descriptor.description.containsIgnoreCase(_text),
descriptor.bibliographicCitation.containsIgnoreCase(_text),
descriptor.crop.equalsIgnoreCase(_text),
descriptor.versionTag.equalsIgnoreCase(_text),
descriptor.publisher.equalsIgnoreCase(_text),
// owner
descriptor.owner.shortName.equalsIgnoreCase(_text),
descriptor.owner.name.containsIgnoreCase(_text),
// descriptor lists
descriptor.descriptorLists.any().publisher.equalsIgnoreCase(_text),
descriptor.descriptorLists.any().versionTag.equalsIgnoreCase(_text),
descriptor.descriptorLists.any().crop.equalsIgnoreCase(_text),
descriptor.descriptorLists.any().title.containsIgnoreCase(_text)
);
/*@formatter:on*/
}
return and;
}
}
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,6 +19,7 @@ import static org.genesys.catalog.model.traits.QDescriptorList.descriptorList;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.AuditedVersionedModelFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.common.model.QPartner;
......@@ -30,10 +31,14 @@ import com.querydsl.jpa.JPAExpressions;
/**
* The Class DescriptorListFilter.
*
* @author Andrey Lugovskoy.
* @author Andrey Lugovskoy
* @author Matija Obreza
*/
public class DescriptorListFilter extends AuditedVersionedModelFilter {
/** Any text. */
public String _text;
/** The owner. */
public PartnerFilter owner;
......@@ -85,6 +90,27 @@ public class DescriptorListFilter extends AuditedVersionedModelFilter {
if (owner != null) {
and.and(descriptorList.owner.in(JPAExpressions.selectFrom(QPartner.partner).where(owner.buildQuery())));
}
if (StringUtils.isNotBlank(_text)) {
/*@formatter:off*/
and.andAnyOf(
descriptorList.title.containsIgnoreCase(_text),
descriptorList.description.containsIgnoreCase(_text),
descriptorList.bibliographicCitation.containsIgnoreCase(_text),
descriptorList.crop.equalsIgnoreCase(_text),
descriptorList.versionTag.equalsIgnoreCase(_text),
descriptorList.publisher.equalsIgnoreCase(_text),
// owner
descriptorList.owner.shortName.equalsIgnoreCase(_text),
descriptorList.owner.name.containsIgnoreCase(_text),
// descriptors
descriptorList.descriptors.any().title.containsIgnoreCase(_text),
descriptorList.descriptors.any().crop.equalsIgnoreCase(_text),
descriptorList.descriptors.any().versionTag.equalsIgnoreCase(_text)
);
/*@formatter:on*/
}
return and;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment