PathogenTaxonomySpeciesMapFilter.java

/*
 * Copyright 2026 Global Crop Diversity Trust
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
 */

package org.gringlobal.service.filter;

import java.util.List;

import org.genesys.blocks.model.filters.StringFilter;

import org.gringlobal.model.community.PathogenTaxonomySpeciesMap;
import org.gringlobal.model.community.QPathogenTaxonomySpeciesMap;

import com.querydsl.core.types.Predicate;

/**
 * Filters for {@link PathogenTaxonomySpeciesMap}
 */
public class PathogenTaxonomySpeciesMapFilter extends CooperatorOwnedModelFilter<PathogenTaxonomySpeciesMapFilter, PathogenTaxonomySpeciesMap, QPathogenTaxonomySpeciesMap> {

	private static final long serialVersionUID = -1234567890123456791L;

	/** The pathogen. */
	public PathogenFilter pathogen;

	/** The taxonomy species. */
	public TaxonomySpeciesFilter taxonomySpecies;

	/** The note. */
	public StringFilter note;

	@Override
	public List<Predicate> collectPredicates() {
		return collectPredicates(QPathogenTaxonomySpeciesMap.pathogenTaxonomySpeciesMap);
	}

	/**
	 * Builds the query.
	 *
	 * @param pathogenTaxonomySpeciesMap the pathogen taxonomy species map
	 * @return the predicate list
	 */
	public List<Predicate> collectPredicates(QPathogenTaxonomySpeciesMap pathogenTaxonomySpeciesMap) {
		final List<Predicate> predicates = super.collectSuperPredicates(pathogenTaxonomySpeciesMap, pathogenTaxonomySpeciesMap._super);

		if (pathogen != null) {
			predicates.add(pathogen.nestedPredicate(pathogenTaxonomySpeciesMap.pathogen()));
		}
		if (taxonomySpecies != null) {
			predicates.add(taxonomySpecies.nestedPredicate(pathogenTaxonomySpeciesMap.taxonomySpecies()));
		}
		if (note != null) {
			predicates.add(note.buildQuery(pathogenTaxonomySpeciesMap.note));
		}

		return predicates;
	}
}