public class CatalogCategoryController extends JDBCObjectController<CatalogCategory>
CatalogCategory
class. Provides methods for
retrieving and persisting category relationship table records in the database.Modifier and Type | Field and Description |
---|---|
private static java.util.Hashtable<java.lang.String,java.util.ArrayList<CatalogCategory>> |
cvChildren
A hash table for caching all child catalog entries for each parent.
|
private static java.util.Hashtable<java.lang.String,java.util.ArrayList<CatalogCategory>> |
cvParents
A hash table for caching all parent catalog entries for each child.
|
private static long |
serialVersionUID
The class' serialization version id.
|
ivDBObjCls, ivFieldCount, ivFieldKeyAlt, ivFieldKeyPri, ivFieldResPfx, ivSyncLast, ivSyncType, ivTableName
ivHashCode, ivHashFlds, ivObjAttrs
Constructor and Description |
---|
CatalogCategoryController()
The constructor for the controller.
|
Modifier and Type | Method and Description |
---|---|
int |
add(CatalogCategory obj,
boolean logdup)
Adds a new record to the table associated with the controller.
|
boolean |
delete(CatalogCategory obj)
Deletes an existing record from the table associated with the controller.
|
boolean |
deleteAll()
Deletes all records in the table associated with the controller.
|
boolean |
deleteChild(java.lang.String child)
Deletes all catalog category records for a given child category code.
|
boolean |
deleteParent(java.lang.String parent)
Deletes all catalog category records for a given parent category code.
|
CatalogCategory |
get(java.lang.String parent,
java.lang.String child)
Returns the catalog category record for the given parent and child
category codes.
|
java.util.ArrayList<CatalogCategory> |
getChildren(java.lang.String parent)
Returns a collection of child catalog category records for a given parent
category code.
|
private java.util.ArrayList<CatalogCategory> |
getChildrenForCache(java.lang.String parent)
Returns a collection of child catalog category records for a given parent
category code.
|
java.util.ArrayList<CatalogCategory> |
getParents(java.lang.String child)
Returns a collection of parent catalog category records for a given child
category code.
|
private java.util.ArrayList<CatalogCategory> |
getParentsForCache(java.lang.String child)
Returns a collection of parent catalog category records for a given child
category code.
|
java.util.ArrayList<CatalogCategory> |
getPathToChild(java.lang.String parent,
java.lang.String child)
Returns a collection of
CatalogCategory objects for the path to
the given child category (exclusive), starting with the given parent
category. |
private boolean |
getPathToParent(java.lang.String parent,
java.lang.String child,
java.lang.String path,
java.util.Hashtable<java.lang.String,CatalogCategory> paths)
Internal method used for determining the path to a category.
|
private void |
loadCache()
Loads the child and parent caches with catalog entries.
|
boolean |
update(CatalogCategory obj)
Updates an existing record in the table associated with the controller.
|
add, add, arrayToMap, arrayToMap, countAll, delete, dispose, equals, getAll, getConnection, getConnectionInfo, getController, getFieldNames, getFieldNamesForKey, getFieldNamesForUpdate, getFieldNulls, getFieldNullsForKey, getFieldNullsForUpdate, getFieldsForOrderBy, getFieldsForWhere, getFieldSize, getFieldTypes, getFieldTypesForKey, getFieldTypesForUpdate, getStatementForDelete, getStatementForGet, getStatementForGetAll, getStatementForInsert, getStatementForUpdate, getStatementKey, getStatementString, getTableName, hasFieldNamesForKey, hasFieldNamesForUpdate, isDuplicate, resultSetToArray, resultSetToMap, resultSetToMap, resultSetToObject, setConnectionInfo, setPSDeleteValues, setPSExistsValues, setPSInsertValues, setPSUpdateValues, setPSValue, update, valuesToObject
cloneMapAttributes, formatValue, formatValue, getHashFields, getMapArrayList, getMapAttributes, getMapBigDecimal, getMapBoolean, getMapDate, getMapDouble, getMapInteger, getMapLong, getMapMapped, getMapObject, getMapShort, getMapString, getMapString, getMapStringBuffer, getMapStringBuilder, getMapTime, getMapTimestamp, getMapVector, hashCode, setHashFields, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMapAttributes, setMapObject, setMapTime, setMapTimestamp, toStringArray
private static final long serialVersionUID
private static final java.util.Hashtable<java.lang.String,java.util.ArrayList<CatalogCategory>> cvChildren
CatalogCategory
objects.private static final java.util.Hashtable<java.lang.String,java.util.ArrayList<CatalogCategory>> cvParents
CatalogCategory
objects.public CatalogCategoryController()
public int add(CatalogCategory obj, boolean logdup)
add
in JDBCObjectController
.add
in class JDBCObjectController<CatalogCategory>
obj
- (JDBCObject) The object for the record to be added.logdup
- (boolean) true
if duplicate errors are to be
logged as an exception, otherwise false
if not. When
duplicates are logged, the return value of 1 is never returned.public boolean delete(CatalogCategory obj)
delete
in JDBCObjectController
.delete
in class JDBCObjectController<CatalogCategory>
obj
- (JDBCObject) The object for the record to be deleted.true
if the record deleted successfully,
otherwise false
.public boolean deleteAll()
deleteAll
in JDBCObjectController
.deleteAll
in class JDBCObjectController<CatalogCategory>
true
if the deletes are successful,
otherwise false
.public boolean update(CatalogCategory obj)
update
in JDBCObjectController
.update
in class JDBCObjectController<CatalogCategory>
obj
- (JDBCObject) The object for the record to be updated.true
if the record updated successfully,
otherwise false
.public boolean deleteChild(java.lang.String child)
child
- (String) The child category code to delete.true
if the deletes are successful,
otherwise false
.public boolean deleteParent(java.lang.String parent)
parent
- (String) The parent category code to delete.true
if the deletes are successful,
otherwise false
.public CatalogCategory get(java.lang.String parent, java.lang.String child)
parent
- (String) The parent category code for the desired record.child
- (String) The child category code for the desired record.public java.util.ArrayList<CatalogCategory> getChildren(java.lang.String parent)
parent
- (String) The parent category code for the desired child
records.private java.util.ArrayList<CatalogCategory> getChildrenForCache(java.lang.String parent)
parent
- (String) The parent category code for the desired child
records.public java.util.ArrayList<CatalogCategory> getParents(java.lang.String child)
child
- (String) The child category code for the desired parent
records.private java.util.ArrayList<CatalogCategory> getParentsForCache(java.lang.String child)
child
- (String) The child category code for the desired parent
records.public java.util.ArrayList<CatalogCategory> getPathToChild(java.lang.String parent, java.lang.String child)
CatalogCategory
objects for the path to
the given child category (exclusive), starting with the given parent
category. If the child category is not found in the path, the collection
returned will be empty. Note that the returned results do NOT include
the child.parent
- (String) The code for parent category from which the path
is to be built.child
- (String) The code for child category to which the path is
to be built.CatalogCategory
objects for the path
from the specified parent to the specified child. The collection
elements are in order beginning with the parent and ending with
the child. An empty collection is returned if the child is not
found in the path.private boolean getPathToParent(java.lang.String parent, java.lang.String child, java.lang.String path, java.util.Hashtable<java.lang.String,CatalogCategory> paths)
The method actually reads the parent-child relationships in reverse order, in that it begins its search at the child level and works its way up through each successive level of parents.
The method stops searching when it finds the first occurrence of parent or when it has no more parents (and parents of parents, etc.) to investigate.
When the method completes its processing, two values are available to the original caller. First, a boolean is returned to indicate whether the path that was originally requested is valid. Second, the hashtable of paths will contain all the paths accumulated up to the point when the search was terminated.
parent
- (String) The code for the parent category to which the
path is to be built.child
- (String) The code for the child category from which the
path is to be built.path
- (String) A string representation of the path that has been
built prior to this invocation. The string contents are in the
form of code/code/code/code where (from left to right) the first
code is the lowest level of the path (child) and the last code
is the highest level of the path (parent).paths
- (Hashtable) An accumulation of path information, added to
by each recursive call to this method. The keys for the hashtable
are string representations of path information (see path
parameter above). The hashtable values are the corresponding
CatalogCategory
objects for the rightmost category codes
in the key.true
if the requested path was found,
otherwise false
.private void loadCache()