Class EntityUtil


  • public final class EntityUtil
    extends java.lang.Object
    Helper methods when dealing with Entities, especially ones that follow certain conventions
    • Field Detail

      • module

        public static final java.lang.String module
    • Method Detail

      • makeFields

        @SafeVarargs
        public static <V> java.util.Map<java.lang.String,​V> makeFields​(V... args)
      • 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
      • localizedOrderBy

        public static <T extends GenericEntity> java.util.List<T> localizedOrderBy​(java.util.Collection<T> values,
                                                                                   java.util.List<java.lang.String> orderBy,
                                                                                   java.util.Locale locale)
        returns the values in the order specified after with localized value
        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
        locale - Locale use to retrieve localized value
        Returns:
        List of GenericValue's in the proper order
      • 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
      • 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)
      • delDatedInclusionEntity

        public static void delDatedInclusionEntity​(Delegator 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)
      • isMultiTenantEnabled

        public static boolean isMultiTenantEnabled()
        Returns true if multi-tenant has been enabled.

        Multi-tenant features are enabled by setting the multitenant property in general.properties to "Y".