WebUserFilter.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.genesys.blocks.model.filters.AuditedVersionedModelFilter;
import org.genesys.blocks.model.filters.StringFilter;
import org.gringlobal.model.QWebUser;
import org.gringlobal.model.WebUser;
import com.querydsl.core.types.Predicate;
/**
* Filters for {@link WebUser}
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class WebUserFilter extends AuditedVersionedModelFilter<WebUserFilter, WebUser> implements IFullTextFilter {
private static final long serialVersionUID = 3207874212833072010L;
/** Any text. */
public String _text;
/** The username. */
public StringFilter username;
/** Is enabled */
public Boolean enabled;
/**
* Builds the query.
*
* @return the predicate
*/
@Override
public List<Predicate> collectPredicates() {
return collectPredicates(QWebUser.webUser);
}
/**
* Builds the query.
*
* @param webUser the webUser
* @return the predicate
*/
public List<Predicate> collectPredicates(QWebUser webUser) {
final List<Predicate> predicates = super.collectPredicates(webUser, webUser._super._super._super);
if (username != null) {
predicates.add(username.buildQuery(webUser.username));
}
if (enabled != null) {
predicates.add(webUser.isEnabled.eq(enabled ? "Y" : "N"));
}
return predicates;
}
/**
* Gets the text.
*
* @return the text
*/
@Override
public String get_text() {
return _text;
}
/**
* Username filter.
*
* @return the string filter
*/
public synchronized StringFilter username() {
return this.username == null ? this.username = new StringFilter() : this.username;
}
}