com.instantbank.component.parameter.ejb
Class ParameterDAO

java.lang.Object
  |
  +--com.instantbank.component.parameter.ejb.ParameterDAO

public class ParameterDAO
extends java.lang.Object

This class has JDBC calls required by EJB Parameter for implementing its services

Author:
Instant-bank (Consuelo Franky, Roberto Contreras)

Field Summary
(package private)  java.lang.String companyId
          current company
private  javax.sql.DataSource datasource
          datasource corresponding to the database
private  java.sql.Connection dbConnection
          connection with the database
private  Debug debug
           
private  java.lang.String expressionNumC
          Regular Exprsision
private  java.lang.String expressionNumInt
           
private  java.lang.String expressionNumP
           
private  java.lang.String expressionSeqInt
           
private  org.apache.regexp.RE regularExpressionNumC
           
private  org.apache.regexp.RE regularExpressionNumInt
           
private  org.apache.regexp.RE regularExpressionNumP
           
private  org.apache.regexp.RE regularExpressionSeqInt
           
(package private)  java.lang.Long userId
          current user
 
Constructor Summary
ParameterDAO(java.lang.String companyId, java.lang.Long userId)
          Constructor: searchs the DataSource in the InitialContext
 
Method Summary
 java.util.ArrayList applyItemsParamLevel1Points(java.util.ArrayList items)
          Applies a set of changes in the values of parameter level 1 of the current company in DatabaseNames.SV_LEVEL1_POINT table.
 java.util.ArrayList applyItemsParamLevel2Points(java.util.ArrayList items)
          Applies a set of changes in the values of parameter level 2 of the current company in DatabaseNames.SV_LEVEL2_POINT table.
private  java.util.ArrayList auxListParamRestrictions(java.sql.PreparedStatement ps, java.sql.ResultSet rs)
          Auxiliary for load a parameter restrictions from DB.
private  Header[] buildHeader(java.lang.String order2, java.lang.String skip2, java.lang.String skip3, java.lang.String level_1_2, java.lang.String level_1_any, java.lang.String level_any_2, java.lang.String level_any_any)
          Auxiliary for load a set parameter values from DB.
private  int[] buildOrder(java.lang.String order2)
          Auxiliary for load a set parameter values from DB and build the array with the order search.
 java.util.Hashtable buildParmValue(java.util.ArrayList level1Point, java.util.ArrayList level2Point, java.util.Hashtable pointValue)
          Auxiliary for load a set parameter values from DB and build a Hashtable with point1+"|"+point2 as the Key and ValueRow as the Value.
 CodeDescription[] listParamLevel1Points()
          Loads all [code, value] of the values of parameter level 1 of the current company from DatabaseNames.SV_LEVEL1_POINT table.
 CodeDescription[] listParamLevel2Points()
          Loads all [code, value] of the values of parameter level 2 of the current company from DatabaseNames.SV_LEVEL2_POINT table.
 java.util.ArrayList listParamRestrictions()
          Loads the set parameters restrictions(group name, code parameter name parameter, description, warning, level_1_2, level_1_any level_any_2 and level_any_any) of the current company for each group parameter from DatabaseNames.SV_PARAMETER_GROUP, DatabaseNames.SV_PARAMETER and DatabaseNames.SV_PARM_RESTRICTION tables.
 ParameterModel listParamValues(java.lang.String codeParameter)
          Loads the set parameters values of the current company for the parameter without warning colors from DatabaseNames.COMPANIES, DatabaseNames.SV_PARAMETER, DatabaseNames.SV_PARMETER_VALUE, DatabaseNames.SV_PARM_RESTRICTION, DatabaseNames.SV_LEVEL1_POINT, DatabaseNames.SV_LEVEL2_POINT tables.
 java.util.Hashtable loadLevel1Code()
          Loads the value an code of level 1 point from DatabaseNames.SV_LEVEL1_POINT table.
 java.util.Hashtable loadLevel2Code()
          Loads the value an code of level 2 point from DatabaseNames.SV_LEVEL2_POINT table.
 java.util.ArrayList loadParamLevelsName()
          Loads parameters levels names of the current company from DatabaseNames.COMPANIES table.
 java.util.ArrayList loadParamSearchValues()
          Loads parameters search order of the current company from DatabaseNames.COMPANIES.
