InventoryQualityStatusFilter.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 com.querydsl.core.types.Predicate;
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.TemporalFilter;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.gringlobal.model.InventoryQualityStatus;
import org.gringlobal.model.QInventoryQualityStatus;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class InventoryQualityStatusFilter extends CooperatorOwnedModelFilter<InventoryQualityStatusFilter, InventoryQualityStatus> implements IFullTextFilter {
private static final long serialVersionUID = -7218038584777524111L;
/** Any text. */
public String _text;
/** The completed number. */
public NumberFilter<Integer> completedCount;
/** The completed date. */
public TemporalFilter<Date> completedDate;
/** The completed date code. */
public Set<String> completedDateCode;
/** The contaminant code. */
public Set<String> contaminantCode;
/** The inventory. */
public InventoryFilter inventory;
/** The method. */
public MethodFilter method;
/** The negativeControl. */
public NumberFilter<Double> negativeControl;
/** The note. */
public StringFilter note;
/** The plant part tested code. */
public Set<String> plantPartTestedCode;
/** The plate or assay number. */
public Set<String> plateOrAssayNumber;
/** The positiveControl. */
public NumberFilter<Double> positiveControl;
/** The replicate. */
public NumberFilter<Integer> replicate;
/** The required replication number. */
public NumberFilter<Integer> requiredReplicationCount;
/** The startedCount. */
public NumberFilter<Integer> startedCount;
/** The started date. */
public TemporalFilter<Date> startedDate;
/** The started date code. */
public Set<String> startedDateCode;
/** The test result code. */
public Set<String> testResultCode;
/** The test result score. */
public Set<String> testResultsScore;
/** The test result score type code. */
public Set<String> testResultsScoreTypeCode;
/** The test type code. */
public Set<String> testTypeCode;
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QInventoryQualityStatus.inventoryQualityStatus);
}
/**
* Builds the query.
*
* @param status the inventory quality status
* @return the predicate
*/
public List<Predicate> collectPredicates(QInventoryQualityStatus status) {
final List<Predicate> predicates = super.collectPredicates(status, status._super);
if (completedCount != null) {
predicates.add(completedCount.buildQuery(status.completedCount));
}
if (completedDate != null) {
predicates.add(completedDate.buildQuery(status.completedDate));
}
if (CollectionUtils.isNotEmpty(completedDateCode)) {
predicates.add(status.completedDateCode.in(completedDateCode));
}
if (CollectionUtils.isNotEmpty(contaminantCode)) {
predicates.add(status.contaminantCode.in(contaminantCode));
}
if (inventory != null) {
predicates.addAll(inventory.collectPredicates(status.inventory()));
}
if (method != null) {
predicates.addAll(method.collectPredicates(status.method()));
}
if (negativeControl != null) {
predicates.add(negativeControl.buildQuery(status.negativeControl));
}
if (note != null) {
predicates.add(note.buildQuery(status.note));
}
if (CollectionUtils.isNotEmpty(plantPartTestedCode)) {
predicates.add(status.plantPartTestedCode.in(plantPartTestedCode));
}
if (CollectionUtils.isNotEmpty(plateOrAssayNumber)) {
predicates.add(status.plateOrAssayNumber.in(plateOrAssayNumber));
}
if (positiveControl != null) {
predicates.add(positiveControl.buildQuery(status.positiveControl));
}
if (replicate != null) {
predicates.add(replicate.buildQuery(status.replicate));
}
if (requiredReplicationCount != null) {
predicates.add(requiredReplicationCount.buildQuery(status.requiredReplicationCount));
}
if (startedCount != null) {
predicates.add(startedCount.buildQuery(status.startedCount));
}
if (startedDate != null) {
predicates.add(startedDate.buildQuery(status.startedDate));
}
if (CollectionUtils.isNotEmpty(startedDateCode)) {
predicates.add(status.startedDateCode.in(startedDateCode));
}
if (CollectionUtils.isNotEmpty(testResultCode)) {
predicates.add(status.testResultCode.in(testResultCode));
}
if (CollectionUtils.isNotEmpty(testResultsScore)) {
predicates.add(status.testResultsScore.in(testResultsScore));
}
if (CollectionUtils.isNotEmpty(testResultsScoreTypeCode)) {
predicates.add(status.testResultsScoreTypeCode.in(testResultsScoreTypeCode));
}
if (CollectionUtils.isNotEmpty(testTypeCode)) {
predicates.add(status.testTypeCode.in(testTypeCode));
}
return predicates;
}
/**
* Id.
*
* @return the sets the
*/
public synchronized Set<Long> id() {
if (id == null) {
id = new HashSet<>();
}
return id;
}
/**
* Gets the text.
*
* @return the text
*/
@Override
public String get_text() {
return _text;
}
}