DatasetLocationFilter.java
package org.genesys.server.model.filters;
import static org.genesys.server.model.dataset.QDatasetLocation.datasetLocation;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.server.model.dataset.DatasetLocation;
import org.genesys.server.model.dataset.QDatasetLocation;
import com.querydsl.core.types.Predicate;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class DatasetLocationFilter extends UuidModelFilter<DatasetLocationFilter, DatasetLocation> {
private static final long serialVersionUID = -601069622681438809L;
/**
* The longitude.
*/
public NumberFilter<Double> decimalLongitude;
/**
* The latitude.
*/
public NumberFilter<Double> decimalLatitude;
/**
* The elevation.
*/
public Set<String> userCountry;
/**
* Builds the query.
*
* @return the predicate
*/
public List<Predicate> collectPredicates() {
return collectPredicates(datasetLocation);
}
/**
* Builds the query.
*
* @param datasetLocation the country
* @return the predicate
*/
public List<Predicate> collectPredicates(QDatasetLocation datasetLocation) {
final List<Predicate> predicates = super.collectPredicates(datasetLocation, datasetLocation._super);
if (decimalLongitude != null) {
predicates.add(datasetLocation.decimalLongitude.isNotNull().and(decimalLongitude.buildQuery(datasetLocation.decimalLongitude)));
}
if (decimalLatitude != null) {
predicates.add(datasetLocation.decimalLatitude.isNotNull().and(decimalLatitude.buildQuery(datasetLocation.decimalLatitude)));
}
if (CollectionUtils.isNotEmpty(userCountry)) {
predicates.add(datasetLocation.userCountry.isNotNull().and(datasetLocation.userCountry.in(userCountry)));
}
return predicates;
}
}