com.knowgate.hipergate
Class Categories

java.lang.Object
  extended bycom.knowgate.hipergate.Categories

public class Categories
extends java.lang.Object

Singleton manager for Categories Tree

Version:
2.1

Field Summary
static int ORDER_BY_ID
           
static int ORDER_BY_LOCALE_NAME
           
static int ORDER_BY_NEUTRAL_NAME
           
static int ORDER_BY_NONE
           
 
Constructor Summary
Categories()
           
 
Method Summary
 void clearCache()
          Clear root categories cache.
static void expand(JDCConnection oConn, java.lang.String sRootCategoryId)
          Expand Category Childs into k_cat_expand table
 Category forDomain(JDCConnection oConn, int iDomain)
          Get root category for a given Domain
 DBSubset getChildsNamed(JDCConnection oConn, java.lang.String idParent, java.lang.String sLanguage, int iOrderBy)
          Get first level childs for a given category.
 DBSubset getRoots(JDCConnection oConn)
          Get root categories as a DBSubset.
 int getRootsCount()
          Get root categories count.
 DBSubset getRootsNamed(JDCConnection oConn, java.lang.String sLanguage, int iOrderBy)
          Get Root Caetgories and their names as a DBSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDER_BY_NONE

public static final int ORDER_BY_NONE
See Also:
Constant Field Values

ORDER_BY_ID

public static final int ORDER_BY_ID
See Also:
Constant Field Values

ORDER_BY_NEUTRAL_NAME

public static final int ORDER_BY_NEUTRAL_NAME
See Also:
Constant Field Values

ORDER_BY_LOCALE_NAME

public static final int ORDER_BY_LOCALE_NAME
See Also:
Constant Field Values
Constructor Detail

Categories

public Categories()
Method Detail

clearCache

public void clearCache()
Clear root categories cache. Root category names are loaded once and then cached into a static variable. Use this method for forcing reload of categories from database on next call to getRoots() or getRootsNamed().


expand

public static void expand(JDCConnection oConn,
                          java.lang.String sRootCategoryId)
                   throws java.sql.SQLException

Expand Category Childs into k_cat_expand table

Parameters:
oConn - Database Connection
sRootCategoryId - GUID of Category to expand.
Throws:
java.sql.SQLException

forDomain

public Category forDomain(JDCConnection oConn,
                          int iDomain)
                   throws java.sql.SQLException

Get root category for a given Domain

The root Category for a Domain will be the one such that nm_category=nm_domain

Parameters:
oConn - Database Connection
iDomain - Domain Numeric Identifier
Returns:
Category GUID or null if root Category for Domain was not found.
Throws:
java.sql.SQLException

getRoots

public DBSubset getRoots(JDCConnection oConn)
                  throws java.sql.SQLException

Get root categories as a DBSubset.

Root categories are those present at k_cat_root table.
It is recommended to use this criteria instead of seeking those categories not present as childs at k_cat_tree. Selecting from k_cat_root is much faster than scanning the k_cat_tree table.

Parameters:
oConn - Database Connection
Returns:
A single column DBSubset containing th GUID of root categories.
Throws:
java.sql.SQLException

getRootsCount

public int getRootsCount()
                  throws java.lang.IllegalStateException
Get root categories count.

Throws:
java.lang.IllegalStateException - If getRoots() or getRootsNamed() have not been called prior to getRootsCount()

getRootsNamed

public DBSubset getRootsNamed(JDCConnection oConn,
                              java.lang.String sLanguage,
                              int iOrderBy)
                       throws java.sql.SQLException

Get Root Caetgories and their names as a DBSubset

Categories not having any translation at k_cat_labels will not be retrieved.
Root Category Names are loaded once and then cached internally as a static object.
Use clearCahce() method for refreshing root categories from database.

Parameters:
oConn - Database Connection
sLanguage - Language for category label retrieval.
iOrderBy - Column for order by { ORDER_BY_NONE, ORDER_BY_NEUTRAL_NAME, ORDER_BY_LOCALE_NAME }
Returns:
A DBSubset with the following columns:
gu_categorynm_categorytr_categorynm_iconnm_icon2
Category GUIDCategory Internal NameCategory Translated LabelIcon for Closed FolderIcon for Opened Folder
Throws:
java.sql.SQLException

getChildsNamed

public DBSubset getChildsNamed(JDCConnection oConn,
                               java.lang.String idParent,
                               java.lang.String sLanguage,
                               int iOrderBy)
                        throws java.sql.SQLException

Get first level childs for a given category.

Categories not having any translation at k_cat_labels will not be retrieved.

Parameters:
oConn - Database Connection
idParent - Parent Category
sLanguage - Language for label retrieval
iOrderBy - Column for order by { ORDER_BY_NONE, ORDER_BY_NEUTRAL_NAME, ORDER_BY_LOCALE_NAME }
Returns:
A DBSubset with the following columns:
gu_categorynm_categorytr_categorynm_iconnm_icon2
Category GUIDCategory Internal NameCategory Translated LabelIcon for Closed FolderIcon for Opened Folder
Throws:
java.sql.SQLException