Class SetGetUtil


  • public class SetGetUtil
    extends Object
    • Constructor Detail

      • SetGetUtil

        public SetGetUtil()
    • Method Detail

      • updateColumns

        public static void updateColumns​(SetGetModel[] models,
                                         String[] columnNames,
                                         ResultSet rs)
                                  throws SQLException
        Update columns from the result of the given query.
        Parameters:
        models -
        columnNames - column names; if null, all columns from given query are used; if a columnName from array is null it will be ignored
        rs -
        Throws:
        SQLException
      • copyValues

        public static boolean copyValues​(PO to,
                                         PO from,
                                         String[] includeFields,
                                         String[] excludeFields)
        Copy from the fields to. The second object is not required to be in the same table. The following fields are not copied: AD_Client_ID, AD_Org_ID, Created% Updated% IsActive. If excludeFields includeFields and are null, then it will copy all the fields (which can be copied).
        Returns:
        false if "to" or "from" is null, true otherwise
      • copyChangedValues

        public static int copyChangedValues​(PO to,
                                            PO from)
        Copy all values from "from" to "to"
        Returns:
        number of columns that were copied and were were also changed in object "from"
        See Also:
        copyValues(PO, PO, String[], String[])
      • copyValues

        public static boolean copyValues​(SetGetModel to,
                                         String from_tableName,
                                         int from_id,
                                         String[] includeFields)
        Copy from the fields to the. The two objects do not need to be in the same table.
        Parameters:
        to - destination object
        from_tableName - source object table
        from_id - source object ID
        includeFields - name fields to be excluded, null will be interpreted as String[0];
        See Also:
        updateColumns(SetGetModel, String[], String, String)
      • get_AttrValueAsInt

        public static int get_AttrValueAsInt​(SetGetModel model,
                                             String name)
        Get Value as integer
        Parameters:
        model -
        name -
        Returns:
        int value
      • get_AttrValueAsDate

        public static Timestamp get_AttrValueAsDate​(SetGetModel model,
                                                    String name)
        Get Value as Timestamp
        Parameters:
        model -
        name -
        Returns:
        Timestamp value
      • get_AttrValueAsBoolean

        public static boolean get_AttrValueAsBoolean​(SetGetModel model,
                                                     String name)
        Get Value as Boolean
        Parameters:
        model -
        name -
        Returns:
        boolean value
      • get_AttrValueAsString

        public static String get_AttrValueAsString​(SetGetModel model,
                                                   String name,
                                                   String valueIfNull)
        Get Value as String
        Parameters:
        model -
        name -
        valueIfNull - value that will be returned if the value is null
        Returns:
        String value
      • set_AttrValueEx

        public static void set_AttrValueEx​(SetGetModel model,
                                           String name,
                                           Object value)
        Set Attribute Value
        Parameters:
        model -
        name -
        value -
        Throws:
        AdempiereException - if it can not be set (error setting, attribute/column name not found).
      • is_ValueChanged

        public static boolean is_ValueChanged​(SetGetModel model,
                                              String... propertyNames)
        Parameters:
        model -
        propertyNames -
        Returns:
        true if ANY of given properties had changed
      • getTrxName

        public static String getTrxName​(Object o)
        Get TrxName for given object.
        Parameters:
        o -
        Returns:
        trxName or null
      • isUserEntry

        public static boolean isUserEntry​(Object o)
        Check if given object was produced by used entry (i.e. created from a window)
        Parameters:
        o - object
        Returns:
        If object is instanceof PO then ... If object is null then false will be returned. Else true will be returned.
      • setLineNo

        public static void setLineNo​(SetGetModel model,
                                     String parentColumnName,
                                     String lineColumnName)
        Set model's Line#
        Parameters:
        model -
        parentColumnName - parent column name; if null then it won't be used
        lineColumnName - line column name; if null "Line" will be used
      • getTableName

        public static String getTableName​(Class<? extends PO> clazz)
        Get Table_Name for given PO class
        Parameters:
        clazz -
        Returns:
        tableName
        Throws:
        AdempiereException - if no table name found or any other exception occurs
      • isPersistent

        public static final boolean isPersistent​(Object o)
        Check if given object is persistent object
        Parameters:
        o - object
        Returns:
        true if is persistent (i.e. instanceof PO)
      • getCtx

        public static Properties getCtx​(Object o)
        Get Context from given object. If object is null, null will be returned. If object does not have getCtx() support then Env.getCtx() will be returned.
        Parameters:
        o - object
        Returns:
        context or null(if object is null)
      • wrap

        public static SetGetModel wrap​(Object o)
        Wrap given object (if possible) to SetGetModel
        Parameters:
        o - object
        Returns:
        object wrapped to SetGetModel
      • getInfoString

        public static String getInfoString​(Properties ctx,
                                           String tableName,
                                           int id,
                                           String trxName)
        Get Info for given table and ID. This method calls to generate the info string.
        Parameters:
        ctx - context
        tableName - tablename
        id - record id
        trxName -
        Returns:
        record description