com.instantbank.component.lettertemplate.ejb
Class LetterTemplateDAO

java.lang.Object
  |
  +--com.instantbank.component.lettertemplate.ejb.LetterTemplateDAO

public class LetterTemplateDAO
extends java.lang.Object

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

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

Field Summary
private  java.util.GregorianCalendar calendar
          GregorianCalendar
private  java.util.Hashtable companyCalendars
          calendars of current company
(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
          for debugging
private  java.text.DateFormat form
          Format Date of US (Mon day, Year)
private  java.util.Date toDay
          The Date of today
(package private)  java.lang.Long userId
          current user
 
Constructor Summary
LetterTemplateDAO(java.lang.String companyId, java.lang.Long userId)
          Constructor: searchs the DataSource in the InitialContext
 
Method Summary
 java.util.ArrayList applyImagesRepository(java.util.ArrayList items)
          Applies a set of changes in the images of the current company in DatabaseNames.LETT_IMAGES_REPOSITORY ;
 java.util.ArrayList applyItemsCategory(java.util.ArrayList items)
          Applies a set of changes in the categories of the current company; in DatabaseNames.LETT_CATEGORY;
 java.util.ArrayList applyItemsComponent(java.util.ArrayList items)
          Applies a set of changes in the components of the current company where the relationship between Template and Component doesn't exist from DatabaseNames.LETT_VARIABLE, LETT_IMAGE, LETT_COMPONENT.
 java.util.ArrayList applyItemsTemplate(java.util.ArrayList items)
          Applies a set of changes in the templates of the current company from DatabaseNames.LETT_TEMPLATE_COMPONENT_LINK and LETT_TEMPLATE.
private  LetterComponent auxLoadComponent(long componentCode, java.sql.PreparedStatement ps, java.sql.ResultSet rs)
          Auxiliary for loadComponent: loads a letter component from tables DatabaseNames.LETT_COMPONENT, LETT_VARIABLE, LETT_IMAGE
private  java.lang.String auxReplaceWorkableOperator(java.lang.String sentence, java.lang.String workableOperator, java.sql.Date sysDate, java.sql.Date companyDate)
          Auxiliary for executeSQL service.
private  CodeDescription auxStoreComponent(LetterComponent component, java.sql.PreparedStatement ps, java.sql.ResultSet rs)
          Auxiliary for storeComponent: stores a letter component in tables DatabaseNames.LETT_COMPONENT, LETT_VARIABLE, LETT_IMAGE
private  java.lang.String auxTransformWorkableOffset(java.lang.String sentenceSQL, java.sql.Date sysDate, java.sql.Date companyDate)
          Auxiliary for executeSQL service.
 java.util.ArrayList[] executeSQL(java.lang.String sentenceSQL, java.lang.Long[] selectFields, java.util.Hashtable jobORDERhashtable, java.util.Hashtable systemFields)
          Gets a result set executing a SQL sentence, associated with a letter job.
 java.util.ArrayList generatePreviewTemplate(long templateCode, long loanCode, java.lang.Long[] templateVarsCodes, java.util.Hashtable systemAlias, java.util.Hashtable systemFields)
          Gets template variables values for one loan of the current company, which will be used in a preview of the template.
 void insertLetterARHistory(java.sql.Connection dbConnection, long lCompID, long lAgrmID, java.sql.Date procDate, long lLettID, long lLettCode, long lActionCode, long lResultCode)
           
private  void linkTemplateComponent(long templateCode, long componentCode, java.sql.PreparedStatement ps, java.sql.ResultSet rs)
          Auxiliary for linking a template and a component precondition there isn't any link before between template and component
 java.util.Hashtable loadAlias()
          Loads data of DatabaseNames.LETT_ALIAS
 java.util.ArrayList loadAllTemplatesDescription()
          Loads code, print type, category and name of templates and their categories names.
 java.util.Hashtable loadCalendars()
          Loads all the calendars of the current company; from DatabaseNames.CALENDARS;
 CodeDescription[] loadCategories()
          Loads all [code, description] of the categories of the current company, in DatabaseNames.LETT_CATEGORY; ordered by name
 CodeDescription[] loadCodesStamps(long category, int printType, java.lang.String name, java.lang.String header, java.lang.String body, java.lang.String closing)
          Loads code and stamp of template and components from DatabaseNames.LETT_TEMPLATE and LETT_COMPONENT tables
 CompanyLocation loadCompanyLocation(long ftpId)
          Load the data of company locations from DatabaseNames.COMPANY_LOCATIONS table.
 java.lang.String loadCompanyWorkDir()
          Loads the temporal directory path of the current company.
 LetterComponent loadComponent(long componentCode)
          Loads a letters component of the current company, corresponding to a code, from tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE
 CodeDescription loadComponentCode(int componentType, int printType, java.lang.String name)
          Load [code, stamp] for specified component from DatabaseNames.LETT_COMPONENT table
 CodeDescription[] loadComponentsDescription(int componentType, int printType)
          Loads code and description of all components, for the current company, for the specified component type and print type; from DatabaseNames.LETT_COMPONENT table; ordered by name
 java.util.ArrayList loadFieldMenus()
          Loads system field Menus with its values ordered by description (name of menu); from DatabaseNames.LETT_FIELD_MENU, LETT_FIELD_VALUE
 java.util.Hashtable loadFields()
          Loads data of DatabaseNames.LETT_FIELD of the current company (i.e.
 java.util.ArrayList loadFieldsDisplay()
          Loads company fields with display information and menu references (for current company).
 CodeDescription[] loadFTPCodes()
          Loads all [code, name] of the ftp's of the current company, from DatabaseNames.COMPANY_ADDRESSES and COMPANY_LOCATIONS tables; ordered by name
 byte[] loadImageRepository(java.lang.String nameImage)
          Loads an image of the current company; from DatabaseNames.LETT_IMAGES_REPOSITORY
 CodeDescription[] loadImagesNamesRepository()
          Loads all [code, description] of the images of the current company; ordered by name from DatabaseNames.LETT_IMAGES_REPOSITORY
 CodeDescription[] loadJobsCodes()
          Loads all [code, name] of the jobs of the current company; from DatabaseNames.LETT_JOB; ordered by name
 LetterBatchReviewModel loadLetterBatchReview(java.lang.String dayMonthYear)
          Review the batch of letters jobs from tables
 LetterBatchStartModel loadLetterJob()
          Loads all letters Job information.
 java.lang.String loadLoanDummy()
          Load the dummy loan of a company from DatabaseNames.PREVIEW_LOAN table.
 CodeDescription[] loadPrintTypes()
          Loads code and description of printTypes; from DatabaseNames.LETT_PRINT_TYPE table; ordered by description
 java.sql.Date loadSysDate()
          Loads the date (Oracle SYSDATE() function).
 Template loadTemplate(long templateCode)
          Loads a letters template of the current company, corresponding to a code, from tables DatabaseNames.LETT_TEMPLATE, LETT_TEMPLATE_COMPONENT_LINK, LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE
 CodeDescription[] loadTemplateCodeDescription(long category, int printType, java.lang.String name)
          Loads code and description of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
 CodeDescription[] loadTemplateCodes(long templateCode)
          Loads code and description of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
 CodeDescription[] loadTemplateCodes(long category, int printType, java.lang.String name)
          Loads code and stamp of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
 java.sql.Date loadTemplateDate(long templateCode)
          Load the date of template from DatabaseNames.LETT_TEMPLATE table.
 CodeDescription[] loadTemplatesDescription(long category, int printType)
          Loads code and description of all templates, for the current company and for the specified category; from DatabaseNames.LETT_TEMPLATE table; ordered by name.
 java.util.ArrayList loadUnlikedComponents()
          If the relationship between Template and Component doesn't exist loads code, name and print type of components and name of component type from DatabaseNames.LETT_COMPONENT, LETT_COMPONENT_TYPE, LETT_PRINT_TYPE and LETT_TEMPLATE_COMPONENT_LINK.
 CodeDescription[] loadVariableFormats()
          Loads code and description of format of letter variables from DatabaseNames.LETT_FORMAT table; ordered by description
 java.util.ArrayList loadVariables()
          Loads name of letter variables of the current company, ordered by name from DatabaseNames.LETT_FIELD and DatabaseNames.LETT_COMPANY_FIELD
 void removeComponent(long componentCode)
          Removes a letters component of the current company, corresponding to a code, from tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Fails if the component has links with one or several templates
 void removeImageRepository(java.lang.String nameImage)
          Removes an image of the current company in DatabaseNames.LETT_IMAGES_REPOSITORY
 void removeTemplate(long templateCode)
          Removes a letters template (not its components) of the current company, corresponding to a code, from tables DatabaseNames.LETT_TEMPLATE and LETT_TEMPLATE_COMPONENT_LINK
 CodeDescription storeComponent(LetterComponent component)
          Stores a letters component for the current company, in tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Generates code for the component if it is new.
 CodeDescription storeComponentAs(long templateCode, LetterComponent component)
          Store as a letters component for the current company in tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE generating code for the component if it is new.
 long storeImageRepository(java.lang.String nameImage, byte[] image)
          Stores a new image for the current company in DatabaseNames.LETT_IMAGES_REPOSITORY
 void storeLetterFtpJobLog(long jobLogId, java.lang.String fullFilePath, boolean succes, int attempts, java.lang.String ip, java.lang.String path, java.lang.String failureDescription)
          Store the Log of ftps made for executed letter jobs of the current company in DatabaseNames.LETT_JOB_FTP_LOG table.
 LettersJobLogBean storeLetterJobLog(long jobId, java.sql.Date executionDate, java.lang.String success, long resultSetLength, java.lang.String loggeableResultSet, java.lang.String foTemplate)
          Store the log of executed letter jobs of the current company.
 CodeDescription[] storeTemplate(Template template)
          Stores a letters template for the current company, in tables DatabaseNames.LETT_TEMPLATE, LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Generates code for the template if it is new, and generates code for each component if it is new.
 void updateJobExecDate(long jobId, java.sql.Date date)
          Update the date of execution of the letter job of the current company.
 void updateLetterFtpJobLog(long jobLogId, java.lang.String fullFilePath, boolean succes, int attempts, java.lang.String ip, java.lang.String path, java.lang.String failureDescription)
          Update the Log of ftps made for executed letter jobs of the current company in DatabaseNames.LETT_JOB_FTP_LOG table.
private  java.lang.String verifyDate(java.lang.String frequency, java.lang.String status, java.sql.Date activationDate, java.sql.Date lastDate, java.lang.String empty)
          Auxiliary for loadLetterJob service.
 
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

form

private java.text.DateFormat form
Format Date of US (Mon day, Year)

calendar

private java.util.GregorianCalendar calendar
GregorianCalendar

toDay

private java.util.Date toDay
The Date of today

companyCalendars

private java.util.Hashtable companyCalendars
calendars of current company

debug

private Debug debug
for debugging
Constructor Detail

LetterTemplateDAO

public LetterTemplateDAO(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
DAOException - Description of the Exception
Method Detail

loadFields

public java.util.Hashtable loadFields()
                               throws DAOException
Loads data of DatabaseNames.LETT_FIELD of the current company (i.e. restricting with DatabaseNames.LETT_COMPANY_FIELD)
Returns:
Hashtable of system Fields for current company key: fieldId (in Long), value: com.instantbank.component.job.util.Field object
Throws:
DAOException -  

loadFieldsDisplay

public java.util.ArrayList loadFieldsDisplay()
                                      throws DAOException
Loads company fields with display information and menu references (for current company). from DatabaseNames.LETT_FIELD_MENU, LETT_FIELD, LETT_COMPANY_FIELD, ordered by display name
Returns:
ArrayList of company fields where each element is an inner ArrayList composed of: fieldId(Long), displayName(String), dataType(String), menuId(Long), menuName (String), offsetType(String)
Throws:
DAOException -  

loadFieldMenus

public java.util.ArrayList loadFieldMenus()
                                   throws DAOException
Loads system field Menus with its values ordered by description (name of menu); from DatabaseNames.LETT_FIELD_MENU, LETT_FIELD_VALUE
Returns:
ArrayList of menus where each element is an inner ArrayList composed of: menuName(String), menuValues(ArrayList); each menuValues element is a String[] with an internalValue(String) and display(String)
Throws:
DAOException -  

loadAlias

public java.util.Hashtable loadAlias()
                              throws DAOException
Loads data of DatabaseNames.LETT_ALIAS
Returns:
Hashtable of system Alias key: String = tableAlias|rootType value: com.instantbank.component.job.util.Alias object
Throws:
DAOException -  

loadVariables

public java.util.ArrayList loadVariables()
                                  throws DAOException
Loads name of letter variables of the current company, ordered by name from DatabaseNames.LETT_FIELD and DatabaseNames.LETT_COMPANY_FIELD
Returns:
ArrayList of variables where each element is an inner ArrayList with the following elements of a variable: fieldId(Long): code of field (variable) in the system, name(String): name of variable to display in user interface, dataType(String): type of variable: numeric: LetterTemplateGlobals.FIELD_NUMERIC, string: LetterTemplateGlobals.FIELD_STRING, date: LetterTemplateGlobals.FIELD_DATE offsetType(String): type of offset (relevant for date fields): no: LetterTemplateGlobals.NO_OFFSET, chronological: LetterTemplateGlobals.CHRONO_DAYS_OFFSET, workable : LetterTemplateGlobals.WORKABLE_DAYS_OFFSET
Throws:
DAOException -  

loadVariableFormats

public CodeDescription[] loadVariableFormats()
                                      throws DAOException
Loads code and description of format of letter variables from DatabaseNames.LETT_FORMAT table; ordered by description
Returns:
CodeDescription[] object with [code, description] of formats
Throws:
DAOException -  

loadPrintTypes

public CodeDescription[] loadPrintTypes()
                                 throws DAOException
Loads code and description of printTypes; from DatabaseNames.LETT_PRINT_TYPE table; ordered by description
Returns:
CodeDescription[] object with [code, description] of printTypes
Throws:
DAOException -  

loadCategories

public CodeDescription[] loadCategories()
                                 throws DAOException
Loads all [code, description] of the categories of the current company, in DatabaseNames.LETT_CATEGORY; ordered by name
Returns:
CodeDescription[] object with [code, description] of the categories
Throws:
DAOException -  

applyItemsCategory

public java.util.ArrayList applyItemsCategory(java.util.ArrayList items)
                                       throws DAOException
Applies a set of changes in the categories of the current company; in DatabaseNames.LETT_CATEGORY;
Parameters:
items - ArrayList with 3 elements of type String[] representing the attributes of items to apply code, name and status status indicates if the item is for inserting, deleting or updating (LetterTemplateGlobals.INSERT, LetterTemplateGlobals.DELETE, LetterTemplateGlobals.UPDATE)
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current categories list (CodeDescription[])
Throws:
DAOException -  

storeImageRepository

public long storeImageRepository(java.lang.String nameImage,
                                 byte[] image)
                          throws DAOException
Stores a new image for the current company in DatabaseNames.LETT_IMAGES_REPOSITORY
Parameters:
nameImage - name of image
image - bytes of image
Returns:
code (long) assigned to the image
Throws:
DAOException -  

loadImagesNamesRepository

public CodeDescription[] loadImagesNamesRepository()
                                            throws DAOException
Loads all [code, description] of the images of the current company; ordered by name from DatabaseNames.LETT_IMAGES_REPOSITORY
Returns:
CodeDescription[] object with [code, description] of images
Throws:
DAOException -  

loadImageRepository

public byte[] loadImageRepository(java.lang.String nameImage)
                           throws DAOException
Loads an image of the current company; from DatabaseNames.LETT_IMAGES_REPOSITORY
Parameters:
nameImage - name of image
Returns:
byte[] with bytes of image
Throws:
DAOException -  

removeImageRepository

public void removeImageRepository(java.lang.String nameImage)
                           throws DAOException
Removes an image of the current company in DatabaseNames.LETT_IMAGES_REPOSITORY
Parameters:
nameImage - name of image
Throws:
DAOException -  

applyImagesRepository

public java.util.ArrayList applyImagesRepository(java.util.ArrayList items)
                                          throws DAOException
Applies a set of changes in the images of the current company in DatabaseNames.LETT_IMAGES_REPOSITORY ;
Parameters:
items - ArrayList with 2 elements of type String[] representing the attributes of items to apply code, name and status; status indicates if the item is for deleting or updating (LetterTemplateGlobals.DELETE, LetterTemplateGlobals.UPDATE).
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current images list (CodeDescription[])
Throws:
DAOException -  

storeTemplate

public CodeDescription[] storeTemplate(Template template)
                                throws DAOException
Stores a letters template for the current company, in tables DatabaseNames.LETT_TEMPLATE, LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Generates code for the template if it is new, and generates code for each component if it is new. If the template exists before, its version is validated and the old template is replaced. The associations between the template and its components are established in DatabaseNames.LETT_TEMPLATE_COMPONENT_LINK table, replacing possible old associations
Parameters:
template - to store
Returns:
CodeDescription[] with 4 [code, stamp] in the following order: template, HEADER, BODY, CLOSING
Throws:
DAOException -  

loadTemplatesDescription

public CodeDescription[] loadTemplatesDescription(long category,
                                                  int printType)
                                           throws DAOException
Loads code and description of all templates, for the current company and for the specified category; from DatabaseNames.LETT_TEMPLATE table; ordered by name.
Parameters:
category - specified letter category
printType - specified print type
Returns:
CodeDescription[] object with [code, description] of templates
Throws:
DAOException -  

loadTemplateCodes

public CodeDescription[] loadTemplateCodes(long templateCode)
                                    throws DAOException
Loads code and description of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
Parameters:
templateCode - code of template
Returns:
CodeDescription[] object with [code, description] of template and components in the order: template, HEADER, BODY, CLOSING
Throws:
DAOException -  

loadTemplateCodes

public CodeDescription[] loadTemplateCodes(long category,
                                           int printType,
                                           java.lang.String name)
                                    throws DAOException
Loads code and stamp of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
Parameters:
category - category of template
printType - type of print
name - name of template
Returns:
CodeDescription[] composed by [code, stamp] of template and its components ordered by template, HEADER, BODY, CLOSING
Throws:
DAOException -  

loadTemplateCodeDescription

public CodeDescription[] loadTemplateCodeDescription(long category,
                                                     int printType,
                                                     java.lang.String name)
                                              throws DAOException
Loads code and description of one template and its components for the specified template code from DatabaseNames.LETT_TEMPLATE, DatabaseNames.LETT_COMPONENT tables
Parameters:
category - category of template
printType - type of print
name - name of template
Returns:
CodeDescription[] composed by [code, description] of template and its components ordered by template, HEADER, BODY, CLOSING
Throws:
DAOException -  

loadCodesStamps

public CodeDescription[] loadCodesStamps(long category,
                                         int printType,
                                         java.lang.String name,
                                         java.lang.String header,
                                         java.lang.String body,
                                         java.lang.String closing)
                                  throws DAOException
Loads code and stamp of template and components from DatabaseNames.LETT_TEMPLATE and LETT_COMPONENT tables
Parameters:
category - category of template
printType - type of print
name - name of template
header - name of component header
body - name of component body
closing - name of component closing
Returns:
CodeDescription[i] for i = 1(HEADER),2(BODY),3(CLOSING) is: [code, stamp] of component, if it exists, [LetterTemplateGlobals.UNDEF,LetterTemplateGlobals.STR_UNDEF] if component doesn't exist
Throws:
DAOException -  

loadTemplate

public Template loadTemplate(long templateCode)
                      throws DAOException
Loads a letters template of the current company, corresponding to a code, from tables DatabaseNames.LETT_TEMPLATE, LETT_TEMPLATE_COMPONENT_LINK, LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE
Parameters:
templateCode - code of template
Returns:
Template selected
Throws:
DAOException -  

removeTemplate

public void removeTemplate(long templateCode)
                    throws DAOException
Removes a letters template (not its components) of the current company, corresponding to a code, from tables DatabaseNames.LETT_TEMPLATE and LETT_TEMPLATE_COMPONENT_LINK
Parameters:
templateCode - code of template
Throws:
DAOException -  

loadAllTemplatesDescription

public java.util.ArrayList loadAllTemplatesDescription()
                                                throws DAOException
Loads code, print type, category and name of templates and their categories names. from DatabaseNames.LETT_TEMPLATE, LETT_CATEGORY, LETT_PRINT_TYPE.
Returns:
ArrayList of variables where each element is an inner ArrayList with the following elements of a variable: code(Long): code of template, nameCategory(String): name of category, type(String): print type, nameTemplate (String): name of template.
Throws:
DAOException -  

applyItemsTemplate

public java.util.ArrayList applyItemsTemplate(java.util.ArrayList items)
                                       throws DAOException
Applies a set of changes in the templates of the current company from DatabaseNames.LETT_TEMPLATE_COMPONENT_LINK and LETT_TEMPLATE.
Parameters:
items - ArrayList with 4 elements of type String[] representing the attributes of items to apply: code of template, code of category, name of template and status; status indicates if the item is for deleting or updating (LetterTemplateGlobals.DELETE, LetterTemplateGlobals.UPDATE).
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current Template description list (ArrayList)
Throws:
DAOException -  

loadTemplateDate

public java.sql.Date loadTemplateDate(long templateCode)
                               throws DAOException
Load the date of template from DatabaseNames.LETT_TEMPLATE table.
Parameters:
templateCode - Code of template.
Returns:
date date of template.
Throws:
DAOException -  

loadLoanDummy

public java.lang.String loadLoanDummy()
                               throws DAOException
Load the dummy loan of a company from DatabaseNames.PREVIEW_LOAN table.
Returns:
code dummy agreement code.
Throws:
DAOException -  
java.rmi.RemoteException - Description of the Exception

storeComponent

public CodeDescription storeComponent(LetterComponent component)
                               throws DAOException
Stores a letters component for the current company, in tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Generates code for the component if it is new. If the component exists before, its version is validated and the old component is replaced.
Parameters:
component - is the letter component to store
Returns:
CodeDescription: [code, stamp] of component
Throws:
DAOException -  

storeComponentAs

public CodeDescription storeComponentAs(long templateCode,
                                        LetterComponent component)
                                 throws DAOException
Store as a letters component for the current company in tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE generating code for the component if it is new. If the component exists before, its version is validated and the old component is replaced. The association between the template and the component is established in DatabaseNames.LETT_TEMPLATE_COMPONENT_LINK table
Parameters:
templateCode - code of template
component - is the letter component to store
Returns:
CodeDescription: [code, stamp] of component
Throws:
DAOException -  

loadComponentsDescription

public CodeDescription[] loadComponentsDescription(int componentType,
                                                   int printType)
                                            throws DAOException
Loads code and description of all components, for the current company, for the specified component type and print type; from DatabaseNames.LETT_COMPONENT table; ordered by name
Parameters:
componentType - type of components to load
printType - print type of components to load
Returns:
CodeDescription[] object with [code, description] of components
Throws:
DAOException -  

loadComponent

public LetterComponent loadComponent(long componentCode)
                              throws DAOException
Loads a letters component of the current company, corresponding to a code, from tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE
Parameters:
componentCode - code of component to load
Returns:
LetterComponent is the loaded component
Throws:
DAOException -  

removeComponent

public void removeComponent(long componentCode)
                     throws DAOException
Removes a letters component of the current company, corresponding to a code, from tables DatabaseNames.LETT_COMPONENT, LETT_IMAGE, LETT_VARIABLE Fails if the component has links with one or several templates
Parameters:
componentCode - is the component code to remove
Throws:
DAOException -  

loadComponentCode

public CodeDescription loadComponentCode(int componentType,
                                         int printType,
                                         java.lang.String name)
                                  throws DAOException
Load [code, stamp] for specified component from DatabaseNames.LETT_COMPONENT table
Parameters:
componentType - type of component (HEADER, BODY or CLOSING)
printType - type of print
name - name of component
Returns:
CodeDescription: [code, stamp] if the component exists, [LetterTemplateGlobals.UNDEF,LetterTemplateGlobals.STR_UNDEF] if the component doesn't exist
Throws:
DAOException -  

loadUnlikedComponents

public java.util.ArrayList loadUnlikedComponents()
                                          throws DAOException
If the relationship between Template and Component doesn't exist loads code, name and print type of components and name of component type from DatabaseNames.LETT_COMPONENT, LETT_COMPONENT_TYPE, LETT_PRINT_TYPE and LETT_TEMPLATE_COMPONENT_LINK.
Returns:
ArrayList of variables where each element is an inner ArrayList with the following elements of a variable: code(Long): code of component, nameComponentType(String): name of component type, type(String): print type, nameComponent (String): name of component.
Throws:
DAOException -  

applyItemsComponent

public java.util.ArrayList applyItemsComponent(java.util.ArrayList items)
                                        throws DAOException
Applies a set of changes in the components of the current company where the relationship between Template and Component doesn't exist from DatabaseNames.LETT_VARIABLE, LETT_IMAGE, LETT_COMPONENT.
Parameters:
items - ArrayList with 3 elements of type String[] representing the attributes of items to apply: code, name of component and status; status indicates if the item is for deleting or updating
Returns:
ArrayList with 2 elements: (0) possible problem (String), (1) current Template description list (ArrayList)
Throws:
DAOException -  

generatePreviewTemplate

public java.util.ArrayList generatePreviewTemplate(long templateCode,
                                                   long loanCode,
                                                   java.lang.Long[] templateVarsCodes,
                                                   java.util.Hashtable systemAlias,
                                                   java.util.Hashtable systemFields)
                                            throws DAOException
Gets template variables values for one loan of the current company, which will be used in a preview of the template. It creates an entity EJB Job instance associated to the template preview and generates the associated SQL sentence. This sentence is executed on any tables and gets the template variables values.
Parameters:
templateCode - is the code of template to preview
loanCode - is the code of the loan (i.e. agreement)
templateVarsCodes - template variables codes
systemAlias - Hashtable of system Alias key: String = tableAlias|rootType value: Alias object
systemFields - Hashtable of system Fields for current company key: fieldId (in Long), value: Field object
Returns:
ArrayList of one tuple that is an Object[] of Strings; each String is the value of a template variable for the chosen loan
Throws:
DAOException -  

executeSQL

public java.util.ArrayList[] executeSQL(java.lang.String sentenceSQL,
                                        java.lang.Long[] selectFields,
                                        java.util.Hashtable jobORDERhashtable,
                                        java.util.Hashtable systemFields)
                                 throws DAOException
Gets a result set executing a SQL sentence, associated with a letter job.
Parameters:
sentenceSQL - SQL sentence for executing; in addition to SQL sintax, it can contain ++ or -- operators that must be transformed in workable days offset
selectFields - output fields ids (in job SELECT order) or a Long[] of length 0 if there are no output fields.
jobORDERhashtable - Hashtable of job ORDER elements: key: fieldId (in Long), value: JobORDERelement
systemFields - Hashtable of system Fields for current company key: fieldId (in Long), value: Field object
Returns:
ArrayList[] as following: ArrayList[0]: first (aggregated) column of the result set (i.e. agreement code) it is an ArrayList of String elements. ArrayList[1]: the others columns of the result set it is an ArrayList of String[] elements.
Throws:
DAOException -  

loadFTPCodes

public CodeDescription[] loadFTPCodes()
                               throws DAOException
Loads all [code, name] of the ftp's of the current company, from DatabaseNames.COMPANY_ADDRESSES and COMPANY_LOCATIONS tables; ordered by name
Returns:
CodeDescription[] object with [code, name] of the ftp's
Throws:
DAOException -  

loadJobsCodes

public CodeDescription[] loadJobsCodes()
                                throws DAOException
Loads all [code, name] of the jobs of the current company; from DatabaseNames.LETT_JOB; ordered by name
Returns:
CodeDescription[] object with [code, description] of the categories
Throws:
DAOException -  

loadCalendars

public java.util.Hashtable loadCalendars()
                                  throws DAOException
Loads all the calendars of the current company; from DatabaseNames.CALENDARS;
Returns:
Hashtable of company calendars: key: year (Integer), value: String of 365/366 characters representing the year calendar (each day of year is a character : 'P' if it is workable(Processing) day, 'N' otherwise)
Throws:
DAOException -  

loadLetterJob

public LetterBatchStartModel loadLetterJob()
                                    throws DAOException
Loads all letters Job information. this method service imvoke the verifyDate() methos.
Returns:
answer The LetterBatchStartModel object with all letters Job when each atribute represents: Jobs to run, Jobs out of frequency and other Jobs(inactive,no yet active and on request)
Throws:
DAOException -  

loadSysDate

public java.sql.Date loadSysDate()
                          throws DAOException
Loads the date (Oracle SYSDATE() function).
Returns:
date The date of Oracle SYSDATE() function.
Throws:
DAOException -  

loadCompanyWorkDir

public java.lang.String loadCompanyWorkDir()
                                    throws DAOException
Loads the temporal directory path of the current company. from DatabasesNames.COLLECTIONS_CONFIG table.
Returns:
path Path for the Downloads generated by the system.
Throws:
DAOException -  

storeLetterJobLog

public LettersJobLogBean storeLetterJobLog(long jobId,
                                           java.sql.Date executionDate,
                                           java.lang.String success,
                                           long resultSetLength,
                                           java.lang.String loggeableResultSet,
                                           java.lang.String foTemplate)
                                    throws DAOException
Store the log of executed letter jobs of the current company.
Parameters:
resultSetLength - Number of records retrieved by the job execution.
loggeableResultSet - Result set with the records retrieved by the job execution.
foTemplate - Transformed text of template used by the job execution.
jobId - Description of the Parameter
executionDate - Description of the Parameter
success - Description of the Parameter
Returns:
answer The LettersJobLogBean object with the log code, job id and execution date of executed letter jobs.
Throws:
DAOException -  

storeLetterFtpJobLog

public void storeLetterFtpJobLog(long jobLogId,
                                 java.lang.String fullFilePath,
                                 boolean succes,
                                 int attempts,
                                 java.lang.String ip,
                                 java.lang.String path,
                                 java.lang.String failureDescription)
                          throws DAOException
Store the Log of ftps made for executed letter jobs of the current company in DatabaseNames.LETT_JOB_FTP_LOG table.
Parameters:
succes - Indicates if the JOB_FILE was sucessfully sent by ftp (yes) or not (no).
attempts - Number of failed attempts in sending by ftp the JOB_FILE.
ip - IP address used in last attempt in sending by ftp the JOB_FILE (null when the job is not distributed by ftp).
path - complementary PATH of LAST_FTP_IP_ADDRESS. (null when the job is not distributed by ftp).
failureDescription - explanation in failure case (null when the job is not distributed by ftp).
jobLogId - Description of the Parameter
fullFilePath - Description of the Parameter
Throws:
DAOException -  

updateLetterFtpJobLog

public void updateLetterFtpJobLog(long jobLogId,
                                  java.lang.String fullFilePath,
                                  boolean succes,
                                  int attempts,
                                  java.lang.String ip,
                                  java.lang.String path,
                                  java.lang.String failureDescription)
                           throws DAOException
Update the Log of ftps made for executed letter jobs of the current company in DatabaseNames.LETT_JOB_FTP_LOG table.
Parameters:
succes - Indicates if the JOB_FILE was sucessfully sent by ftp (yes) or not (no).
attempts - Number of failed attempts in sending by ftp the JOB_FILE.
ip - IP address used in last attempt in sending by ftp the JOB_FILE.
path - complementary PATH of LAST_FTP_IP_ADDRESS.
failureDescription - explanation in failure case.
jobLogId - Description of the Parameter
fullFilePath - Description of the Parameter
Throws:
DAOException -  

updateJobExecDate

public void updateJobExecDate(long jobId,
                              java.sql.Date date)
                       throws DAOException
Update the date of execution of the letter job of the current company.
Parameters:
date - The date of execution of the letter job.
jobId - Description of the Parameter
Throws:
DAOException -  

loadCompanyLocation

public CompanyLocation loadCompanyLocation(long ftpId)
                                    throws DAOException
Load the data of company locations from DatabaseNames.COMPANY_LOCATIONS table.
Parameters:
ftpId - The code of ftp.
Returns:
answer The CompanyLocation object with location id, path ip address, ftp login name and ftp password.
Throws:
DAOException -  

loadLetterBatchReview

public LetterBatchReviewModel loadLetterBatchReview(java.lang.String dayMonthYear)
                                             throws DAOException
Review the batch of letters jobs from tables
Parameters:
dayMonthYear - The date to ask for letter Job Log information
Returns:
answer The LetterBatchReviewModel object with Job Log information.
Throws:
DAOException -  

auxStoreComponent

private CodeDescription auxStoreComponent(LetterComponent component,
                                          java.sql.PreparedStatement ps,
                                          java.sql.ResultSet rs)
                                   throws java.lang.Exception
Auxiliary for storeComponent: stores a letter component in tables DatabaseNames.LETT_COMPONENT, LETT_VARIABLE, LETT_IMAGE
Parameters:
component - to store (LetterComponent)
ps - auxiliary PreparedStatement
rs - auxiliary ResultSet
Returns:
CodeDescription: [code, stamp] of component
Throws:
java.lang.Exception -  

auxLoadComponent

private LetterComponent auxLoadComponent(long componentCode,
                                         java.sql.PreparedStatement ps,
                                         java.sql.ResultSet rs)
                                  throws java.lang.Exception
Auxiliary for loadComponent: loads a letter component from tables DatabaseNames.LETT_COMPONENT, LETT_VARIABLE, LETT_IMAGE
Parameters:
componentCode - code of component to load
ps - auxiliary PreparedStatement
rs - auxiliary ResultSet
Returns:
LetterComponent: letter component
Throws:
java.lang.Exception -  

linkTemplateComponent

private void linkTemplateComponent(long templateCode,
                                   long componentCode,
                                   java.sql.PreparedStatement ps,
                                   java.sql.ResultSet rs)
                            throws java.lang.Exception
Auxiliary for linking a template and a component precondition there isn't any link before between template and component
Parameters:
templateCode - code of template
componentCode - code of component
ps - auxiliary PreparedStatement
rs - auxiliary ResultSet
Throws:
java.lang.Exception -  

verifyDate

private java.lang.String verifyDate(java.lang.String frequency,
                                    java.lang.String status,
                                    java.sql.Date activationDate,
                                    java.sql.Date lastDate,
                                    java.lang.String empty)
Auxiliary for loadLetterJob service. Check the type of letter job.
Parameters:
frequency - The frequency of letter job generation.
status - The state of letter job.
activationDate - Date in which the letter job can be executed the first time.
lastDate - The date of last execution of the letter job.
empty - If lastDate is null its value is LetterTemplateGlobals.STR_UNDEF
Returns:
type The type of letter Job.

auxTransformWorkableOffset

private java.lang.String auxTransformWorkableOffset(java.lang.String sentenceSQL,
                                                    java.sql.Date sysDate,
                                                    java.sql.Date companyDate)
                                             throws DAOException
Auxiliary for executeSQL service. Transform a sentenceSQL replacing all expressions: "SYSDATE", "COMPANY_DATE", "SYSDATE ++ n", "SYSDATE -- n", "COMPANY_DATE ++ n", "COMPANY_DATE -- n" by equivalent SQL date literals to the workable days offset.
Parameters:
sentenceSQL - The SQL sentence to transform.
sysDate - Date of today.
companyDate - batch Date of current company.
Returns:
String resulting of transformation.
Throws:
DAOException - Description of the Exception

auxReplaceWorkableOperator

private java.lang.String auxReplaceWorkableOperator(java.lang.String sentence,
                                                    java.lang.String workableOperator,
                                                    java.sql.Date sysDate,
                                                    java.sql.Date companyDate)
                                             throws DAOException
Auxiliary for executeSQL service. Transform a SQL sentence replacing each substring of type (example: COMPANY_DATE ++ 67) by equivalent SQL date literals to the workable days offset. The transformation is made only for one of the workable operator (++, --)
Parameters:
sentence - The SQL sentence to transform.
workableOperator - The workable operator (++ or -- )
sysDate - Date of today.
companyDate - batch Date of current company.
Returns:
String resulting of transformation.
Throws:
DAOException - Description of the Exception

insertLetterARHistory

public void insertLetterARHistory(java.sql.Connection dbConnection,
                                  long lCompID,
                                  long lAgrmID,
                                  java.sql.Date procDate,
                                  long lLettID,
                                  long lLettCode,
                                  long lActionCode,
                                  long lResultCode)
                           throws java.rmi.RemoteException,
                                  DAOException