Package org.openbravo.erpCommon.utility
Class ComboTableData
- java.lang.Object
-
- org.openbravo.erpCommon.utility.ComboTableData
-
public class ComboTableData extends Object
- Author:
- Fernando Iriazabal This class builds the queries for populating the different kind of combos in the application.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLIENT_LIST_PARAM_HOLDER
int
index
static String
ORG_LIST_PARAM_HOLDER
-
Constructor Summary
Constructors Constructor Description ComboTableData()
ComboTableData(VariablesSecureApp _vars, ConnectionProvider _conn, String _referenceType, String _name, String _objectReference, String _validation, String _orgList, String _clientList, int _index)
ConstructorComboTableData(ConnectionProvider _conn, String _referenceType, String _name, String _objectReference, String _validation, String _orgList, String _clientList, int _index)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFromField(String _field, String _alias)
Adds new field to the from section of the query.void
addFromParameter(String _parameter, String _fieldName)
Adds a new parameter to the from section of the query.void
addOrderByField(String _field)
Adds new field to the order by section of the query.void
addSelectField(String _field, String _alias)
Adds new field to the select section of the query.void
addWhereField(String _field, String _type)
Adds new field to the where section of the query.void
addWhereParameter(String _parameter, String _fieldName, String _type)
Adds a new parameter to the where section of the query.boolean
canBeCached()
void
fillParameters(FieldProvider data, String window, String actual_value)
Fill the parameters of the sql with the session values or FieldProvider values.Map<String,String>
fillSQLParametersIntoMap(ConnectionProvider conn, VariablesSecureApp variables, FieldProvider data, String window, String actual_value)
String
getClientList()
Getter for the granted clients list.String
getObjectName()
Getter for the object name.String
getObjectReference()
Getter for the object reference id.String
getOrgList()
Getter for the granted organizations list.ConnectionProvider
getPool()
Getter for the database handler object.static ComboTableData
getTableComboDataFor(Field field)
Creates a new combo for a given fieldVariablesSecureApp
getVars()
Getter for the session object.void
identifier(String tableName, FieldProvider field)
Support method for the generateSQL method, to build the query.boolean
isAllowedCrossOrgReference()
Returns whether the columns this combo is for allows cross organization referencesString
parseContext(String context, String type)
Auxiliar method to replace the variable sections of the clauses.void
parseValidation()
Parse the validation string searching the @ elements and replacing them with the correct values, adding the needed parameters.FieldProvider[]
select(boolean includeActual)
Executes the query in the database and returns the data.FieldProvider[]
select(ConnectionProvider conn, Map<String,String> lparameters, boolean includeActual)
FieldProvider[]
select(ConnectionProvider conn, Map<String,String> lparameters, boolean includeActual, Integer startRow, Integer endRow)
void
setParameter(String name, String value)
Setter for the parameters value.
-
-
-
Field Detail
-
CLIENT_LIST_PARAM_HOLDER
public static final String CLIENT_LIST_PARAM_HOLDER
- See Also:
- Constant Field Values
-
ORG_LIST_PARAM_HOLDER
public static final String ORG_LIST_PARAM_HOLDER
- See Also:
- Constant Field Values
-
index
public int index
-
-
Constructor Detail
-
ComboTableData
public ComboTableData(ConnectionProvider _conn, String _referenceType, String _name, String _objectReference, String _validation, String _orgList, String _clientList, int _index) throws Exception
Constructor- Parameters:
_conn
- Object with the database connection methods._referenceType
- String with the type of reference._name
- String with the Object name._objectReference
- String with id to the reference value._validation
- String with the id to the validation._orgList
- String with the list of granted organizations._clientList
- String with the list of granted clients._index
- String with the id of the default value for the combo.- Throws:
Exception
-
ComboTableData
public ComboTableData(VariablesSecureApp _vars, ConnectionProvider _conn, String _referenceType, String _name, String _objectReference, String _validation, String _orgList, String _clientList, int _index) throws Exception
Constructor- Parameters:
_vars
- Object with the session methods._conn
- Object with the database connection methods._referenceType
- String with the type of reference._name
- String with the Object name._objectReference
- String with id to the reference value._validation
- String with the id to the validation._orgList
- String with the list of granted organizations._clientList
- String with the list of granted clients._index
- String with the id of the default value for the combo.- Throws:
Exception
-
ComboTableData
public ComboTableData()
-
-
Method Detail
-
getTableComboDataFor
public static ComboTableData getTableComboDataFor(Field field) throws Exception
Creates a new combo for a given field- Throws:
Exception
-
getVars
public VariablesSecureApp getVars()
Getter for the session object.- Returns:
- Session object.
-
getPool
public ConnectionProvider getPool()
Getter for the database handler object.- Returns:
- Database handler object.
-
getObjectName
public String getObjectName()
Getter for the object name.- Returns:
- String with the object name.
-
getObjectReference
public String getObjectReference()
Getter for the object reference id.- Returns:
- String with the object reference id.
-
getOrgList
public String getOrgList()
Getter for the granted organizations list.- Returns:
- String with the granted organizations list.
-
getClientList
public String getClientList()
Getter for the granted clients list.- Returns:
- String with the granted clients list.
-
addSelectField
public void addSelectField(String _field, String _alias)
Adds new field to the select section of the query.- Parameters:
_field
- String with the field._alias
- String with the alias for this field.
-
addFromField
public void addFromField(String _field, String _alias)
Adds new field to the from section of the query.- Parameters:
_field
- String with the field._alias
- String with the alias for the field.
-
addWhereField
public void addWhereField(String _field, String _type)
Adds new field to the where section of the query.- Parameters:
_field
- String with the field._type
- String for group fields.
-
addOrderByField
public void addOrderByField(String _field)
Adds new field to the order by section of the query.- Parameters:
_field
- String with the field.
-
addFromParameter
public void addFromParameter(String _parameter, String _fieldName)
Adds a new parameter to the from section of the query.- Parameters:
_parameter
- String with the parameter._fieldName
- String with the name od the field.
-
addWhereParameter
public void addWhereParameter(String _parameter, String _fieldName, String _type)
Adds a new parameter to the where section of the query.- Parameters:
_parameter
- String with the parameter._fieldName
- String with the name of the field._type
- String with a group name.
-
setParameter
public void setParameter(String name, String value) throws Exception
Setter for the parameters value.- Parameters:
name
- The name of the field defined for the parameter.value
- The value for this parameter.- Throws:
Exception
-
parseValidation
public void parseValidation() throws Exception
Parse the validation string searching the @ elements and replacing them with the correct values, adding the needed parameters.- Throws:
Exception
-
parseContext
public String parseContext(String context, String type)
Auxiliar method to replace the variable sections of the clauses.- Parameters:
context
- String with the variable.type
- String with the type of the clause (WHERE, ORDER...)- Returns:
- String with the text replaced.
-
identifier
public void identifier(String tableName, FieldProvider field) throws Exception
Support method for the generateSQL method, to build the query.- Parameters:
tableName
- String with the name of the table.field
- String with the name of the field.- Throws:
Exception
-
select
public FieldProvider[] select(boolean includeActual) throws Exception
Executes the query in the database and returns the data.- Parameters:
includeActual
- Boolean that indicates if the actual selected value must be included in the result, even if it doesn´t exists in the new query.- Returns:
- Array of FieldProvider with the data.
- Throws:
Exception
-
select
public FieldProvider[] select(ConnectionProvider conn, Map<String,String> lparameters, boolean includeActual) throws Exception
- Throws:
Exception
-
select
public FieldProvider[] select(ConnectionProvider conn, Map<String,String> lparameters, boolean includeActual, Integer startRow, Integer endRow) throws Exception
- Throws:
Exception
-
fillParameters
public void fillParameters(FieldProvider data, String window, String actual_value) throws javax.servlet.ServletException
Fill the parameters of the sql with the session values or FieldProvider values. Used in the combo fields.- Parameters:
data
- optional FieldProvider which can be used to get the needed parameter values from. If the FieldProvider has a filed named after a parameter, then its value will be used if the value could not be already obtained from the request parameters.window
- Window id.actual_value
- actual value for the combo.- Throws:
javax.servlet.ServletException
-
fillSQLParametersIntoMap
public Map<String,String> fillSQLParametersIntoMap(ConnectionProvider conn, VariablesSecureApp variables, FieldProvider data, String window, String actual_value) throws javax.servlet.ServletException
- Throws:
javax.servlet.ServletException
-
canBeCached
public boolean canBeCached()
-
isAllowedCrossOrgReference
public boolean isAllowedCrossOrgReference()
Returns whether the columns this combo is for allows cross organization references
-
-