private  ParameterModel setColor(ParameterModel parameterModel)
          Auxiliary for load a set parameter values from DB and set warning colors to ParameterModel object of the current company for the parameter.
 java.util.ArrayList updateParamLevelsName(java.util.ArrayList items)
          Applies a set of updates in the parameters levels names of the current company in DatabaseNames.COMPANIES table.
 java.util.ArrayList updateParamRestrictions(java.util.Hashtable items)
          Applies a set of updates in the parameters restrictions in the current company in DatabaseNames.SV_PARM_RESTRICTION table.
 java.util.ArrayList updateParamSearchValues(java.util.ArrayList items)
          Applies a set of updates in the parameters search order of the current company in DatabaseNames.COMPANIES.
 java.lang.String updateParamValues(ParameterValue items, java.util.Hashtable level1code, java.util.Hashtable level2code)
          Applies a set of updates in the parameters values in the current company in DatabaseNames.SV_PARAMETER_VALUE table.
private  ValueRow verifyCellsColor(int[] order, ValueRow valueRow, Header[] header)
          Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color.
private  java.util.Hashtable verifyColor(java.util.Hashtable parmValue, Header[] header, int[] order)
          Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color.
private  Header[] verifyHeaderColor(Header[] header)
          Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color.
 ParameterModel verifyParamValues(ParameterValue items)
          Check the parameters values and set warning colors to ParameterModel object of the current company for the parameter.
private  java.lang.String verifyValue(java.lang.String value, java.lang.String type)
          Auxiliary for update a set parameter values from DB veryfy the condition over parameter value
private  java.lang.String verifyWarning(java.lang.String level_1_2, java.lang.String level_1_any, java.lang.String level_any_2, java.lang.String level_any_any)
          Auxiliary for load a parameter restrictions from DB and veryfy the conditions over parameter restrictions
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

companyId

java.lang.String companyId
current company

userId

java.lang.Long userId
current user

dbConnection

private java.sql.Connection dbConnection
connection with the database

datasource

private javax.sql.DataSource datasource
datasource corresponding to the database

debug

private Debug debug

expressionNumC

private java.lang.String expressionNumC
Regular Exprsision

expressionNumP

private java.lang.String expressionNumP

expressionNumInt

private java.lang.String expressionNumInt

expressionSeqInt

private java.lang.String expressionSeqInt

regularExpressionNumC

private org.apache.regexp.RE regularExpressionNumC

regularExpressionNumP

private org.apache.regexp.RE regularExpressionNumP

regularExpressionNumInt

private org.apache.regexp.RE regularExpressionNumInt

regularExpressionSeqInt

private org.apache.regexp.RE regularExpressionSeqInt
Constructor Detail

ParameterDAO

public ParameterDAO(java.lang.String companyId,
                    java.lang.Long userId)
             throws DAOException
Constructor: searchs the DataSource in the InitialContext
Parameters:
companyId - current company
userId - current user
Throws:
DAOException - Description of the Exception
Method Detail

loadParamLevelsName

public java.util.ArrayList loadParamLevelsName()
                                        throws DAOException
Loads parameters levels names of the current company from DatabaseNames.COMPANIES table.
Returns:
ArrayList object with 2 elements: (0) parameter level 1 name. (1) parameter level 2 name.
Throws:
DAOException - Description of the Exception

updateParamLevelsName

public java.util.ArrayList updateParamLevelsName(java.util.ArrayList items)
                                          throws DAOException
Applies a set of updates in the parameters levels names of the current company in DatabaseNames.COMPANIES table.
Parameters:
items - ArrayList with 2 elements of type String representing the attributes of items to apply param name of level 1 and level 2.
Returns:
ArrayList object with 2 elements: (0) probabily problem. (1) ArrayList with a set of parameters levels names.
Throws:
DAOException - Description of the Exception

