use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class CatalogItemFinder method findBySearchCriteria.
public <T extends CatalogItem> List<T> findBySearchCriteria(EntityPath<T> entityPath, String searchCriteria, Integer offset, Integer limit, String orderBy, Boolean isDesc) {
QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
JPAQuery<T> query = new JPAQueryFactory(entityManager).selectFrom(entityPath).where(buildSearchPredicate(searchCriteria, qCatalogItem));
addOffsetAndLimitToQuery(offset, limit, query, orderBy, isDesc, qCatalogItem);
return query.fetch();
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class CatalogItemFinder method countBySearchCriteria.
public Long countBySearchCriteria(EntityPath<? extends CatalogItem> entityPath, String searchCriteria) {
QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(qCatalogItem).where(buildSearchPredicate(searchCriteria, qCatalogItem));
return query.fetchCount();
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class DiscountFinder method findEligibleOrderDiscounts.
/*
* Returns all discounts eligible for end-user
* @param applicableTo the applicable type of discount
* @param locale the locale for results localization
* @return the visible discounts: not disabled, with startDate and endDate respectively before and after now and without
* voucher code, applicable to given number of orders
*/
public List<Discount> findEligibleOrderDiscounts(String locale, Long completedOrderNumbers) {
Date now = new Date();
List<Discount> results = new JPAQueryFactory(entityManager).selectFrom(discount).where(discount.disabled.isFalse(), discount.endDate.after(now).or(discount.endDate.isNull()), discount.startDate.before(now).or(discount.startDate.isNull()), discount.applicableTo.eq(ApplicableTo.ORDER), discount.triggerRule.ne(Discount.Trigger.ORDER_NUMBER).or(discount.triggerValue.eq(completedOrderNumbers.doubleValue() + 1)), discount.voucherCode.isNull()).fetch();
results.forEach((discount) -> discount.setLocalizedPresentation(locale));
return results;
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class DiscountFinder method findVisibleDiscounts.
/*
* Returns all discounts visible to end user
* @param applicableTo the applicable type of discount
* @param locale the locale for results localization
* @return the visible discounts: not disabled, with startDate and endDate respectively before and after now and without
* voucher code
*/
public List<Discount> findVisibleDiscounts(ApplicableTo applicableTo, String locale) {
Date now = new Date();
List<Discount> results = new JPAQueryFactory(entityManager).selectFrom(discount).where(discount.disabled.isFalse(), discount.endDate.after(now).or(discount.endDate.isNull()), discount.startDate.before(now).or(discount.startDate.isNull()), discount.applicableTo.eq(applicableTo), discount.voucherCode.isNull()).fetch();
results.forEach((discount) -> discount.setLocalizedPresentation(locale));
return results;
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class UserFinder method findAll.
public List<User> findAll(Integer offset, Integer limit, String orderBy, Boolean isDesc) {
JPAQuery<User> query = new JPAQueryFactory(entityManager).selectFrom(user);
if (offset != null)
query.offset(offset);
if (limit != null)
query.limit(limit);
sortBy(orderBy, isDesc, query);
return query.fetch();
}
Aggregations