com.knowgate.hipergate
Class DBLanguages

java.lang.Object
  extended by com.knowgate.hipergate.DBLanguages

public class DBLanguages
extends java.lang.Object

Display static tables as HTML elements like <SELECT>.

This class is a singleton memory cache for frecuently accessed static tables.


Field Summary
static java.lang.String[] SupportedLanguages
          Array of language identifiers supported by the database
 
Constructor Summary
DBLanguages()
           
 
Method Summary
static boolean addLookup(java.sql.Connection oConn, java.lang.String sLookupTableName, java.lang.String sGuOwner, java.lang.String sIdSection, java.lang.String sVlLookUp, java.util.HashMap<java.lang.String,java.lang.String> oTranslatMap)
          Add a lookup value for a given section This methods checks whether the lookup value exists and, if not, then inserts it.
static void deleteLookup(java.sql.Connection oConn, java.lang.String sLookupTableName, java.lang.String sBaseTable, java.lang.String sGuOwner, java.lang.String sIdSection, int iPgLookUp)
          Delete lookup value
static void deleteLookup(java.sql.Connection oConn, java.lang.String sLookupTableName, java.lang.String sBaseTable, java.lang.String sGuOwner, java.lang.String sIdSection, java.lang.String sVlLookUp)
          Delete lookup value
 java.lang.String getCountryName(JDCConnection oConn, java.lang.String sCountryId, java.lang.String sIdLanguage)
          Get country translated name given its 2 letter ISO code.
 java.lang.String getHTMLCountrySelect(JDCConnection oConn, java.lang.String sIdLanguage)
          Get an HTML ComboBox with a list of all languages at k_lu_countries.
static java.lang.String getHTMLSelectLookUp(DistributedCachePeer oCache, JDCConnection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage)
          Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.
static java.lang.String getHTMLSelectLookUp(DistributedCachePeer oCache, JDCConnection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage, int iOrderBy)
          Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.
static java.lang.String getHTMLSelectLookUp(JDCConnection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage)
          Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.
static java.lang.String getHTMLSelectLookUp(JDCConnection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage, java.lang.String sDefaultValue)
          Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.
 java.lang.String getHTMLStateSelect(JDCConnection oConn, java.lang.String sCountryId, java.lang.String sIdLanguage)
          Get list of states for a country in HTML SELECT format
 java.lang.String getHTMLTermSelect(JDCConnection oConn, int iIdDomain, java.lang.String sGuWorkArea)
          Get list of thesauri terms for a given Domain and WorkArea
static java.util.HashMap getLanguageLookUpMap(java.sql.Connection oConn, java.lang.String sLanguage)
          Get a Map of language lookup talbe values and their corresponding translated labels for a language.
 java.lang.String getLanguageName(JDCConnection oConn, java.lang.String sLanguageId, java.lang.String sIdLanguage)
          Get language translated name given its 2 letter ISO code.
static java.util.HashMap getLookUpMap(java.sql.Connection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage)
          Get a Map of lookup values and their corresponding translated labels for a language.
static java.lang.String getLookUpTranslation(java.sql.Connection oConn, java.lang.String sTableName, java.lang.String sOwnerId, java.lang.String sSectionId, java.lang.String sLanguage, java.lang.String sLookupId)
          Get a translated label for a lookup value.
static java.lang.String getLookupTranslationsColumnList()
          A comma separated list of column names for translated labels of lookup tables
 java.lang.String getPlainTextStateList(JDCConnection oConn, java.lang.String sCountryId, java.lang.String sIdLanguage)
          Get list of states for a country in plain text format
static int nextLookuUpProgressive(java.sql.Connection oConn, java.lang.String sLookupTableName, java.lang.String sGuOwner, java.lang.String sIdSection)
          Find value of next unused lookup index for a given table section
static void storeLookup(java.sql.Connection oConn, java.lang.String sLookupTableName, java.lang.String sGuOwner, java.lang.String sIdSection, java.lang.String sVlLookUp, java.util.HashMap oTranslations)
          Add or update a lookup value for a given section This methods checks whether the lookup value exists and, if not, then inserts it.
 java.lang.String toHTMLSelect(JDCConnection oConn, java.lang.String sIdLanguage)
          Get an HTML ComboBox with a list of all languages available at table k_lu_languages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SupportedLanguages

public static final java.lang.String[] SupportedLanguages
Array of language identifiers supported by the database

Since:
4.0
Constructor Detail

DBLanguages

public DBLanguages()
Method Detail

getLookupTranslationsColumnList

public static java.lang.String getLookupTranslationsColumnList()

