Package org.compiere.model
Class SetGetUtil
java.lang.Object
org.compiere.model.SetGetUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendValue
(SetGetModel model, String columnName, String value) static int
copyChangedValues
(PO to, PO from) Copy all values from "from" to "to"static boolean
copyValues
(PO to, PO from, String[] includeFields, String[] excludeFields) Copy from the fields to.static boolean
copyValues
(SetGetModel to, String from_tableName, int from_id, String[] includeFields) Copy from the fields to the.static BigDecimal
get_AttrValueAsBigDecimal
(SetGetModel model, String name) Get Value as BigDecimalstatic boolean
get_AttrValueAsBoolean
(SetGetModel model, String name) Get Value as Booleanstatic Timestamp
get_AttrValueAsDate
(SetGetModel model, String name) Get Value as Timestampstatic int
get_AttrValueAsInt
(SetGetModel model, String name) Get Value as integerstatic String
get_AttrValueAsString
(SetGetModel model, String name, String valueIfNull) Get Value as Stringstatic Properties
Get Context from given object.static String
getInfoString
(Properties ctx, String tableName, int id, String trxName) Get Info for given table and ID.static String
getTableName
(Class<? extends PO> clazz) Get Table_Name for given PO classstatic String
getTrxName
(Object o) Get TrxName for given object.static boolean
is_ValueChanged
(SetGetModel model, String... propertyNames) static final boolean
Check if given object is persistent objectstatic boolean
Check if given object was produced by used entry (i.e. created from a window)static <T> T
newInstance
(Properties ctx, Class<T> clazz, String trxName) static void
set_AttrValueEx
(SetGetModel model, String name, Object value) Set Attribute Valuestatic void
setLineNo
(SetGetModel model, String parentColumnName, String lineColumnName) Set model's Line#static void
updateColumns
(SetGetModel[] models, String[] columnNames, String sql, Object[] params, String trxName) Update columns from the result of the given query.static void
updateColumns
(SetGetModel[] models, String[] columnNames, ResultSet rs) Update columns from the result of the given query.static void
updateColumns
(SetGetModel model, String[] columnNames, String sql, Object[] params, String trxName) Update columns from the result of the given query.static void
updateColumns
(SetGetModel model, String[] columnNames, String sql, String trxName) static void
updateColumns
(SetGetModel model, String[] columnNames, ResultSet rs) static SetGetModel
Wrap given object (if possible) to SetGetModel
-
Constructor Details
-
SetGetUtil
public SetGetUtil()
-
-
Method Details
-
updateColumns
public static void updateColumns(SetGetModel model, String[] columnNames, String sql, Object[] params, String trxName) Update columns from the result of the given query.If the query returns more than one row, only the first row will be used.
This is a simplified version of
updateColumns(SetGetModel[], String[], String, Object[], String)
which calls:updateColumns(new SetGetModel[]{model}, columnNames, query, trxName);
- Parameters:
model
-columnNames
- column names; if null, all columns from given query are used; if a columnName from array is null it will be ignoredsql
- sql queryparams
- sql parameterstrxName
-- See Also:
-
updateColumns
public static void updateColumns(SetGetModel model, String[] columnNames, String sql, String trxName) -
updateColumns
public static void updateColumns(SetGetModel[] models, String[] columnNames, String sql, Object[] params, String trxName) Update columns from the result of the given query.- Parameters:
models
-columnNames
-sql
-params
-trxName
-- See Also:
-
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 ignoredrs
-- Throws:
SQLException
-
updateColumns
public static void updateColumns(SetGetModel model, String[] columnNames, ResultSet rs) throws SQLException - Throws:
SQLException
-
copyValues
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
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
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 objectfrom_tableName
- source object tablefrom_id
- source object IDincludeFields
- name fields to be excluded, null will be interpreted as String[0];- See Also:
-
get_AttrValueAsInt
Get Value as integer- Parameters:
model
-name
-- Returns:
- int value
-
get_AttrValueAsDate
Get Value as Timestamp- Parameters:
model
-name
-- Returns:
- Timestamp value
-
get_AttrValueAsBigDecimal
Get Value as BigDecimal- Parameters:
model
-name
-- Returns:
- BigDecimal or
BigDecimal.ZERO
-
get_AttrValueAsBoolean
Get Value as Boolean- Parameters:
model
-name
-- Returns:
- boolean value
-
get_AttrValueAsString
Get Value as String- Parameters:
model
-name
-valueIfNull
- value that will be returned if the value is null- Returns:
- String value
-
set_AttrValueEx
Set Attribute Value- Parameters:
model
-name
-value
-- Throws:
AdempiereException
- if it can not be set (error setting, attribute/column name not found).
-
is_ValueChanged
- Parameters:
model
-propertyNames
-- Returns:
- true if ANY of given properties had changed
-
getTrxName
Get TrxName for given object.- Parameters:
o
-- Returns:
- trxName or null
-
isUserEntry
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
Set model's Line#- Parameters:
model
-parentColumnName
- parent column name; if null then it won't be usedlineColumnName
- line column name; if null "Line" will be used
-
getTableName
Get Table_Name for given PO class- Parameters:
clazz
-- Returns:
- tableName
- Throws:
AdempiereException
- if no table name found or any other exception occurs
-
isPersistent
Check if given object is persistent object- Parameters:
o
- object- Returns:
- true if is persistent (i.e. instanceof PO)
-
getCtx
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
Wrap given object (if possible) to SetGetModel- Parameters:
o
- object- Returns:
- object wrapped to SetGetModel
-
newInstance
-
appendValue
-
getInfoString
Get Info for given table and ID. This method callsMLookupFactory.getLookup_TableDirEmbed(Language, String, String, String)
to generate the info string.- Parameters:
ctx
- contexttableName
- tablenameid
- record idtrxName
-- Returns:
- record description
-