InventoryMaintenancePolicyFilter.java
/*
* Copyright 2020 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.util.HashSet;
import java.util.List;
import java.util.Set;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.gringlobal.model.InventoryMaintenancePolicy;
import org.gringlobal.model.QInventoryMaintenancePolicy;
import com.querydsl.core.types.Predicate;
/**
* Filters for {@link InventoryMaintenancePolicy}
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class InventoryMaintenancePolicyFilter extends CooperatorOwnedModelFilter<InventoryMaintenancePolicyFilter, InventoryMaintenancePolicy> {
private static final long serialVersionUID = -6521156076517165042L;
/** The curator cooperator. */
public CooperatorFilter curatorCooperator;
/** The distribution critical quantity. */
public NumberFilter<Double> distributionCriticalQuantity;
/** The distribution default form code. */
public Set<String> distributionDefaultFormCode;
/** The distribution default quantity. */
public NumberFilter<Double> distributionDefaultQuantity;
/** The distribution unit code. */
public Set<String> distributionUnitCode;
/** The form type code. */
public Set<String> formTypeCode;
/** Is auto deducted */
public Boolean autoDeducted;
/** The maintenance name. */
public StringFilter maintenanceName;
/** The note. */
public StringFilter note;
/** The quantity on hand unit code. */
public Set<String> quantityOnHandUnitCode;
/** The regeneration critical quantity. */
public NumberFilter<Double> regenerationCriticalQuantity;
/** The regeneration method code. */
public Set<String> regenerationMethodCode;
/** The web availability note. */
public StringFilter webAvailabilityNote;
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QInventoryMaintenancePolicy.inventoryMaintenancePolicy);
}
/**
* Builds the query.
*
* @param maintenance the inventory maintenance policy
* @return the predicate
*/
public List<Predicate> collectPredicates(QInventoryMaintenancePolicy maintenance) {
final List<Predicate> predicates = super.collectPredicates(maintenance, maintenance._super);
if (CollectionUtils.isNotEmpty(id)) {
predicates.add(maintenance.id.in(id));
}
if (curatorCooperator != null) {
predicates.addAll(curatorCooperator.collectPredicates(maintenance.curatorCooperator()));
}
if (distributionCriticalQuantity != null) {
predicates.add(distributionCriticalQuantity.buildQuery(maintenance.distributionCriticalQuantity));
}
if (CollectionUtils.isNotEmpty(distributionDefaultFormCode)) {
predicates.add(maintenance.distributionDefaultFormCode.in(distributionDefaultFormCode));
}
if (distributionDefaultQuantity != null) {
predicates.add(distributionDefaultQuantity.buildQuery(maintenance.distributionDefaultQuantity));
}
if (CollectionUtils.isNotEmpty(distributionUnitCode)) {
predicates.add(maintenance.distributionUnitCode.in(distributionUnitCode));
}
if (CollectionUtils.isNotEmpty(formTypeCode)) {
predicates.add(maintenance.formTypeCode.in(formTypeCode));
}
if (autoDeducted != null) {
predicates.add(maintenance.isAutoDeducted.eq(convertToString(autoDeducted)));
}
if (maintenanceName != null) {
predicates.add(maintenanceName.buildQuery(maintenance.maintenanceName));
}
if (note != null) {
predicates.add(note.buildQuery(maintenance.note));
}
if (CollectionUtils.isNotEmpty(quantityOnHandUnitCode)) {
predicates.add(maintenance.quantityOnHandUnitCode.in(quantityOnHandUnitCode));
}
if (regenerationCriticalQuantity != null) {
predicates.add(regenerationCriticalQuantity.buildQuery(maintenance.regenerationCriticalQuantity));
}
if (CollectionUtils.isNotEmpty(regenerationMethodCode)) {
predicates.add(maintenance.regenerationMethodCode.in(regenerationMethodCode));
}
if (webAvailabilityNote != null) {
predicates.add(webAvailabilityNote.buildQuery(maintenance.webAvailabilityNote));
}
return predicates;
}
public synchronized Set<String> distributionDefaultFormCode() {
return this.distributionDefaultFormCode == null ? this.distributionDefaultFormCode = new HashSet<>() : this.distributionDefaultFormCode;
}
}