A comma separated list of column names for translated labels of lookup tables

Returns:
String like "tr_es,tr_en,tr_de,tr_it,tr_fr,tr_pt,tr_ca,tr_eu,tr_ja,tr_cn,tr_tw,tr_fi,tr_ru,tr_nl,tr_th,tr_cs,tr_uk,tr_no,tr_sk"
Since:
4.0

toHTMLSelect

public java.lang.String toHTMLSelect(JDCConnection oConn,
                                     java.lang.String sIdLanguage)
                              throws java.sql.SQLException

Get an HTML ComboBox with a list of all languages available at table k_lu_languages.

Language names are written in the language passed as parameter.
Languages names are sorted.

Parameters:
oConn - Database Connection
sIdLanguage - 2 chraracters code of language for displaying <OPTION> texts.
Returns:
java.sql.SQLException

getHTMLCountrySelect

public java.lang.String getHTMLCountrySelect(JDCConnection oConn,
                                             java.lang.String sIdLanguage)
                                      throws java.sql.SQLException

Get an HTML ComboBox with a list of all languages at k_lu_countries.

Country names are written in the language passed as parameter.
Country names are sorted.

Parameters:
oConn - Database Connection
sIdLanguage - 2 chraracters code of language for displaying <OPTION> texts.
Returns:
java.sql.SQLException

getCountryName

public java.lang.String getCountryName(JDCConnection oConn,
                                       java.lang.String sCountryId,
                                       java.lang.String sIdLanguage)
                                throws java.sql.SQLException

Get country translated name given its 2 letter ISO code.

Parameters:
oConn - Database Connection
sCountryId - 2 characters code of country as at k_lu_countries table
sIdLanguage - 2 characters code of derired language for displaying
Returns:
Country name for the given language or null if no country with such code is found
Throws:
java.sql.SQLException
Since:
4.0

getLanguageName

public java.lang.String getLanguageName(JDCConnection oConn,
                                        java.lang.String sLanguageId,
                                        java.lang.String sIdLanguage)
                                 throws java.sql.SQLException

Get language translated name given its 2 letter ISO code.

Parameters:
oConn - Database Connection
sLanguageId - 2 characters code of country as at k_lu_languages table
sIdLanguage - 2 characters code of derired language for displaying
Returns:
Language name for the given language or null if no language with such code is found
Throws:
java.sql.SQLException
Since:
5.0

getHTMLTermSelect

public java.lang.String getHTMLTermSelect(JDCConnection oConn,
                                          int iIdDomain,
                                          java.lang.String sGuWorkArea)
                                   throws java.sql.SQLException
Get list of thesauri terms for a given Domain and WorkArea

Parameters:
oConn - JDCConnection
iIdDomain - int Domain Unique Identifier
sGuWorkArea - String WorkArea GUID
Returns:
java.sql.SQLException
Since:
4.0

getHTMLStateSelect

public java.lang.String getHTMLStateSelect(JDCConnection oConn,
                                           java.lang.String sCountryId,
                                           java.lang.String sIdLanguage)
                                    throws java.sql.SQLException
Get list of states for a country in HTML SELECT format

Parameters:
oConn - JDCConnection
sCountryId - 2 letters ISO country code (from k_lu_countries table)
sIdLanguage - 2 letters ISO language code (from k_lu_languages table)
Returns:
java.sql.SQLException
Since:
4.0

getPlainTextStateList

public java.lang.String getPlainTextStateList(JDCConnection oConn,
                                              java.lang.String sCountryId,
                                              java.lang.String sIdLanguage)
                                       throws java.sql.SQLException
Get list of states for a country in plain text format

Parameters:
oConn - JDCConnection
sCountryId - 2 letters ISO country code (from k_lu_countries table)
sIdLanguage - 2 letters ISO language code (from k_lu_languages table)
Returns:
Throws:
java.sql.SQLException
Since:
4.0

getHTMLSelectLookUp

public static java.lang.String getHTMLSelectLookUp(JDCConnection oConn,
                                                   java.lang.String sTableName,
                                                   java.lang.String sOwnerId,
                                                   java.lang.String sSectionId,
                                                   java.lang.String sLanguage,
                                                   java.lang.String sDefaultValue)
                                            throws java.sql.SQLException

Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.

This method goes directly to database without any intermediate cache or temporary storage object.

Parameters:
oConn - Database connection
sTableName - Lookup table name
sOwnerId - WorkArea for filtering results
sSectionId - Name of section (field) to retrieve
sDefaultValue - Default selected value, if null then there is no default
sLanguage - 2 chracters language code for ComboBox texts (see k_lu_languages table)
Returns:
...
Throws:
java.sql.SQLException
Since:
3.0

