use of org.broadleafcommerce.cms.page.domain.PageImpl in project BroadleafCommerce by BroadleafCommerce.
the class PageDaoImpl method readAllPages.
@Override
public List<Page> readAllPages() {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Page> criteria = builder.createQuery(Page.class);
Root<PageImpl> page = criteria.from(PageImpl.class);
criteria.select(page);
try {
Query query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
return query.getResultList();
} catch (NoResultException e) {
return Collections.emptyList();
}
}
use of org.broadleafcommerce.cms.page.domain.PageImpl in project BroadleafCommerce by BroadleafCommerce.
the class PageDaoImpl method readOnlineAndIncludedPages.
@Override
public List<Page> readOnlineAndIncludedPages(int limit, int offset, String sortBy) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Page> criteria = builder.createQuery(Page.class);
Root<PageImpl> page = criteria.from(PageImpl.class);
criteria.select(page);
criteria.where(builder.and(builder.or(builder.isFalse(page.get("offlineFlag").as(Boolean.class)), builder.isNull(page.get("offlineFlag").as(Boolean.class))), builder.or(builder.isFalse(page.get("excludeFromSiteMap").as(Boolean.class)), builder.isNull(page.get("excludeFromSiteMap").as(Boolean.class)))));
criteria.orderBy(builder.asc(page.get(sortBy)));
TypedQuery<Page> query = em.createQuery(criteria);
query.setFirstResult(offset);
query.setMaxResults(limit);
query.setHint(QueryHints.HINT_CACHEABLE, true);
return query.getResultList();
}
use of org.broadleafcommerce.cms.page.domain.PageImpl in project BroadleafCommerce by BroadleafCommerce.
the class PageSiteMapGeneratorTest method testPageSiteMapGenerator.
@Test
public void testPageSiteMapGenerator() throws SiteMapException, IOException {
Page p1 = new PageImpl();
p1.setFullUrl("/about_us");
Page p2 = new PageImpl();
p2.setFullUrl("faq");
Page p3 = new PageImpl();
p3.setFullUrl("/new-to-hot-sauce");
List<Page> pages = new ArrayList<Page>();
pages.add(p1);
pages.add(p2);
pages.add(p3);
PageDao pageDao = EasyMock.createMock(PageDao.class);
EasyMock.expect(pageDao.readOnlineAndIncludedPages(5, 0, "fullUrl")).andReturn(pages);
EasyMock.replay(pageDao);
PageSiteMapGenerator psmg = new PageSiteMapGenerator();
psmg.setPageDao(pageDao);
psmg.setRowLimit(5);
SiteMapGeneratorConfiguration smgc = new SiteMapGeneratorConfigurationImpl();
smgc.setDisabled(false);
smgc.setSiteMapGeneratorType(SiteMapGeneratorType.PAGE);
smgc.setSiteMapChangeFreq(SiteMapChangeFreqType.HOURLY);
smgc.setSiteMapPriority(SiteMapPriorityType.POINT5);
testGenerator(smgc, psmg);
File file1 = fileService.getResource("/sitemap_index.xml");
File file2 = fileService.getResource("/sitemap1.xml");
File file3 = fileService.getResource("/sitemap2.xml");
compareFiles(file1, "src/test/resources/org/broadleafcommerce/sitemap/page/sitemap_index.xml");
compareFiles(file2, "src/test/resources/org/broadleafcommerce/sitemap/page/sitemap1.xml");
compareFiles(file3, "src/test/resources/org/broadleafcommerce/sitemap/page/sitemap2.xml");
}
Aggregations