PathogenFilter.java
/*
* Copyright 2022 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gringlobal.service.filter;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.TemporalFilter;
import org.gringlobal.model.community.Pathogen;
import org.gringlobal.model.community.QPathogen;
import com.querydsl.core.types.Predicate;
public class PathogenFilter extends CooperatorOwnedModelFilter<PathogenFilter, Pathogen, QPathogen> {
private static final long serialVersionUID = -8011503348135826942L;
/** The type of pathogen. */
public Set<String> pathogenType;
/** Full scientific name of the pathogen */
public StringFilter name;
/** The name authority */
public StringFilter nameAuthority;
/** Abbreviated name of the pathogen */
public StringFilter abbreviatedName;
/** The name verified date. */
public TemporalFilter<LocalDate> nameVerifiedDate;
/** The verifier cooperator */
public CooperatorFilter verifierCooperator;
/** Alternative name for the pathogen */
public StringFilter alternateName;
/** Is the on the FAO Quarantine list? */
public Boolean isQuarantine;
/** Is the pathogen extinct? */
public Boolean extinct;
/** The family name */
public StringFilter familyName;
/** The family authority */
public StringFilter familyAuthority;
/** The genus name */
public StringFilter genusName;
/** The genus authority */
public StringFilter genusAuthority;
/** The subgenus name */
public StringFilter subgenusName;
/** The species name */
public StringFilter speciesName;
/** The subspecies authority */
public StringFilter subspeciesAuthority;
/** The protologue */
public StringFilter protologue;
/** The pathogen geographies */
public GeographyFilter geographies;
/** The pathogen symptoms */
public SymptomFilter symptoms;
/** The pathogen order request items */
public OrderRequestItemFilter orderRequestItems ;
/** The
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QPathogen.pathogen);
}
/**
* Builds the query.
*
* @param pathogen the crop
* @return the predicate
*/
public List<Predicate> collectPredicates(QPathogen pathogen) {
final List<Predicate> predicates = super.collectSuperPredicates(pathogen, pathogen._super);
if (CollectionUtils.isNotEmpty(pathogenType)) {
predicates.add(pathogen.pathogenType.in(pathogenType));
}
if (name != null) {
predicates.add(name.buildQuery(pathogen.name));
}
if (nameAuthority != null) {
predicates.add(nameAuthority.buildQuery(pathogen.nameAuthority));
}
if (abbreviatedName != null) {
predicates.add(abbreviatedName.buildQuery(pathogen.abbreviatedName));
}
if (nameVerifiedDate != null) {
predicates.add(nameVerifiedDate.buildQuery(pathogen.nameVerifiedDate));
}
if (verifierCooperator != null) {
predicates.add(verifierCooperator.nestedPredicate(pathogen.verifierCooperator()));
}
if (alternateName != null) {
predicates.add(alternateName.buildQuery(pathogen.alternateName));
}
if (isQuarantine != null) {
predicates.add(pathogen.isQuarantine.eq(convertToString(isQuarantine)));
}
if (extinct != null) {
predicates.add(pathogen.isExtinct.eq(convertToString(extinct)));
}
if (familyName != null) {
predicates.add(familyName.buildQuery(pathogen.familyName));
}
if (familyAuthority != null) {
predicates.add(familyAuthority.buildQuery(pathogen.familyAuthority));
}
if (genusName != null) {
predicates.add(genusName.buildQuery(pathogen.genusName));
}
if (genusAuthority != null) {
predicates.add(genusAuthority.buildQuery(pathogen.genusAuthority));
}
if (subgenusName != null) {
predicates.add(subgenusName.buildQuery(pathogen.subgenusName));
}
if (speciesName != null) {
predicates.add(speciesName.buildQuery(pathogen.speciesName));
}
if (subspeciesAuthority != null) {
predicates.add(subspeciesAuthority.buildQuery(pathogen.subspeciesAuthority));
}
if (protologue != null) {
predicates.add(protologue.buildQuery(pathogen.protologue));
}
if (geographies != null) {
predicates.add(geographies.nestedPredicate(pathogen.geographies.any().geography()));
}
if (symptoms != null) {
predicates.add(symptoms.nestedPredicate(pathogen.symptoms.any().symptom()));
}
if (orderRequestItems != null) {
predicates.add(orderRequestItems.nestedPredicate(pathogen.orderRequestItems.any().orderRequestItem()));
}
return predicates;
}
}