getHTMLSelectLookUp

public static java.lang.String getHTMLSelectLookUp(JDCConnection oConn,
                                                   java.lang.String sTableName,
                                                   java.lang.String sOwnerId,
                                                   java.lang.String sSectionId,
                                                   java.lang.String sLanguage)
                                            throws java.sql.SQLException

Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.

This method goes directly to database without any intermediate cache or temporary storage object.

Parameters:
oConn - Database connection
sTableName - Lookup table name
sOwnerId - WorkArea for filtering results
sSectionId - Name of section (field) to retrieve
sLanguage - 2 chracters language code for ComboBox texts (see k_lu_languages table)
Returns:
...
Throws:
java.sql.SQLException

getHTMLSelectLookUp

public static java.lang.String getHTMLSelectLookUp(DistributedCachePeer oCache,
                                                   JDCConnection oConn,
                                                   java.lang.String sTableName,
                                                   java.lang.String sOwnerId,
                                                   java.lang.String sSectionId,
                                                   java.lang.String sLanguage,
                                                   int iOrderBy)
                                            throws java.rmi.RemoteException,
                                                   java.sql.SQLException

Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.

This method first checks the DistributedCachePeer for a matching ResultSet, then goes to database if ResultSet is not cached. Result is placed at cache as a DBSubset object with key sTableName.sSectionId[sOwnerId].

Parameters:
oCache - Local cache peer
oConn - Database connection
sTableName - Lookup table name
sOwnerId - WorkArea for filtering results
sSectionId - Name of section (field) to retrieve
sLanguage - 2 chracters language code for ComboBox texts (see k_lu_languages table)
iOrderBy - Column for ordering results: 0=Internal Lookup Value, 1=Displayed Label, 2=Lookup Ordinal
Returns:
...
Throws:
java.sql.SQLException
java.rmi.RemoteException
See Also:
DistributedCachePeer

getHTMLSelectLookUp

public static java.lang.String getHTMLSelectLookUp(DistributedCachePeer oCache,
                                                   JDCConnection oConn,
                                                   java.lang.String sTableName,
                                                   java.lang.String sOwnerId,
                                                   java.lang.String sSectionId,
                                                   java.lang.String sLanguage)
                                            throws java.rmi.RemoteException,
                                                   java.sql.SQLException

Get an HTML ComboBox options with translated labels for a standard hipergate lookup table.

This method first checks the DistributedCachePeer for a matching ResultSet, then goes to database if ResultSet is not cached. Result is placed at cache as a DBSubset object with key sTableName.sSectionId[sOwnerId].

Parameters:
oCache - Local cache peer
oConn - Database connection
sTableName - Lookup table name
sOwnerId - WorkArea for filtering results
sSectionId - Name of section (field) to retrieve
sLanguage - 2 chracters language code for ComboBox texts (see k_lu_languages table)
Returns:
...
Throws:
java.sql.SQLException
java.rmi.RemoteException
See Also:
DistributedCachePeer

getLookUpTranslation

public static java.lang.String getLookUpTranslation(java.sql.Connection oConn,
                                                    java.lang.String sTableName,
                                                    java.lang.String sOwnerId,
                                                    java.lang.String sSectionId,
                                                    java.lang.String sLanguage,
                                                    java.lang.String sLookupId)
                                             throws java.sql.SQLException

Get a translated label for a lookup value.

Parameters:
oConn - Database Connection
sTableName - Lookup table name
sOwnerId - WorkArea GUID
sSectionId - Section name (field)
sLanguage - Language code for retrieved label
sLookupId - Lookup value to find
Returns:
Translated label of lookup value or null if label for such language was not found
Throws:
java.sql.SQLException

getLookUpMap

public static java.util.HashMap getLookUpMap(java.sql.Connection oConn,
                                             java.lang.String sTableName,
                                             java.lang.String sOwnerId,
                                             java.lang.String sSectionId,
                                             java.lang.String sLanguage)
                                      throws java.sql.SQLException

Get a Map of lookup values and their corresponding translated labels for a language.

This method is to be used when a listing routine has to lookup several values at a base table for their translated lookup labels. Instead of joining the base table and the lookup table, a memory map may be fetched first and then the painting routine translates each value into its labels without any database access.

Parameters:
oConn - Database connection
sTableName - Lookup table name
sOwnerId - WorkArea GUID
sSectionId - Section name (field)
sLanguage - Language code for retrieved labels
Returns:
A Map associating looukp values (as keys) with values for translated labels into the given language.
Throws:
java.sql.SQLException

