org.ofbiz.entity.util
Class EntityUtil

java.lang.Object
  extended by org.ofbiz.entity.util.EntityUtil

public class EntityUtil
extends java.lang.Object

Helper methods when dealing with Entities, especially ones that follow certain conventions


Field Summary
static java.lang.String module
           
 
Constructor Summary
EntityUtil()
           
 
Method Summary
static void delDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> search)
           
static void delDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> search, java.sql.Timestamp now)
           
static
<T extends GenericEntity>
java.util.List<T>
filterByAnd(java.util.List<T> values, java.util.List<? extends EntityCondition> exprs)
          returns the values that match all of the exprs in list
static
<T extends GenericEntity>
java.util.List<T>
filterByAnd(java.util.List<T> values, java.util.Map<java.lang.String,? extends java.lang.Object> fields)
          returns the values that match the values in fields
static
<T extends GenericEntity>
java.util.List<T>
filterByCondition(java.util.List<T> values, EntityCondition condition)
           
static
<T extends GenericEntity>
java.util.List<T>
filterByDate(java.util.List<T> datedValues)
          returns the values that are currently active.
static
<T extends GenericEntity>
java.util.List<T>
filterByDate(java.util.List<T> datedValues, boolean allAreSame)
          returns the values that are currently active.
static
<T extends GenericEntity>
java.util.List<T>
filterByDate(java.util.List<T> datedValues, java.util.Date moment)
          returns the values that are active at the moment.
static
<T extends GenericEntity>
java.util.List<T>
filterByDate(java.util.List<T> datedValues, java.sql.Timestamp moment)
          returns the values that are active at the moment.
static
<T extends GenericEntity>
java.util.List<T>
filterByDate(java.util.List<T> datedValues, java.sql.Timestamp moment, java.lang.String fromDateName, java.lang.String thruDateName, boolean allAreSame)
          returns the values that are active at the moment.
static
<T extends GenericEntity>
java.util.List<T>
filterByOr(java.util.List<T> values, java.util.List<? extends EntityCondition> exprs)
          returns the values that match any of the exprs in list
static
<T extends GenericEntity>
java.util.List<T>
filterOutByCondition(java.util.List<T> values, EntityCondition condition)
           
static java.util.List<GenericValue> findDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> search)
           
static java.util.List<GenericValue> findDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> search, java.sql.Timestamp now)
           
static
<T> java.util.List<T>
getFieldListFromEntityList(java.util.List<GenericValue> genericValueList, java.lang.String fieldName, boolean distinct)
           
static
<T> java.util.List<T>
getFieldListFromEntityListIterator(EntityListIterator genericValueEli, java.lang.String fieldName, boolean distinct)
           
static EntityCondition getFilterByDateExpr()
           
static EntityCondition getFilterByDateExpr(java.util.Date moment)
           
static EntityCondition getFilterByDateExpr(java.lang.String fromDateName, java.lang.String thruDateName)
           
static EntityCondition getFilterByDateExpr(java.sql.Timestamp moment)
           
static EntityCondition getFilterByDateExpr(java.sql.Timestamp moment, java.lang.String fromDateName, java.lang.String thruDateName)
           
static GenericValue getFirst(java.util.List<GenericValue> values)
           
static GenericValue getOnly(java.util.List<GenericValue> values)
           
static java.util.List<GenericValue> getRelated(java.lang.String relationName, java.util.List<GenericValue> values)
           
static java.util.List<GenericValue> getRelatedByAnd(java.lang.String relationName, java.util.Map<java.lang.String,? extends java.lang.Object> fields, java.util.List<GenericValue> values)
           
static java.util.List<GenericValue> getRelatedCache(java.lang.String relationName, java.util.List<GenericValue> values)
           
static boolean isValueActive(GenericValue datedValue, java.sql.Timestamp moment)
           
static boolean isValueActive(GenericValue datedValue, java.sql.Timestamp moment, java.lang.String fromDateName, java.lang.String thruDateName)
           
static java.util.Map<java.lang.String,java.lang.Object> makeFields(java.lang.Object... args)
           
static GenericValue newDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> search)
           
static GenericValue newDatedInclusionEntity(GenericDelegator delegator, java.lang.String entityName, java.util.Map<java.lang.String,? extends java.lang.Object> find, java.sql.Timestamp now)
           
