org.broadleafcommerce.openadmin.server.service.persistence.module.criteria
Class CriteriaTranslatorImpl

java.lang.Object
  extended by org.broadleafcommerce.openadmin.server.service.persistence.module.criteria.CriteriaTranslatorImpl
All Implemented Interfaces:
CriteriaTranslator

@Service(value="blCriteriaTranslator")
public class CriteriaTranslatorImpl
extends Object
implements CriteriaTranslator

Author:
Jeff Fischer

Field Summary
protected  List<CriteriaTranslatorEventHandler> eventHandlers
           
 
Constructor Summary
CriteriaTranslatorImpl()
           
 
Method Summary
protected  void addPaging(javax.persistence.Query response, Integer firstResult, Integer maxResults)
           
protected  void addRestrictions(String ceilingEntity, List<FilterMapping> filterMappings, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.Root original, List<javax.persistence.criteria.Predicate> restrictions, List<javax.persistence.criteria.Order> sorts)
          Deprecated. 
protected  void addRestrictions(String ceilingEntity, List<FilterMapping> filterMappings, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.Root original, List<javax.persistence.criteria.Predicate> restrictions, List<javax.persistence.criteria.Order> sorts, javax.persistence.criteria.CriteriaQuery criteria)
           
protected  void addSorting(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, List<javax.persistence.criteria.Order> sorts, FilterMapping filterMapping, javax.persistence.criteria.Path path)
           
protected  javax.persistence.TypedQuery<Serializable> constructQuery(DynamicEntityDao dynamicEntityDao, String ceilingEntity, List<FilterMapping> filterMappings, boolean isCount, boolean isMax, Integer firstResult, Integer maxResults, String maxField)
           
protected  Class<Serializable> determineRoot(DynamicEntityDao dynamicEntityDao, Class<Serializable> ceilingMarker, List<FilterMapping> filterMappings)
          Determines the appropriate entity in this current class tree to use as the ceiling entity for the query.
protected  ClassTree determineRootInternal(ClassTree root, List<ClassTree> parents, Class<?> classToCheck)
          Because of the restriction described in determineRoot(DynamicEntityDao, Class, List), we must check that a class lies inside of the same tree as the current known root.
 javax.persistence.TypedQuery<Serializable> translateCountQuery(DynamicEntityDao dynamicEntityDao, String ceilingEntity, List<FilterMapping> filterMappings)
           
 javax.persistence.TypedQuery<Serializable> translateMaxQuery(DynamicEntityDao dynamicEntityDao, String ceilingEntity, List<FilterMapping> filterMappings, String maxField)
           
 javax.persistence.TypedQuery<Serializable> translateQuery(DynamicEntityDao dynamicEntityDao, String ceilingEntity, List<FilterMapping> filterMappings, Integer firstResult, Integer maxResults)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventHandlers

protected List<CriteriaTranslatorEventHandler> eventHandlers
Constructor Detail

CriteriaTranslatorImpl

public CriteriaTranslatorImpl()
Method Detail

translateCountQuery

public javax.persistence.TypedQuery<Serializable> translateCountQuery(DynamicEntityDao dynamicEntityDao,
                                                                      String ceilingEntity,
                                                                      List<FilterMapping> filterMappings)
Specified by:
translateCountQuery in interface CriteriaTranslator

translateMaxQuery

public javax.persistence.TypedQuery<Serializable> translateMaxQuery(DynamicEntityDao dynamicEntityDao,
                                                                    String ceilingEntity,
                                                                    List<FilterMapping> filterMappings,
                                                                    String maxField)
Specified by:
translateMaxQuery in interface CriteriaTranslator

translateQuery

public javax.persistence.TypedQuery<Serializable> translateQuery(DynamicEntityDao dynamicEntityDao,
                                                                 String ceilingEntity,
                                                                 List<FilterMapping> filterMappings,
                                                                 Integer firstResult,
                                                                 Integer maxResults)
Specified by:
translateQuery in interface CriteriaTranslator

determineRoot

protected Class<Serializable> determineRoot(DynamicEntityDao dynamicEntityDao,
                                            Class<Serializable> ceilingMarker,
                                            List<FilterMapping> filterMappings)
                                     throws NoPossibleResultsException
Determines the appropriate entity in this current class tree to use as the ceiling entity for the query. Because we filter with AND instead of OR, we throw an exception if an attempt to utilize properties from mutually exclusive class trees is made as it would be impossible for such a query to return results.

Parameters:
dynamicEntityDao -
ceilingMarker -
filterMappings -
Returns:
the root class
Throws:
NoPossibleResultsException

determineRootInternal

protected ClassTree determineRootInternal(ClassTree root,
                                          List<ClassTree> parents,
                                          Class<?> classToCheck)
Because of the restriction described in determineRoot(DynamicEntityDao, Class, List), we must check that a class lies inside of the same tree as the current known root. Consider the following situation: Class C extends Class B, which extends Class A. Class E extends Class D, which also extends Class A. We can allow filtering on properties that are either all in C/B/A or all in E/D/A. Filtering on properties across C/B and E/D will always produce no results given an AND style of joining the filtered properties.

Parameters:
root -
parents -
classToCheck -
Returns:
the (potentially new) root or null if invalid

constructQuery

protected javax.persistence.TypedQuery<Serializable> constructQuery(DynamicEntityDao dynamicEntityDao,
                                                                    String ceilingEntity,
                                                                    List<FilterMapping> filterMappings,
                                                                    boolean isCount,
                                                                    boolean isMax,
                                                                    Integer firstResult,
                                                                    Integer maxResults,
                                                                    String maxField)

addPaging

protected void addPaging(javax.persistence.Query response,
                         Integer firstResult,
                         Integer maxResults)

addRestrictions

@Deprecated
protected void addRestrictions(String ceilingEntity,
                                          List<FilterMapping> filterMappings,
                                          javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                                          javax.persistence.criteria.Root original,
                                          List<javax.persistence.criteria.Predicate> restrictions,
                                          List<javax.persistence.criteria.Order> sorts)
Deprecated. 

This method is deprecated in favor of addRestrictions(String, List, CriteriaBuilder, Root, List, List, CriteriaQuery) It will be removed in Broadleaf version 3.1.0.

Parameters:
ceilingEntity -
filterMappings -
criteriaBuilder -
original -
restrictions -
sorts -

addRestrictions

protected void addRestrictions(String ceilingEntity,
                               List<FilterMapping> filterMappings,
                               javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                               javax.persistence.criteria.Root original,
                               List<javax.persistence.criteria.Predicate> restrictions,
                               List<javax.persistence.criteria.Order> sorts,
                               javax.persistence.criteria.CriteriaQuery criteria)

addSorting

protected void addSorting(javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                          List<javax.persistence.criteria.Order> sorts,
                          FilterMapping filterMapping,
                          javax.persistence.criteria.Path path)


Copyright © 2013. All Rights Reserved.