getLanguageLookUpMap

public static java.util.HashMap getLanguageLookUpMap(java.sql.Connection oConn,
                                                     java.lang.String sLanguage)
                                              throws java.sql.SQLException

Get a Map of language lookup talbe values and their corresponding translated labels for a language.

This method is to be used when a listing routine has to lookup several values at language lookup table for their translated lookup labels. Instead of joining the base table and the language lookup table, a memory map may be fetched first and then the painting routine translates each value into its labels without any database access.

Parameters:
oConn - Database connection
sLanguage - Language code for retrieved labels
Returns:
A Map associating looukp values (as keys) with values for translated labels into the given language.
Throws:
java.sql.SQLException

nextLookuUpProgressive

public static int nextLookuUpProgressive(java.sql.Connection oConn,
                                         java.lang.String sLookupTableName,
                                         java.lang.String sGuOwner,
                                         java.lang.String sIdSection)
                                  throws java.sql.SQLException
Find value of next unused lookup index for a given table section

Parameters:
oConn - Connection Opened JDBC database connection
sLookupTableName - String Look up table name (ex. k_companies_lookup)
sGuOwner - String GUID of WorkArea to which the new lookup value will belong
sIdSection - String Name of section (usually corresponding column name at base table)
Returns:
int Next unused lookup index (pg_lookup column at sLookupTableName)
Throws:
java.sql.SQLException
Since:
3.0

addLookup

public static boolean addLookup(java.sql.Connection oConn,
                                java.lang.String sLookupTableName,
                                java.lang.String sGuOwner,
                                java.lang.String sIdSection,
                                java.lang.String sVlLookUp,
                                java.util.HashMap<java.lang.String,java.lang.String> oTranslatMap)
                         throws java.sql.SQLException

Add a lookup value for a given section

This methods checks whether the lookup value exists and, if not, then inserts it.
If lookup value already exists then it is not updated.

Parameters:
oConn - JDCConnection
sLookupTableName - String Name of Lookup Table
sGuOwner - String GUID of Owner WorkArea
sIdSection - String Lookup Section name
sVlLookUp - String Lookup Internal Value
oTranslatMap - HashMap with one entry for each language. Language codes must be those from id_language column of k_lu_languages table.
Returns:
boolean true if value was added, false if it already existed
Throws:
java.sql.SQLException
Since:
3.0

storeLookup

public static void storeLookup(java.sql.Connection oConn,
                               java.lang.String sLookupTableName,
                               java.lang.String sGuOwner,
                               java.lang.String sIdSection,
                               java.lang.String sVlLookUp,
                               java.util.HashMap oTranslations)
                        throws java.sql.SQLException

Add or update a lookup value for a given section

This methods checks whether the lookup value exists and, if not, then inserts it.
If lookup value already exists then it is updated.

Parameters:
oConn - JDCConnection
sLookupTableName - String Name of Lookup Table
sGuOwner - String GUID of Owner WorkArea
sIdSection - String Lookup Section name
sVlLookUp - String Lookup Internal Value
oTranslations - HashMap with one entry for each language. Language codes must be those from id_language column of k_lu_languages table.
Throws:
java.sql.SQLException
Since:
3.0

deleteLookup

public static void deleteLookup(java.sql.Connection oConn,
                                java.lang.String sLookupTableName,
                                java.lang.String sBaseTable,
                                java.lang.String sGuOwner,
                                java.lang.String sIdSection,
                                java.lang.String sVlLookUp)
                         throws java.sql.SQLException
Delete lookup value

Parameters:
oConn - Connection
sLookupTableName - String Name of Lookup Table
sBaseTable - String Base table which column named like sIdSection will be set to null
sGuOwner - String GUID of Owner WorkArea
sIdSection - String Lookup Section name
sVlLookUp - String Lookup Internal Value
Throws:
java.sql.SQLException
Since:
3.0

deleteLookup

public static void deleteLookup(java.sql.Connection oConn,
                                java.lang.String sLookupTableName,
                                java.lang.String sBaseTable,
                                java.lang.String sGuOwner,
                                java.lang.String sIdSection,
                                int iPgLookUp)
                         throws java.sql.SQLException
Delete lookup value

Parameters:
oConn - Connection
sLookupTableName - String Name of Lookup Table
sBaseTable - String Base table which column named like sIdSection will be set to null
sGuOwner - String GUID of Owner WorkArea
sIdSection - String Lookup Section name
iPgLookUp - int Lookup Ordinal Value
Throws:
java.sql.SQLException
Since:
3.0