Search in sources :

Example 1 with PageTemplate

use of org.broadleafcommerce.cms.page.domain.PageTemplate in project BroadleafCommerce by BroadleafCommerce.

the class PageDaoImpl method readAllPageTemplates.

@Override
public List<PageTemplate> readAllPageTemplates() {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<PageTemplate> criteria = builder.createQuery(PageTemplate.class);
    Root<PageTemplateImpl> template = criteria.from(PageTemplateImpl.class);
    criteria.select(template);
    try {
        Query query = em.createQuery(criteria);
        query.setHint(QueryHints.HINT_CACHEABLE, true);
        return query.getResultList();
    } catch (NoResultException e) {
        return Collections.emptyList();
    }
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) TypedQuery(javax.persistence.TypedQuery) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) PageTemplate(org.broadleafcommerce.cms.page.domain.PageTemplate) PageTemplateImpl(org.broadleafcommerce.cms.page.domain.PageTemplateImpl) NoResultException(javax.persistence.NoResultException)

Example 2 with PageTemplate

use of org.broadleafcommerce.cms.page.domain.PageTemplate in project BroadleafCommerce by BroadleafCommerce.

the class PageTemplateCustomPersistenceHandler method getFieldGroups.

protected List<FieldGroup> getFieldGroups(PersistencePackage pp, DynamicEntityDao dynamicEntityDao) {
    String pageId = pp.getCustomCriteria()[1];
    String pageTemplateId = pp.getCustomCriteria().length > 3 ? pp.getCustomCriteria()[3] : null;
    if (pageId == null) {
        return new ArrayList<FieldGroup>(0);
    }
    Page page = pageService.findPageById(Long.valueOf(pageId));
    PageTemplate template = null;
    if (pageTemplateId != null) {
        template = pageService.findPageTemplateById(Long.valueOf(pageTemplateId));
    }
    return getFieldGroups(page, template);
}
Also used : PageTemplate(org.broadleafcommerce.cms.page.domain.PageTemplate) ArrayList(java.util.ArrayList) Page(org.broadleafcommerce.cms.page.domain.Page)

Example 3 with PageTemplate

use of org.broadleafcommerce.cms.page.domain.PageTemplate in project BroadleafCommerce by BroadleafCommerce.

the class AdminPageController method viewEntityForm.

@Override
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String viewEntityForm(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @PathVariable(value = "id") String id) throws Exception {
    // Get the normal entity form for this item
    String returnPath = super.viewEntityForm(request, response, model, pathVars, id);
    EntityForm ef = (EntityForm) model.asMap().get("entityForm");
    DynamicEntityFormInfo info = getDynamicForm(ef, id);
    EntityForm dynamicForm;
    if (info.getPropertyValue() != null) {
        dynamicForm = getDynamicFieldTemplateForm(info, id, null);
    } else {
        dynamicForm = getEntityForm(info, null);
    }
    if (dynamicForm.getCeilingEntityClassname().equals(PageTemplate.class.getName())) {
        dynamicForm.setTranslationCeilingEntity(Page.class.getName());
        dynamicForm.setTranslationId(id);
    }
    ef.putDynamicFormInfo("pageTemplate", info);
    ef.putDynamicForm("pageTemplate", dynamicForm);
    // Mark the field that will drive this dynamic form
    addOnChangeTrigger(ef);
    ef.removeListGrid("additionalAttributes");
    return returnPath;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) PageTemplate(org.broadleafcommerce.cms.page.domain.PageTemplate) Page(org.broadleafcommerce.cms.page.domain.Page) DynamicEntityFormInfo(org.broadleafcommerce.openadmin.web.form.entity.DynamicEntityFormInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PageTemplate (org.broadleafcommerce.cms.page.domain.PageTemplate)3 Page (org.broadleafcommerce.cms.page.domain.Page)2 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)1 PageTemplateImpl (org.broadleafcommerce.cms.page.domain.PageTemplateImpl)1 DynamicEntityFormInfo (org.broadleafcommerce.openadmin.web.form.entity.DynamicEntityFormInfo)1 EntityForm (org.broadleafcommerce.openadmin.web.form.entity.EntityForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1