InventoryExtraFilter.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 com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.EntityPathBase;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.TemporalFilter;
import org.gringlobal.model.InventoryExtra;
import org.gringlobal.model.QInventoryExtra;
import org.gringlobal.model.QSeedInventoryExtra;
import org.gringlobal.model.QTissueCultureExtra;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class InventoryExtraFilter extends CooperatorOwnedModelFilter<InventoryExtraFilter, InventoryExtra> {
private static final long serialVersionUID = 1366212771064959076L;
public NumberFilter<Float> moistureContent;
public TemporalFilter<Date> moistureContentDate;
public NumberFilter<Double> initialViability;
public TemporalFilter<Date> initialViabilityDate;
/** The inventoryViability. */
public InventoryViabilityFilter lastViability;
public NumberFilter<Double> lastViabilityResult;
/** The inventory medium. */
public MaterielFilter medium;
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QInventoryExtra.inventoryExtra);
}
/**
* Builds the query.
*
* @param inventoryExtra the inventoryExtra
* @return the predicate
*/
public List<Predicate> collectPredicates(QInventoryExtra inventoryExtra) {
final List<Predicate> predicates = super.collectPredicates(inventoryExtra, inventoryExtra._super);
if (moistureContent != null) {
predicates.add(moistureContent.buildQuery(inventoryExtra.as(QSeedInventoryExtra.class).moistureContent));
}
if (moistureContentDate != null) {
predicates.add(moistureContentDate.buildQuery(inventoryExtra.as(QSeedInventoryExtra.class).moistureContentDate));
}
if (initialViability != null) {
predicates.add(initialViability.buildQuery(inventoryExtra.as(QSeedInventoryExtra.class).initialViability));
}
if (initialViabilityDate != null) {
predicates.add(initialViabilityDate.buildQuery(inventoryExtra.as(QSeedInventoryExtra.class).initialViabilityDate));
}
if (lastViability != null) {
predicates.addAll(lastViability.collectPredicates(inventoryExtra.as(QSeedInventoryExtra.class).lastViability()));
}
if (lastViabilityResult != null) {
predicates.add(lastViabilityResult.buildQuery(inventoryExtra.as(QSeedInventoryExtra.class).lastViabilityResult));
}
if (medium != null) {
predicates.addAll(medium.collectPredicates(inventoryExtra.as(QTissueCultureExtra.class).medium()));
}
return predicates;
}
@Override
protected Set<Class<? extends EntityPathBase<? extends InventoryExtra>>> getSubClasses() {
return Set.of(QSeedInventoryExtra.class, QTissueCultureExtra.class);
}
}