static
<T extends GenericEntity>
java.util.List<T>
orderBy(java.util.Collection<T> values, java.util.List<java.lang.String> orderBy)
          returns the values in the order specified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module
Constructor Detail

EntityUtil

public EntityUtil()
Method Detail

makeFields

public static java.util.Map<java.lang.String,java.lang.Object> makeFields(java.lang.Object... args)

getFirst

public static GenericValue getFirst(java.util.List<GenericValue> values)

getOnly

public static GenericValue getOnly(java.util.List<GenericValue> values)

getFilterByDateExpr

public static EntityCondition getFilterByDateExpr()

getFilterByDateExpr

public static EntityCondition getFilterByDateExpr(java.lang.String fromDateName,
                                                  java.lang.String thruDateName)

getFilterByDateExpr

public static EntityCondition getFilterByDateExpr(java.util.Date moment)

getFilterByDateExpr

public static EntityCondition getFilterByDateExpr(java.sql.Timestamp moment)

getFilterByDateExpr

public static EntityCondition getFilterByDateExpr(java.sql.Timestamp moment,
                                                  java.lang.String fromDateName,
                                                  java.lang.String thruDateName)

filterByDate

public static <T extends GenericEntity> java.util.List<T> filterByDate(java.util.List<T> datedValues)
returns the values that are currently active.

Parameters:
datedValues - GenericValue's that have "fromDate" and "thruDate" fields
Returns:
List of GenericValue's that are currently active

filterByDate

public static <T extends GenericEntity> java.util.List<T> filterByDate(java.util.List<T> datedValues,
                                                                       boolean allAreSame)
returns the values that are currently active.

Parameters:
datedValues - GenericValue's that have "fromDate" and "thruDate" fields
allAreSame - Specifies whether all values in the List are of the same entity; this can help speed things up a fair amount since we only have to see if the from and thru date fields are valid once
Returns:
List of GenericValue's that are currently active

filterByDate

public static <T extends GenericEntity> java.util.List<T> filterByDate(java.util.List<T> datedValues,
                                                                       java.util.Date moment)
returns the values that are active at the moment.

Parameters:
datedValues - GenericValue's that have "fromDate" and "thruDate" fields
moment - the moment in question
Returns:
List of GenericValue's that are active at the moment

filterByDate

public static <T extends GenericEntity> java.util.List<T> filterByDate(java.util.List<T> datedValues,
                                                                       java.sql.Timestamp moment)
returns the values that are active at the moment.

Parameters:
datedValues - GenericValue's that have "fromDate" and "thruDate" fields
moment - the moment in question
Returns:
List of GenericValue's that are active at the moment

filterByDate

public static <T extends GenericEntity> java.util.List<T> filterByDate(java.util.List<T> datedValues,
                                                                       java.sql.Timestamp moment,
                                                                       java.lang.String fromDateName,
                                                                       java.lang.String thruDateName,
                                                                       boolean allAreSame)
returns the values that are active at the moment.

Parameters:
datedValues - GenericValue's that have "fromDate" and "thruDate" fields
moment - the moment in question
allAreSame - Specifies whether all values in the List are of the same entity; this can help speed things up a fair amount since we only have to see if the from and thru date fields are valid once
Returns:
List of GenericValue's that are active at the moment

isValueActive

public static boolean isValueActive(GenericValue datedValue,
                                    java.sql.Timestamp moment)

isValueActive

public static boolean isValueActive(GenericValue datedValue,
                                    java.sql.Timestamp moment,
                                    java.lang.String fromDateName,
                                    java.lang.String thruDateName)

filterByAnd

public static <T extends GenericEntity> java.util.List<T> filterByAnd(java.util.List<T> values,
                                                                      java.util.Map<java.lang.String,? extends java.lang.Object> fields)
returns the values that match the values in fields

Parameters:
values - List of GenericValues
fields - the field-name/value pairs that must match
Returns:
List of GenericValue's that match the values in fields

filterByAnd

public static <T extends GenericEntity> java.util.List<T> filterByAnd(java.util.List<T> values,
                                                                      java.util.List<? extends EntityCondition> exprs)
