use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class BooleanOperationsTest method booleanBuilder2.
@Test
public void booleanBuilder2() {
BooleanBuilder bb1 = new BooleanBuilder();
bb1.and(cat.eq(cat));
BooleanBuilder bb2 = new BooleanBuilder();
bb2.or(cat.eq(cat));
bb2.or(cat.eq(cat));
assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2.getValue()));
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class BooleanOperationsTest method booleanBuilder1.
@Test
public void booleanBuilder1() {
BooleanBuilder bb1 = new BooleanBuilder();
bb1.and(cat.eq(cat));
BooleanBuilder bb2 = new BooleanBuilder();
bb2.or(cat.eq(cat));
bb2.or(cat.eq(cat));
assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2));
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class CustomFinder method findCustom.
@SuppressWarnings("unchecked")
public static <T> List<T> findCustom(EntityManager em, Class<T> entityClass, Map<String, ?> filters, String sort) {
EntityPath<T> entityPath = new EntityPathBase<T>(entityClass, "entity");
BooleanBuilder builder = new BooleanBuilder();
for (Map.Entry<String, ?> entry : filters.entrySet()) {
SimplePath<Object> property = Expressions.path((Class) entry.getValue().getClass(), entityPath, entry.getKey());
builder.and(property.eq(entry.getValue()));
}
ComparablePath<?> sortProperty = Expressions.comparablePath(Comparable.class, entityPath, sort);
return new JPAQuery<Void>(em).from(entityPath).where(builder.getValue()).orderBy(sortProperty.asc()).select(entityPath).fetch();
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class SQLSerializerTest method boolean_.
@Test
public void boolean_() {
QSurvey s = new QSurvey("s");
BooleanBuilder bb1 = new BooleanBuilder();
bb1.and(s.name.eq(s.name));
BooleanBuilder bb2 = new BooleanBuilder();
bb2.or(s.name.eq(s.name));
bb2.or(s.name.eq(s.name));
String str = new SQLSerializer(Configuration.DEFAULT).handle(bb1.and(bb2)).toString();
assertEquals("s.NAME = s.NAME and (s.NAME = s.NAME or s.NAME = s.NAME)", str);
}
use of com.querydsl.core.BooleanBuilder in project sic by belluccifranco.
the class ProductoServiceImpl method buscarProductos.
@Override
public Page<Producto> buscarProductos(BusquedaProductoCriteria criteria) {
//Empresa
if (criteria.getEmpresa() == null) {
throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
}
//Rubro
if (criteria.isBuscarPorRubro() == true && criteria.getRubro() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_producto_vacio_rubro"));
}
//Proveedor
if (criteria.isBuscarPorProveedor() == true && criteria.getProveedor() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_producto_vacio_proveedor"));
}
QProducto qproducto = QProducto.producto;
BooleanBuilder builder = new BooleanBuilder();
builder.and(qproducto.empresa.eq(criteria.getEmpresa()).and(qproducto.eliminado.eq(false)));
if (criteria.isBuscarPorCodigo() == true && criteria.isBuscarPorDescripcion() == true) {
builder.and(qproducto.codigo.containsIgnoreCase(criteria.getCodigo()).or(this.buildPredicadoDescripcion(criteria.getDescripcion(), qproducto)));
} else {
if (criteria.isBuscarPorCodigo() == true) {
builder.and(qproducto.codigo.containsIgnoreCase(criteria.getCodigo()));
}
if (criteria.isBuscarPorDescripcion() == true) {
builder.and(this.buildPredicadoDescripcion(criteria.getDescripcion(), qproducto));
}
}
if (criteria.isBuscarPorRubro() == true) {
builder.and(qproducto.rubro.eq(criteria.getRubro()));
}
if (criteria.isBuscarPorProveedor()) {
builder.and(qproducto.proveedor.eq(criteria.getProveedor()));
}
if (criteria.isListarSoloFaltantes() == true) {
builder.and(qproducto.cantidad.loe(qproducto.cantMinima)).and(qproducto.ilimitado.eq(false));
}
return productoRepository.findAll(builder, criteria.getPageable());
}
Aggregations