listParamLevel1Points

public CodeDescription[] listParamLevel1Points()
                                        throws DAOException
Loads all [code, value] of the values of parameter level 1 of the current company from DatabaseNames.SV_LEVEL1_POINT table.
Returns:
CodeDescription[] object with [code, value] of the values of parameter level 1.
Throws:
DAOException - Description of the Exception

applyItemsParamLevel1Points

public java.util.ArrayList applyItemsParamLevel1Points(java.util.ArrayList items)
                                                throws DAOException
Applies a set of changes in the values of parameter level 1 of the current company in DatabaseNames.SV_LEVEL1_POINT table.
Parameters:
items - ArrayList with 3 elements of type String[] representing the attributes of items to apply code, value and status. Status indicates if the item is for inserting, deleting or updating (ServicingGlobals.INSERT, ServicingGlobals.DELETE, ServicingGlobals.UPDATE)
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current values of parameter level 1 list (CodeDescription[])
Throws:
DAOException - Description of the Exception

listParamLevel2Points

public CodeDescription[] listParamLevel2Points()
                                        throws DAOException
Loads all [code, value] of the values of parameter level 2 of the current company from DatabaseNames.SV_LEVEL2_POINT table.
Returns:
CodeDescription[] object with [code, value] of the values of parameter level 2.
Throws:
DAOException - Description of the Exception

applyItemsParamLevel2Points

public java.util.ArrayList applyItemsParamLevel2Points(java.util.ArrayList items)
                                                throws DAOException
Applies a set of changes in the values of parameter level 2 of the current company in DatabaseNames.SV_LEVEL2_POINT table.
Parameters:
items - ArrayList with 3 elements of type String[] representing the attributes of items to apply code, value and status. Status indicates if the item is for inserting, deleting or updating (ServicingGlobals.INSERT, ServicingGlobals.DELETE, ServicingGlobals.UPDATE)
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current values of parameter level 2 list (CodeDescription[])
Throws:
DAOException - Description of the Exception

loadParamSearchValues

public java.util.ArrayList loadParamSearchValues()
                                          throws DAOException
Loads parameters search order of the current company from DatabaseNames.COMPANIES.
Returns:
ArrayList object with 2 elements: (0) parameter search 2 value. (1) parameter search 3 value.
Throws:
DAOException - Description of the Exception

updateParamSearchValues

public java.util.ArrayList updateParamSearchValues(java.util.ArrayList items)
                                            throws DAOException
Applies a set of updates in the parameters search order of the current company in DatabaseNames.COMPANIES.
Parameters:
items - ArrayList with 2 elements of type String representing the attributes of items to apply parameters search order.
Returns:
ArrayList object with 2 elements: (0) probabily problem. (1) ArrayList with a set of parameters search order.
Throws:
DAOException - Description of the Exception

listParamRestrictions

public java.util.ArrayList listParamRestrictions()
                                          throws DAOException
Loads the set parameters restrictions(group name, code parameter name parameter, description, warning, level_1_2, level_1_any level_any_2 and level_any_any) of the current company for each group parameter from DatabaseNames.SV_PARAMETER_GROUP, DatabaseNames.SV_PARAMETER and DatabaseNames.SV_PARM_RESTRICTION tables. This method invokes the auxListParamRestrictions(., .,)
Returns:
ArrayList object with (n) elements. When each element is representing a group parameter and its parameters restrictions of type GroupParam.
Throws:
DAOException - Description of the Exception

updateParamRestrictions

public java.util.ArrayList updateParamRestrictions(java.util.Hashtable items)
                                            throws DAOException
Applies a set of updates in the parameters restrictions in the current company in DatabaseNames.SV_PARM_RESTRICTION table.
Parameters:
items - Hashtable with (n) elements of type ParmRestrictionUpdate. When each element is representing the attributes of parameter restrictions.
Returns:
ArrayList object with (n) elements. When each element is representing a group parameter and its parameters restrictions of type GroupParam.
Throws:
DAOException - Description of the Exception

