public class CategoryController extends JDBCObjectController<Category>
Category
class. Provides methods for
retrieving and persisting category table records in the database.Modifier and Type | Field and Description |
---|---|
private static java.util.Hashtable<java.lang.String,Category> |
cvCache
A hash table for caching all categories.
|
private static long |
serialVersionUID
The class' serialization version id.
|
ivDBObjCls, ivFieldCount, ivFieldKeyAlt, ivFieldKeyPri, ivFieldResPfx, ivSyncLast, ivSyncType, ivTableName
ivHashCode, ivHashFlds, ivObjAttrs
Constructor and Description |
---|
CategoryController()
The constructor for the controller.
|
Modifier and Type | Method and Description |
---|---|
int |
add(Category obj,
boolean logdup)
Adds a new record to the table associated with the controller.
|
boolean |
delete(Category obj)
Deletes an existing record from the table associated with the controller.
|
boolean |
deleteAll()
Deletes all records in the table associated with the controller.
|
Category |
get(java.lang.String code)
Returns the category record for the given category code.
|
java.util.ArrayList<Category> |
get1stChildren(java.lang.String code)
Returns a collection of category records for the first level children of
a given category code.
|
java.util.ArrayList<Category> |
get1stParents(java.lang.String code)
Returns a collection of category records for the first level parents of
a given category code.
|
java.util.ArrayList<Category> |
getAll()
Returns a collection of all records in the table associated with the
controller.
|
java.util.ArrayList<Category> |
getAllChildren(java.lang.String code,
boolean unique)
Returns a collection of category records for all levels of children of
a given category code.
|
private CatalogCategoryController |
getCatalogController()
Returns a catalog category controller.
|
java.util.ArrayList<Category> |
getPathFromParent(Category parent,
Category child)
Returns a collection of category records for the path to a child category,
starting with the given parent category and ending with the given child
category.
|
java.util.ArrayList<Category> |
getPathToParent(Category parent,
Category child)
Returns a collection of category records for the path from a given child
category, ending with the given parent category.
|
java.util.ArrayList<Category> |
getTopMost()
Returns a collection of category records that are specified as being the
top most category for at least one active user.
|
Select |
getUISelect(java.lang.String code,
boolean showcode)
Returns an HTML
Select object that contains all categories and has
the given code as the preselected code in the set of options. |
boolean |
hasCategory(java.lang.String code)
Answers if a given category code exists in the category table.
|
boolean |
hasLeadtime(java.lang.String code)
Answers if a given lead time code exists in the category table.
|
boolean |
isDescendant(Category parent,
Category checkee)
Answers if a category is a descendant (child, grandchild, etc.) of the
given parent category.
|
private void |
loadCache()
Loads the cache of categories with all categories.
|
boolean |
update(Category obj)
Updates an existing record in the table associated with the controller.
|
Category |
valuesToObject(java.util.HashMap<java.lang.String,java.lang.Object> attrs)
Returns a database object from the given set of attributes.
|
add, add, arrayToMap, arrayToMap, countAll, delete, dispose, equals, 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
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,Category> cvCache
Category
object as its value.public CategoryController()
public int add(Category obj, boolean logdup)
add
in JDBCObjectController
.add
in class JDBCObjectController<Category>
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(Category obj)
delete
in JDBCObjectController
.delete
in class JDBCObjectController<Category>
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<Category>
true
if the deletes are successful,
otherwise false
.public java.util.ArrayList<Category> getAll()
getAll
in class JDBCObjectController<Category>
public boolean update(Category obj)
update
in JDBCObjectController
.update
in class JDBCObjectController<Category>
obj
- (JDBCObject) The object for the record to be updated.true
if the record updated successfully,
otherwise false
.public Category valuesToObject(java.util.HashMap<java.lang.String,java.lang.Object> attrs)
valuesToObject
in JDBCObjectController
.
This method assumes the attributes were obtained from the zcategory database view.
valuesToObject
in class JDBCObjectController<Category>
attrs
- (HashMap) The attributes to assign to the new object.public Category get(java.lang.String code)
code
- (String) The category code for the desired record.private CatalogCategoryController getCatalogController()
getController(CatalogCategoryController.class)
.public java.util.ArrayList<Category> get1stChildren(java.lang.String code)
Asks the CatalogCategoryController
for the category's child
catalog entries and converts the entries to Category
objects.
code
- (String) The category code for the desired children.CatalogCategoryController
sql statement for getChildren()
.public java.util.ArrayList<Category> getAllChildren(java.lang.String code, boolean unique)
Asks each level of children to return a collection of its children and accumulates a collection of all children from all levels.
code
- (String) The category code for the desired children.unique
- (boolean) true
if the returned collection should
not contain any duplicate category objects. false
if
the returned collection should contain all child category objects
found, even if a child category occurs more than once in this
category's tree.public java.util.ArrayList<Category> get1stParents(java.lang.String code)
Asks the CatalogCategoryController
for the category's parent
catalog entries and converts the entries to Category
objects.
code
- (String) The category code for the desired parents.CatalogCategoryController
sql statement for getParents()
.public java.util.ArrayList<Category> getPathFromParent(Category parent, Category child)
Asks the CatalogCategoryController
for the parent catalog
entries that lead to this category and then converts the entries to
Category
objects.
Returns a top-to-bottom (parent-to-child) list of categories. The
results of this method are the same as getPathToParent()
except
the order of the categories in the returned collection are reversed.
parent
- (Category) The parent category from which the path is
to be built.child
- (Category) The child category to which the path is to
be built.public java.util.ArrayList<Category> getPathToParent(Category parent, Category child)
Asks the CatalogCategoryController
for the parent catalog
entries that lead to the child category and then converts the entries to
Category
objects.
Returns a bottom-to-top (child-to-parent) list of categories. The
results of this method are the same as getPathFromParent()
except
the order of the categories in the returned collection are reversed.
parent
- (Category) The parent category to which the path is to
be built.child
- (Category) The child category from which the path is to
be built.Category
objects for the path from the
specified child category to the specified parent. The collection
elements are in order beginning with the child category and
ending with the parent. An empty collection is returned if the
child category is not found in the parent's path.public java.util.ArrayList<Category> getTopMost()
Category
objects which are defined as a
topmost category for one or more active users.public Select getUISelect(java.lang.String code, boolean showcode)
Select
object that contains all categories and has
the given code as the preselected code in the set of options. Invokers must
assign a form field name to the returned object via the setName
method before adding the object to the velocity template data.code
- (String) The category code to preselect in the select's set
of options. Pass an empty string for this parameter if a blank
option is to be created as the first option and then preselected.
Pass a null
for this parameter if no blank option and no
preselecting is desired.showcode
- (boolean) true
to show each category code as
part of the description, otherwise false
. If code is to
be shown, the Select should be displayed with a fixed-width font
so the codes and descriptions are aligned and easier to read.Select
object.public boolean hasCategory(java.lang.String code)
code
- (String) The category code to check.true
if the category code exists, otherwise
false
.public boolean hasLeadtime(java.lang.String code)
code
- (String) The lead time code to check.true
if the lead time code exists, otherwise
false
.public boolean isDescendant(Category parent, Category checkee)
Asks the CatalogCategoryController
for the parent catalog
entries that lead to the category. If any entries are returned then the
category is deemed to be a descendant of the given parent.
parent
- (Category) The parent category to which ancestory is
to be determined.checkee
- (Category) The category to check.true
if the category to check is a child,
grandchild, great-grandchild, etc. of the specified parent,
otherwise false
.private void loadCache()