AppResourceFilter.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.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.filters.StringFilter;
import org.gringlobal.model.AppResource;
import org.gringlobal.model.QAppResource;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
/**
* Filters for {@link AppResource}
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class AppResourceFilter extends CooperatorOwnedModelFilter<AppResourceFilter, AppResource> {
private static final long serialVersionUID = 2262073031210962761L;
/** Any text. */
public String _text;
/** The appName. */
public StringFilter appName;
/** The appResourceName. */
public StringFilter appResourceName;
/** The description. */
public StringFilter description;
/** The displayMember. */
public StringFilter displayMember;
/** The formName. */
public StringFilter formName;
/** The valueMember. */
public StringFilter valueMember;
/** The properties. */
public StringFilter properties;
/** The sortOrder. */
public Integer sortOrder;
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QAppResource.appResource);
}
/**
* Builds the query.
*
* @param qAppResource the qAppResource
* @return the predicate
*/
public List<Predicate> collectPredicates(QAppResource qAppResource) {
final List<Predicate> predicates = super.collectPredicates(qAppResource, qAppResource._super);
if (StringUtils.isNotBlank(_text)) {
String likeString = _text + "%";
BooleanExpression expression = qAppResource.appName.like(likeString)
.or(qAppResource.appResourceName.like(likeString))
.or(qAppResource.formName.like(likeString))
.or(qAppResource.displayMember.like(likeString));
predicates.add(expression);
}
if (appName != null) {
predicates.add(appName.buildQuery(qAppResource.appName));
}
if (appResourceName != null) {
predicates.add(appResourceName.buildQuery(qAppResource.appResourceName));
}
if (description != null) {
predicates.add(description.buildQuery(qAppResource.description));
}
if (displayMember != null) {
predicates.add(displayMember.buildQuery(qAppResource.displayMember));
}
if (formName != null) {
predicates.add(formName.buildQuery(qAppResource.formName));
}
if (valueMember != null) {
predicates.add(valueMember.buildQuery(qAppResource.valueMember));
}
if (properties != null) {
predicates.add(properties.buildQuery(qAppResource.properties));
}
if (sortOrder != null) {
predicates.add(qAppResource.sortOrder.eq(sortOrder));
}
return predicates;
}
public synchronized StringFilter appName() {
return this.appName == null ? this.appName = new StringFilter() : this.appName;
}
public synchronized StringFilter appResourceName() {
return this.appResourceName == null ? this.appResourceName = new StringFilter() : this.appResourceName;
}
public synchronized StringFilter formName() {
return this.formName == null ? this.formName = new StringFilter() : this.formName;
}
public synchronized AppResourceFilter sortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
return this;
}
}