listParamValues

public ParameterModel listParamValues(java.lang.String codeParameter)
                               throws DAOException
Loads the set parameters values of the current company for the parameter without warning colors from DatabaseNames.COMPANIES, DatabaseNames.SV_PARAMETER, DatabaseNames.SV_PARMETER_VALUE, DatabaseNames.SV_PARM_RESTRICTION, DatabaseNames.SV_LEVEL1_POINT, DatabaseNames.SV_LEVEL2_POINT tables. This method invokes the buildOrder(),this.buildHeader( ), buildParmValue(., .,) and setColor() methods.
Parameters:
codeParameter - The value of code parameter.
Returns:
parameterModel The ParameterModel object. When its atributes are representing the all values and warning colors for the parameter.
Throws:
DAOException - Description of the Exception

loadLevel1Code

public java.util.Hashtable loadLevel1Code()
                                   throws DAOException
Loads the value an code of level 1 point from DatabaseNames.SV_LEVEL1_POINT table.
Returns:
level1Code The Hashtable object with value of level 1 point as the key and the code of point 1 as value.
Throws:
DAOException - Description of the Exception

loadLevel2Code

public java.util.Hashtable loadLevel2Code()
                                   throws DAOException
Loads the value an code of level 2 point from DatabaseNames.SV_LEVEL2_POINT table.
Returns:
level1Code The Hashtable object with value of level 2 point as the key and the code of point 2 as value.
Throws:
DAOException - Description of the Exception

updateParamValues

public java.lang.String updateParamValues(ParameterValue items,
                                          java.util.Hashtable level1code,
                                          java.util.Hashtable level2code)
                                   throws DAOException
Applies a set of updates in the parameters values in the current company in DatabaseNames.SV_PARAMETER_VALUE table.
Parameters:
items - ParameterValue object with the value of code parameter, type of parameter and a Hashtable with the point1+"|"+point2 as the Key and the value of parameter as the Value.
level1code - Description of the Parameter
level2code - Description of the Parameter
Returns:
codeParameter The value of code parameter.
Throws:
DAOException - Description of the Exception

verifyParamValues

public ParameterModel verifyParamValues(ParameterValue items)
                                 throws DAOException
Check the parameters values and set warning colors to ParameterModel object of the current company for the parameter. This service doesn't save parameters values in the data base. Only verify warning colors.
Parameters:
items - ParameterValue object with the value of code parameter, type of parameter and a Hashtable with the point1+"|"+point2 as the Key and the value of parameter as the Value.
Returns:
ParameterModel object. When its atributes are representing the all values and warning colors for the parameter.
Throws:
DAOException - Description of the Exception

auxListParamRestrictions

private java.util.ArrayList auxListParamRestrictions(java.sql.PreparedStatement ps,
                                                     java.sql.ResultSet rs)
                                              throws java.lang.Exception
Auxiliary for load a parameter restrictions from DB. This method invokes the verifyWarning(., ., ., .,) method.
Parameters:
ps - auxiliary PreparedStatement.
rs - auxiliary ResultSet.
Returns:
Arraylist .
Throws:
java.lang.Exception - Description of the Exception

verifyWarning

private java.lang.String verifyWarning(java.lang.String level_1_2,
                                       java.lang.String level_1_any,
                                       java.lang.String level_any_2,
                                       java.lang.String level_any_any)
                                throws java.lang.Exception
Auxiliary for load a parameter restrictions from DB and veryfy the conditions over parameter restrictions
Parameters:
level_1_2 - value of restriction.
level_1_any - value of restriction.
level_any_2 - value of restriction.
level_any_any - value of restriction.
Returns:
String warning this indicates if the parameter restriction has a warning. ServicingGlobals.WARNING_0: No warnings. ServicingGlobals.WARNING_1: More than 1 combination level is forced. ServicingGlobals.WARNING_2: All combination levels are excluded.
Throws:
java.lang.Exception - Description of the Exception

buildOrder

private int[] buildOrder(java.lang.String order2)
                  throws java.lang.Exception
