Class EntityUtil

java.lang.Object
org.ofbiz.core.entity.EntityUtil

public class EntityUtil extends Object
Helper methods when dealing with Entities, especially ones that follow certain conventions Created Tue Aug 07 01:10:32 MDT 2001
Version:
1.0
Author:
Eric Pabst
  • Constructor Details

    • EntityUtil

      public EntityUtil()
  • Method Details

    • getFirst

      public static GenericValue getFirst(List<? extends GenericValue> values)
    • getOnly

      public static GenericValue getOnly(List<? extends GenericValue> values)
    • filterByDate

      public static <T extends GenericEntity> List<T> filterByDate(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> List<T> filterByDate(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> List<T> filterByDate(List<T> datedValues, 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> List<T> filterByDate(List<T> datedValues, 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> List<T> filterByDate(List<T> datedValues, Timestamp moment, String fromDateName, 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
    • filterByAnd

      public static <T extends GenericEntity> List<T> filterByAnd(List<? extends T> values, Map<String,?> 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 GenericValue> List<T> filterByAnd(List<T> values, List<? extends EntityExpr> exprs)
      returns the values that match 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 GenericValue> List<T> orderBy(List<T> values, List<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 List<GenericValue> getRelated(String relationName, List<? extends GenericValue> values) throws GenericEntityException
      Throws:
      GenericEntityException
    • getRelatedCache

      public static List<GenericValue> getRelatedCache(String relationName, List<? extends GenericValue> values) throws GenericEntityException
      Throws:
      GenericEntityException
    • getRelatedByAnd

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