public class Category extends DBPersist
Modifier and Type | Field and Description |
---|---|
static int |
BROWSE_BOTTOMUP |
static int |
BROWSE_DOWN |
static int |
BROWSE_TOPDOWN |
static int |
BROWSE_UP |
static short |
ClassId |
Constructor and Description |
---|
Category()
Create empty Category
|
Category(JDCConnection oConn,
java.lang.String sIdCategory)
Load Category from database
|
Category(java.lang.String sIdCategory)
Create Category and set gu_category.
|
Modifier and Type | Method and Description |
---|---|
int |
addObject(java.sql.Connection oConn,
java.lang.String sIdObject,
int iIdClass,
int iAttribs,
int iOdPosition)
Add object to Category.
|
java.util.LinkedList<Category> |
browse(JDCConnection oConn,
int iDirection,
int iOrder)
Get a list of all parents or childs of a Category.
|
void |
checkIn(JDCConnection oConn,
java.lang.String sUserId)
Check-in all documents from this Category and all its subcategories
|
void |
checkOut(JDCConnection oConn,
java.lang.String sUserId)
Check-out all documents from this Category and all its subcategories
|
static java.lang.String |
create(JDCConnection oConn,
java.lang.Object[] Values)
Create new Category with translated labels.
|
boolean |
delete(JDCConnection oConn)
Delete Category and all its childs.
|
static boolean |
delete(JDCConnection oConn,
java.lang.String sCategoryGUID)
Delete Category and all its childs.
|
void |
expand(java.sql.Connection oConn)
Expand all Category childs.
|
DBSubset |
getACLGroups(JDCConnection oConn)
Get Groups with permissions over this Category.
|
DBSubset |
getACLUsers(JDCConnection oConn)
Get Users with direct permissions over this Category.
|
DBSubset |
getChilds(JDCConnection oConn)
Get first level childs as a DBSubset.
|
int |
getDomainId(JDCConnection oConn)
Get integer indentifier of the domain to which this category belongs
|
int |
getGroupPermissions(java.sql.Connection oConn,
java.lang.String sIdGroup)
Get permissions mas of a group over this category
If there is no explicit permissions mask set at k_x_cat_group_acl for given
group and this category, then the category hierarchy is scanned upwards and
the permissions of the closest parent are assumed to be the ones of this category.
|
static java.lang.String |
getIdFromName(JDCConnection oConn,
java.lang.String sCategoryNm)
Get Category GUID given its internal name.
|
boolean |
getIsRoot(java.sql.Connection oConn) |
java.lang.String |
getLabel(java.sql.Connection oConn,
java.lang.String sLanguage)
Get translated label for a category.
|
DBSubset |
getNames(JDCConnection oConn)
Get Category translated labels as a DBSubset.
|
DBSubset |
getObjects(JDCConnection oConn)
Get objects contained at Category.
|
DBSubset |
getObjectsOfClass(JDCConnection oConn,
short iClassId)
Get objects contained at Category.
|
DBSubset |
getParents(JDCConnection oConn)
Get inmediate parents as a DBSubset.
|
java.lang.String |
getPath(java.sql.Connection oConn)
Compose a path to Category by concatenating all parents names.
|
Product[] |
getProducts(JDCConnection oConn,
java.lang.String sOrderBy)
Get Products contained at this Category
|
int |
getUserPermissions(java.sql.Connection oConn,
java.lang.String sIdUser)
Get User permissions for Category
Calls k_sp_cat_usr_perm stored procedure.
|
void |
inheritPermissions(JDCConnection oConn,
java.lang.String sFromCategory,
short iRecurse,
short iObjects)
Inherits permissions from another Category.
|
boolean |
isChildOf(java.sql.Connection oConn,
java.lang.String sParentCategory)
Get whether or not this category descends at any level from another one.
|
boolean |
isParentOf(java.sql.Connection oConn,
java.lang.String sChildCategory)
Get whether or not this category is parent at any level of another one.
|
int |
level(JDCConnection oConn)
Get category depth level.
|
static java.lang.String |
makeName(JDCConnection oConn,
java.lang.String sCategoryNm)
Make an internal category name from an arbitrary string.
|
void |
removeGroupPermissions(java.sql.Connection oConn,
java.lang.String sIdGroups,
short iRecurse,
short iObjects)
Set group permissions.
|
int |
removeObject(java.sql.Connection oConn,
java.lang.String sIdObject)
Remove object from Category
Removing an object from a Category does not delete it.
|
int |
removeObject(java.sql.Connection oConn,
java.lang.String sIdObject,
int iClassId)
Remove object from Category
Removing an object from a Category does not delete it.
|
void |
removeUserPermissions(java.sql.Connection oConn,
java.lang.String sIdUsers,
short iRecurse,
short iObjects)
Remove permissions for user at a Category.
|
void |
resetParent(java.sql.Connection oConn,
java.lang.String sIdParent)
Remove Category from parent.
|
void |
setGroupPermissions(java.sql.Connection oConn,
java.lang.String sIdGroups,
int iACLMask,
short iRecurse,
short iObjects)
Set group permissions for Category
Calls k_sp_cat_set_grp stored procedure.
|
void |
setIsRoot(java.sql.Connection oConn,
boolean bIsRoot)
Make or unmake a root category.
|
void |
setLabel(java.sql.Connection oConn,
java.lang.String sTr)
Set category label for all supported languages
|
void |
setParent(java.sql.Connection oConn,
java.lang.String sIdParent)
Set New Parent for this category.
|
void |
setUserPermissions(java.sql.Connection oConn,
java.lang.String sIdUsers,
int iACLMask,
short iRecurse,
short iObjects)
Set user permissions for a Category.
|
boolean |
store(JDCConnection oConn)
Store Category.
|
static java.lang.String |
store(JDCConnection oConn,
java.lang.String sCategoryId,
java.lang.String sParentId,
java.lang.String sCategoryName,
short iIsActive,
int iDocStatus,
java.lang.String sOwner,
java.lang.String sIcon1,
java.lang.String sIcon2)
Create or Store Category.
|
void |
storeLabels(JDCConnection oConn,
java.lang.String sNamesTable,
java.lang.String sRowDelim,
java.lang.String sColDelim)
Store a set of labels for this category
This method takes a string of the form "en;Root|es;Raíz|fr;Racine|it;Radice|ru;Корень"
and store one label for each {language,literal} pair
|
java.lang.String |
toXMLWithLabels(JDCConnection oConn)
Get an XML dump for the Category values plus nodes for translated labels
|
java.lang.String |
toXMLWithLabels(JDCConnection oConn,
java.lang.String sIdent)
Get an XML dump for the Category values plus nodes for translated labels
|
java.lang.String |
toXMLWithLabels(JDCConnection oConn,
java.lang.String sIdent,
java.lang.String sDelim)
Get an XML dump for the Category values plus nodes for translated labels
|
void |
uploadDirectory(JDCConnection oConn,
java.lang.String sSourcePath,
java.lang.String sProtocol,
java.lang.String sServer,
java.lang.String sTargetPath,
java.lang.String sLanguage)
Copy a directory and index all its files as products inside this Category
|
allcaps, allcaps, clear, clone, columns, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getIntArray, getInteger, getIntegerArray, getIntervalPart, getItemMap, getItems, getMoney, getPrimaryKey, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTime, getTimeOfDay, getTimestamp, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, setPrimaryKey, size, toLowerCase, toUpperCase, toXML, toXML, toXML, values
public static final int BROWSE_UP
public static final int BROWSE_DOWN
public static final int BROWSE_TOPDOWN
public static final int BROWSE_BOTTOMUP
public static final short ClassId
public Category()
public Category(java.lang.String sIdCategory) throws java.sql.SQLException
sIdCategory
- Category GUIDjava.sql.SQLException
public Category(JDCConnection oConn, java.lang.String sIdCategory) throws java.sql.SQLException
oConn
- Database ConnectionsIdCategory
- Category GUIDjava.sql.SQLException
public java.util.LinkedList<Category> browse(JDCConnection oConn, int iDirection, int iOrder) throws java.sql.SQLException
Get a list of all parents or childs of a Category.
All levels up or down are scanned recursively.oConn
- Database ConnectioniDirection
- BROWSE_UP for browsing parents or BROWSE_DOWN for browsing childs.iOrder
- BROWSE_TOPDOWN first element on the list will be the top most parent,
BROWSE_BOTTOMUP first element on the list will be the deepest child.java.sql.SQLException
public java.lang.String getPath(java.sql.Connection oConn) throws java.sql.SQLException
Compose a path to Category by concatenating all parents names.
Calls k_sp_get_cat_path.oConn
- Database Connectionjava.sql.SQLException
public boolean delete(JDCConnection oConn) throws java.sql.SQLException
Delete Category and all its childs.
First delete all Products and Companies contained in Category, including physical disk files associted with Products and Company attachments.public int addObject(java.sql.Connection oConn, java.lang.String sIdObject, int iIdClass, int iAttribs, int iOdPosition) throws java.sql.SQLException
Add object to Category.
The object GUID and numeric class identifier is inserted at k_x_cat_objs table.oConn
- Database ConnectionsIdObject
- Object GUIDiIdClass
- Object Numeric Class Identifier (variable ClassId)iAttribs
- Object attributes mask (user defined)iOdPosition
- Object Position. An arbitrary position for the object inside the
category. Position is not unique for an object. Two or more objects may have the same
position.java.sql.SQLException
- If object is alredy contanied in Category then a primary key violation exception is raised.public int removeObject(java.sql.Connection oConn, java.lang.String sIdObject) throws java.sql.SQLException
Remove object from Category
Removing an object from a Category does not delete it.oConn
- Database ConnectionsIdObject
- Object GUIDjava.sql.SQLException
public int removeObject(java.sql.Connection oConn, java.lang.String sIdObject, int iClassId) throws java.sql.SQLException
Remove object from Category
Removing an object from a Category does not delete it.oConn
- Database ConnectionsIdObject
- Object GUIDiClassId
- Object Class Numeric Identifierjava.sql.SQLException
public void removeGroupPermissions(java.sql.Connection oConn, java.lang.String sIdGroups, short iRecurse, short iObjects) throws java.sql.SQLException
Set group permissions.
Calls k_sp_cat_del_grp stored procedure.oConn
- Database ConnectionsIdGroups
- String of comma separated GUIDs of ACLGroups with permissions to remove.iRecurse
- Remove permissions also from childs Categories all levels down.iObjects
- Not Used, must be zero.java.sql.SQLException
public void setGroupPermissions(java.sql.Connection oConn, java.lang.String sIdGroups, int iACLMask, short iRecurse, short iObjects) throws java.sql.SQLException
Set group permissions for Category
Calls k_sp_cat_set_grp stored procedure.oConn
- Database ConnectionsIdGroups
- String of comma separated GUIDs of ACLGroups with permissions to set.iACLMask
- Permissions mask, any combination of { ACL.PERMISSION_LIST,
ACL.PERMISSION_READ,ACL.PERMISSION_ADD,ACL.PERMISSION_DELETE,ACL.PERMISSION_MODIFY,
ACL.PERMISSION_MODERATE,ACL.PERMISSION_SEND,ACL.PERMISSION_GRANT,
ACL.PERMISSION_FULL_CONTROL }iRecurse
- Remove permissions also from childs Categories all levels down.iObjects
- Not Used, must be zero.java.sql.SQLException
ACL
public int getUserPermissions(java.sql.Connection oConn, java.lang.String sIdUser) throws java.sql.SQLException
Get User permissions for Category
Calls k_sp_cat_usr_perm stored procedure.oConn
- Database ConnectionsIdUser
- User GUIDjava.sql.SQLException
public int getGroupPermissions(java.sql.Connection oConn, java.lang.String sIdGroup) throws java.sql.SQLException
Get permissions mas of a group over this category
If there is no explicit permissions mask set at k_x_cat_group_acl for given group and this category, then the category hierarchy is scanned upwards and the permissions of the closest parent are assumed to be the ones of this category. If no parent has explicit permissions set for given group then return value is zero.oConn
- Database ConnectionsIdGroup
- ACLGroup GUIDjava.sql.SQLException
public void removeUserPermissions(java.sql.Connection oConn, java.lang.String sIdUsers, short iRecurse, short iObjects) throws java.sql.SQLException
Remove permissions for user at a Category.
Calls k_sp_cat_del_usr.oConn
- Database ConnectionsIdUsers
- String of user GUIDs separated by commas.iRecurse
- Remove permissions from child categories.iObjects
- Not used, must be zero.java.sql.SQLException
public void setUserPermissions(java.sql.Connection oConn, java.lang.String sIdUsers, int iACLMask, short iRecurse, short iObjects) throws java.sql.SQLException
Set user permissions for a Category.
Calls k_sp_cat_set_usr stored procedure.oConn
- Database ConnectionsIdUsers
- String of user GUIDs separated by commas.iACLMask
- Permissions mask. Any combination of:
{ ACL.PERMISSION_LIST, ACL.PERMISSION_READ,ACL.PERMISSION_ADD,
ACL.PERMISSION_DELETE,ACL.PERMISSION_MODIFY, ACL.PERMISSION_MODERATE,
ACL.PERMISSION_SEND,ACL.PERMISSION_GRANT,ACL.PERMISSION_FULL_CONTROL }iRecurse
- Remove permissions from child categories.iObjects
- Not used, must be zero.java.sql.SQLException
public void inheritPermissions(JDCConnection oConn, java.lang.String sFromCategory, short iRecurse, short iObjects) throws java.sql.SQLException
Inherits permissions from another Category.
All previous permissions on this Category are removed before copying permission from the other Category.oConn
- Database ConnectionsFromCategory
- GUID of category with permissions to be inherited.iRecurse
- Propagate permissions to child categories.iObjects
- Not used, must be zero.java.sql.SQLException
public boolean isChildOf(java.sql.Connection oConn, java.lang.String sParentCategory) throws java.sql.SQLException
oConn
- Database ConnectionsParentCategory
- Parent categoryjava.sql.SQLException
public boolean isParentOf(java.sql.Connection oConn, java.lang.String sChildCategory) throws java.sql.SQLException
oConn
- Database ConnectionsChildCategory
- Child Category GUIDjava.sql.SQLException
public int level(JDCConnection oConn) throws java.sql.SQLException
Get category depth level.
Calls k_sp_cat_level stored procedure.oConn
- Database Connectionjava.sql.SQLException
public boolean getIsRoot(java.sql.Connection oConn) throws java.sql.SQLException
oConn
- Database Connectionjava.sql.SQLException
public void setIsRoot(java.sql.Connection oConn, boolean bIsRoot) throws java.sql.SQLException
oConn
- Database ConnectionbIsRoot
- true if category is to be made root.java.sql.SQLException
- If This Category is present as a child of another
category at k_cat_tree table.public java.lang.String getLabel(java.sql.Connection oConn, java.lang.String sLanguage) throws java.sql.SQLException
oConn
- Database ConnectionsLanguage
- Language code from k_lu_languages table.java.sql.SQLException
public void setLabel(java.sql.Connection oConn, java.lang.String sTr) throws java.sql.SQLException
oConn
- Database connectionsTr
- Labeljava.sql.SQLException
java.lang.NullPointerException
- if label is null or empty stringpublic DBSubset getNames(JDCConnection oConn) throws java.sql.SQLException
Get Category translated labels as a DBSubset.
oConn
- Database Connectionid_language | tr_category | url_category |
2 chras. Lang. Id. | Translated Category Name | URL for Category |
java.sql.SQLException
public DBSubset getChilds(JDCConnection oConn) throws java.sql.SQLException
Get first level childs as a DBSubset.
oConn
- Database Connectionjava.sql.SQLException
public DBSubset getParents(JDCConnection oConn) throws java.sql.SQLException
Get inmediate parents as a DBSubset.
oConn
- Database Connectionjava.sql.SQLException
public DBSubset getObjects(JDCConnection oConn) throws java.sql.SQLException
oConn
- Database Connectiongu_object | id_class | bi_attribs |
java.sql.SQLException
public DBSubset getObjectsOfClass(JDCConnection oConn, short iClassId) throws java.sql.SQLException
oConn
- Database ConnectionNumeric
- identifier of class to get (ClassId member variable value)gu_object | id_class | bi_attribs |
java.sql.SQLException
public Product[] getProducts(JDCConnection oConn, java.lang.String sOrderBy) throws java.sql.SQLException
oConn
- Database ConnectionsOrderBy
- Column to sort the products { od_position, nm_product, pr_list, pr_sale, ... }
If null no sorting is performedjava.sql.SQLException
public DBSubset getACLGroups(JDCConnection oConn) throws java.sql.SQLException
oConn
- Database Connectionjava.sql.SQLException
public DBSubset getACLUsers(JDCConnection oConn) throws java.sql.SQLException
oConn
- Database Connectionjava.sql.SQLException
public int getDomainId(JDCConnection oConn) throws java.sql.SQLException, java.lang.IllegalStateException
JDCConnection
- java.sql.SQLException
java.lang.IllegalStateException
public void setParent(java.sql.Connection oConn, java.lang.String sIdParent) throws java.sql.SQLException
Set New Parent for this category.
The old parent (if any) is not changed nor removed.oConn
- Database ConnectionsIdParent
- GUID of parent Categoryjava.sql.SQLException
public void resetParent(java.sql.Connection oConn, java.lang.String sIdParent) throws java.sql.SQLException
Remove Category from parent.
Removing a Category from a parent does not delete it.oConn
- Database ConnectionsIdParent
- Parent Category GUIDjava.sql.SQLException
public boolean store(JDCConnection oConn) throws java.sql.SQLException
Store Category.
If gu_category is null a new GUID is automatically assigned.public void expand(java.sql.Connection oConn) throws java.sql.SQLException
Expand all Category childs.
Calls k_sp_cat_expand stored procedure.oConn
- Database Connectionjava.sql.SQLException
public void storeLabels(JDCConnection oConn, java.lang.String sNamesTable, java.lang.String sRowDelim, java.lang.String sColDelim) throws java.sql.SQLException, java.util.NoSuchElementException
Store a set of labels for this category
This method takes a string of the form "en;Root|es;Raíz|fr;Racine|it;Radice|ru;Корень" and store one label for each {language,literal} pairoConn
- JDCConnectionsNamesTable
- String Language names and translated namessRowDelim
- String Delimiter for {language,literal} pairs,
in the example above it would be "|"sColDelim
- String Delimiter between language and literal,
in the example above it would be ";"java.sql.SQLException
java.util.NoSuchElementException
public void uploadDirectory(JDCConnection oConn, java.lang.String sSourcePath, java.lang.String sProtocol, java.lang.String sServer, java.lang.String sTargetPath, java.lang.String sLanguage) throws java.lang.Exception, java.io.IOException, java.sql.SQLException
Copy a directory and index all its files as products inside this Category
oConn
- JDCConnection Any pending transaction on given connection will be commited.
This methods calls Connection.commit() on oConn object,
so AutoCommit status for connection must be set to true before calling uploadDirectory()sSourcePath
- String "file:///tmp/upload/myfiles"sProtocol
- String "file://"sServer
- String Server name (for FTP transfers)sTargetPath
- String "file:///opt/hipergate/storege/domains/2050/..."sLanguage
- Stringjava.lang.Exception
java.io.IOException
java.sql.SQLException
public java.lang.String toXMLWithLabels(JDCConnection oConn, java.lang.String sIdent, java.lang.String sDelim) throws java.sql.SQLException, java.lang.IllegalStateException
Get an XML dump for the Category values plus nodes for translated labels
sIdent
- Number of blank spaces for left padding at every line.sDelim
- Line delimiter (usually "\n" or "\r\n")java.sql.SQLException
java.lang.IllegalStateException
public java.lang.String toXMLWithLabels(JDCConnection oConn, java.lang.String sIdent) throws java.sql.SQLException, java.lang.IllegalStateException
Get an XML dump for the Category values plus nodes for translated labels
sIdent
- Number of blank spaces for left padding at every line.java.sql.SQLException
java.lang.IllegalStateException
public java.lang.String toXMLWithLabels(JDCConnection oConn) throws java.sql.SQLException, java.lang.IllegalStateException
Get an XML dump for the Category values plus nodes for translated labels
sIdent
- Number of blank spaces for left padding at every line.java.sql.SQLException
java.lang.IllegalStateException
public void checkOut(JDCConnection oConn, java.lang.String sUserId) throws java.lang.SecurityException, java.sql.SQLException, java.lang.IllegalStateException, java.lang.NullPointerException
JDCConnection
- sUserId
- GUID of user requesting check-outjava.lang.SecurityException
- if user does not have modify permission over any category containing this productjava.lang.IllegalStateException
- if product is already checked out by another userjava.lang.NullPointerException
- is sUserId is nulljava.sql.SQLException
public void checkIn(JDCConnection oConn, java.lang.String sUserId) throws java.sql.SQLException, java.lang.IllegalStateException, java.lang.NullPointerException
JDCConnection
- sUserId
- GUID of user requesting check-outjava.lang.IllegalStateException
- if product is already checked out by another userjava.lang.NullPointerException
- is sUserId is nulljava.sql.SQLException
public static java.lang.String store(JDCConnection oConn, java.lang.String sCategoryId, java.lang.String sParentId, java.lang.String sCategoryName, short iIsActive, int iDocStatus, java.lang.String sOwner, java.lang.String sIcon1, java.lang.String sIcon2) throws java.sql.SQLException
Create or Store Category.
oConn
- Database ConnectionsCategoryId
- GUID of Category to store or null if it is a new Category.sParentId
- GUID of Parent Category or null if it is a root category.sCategoryName
- Internal Category Name. It is recommended that makeName()
method is applied always on sCategoryName. Because category names are often used for composing
physical disk paths, assigning characters such as '*', '/', '?' etc. to category names may
lead to errors when creating directories for contained Products. As a general rule use ONLY
upper case letters and numbers for category names.iIsActive
- 1 if category is to be marked active, 0 if it is to be marked as unactive.iDocStatus
- Initial Document Status, { 0=Pending, 1=Active, 2=Locked } See k_lu_status table.sOwner
- GUID of User owner of this Category.sIcon1
- Icon for closed folder.sIcon2
- Icon for opened folder.java.sql.SQLException
public static boolean delete(JDCConnection oConn, java.lang.String sCategoryGUID) throws java.sql.SQLException, java.io.IOException
Delete Category and all its childs.
First delete all Products and Companies contained in Category, including physical disk files associted with Products and Company attachments.oConn
- Database ConnectionsCategoryGUID
- GUID of Category to delete.java.sql.SQLException
java.io.IOException
public static java.lang.String create(JDCConnection oConn, java.lang.Object[] Values) throws java.sql.SQLException
oConn
- Database ConnectionValues
- An array with the following elements:java.sql.SQLException
public static java.lang.String getIdFromName(JDCConnection oConn, java.lang.String sCategoryNm) throws java.sql.SQLException
Get Category GUID given its internal name.
Category name is column nm_category at table k_categories.oConn
- Database ConnectionsCategoryNm
- Category Internal Namejava.sql.SQLException
public static java.lang.String makeName(JDCConnection oConn, java.lang.String sCategoryNm) throws java.sql.SQLException
Make an internal category name from an arbitrary string.
Because nm_category is a primary key for table k_categories and because category names are used for composing physical disk paths, some special rules must be followed when assigning category names.oConn
- Database ConnectionsCategoryNm
- String to be used as a guide for making category name.java.sql.SQLException