Auxiliary for load a set parameter values from DB and build the array with the order search.
Parameters:
order2 - the value of search order 2.
Returns:
order The int array with the order search.
Throws:
java.lang.Exception - Description of the Exception

buildHeader

private Header[] buildHeader(java.lang.String order2,
                             java.lang.String skip2,
                             java.lang.String skip3,
                             java.lang.String level_1_2,
                             java.lang.String level_1_any,
                             java.lang.String level_any_2,
                             java.lang.String level_any_any)
                      throws java.lang.Exception
Auxiliary for load a set parameter values from DB. and build the Header object.
Parameters:
order2 - the value of search order 2.
skip2 - if the coordinate is skip or not .
skip3 - if the coordinate is skip or not .
level_1_2 - the value of parameter restriction.
level_1_any - the value of parameter restriction.
level_any_2 - the value of parameter restriction.
level_any_any - the value of parameter restriction.
Returns:
header The Header object array.
Throws:
java.lang.Exception - Description of the Exception

buildParmValue

public java.util.Hashtable buildParmValue(java.util.ArrayList level1Point,
                                          java.util.ArrayList level2Point,
                                          java.util.Hashtable pointValue)
                                   throws java.lang.Exception
Auxiliary for load a set parameter values from DB and build a Hashtable with point1+"|"+point2 as the Key and ValueRow as the Value.
Parameters:
level1Point - ArrayList with the all points of level1
level2Point - ArrayList with the all points of level2
pointValue - The Hashtable with the all values of the parameter.
Returns:
parmValue The Hashtable with the point1+"|"+point2 as the Key and ValueRow as the Value.
Throws:
java.lang.Exception - Description of the Exception

setColor

private ParameterModel setColor(ParameterModel parameterModel)
                         throws java.lang.Exception
Auxiliary for load a set parameter values from DB and set warning colors to ParameterModel object of the current company for the parameter. This method invokes the verifyHeaderColor() and verifyColor() methods.
Parameters:
parameterModel - The ParameterModel object with all values for the parameter without warning colors.
Returns:
parameterModel The ParameterModel object. When its atributes are representing the all values and warning colors for the parameter.
Throws:
java.lang.Exception - Description of the Exception

verifyHeaderColor

private Header[] verifyHeaderColor(Header[] header)
                            throws java.lang.Exception
Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color.
Parameters:
header - Description of the Parameter
Returns:
Header array object with header warning colors. This indicates if the parameter restriction has a warning. ServicingGlobals.WARNING_0: forced. ServicingGlobals.WARNING_1: allowed. ServicingGlobals.WARNING_2: excluded.
Throws:
java.lang.Exception - Description of the Exception

verifyColor

private java.util.Hashtable verifyColor(java.util.Hashtable parmValue,
                                        Header[] header,
                                        int[] order)
                                 throws java.lang.Exception
Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color. This method invokes verifyCellsColor() method.
Parameters:
parmValue - The Hashtable with the all values of the parameter without warning colors.
header - The Header object.
order - The int array with the order search.
Returns:
answer The Hashtable with all warning colors.
Throws:
java.lang.Exception - Description of the Exception

verifyCellsColor

private ValueRow verifyCellsColor(int[] order,
                                  ValueRow valueRow,
                                  Header[] header)
                           throws java.lang.Exception
Auxiliary for load a set parameter values from DB veryfy the conditions over parameter restrictions and assign the warning color.
Parameters:
order - The int array with the order search.
valueRow - The ValueRow object
header - The Header object.
Returns:
valueRow The ValueRow object with all warning colors.
Throws:
java.lang.Exception - Description of the Exception

verifyValue

private java.lang.String verifyValue(java.lang.String value,
                                     java.lang.String type)
                              throws java.lang.Exception
Auxiliary for update a set parameter values from DB veryfy the condition over parameter value
Parameters:
value - The value of the parameter.
type - The type of the parameter.
Returns:
value The value of the parameter. If the value of the parameter is a bad expression, its value is undefined
Throws:
java.lang.Exception - Description of the Exception