Search in sources :

Example 1 with QCatalogItem

use of org.rembx.jeeshop.catalog.model.QCatalogItem 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();
}
Also used : QCatalogItem(org.rembx.jeeshop.catalog.model.QCatalogItem) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory)

Example 2 with QCatalogItem

use of org.rembx.jeeshop.catalog.model.QCatalogItem 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();
}
Also used : QCatalogItem(org.rembx.jeeshop.catalog.model.QCatalogItem) JPAQuery(com.querydsl.jpa.impl.JPAQuery) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory)

Example 3 with QCatalogItem

use of org.rembx.jeeshop.catalog.model.QCatalogItem in project jeeshop by remibantos.

the class CatalogItemFinder method findVisibleCatalogItems.

public <T extends CatalogItem> List<T> findVisibleCatalogItems(EntityPath<T> entityPath, List<T> items, String locale) {
    QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
    Date now = new Date();
    List<T> results = new JPAQueryFactory(entityManager).selectFrom(entityPath).where(qCatalogItem.disabled.isFalse(), qCatalogItem.endDate.after(now).or(qCatalogItem.endDate.isNull()), qCatalogItem.startDate.before(now).or(qCatalogItem.startDate.isNull()), qCatalogItem.in(items)).fetch();
    results.forEach((catalogItem) -> catalogItem.setLocalizedPresentation(locale));
    return results;
}
Also used : QCatalogItem(org.rembx.jeeshop.catalog.model.QCatalogItem) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory) Date(java.util.Date)

Example 4 with QCatalogItem

use of org.rembx.jeeshop.catalog.model.QCatalogItem in project jeeshop by remibantos.

the class CatalogItemFinder method findAll.

public <T extends CatalogItem> List<T> findAll(EntityPath<T> entityPath, Integer offset, Integer limit, String orderBy, Boolean isDesc) {
    QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
    JPAQuery<T> query = new JPAQueryFactory(entityManager).selectFrom(entityPath);
    addOffsetAndLimitToQuery(offset, limit, query, orderBy, isDesc, qCatalogItem);
    return query.fetch();
}
Also used : QCatalogItem(org.rembx.jeeshop.catalog.model.QCatalogItem) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory)

Example 5 with QCatalogItem

use of org.rembx.jeeshop.catalog.model.QCatalogItem in project jeeshop by remibantos.

the class CatalogItemFinder method countAll.

public Long countAll(EntityPath<? extends CatalogItem> entityPath) {
    QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
    JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(qCatalogItem);
    return query.fetchCount();
}
Also used : QCatalogItem(org.rembx.jeeshop.catalog.model.QCatalogItem) JPAQuery(com.querydsl.jpa.impl.JPAQuery) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory)

Aggregations

JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)5 QCatalogItem (org.rembx.jeeshop.catalog.model.QCatalogItem)5 JPAQuery (com.querydsl.jpa.impl.JPAQuery)2 Date (java.util.Date)1