returns the values that match all of the exprs in list

Parameters:
values - List of GenericValues
exprs - the expressions that must validate to true
Returns:
List of GenericValue's that match the values in fields

filterByOr

public static <T extends GenericEntity> java.util.List<T> filterByOr(java.util.List<T> values,
                                                                     java.util.List<? extends EntityCondition> exprs)
returns the values that match any of the exprs in list

Parameters:
values - List of GenericValues
exprs - the expressions that must validate to true
Returns:
List of GenericValue's that match the values in fields

orderBy

public static <T extends GenericEntity> java.util.List<T> orderBy(java.util.Collection<T> values,
                                                                  java.util.List<java.lang.String> orderBy)
returns the values in the order specified

Parameters:
values - List of GenericValues
orderBy - The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending
Returns:
List of GenericValue's in the proper order

getRelated

public static java.util.List<GenericValue> getRelated(java.lang.String relationName,
                                                      java.util.List<GenericValue> values)
                                               throws GenericEntityException
Throws:
GenericEntityException

getRelatedCache

public static java.util.List<GenericValue> getRelatedCache(java.lang.String relationName,
                                                           java.util.List<GenericValue> values)
                                                    throws GenericEntityException
Throws:
GenericEntityException

getRelatedByAnd

public static java.util.List<GenericValue> getRelatedByAnd(java.lang.String relationName,
                                                           java.util.Map<java.lang.String,? extends java.lang.Object> fields,
                                                           java.util.List<GenericValue> values)
                                                    throws GenericEntityException
Throws:
GenericEntityException

filterByCondition

public static <T extends GenericEntity> java.util.List<T> filterByCondition(java.util.List<T> values,
                                                                            EntityCondition condition)

filterOutByCondition

public static <T extends GenericEntity> java.util.List<T> filterOutByCondition(java.util.List<T> values,
                                                                               EntityCondition condition)

findDatedInclusionEntity

public static java.util.List<GenericValue> findDatedInclusionEntity(GenericDelegator delegator,
                                                                    java.lang.String entityName,
                                                                    java.util.Map<java.lang.String,? extends java.lang.Object> search)
                                                             throws GenericEntityException
Throws:
GenericEntityException

findDatedInclusionEntity

public static java.util.List<GenericValue> findDatedInclusionEntity(GenericDelegator delegator,
                                                                    java.lang.String entityName,
                                                                    java.util.Map<java.lang.String,? extends java.lang.Object> search,
                                                                    java.sql.Timestamp now)
                                                             throws GenericEntityException
Throws:
GenericEntityException

newDatedInclusionEntity

public static GenericValue newDatedInclusionEntity(GenericDelegator delegator,
                                                   java.lang.String entityName,
                                                   java.util.Map<java.lang.String,? extends java.lang.Object> search)
                                            throws GenericEntityException
Throws:
GenericEntityException

newDatedInclusionEntity

public static GenericValue newDatedInclusionEntity(GenericDelegator delegator,
                                                   java.lang.String entityName,
                                                   java.util.Map<java.lang.String,? extends java.lang.Object> find,
                                                   java.sql.Timestamp now)
                                            throws GenericEntityException
Throws:
GenericEntityException

delDatedInclusionEntity

public static void delDatedInclusionEntity(GenericDelegator delegator,
                                           java.lang.String entityName,
                                           java.util.Map<java.lang.String,? extends java.lang.Object> search)
                                    throws GenericEntityException
Throws:
GenericEntityException

delDatedInclusionEntity

public static void delDatedInclusionEntity(GenericDelegator delegator,
                                           java.lang.String entityName,
                                           java.util.Map<java.lang.String,? extends java.lang.Object> search,
                                           java.sql.Timestamp now)
                                    throws GenericEntityException
Throws:
GenericEntityException

getFieldListFromEntityList

public static <T> java.util.List<T> getFieldListFromEntityList(java.util.List<GenericValue> genericValueList,
                                                               java.lang.String fieldName,
                                                               boolean distinct)

getFieldListFromEntityListIterator

public static <T> java.util.List<T> getFieldListFromEntityListIterator(EntityListIterator genericValueEli,
                                                                       java.lang.String fieldName,
                                                                       boolean distinct)