Commit 1f849b78 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov

added filters for dataset locations and rights

parent ab861ffb
......@@ -48,6 +48,8 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> {
/** The accession identifier. */
public AccessionIdentifierFilter accessionIdentifier;
public DatasetLocationFilter location;
public DescriptorFilter descriptor;
/** The title. */
......@@ -65,6 +67,8 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> {
/** The crop. */
public Set<String> crop;
public Set<String> rights;
/**
* Builds the query.
*
......@@ -99,6 +103,14 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> {
and.and(dataset.crops.any().in(crop));
}
if (location != null) {
and.and(location.buildQuery(dataset.locations.any()));
}
if (CollectionUtils.isNotEmpty(rights)) {
and.and(dataset.rights.in(rights));
}
if (StringUtils.isNotBlank(_text)) {
/*@formatter:off*/
and.andAnyOf(
......
package org.genesys.catalog.model.filters;
import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.UuidModelFilter;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import org.genesys.catalog.model.dataset.DatasetLocation;
import org.genesys.catalog.model.dataset.QDatasetLocation;
import java.util.Set;
import static org.genesys.catalog.model.dataset.QDatasetLocation.datasetLocation;
public class DatasetLocationFilter extends UuidModelFilter<DatasetLocationFilter, DatasetLocation> {
/**
* The longitude.
*/
public NumberFilter<Double> longitude;
/**
* The latitude.
*/
public NumberFilter<Double> latitude;
/**
* The elevation.
*/
public Set<String> country;
/**
* Builds the query.
*
* @return the predicate
*/
public Predicate buildQuery() {
return buildQuery(datasetLocation);
}
/**
* Builds the query.
*
* @param datasetLocation the country
* @return the predicate
*/
public Predicate buildQuery(QDatasetLocation datasetLocation) {
final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(datasetLocation, datasetLocation._super, and);
if (longitude != null) {
and.and(longitude.buildQuery(datasetLocation.decimalLongitude));
}
if (latitude != null) {
and.and(latitude.buildQuery(datasetLocation.decimalLatitude));
}
if (CollectionUtils.isNotEmpty(country)) {
and.and(datasetLocation.userCountry.in(country));
}
return and;
}
}
Markdown is supported
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