public class ProductController extends JDBCObjectController<Product>
Product
class. Provides methods for
retrieving and persisting product table records in the database.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
LT_INCLUDE
An array of leadtime codes to include as defined in properties by
"Product.Catalog.Leadtime.Include".
|
private static long |
serialVersionUID
The class' serialization version id.
|
ivDBObjCls, ivFieldCount, ivFieldKeyAlt, ivFieldKeyPri, ivFieldResPfx, ivSyncLast, ivSyncType, ivTableName
ivHashCode, ivHashFlds, ivObjAttrs
Constructor and Description |
---|
ProductController()
The constructor for the controller.
|
Modifier and Type | Method and Description |
---|---|
boolean |
delete(Product product,
boolean dltImages,
boolean dltDescs)
Deletes a given product from the database, plus deletes any associated
product info (catalog entries, cross references, images, descriptions).
|
Product |
get(FlashServletContext ctx,
java.lang.String code,
java.lang.String uom)
Returns the product record for the given product code and unit of
measure code.
|
Product |
get(java.lang.String code,
java.lang.String uom)
Returns the product record for the given product code and unit of
measure code.
|
java.lang.Object[] |
getAllAsRS()
Returns a result set of all product records.
|
Product |
getAutoComplete(FlashServletContext ctx,
java.lang.String code,
java.lang.String uom)
Returns the product record for the given code and unit of measure code.
|
java.util.ArrayList<java.lang.String> |
getAutoCompleteCodes(FlashServletContext ctx,
java.lang.String chars)
Returns a collection of codes that begin with the given characters.
|
protected void |
getAutoCompleteCodes(UserCatalogVerifier verifier,
Product product,
java.util.TreeMap<java.lang.String,java.lang.String> codes,
int codetype)
A companion helper method for the public
getAutoCompleteCodes
method. |
java.util.ArrayList<java.lang.String[]> |
getAutoCompleteUoms(FlashServletContext ctx,
java.lang.String code)
Returns a collection of unit of measure codes and descriptions for the
given code.
|
protected void |
getAutoCompleteUoms(UserCatalogVerifier verifier,
Product product,
java.util.ArrayList<java.lang.String[]> uoms)
A companion helper method for the public
getAutoCompleteUoms
method. |
java.util.ArrayList<Product> |
getCategory(FlashServletContext ctx,
java.lang.String code)
Returns a collection of the product records for the given category code.
|
java.util.ArrayList<Product> |
getCategory(java.lang.String code)
Returns a collection of the product records for the given category code.
|
java.util.ArrayList<Product> |
getForCode(FlashServletContext ctx,
java.lang.String code)
Returns a collection of products that have the same product code.
|
java.util.ArrayList<Product> |
getInStock(FlashServletContext ctx,
java.util.ArrayList<Product> products)
Returns a collection of product records that have stock using the given
collection of product records as the source for determining the results.
|
java.util.ArrayList<Product> |
getInStock(FlashServletContext ctx,
java.util.ArrayList<Product> products,
boolean realtime)
Returns a collection of product records that have stock using the given
collection of product records as the source for determining the results.
|
java.util.ArrayList<Product> |
getMatching(FlashServletContext ctx,
java.lang.String strCriteria,
java.util.ArrayList<java.lang.String[]> attrCriteria)
Returns a collection of
Product objects that have
product codes or product descriptions containing characters matching
the query search string. |
java.util.ArrayList<Product> |
getMatching(java.lang.String field,
java.lang.String operand,
java.lang.String argument)
Returns a collection of product records that have a field that contains
characters matching the given criteria.
|
java.util.ArrayList<Product> |
getMatchingByStringCriteria(FlashServletContext ctx,
java.lang.String strCriteria)
Returns a collection of
Product objects that have
product codes or product descriptions containing characters matching
the query search string. |
boolean |
hasCategory(java.lang.String code)
Answers if a given category code exists in the product table.
|
boolean |
hasLeadtime(java.lang.String code)
Answers if a given lead time code exists in the product table.
|
boolean |
hasManufacturer(java.lang.String code)
Answers if a given manufacturer code exists in the product table.
|
boolean |
hasProduct(java.lang.String code)
Answers if a given product (code only) exists in the product table.
|
boolean |
hasProduct(java.lang.String code,
java.lang.String uom)
Answers if a given product (code & uom) exists in the product table.
|
boolean |
hasUom(java.lang.String code)
Answers if a given unit of measure exists in the product table.
|
void |
includeLeadtimes(FlashServletContext ctx,
java.util.ArrayList<Product> products)
Iterates through the given collection of products and retains the products
having a leadtime that is in the condigured set of leadtimes to include
(LT_INCLUDE).
|
void |
setRealtimeInfo(FlashServletContext ctx,
java.lang.Object requestor,
java.util.ArrayList<Product> products,
int indxBeg,
int indxEnd,
boolean force)
Sets the realtime information (current price, availability, etc.) for
each product within a given set of products.
|
void |
setRealtimeInfo(FlashServletContext ctx,
java.lang.Object requestor,
Product product,
boolean force)
Sets the realtime information (current price, availability, etc.) for
each product within a given set of products.
|
Product |
valuesToObject(java.util.HashMap<java.lang.String,java.lang.Object> attrs)
Returns a database object from the given set of attributes.
|
add, add, add, arrayToMap, arrayToMap, countAll, delete, delete, deleteAll, 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, 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
protected static final java.lang.String[] LT_INCLUDE
public Product valuesToObject(java.util.HashMap<java.lang.String,java.lang.Object> attrs)
valuesToObject
in JDBCObjectController
.
This method assumes the attributes were obtained from the zproduct database view.
valuesToObject
in class JDBCObjectController<Product>
attrs
- (HashMap) The attributes to assign to the new object.public boolean delete(Product product, boolean dltImages, boolean dltDescs)
product
- (Product) The product to be deleted.dltImages
- (boolean) Should product image files be removed?dltDescs
- (boolean) Should product description files be removed?true
if the product deleted successfully,
otherwise false
.public Product get(java.lang.String code, java.lang.String uom)
This implementation of get
is intended for times when a
shopping user is not known, such as when performing admin functions.
code
- (String) The product code for the desired record.uom
- (String) The unit of measure code for the desired record.public Product get(FlashServletContext ctx, java.lang.String code, java.lang.String uom)
ctx
- (FlashServletContext) The current servlet context.
Pass a null
if Xref information is not needed.code
- (String) The product code for the desired record.uom
- (String) The unit of measure code for the desired record.public java.util.ArrayList<Product> getForCode(FlashServletContext ctx, java.lang.String code)
ctx
- (FlashServletContext) The current servlet context.
Pass a null
if Xref information is not needed.code
- (String) The product code for the desired records.public java.lang.Object[] getAllAsRS()
The invoker of this method is responsible for closing the returned result set and prepared statement.
public Product getAutoComplete(FlashServletContext ctx, java.lang.String code, java.lang.String uom)
ctx
- (FlashServletContext) The current servlet context.
Pass a null
if the shopping user should not be a factor
in retrieving the product.code
- (String) The code for the desired record.uom
- (String) The unit of measure code for the desired record.public java.util.ArrayList<java.lang.String> getAutoCompleteCodes(FlashServletContext ctx, java.lang.String chars)
null
and there is a current shopping user, then only the codes associated with
products that are in the shopping user's catalog are returned; otherwise,
all matching codes are returned.ctx
- (FlashServletContext) The current servlet context.
Pass a null
if the shopping user should not be a factor
in determining matching codes.chars
- (String) The characters on which to search.protected void getAutoCompleteCodes(UserCatalogVerifier verifier, Product product, java.util.TreeMap<java.lang.String,java.lang.String> codes, int codetype)
getAutoCompleteCodes
method. Determines if a product is eligible for auto complete processing
and, if so, adds the appropriate code (product code, customer part number,
manufacturer part number) to the given collection of codes.verifier
- (UserCatalogVerifier) The current shopping user's
user catalog verifier or null
if there is no shopping
user.product
- (Product) The current product being processed.codes
- (TreeMap) The collection of codes being accumulated
during the auto complete code search processing.codetype
- (int) The type of code to add to the collection of
accumulated codes where 1=product code, 2=customer part number
and 3=manufacturer part number.public java.util.ArrayList<java.lang.String[]> getAutoCompleteUoms(FlashServletContext ctx, java.lang.String code)
null
and there is a current shopping user, then only the units of measure
associated with products that are in the shopping user's catalog are
returned; otherwise, all units of measure for the code are returned.ctx
- (FlashServletContext) The current servlet context.
Pass a null
if the shopping user should not be a factor
in determining the units of measure.code
- (String) The code for the desired units of measure.protected void getAutoCompleteUoms(UserCatalogVerifier verifier, Product product, java.util.ArrayList<java.lang.String[]> uoms)
getAutoCompleteUoms
method. Determines if a product is eligible for auto complete processing
and, if so, adds the product's unit of measure code and description to the
given collection of units of measure.verifier
- (UserCatalogVerifier) The current shopping user's
user catalog verifier or null
if there is no shopping
user.product
- (Product) The current product being processed.uoms
- (ArrayList) The collection of units of measure being
accumulated during the auto complete uom search processing.public java.util.ArrayList<Product> getCategory(java.lang.String code)
This implementation of getCategory
is intended for times when
a shopping user is not known, such as when performing admin functions.
code
- (String) The category code for the desired records.public java.util.ArrayList<Product> getCategory(FlashServletContext ctx, java.lang.String code)
ctx
- (FlashServletContext) The current servlet context.
Pass a null
if Xref information is not needed.code
- (String) The category code for the desired records.public java.util.ArrayList<Product> getInStock(FlashServletContext ctx, java.util.ArrayList<Product> products)
ctx
- (FlashServletContext) The current servlet context.products
- (ArrayList) The collection of products to process.public java.util.ArrayList<Product> getInStock(FlashServletContext ctx, java.util.ArrayList<Product> products, boolean realtime)
ctx
- (FlashServletContext) The current servlet context.products
- (ArrayList) The collection of products to process.realtime
- (boolean) true
if real time pricing and
availability needs to be retrieved, otherwise false
.public java.util.ArrayList<Product> getMatching(java.lang.String field, java.lang.String operand, java.lang.String argument)
This method is for times when a user session does not apply (i.e. admin functions). Since a user or customer is not known, no customer/item cross reference, real time pricing/availability or permit processing is performed.
field
- (String) The field that is to be involved in determining
the query results. This value is appended to the end of the
sql properties key when obtaining the appropriate sql statement
for the requested query.operand
- (String) The operation that the query is to perform
on the given field in order to determine the query results.
Currently only "contains" and "equals" are supported.argument
- (String) The query search argument. The character
string that the query is to use in determining its results.public java.util.ArrayList<Product> getMatching(FlashServletContext ctx, java.lang.String strCriteria, java.util.ArrayList<java.lang.String[]> attrCriteria)
Product
objects that have
product codes or product descriptions containing characters matching
the query search string.
Invoked by the ProductSearch
servlet via the
ProductSearchInterface
class. Please note that the final
determination of whether the search results can be used (due to the user's
catalog and permits) is made by the ProductSearch
servlet.
ctx
- (FlashServletContext) The current servlet context.strCriteria
- (String) The query search criteria. The character
string that the query is to use in determining its results.attrCriteria
- (ArrayList) The collection of attribute criteria.
Each element is a String array where element 0 is the attribute
code, 1 is the and/or relationship, and 2 is the value.public java.util.ArrayList<Product> getMatchingByStringCriteria(FlashServletContext ctx, java.lang.String strCriteria)
Product
objects that have
product codes or product descriptions containing characters matching
the query search string.
Invoked by the ProductSearch
servlet via the
ProductSearchInterface
class. Please note that the final
determination of whether the search results can be used (due to the user's
catalog and permits) is made by the ProductSearch
servlet.
ctx
- (FlashServletContext) The current servlet context.strCriteria
- (String) The query search criteria. The character
string that the query is to use in determining its results.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 hasManufacturer(java.lang.String code)
code
- (String) The manufacturer code to check.true
if the manufacturer code exists,
otherwise false
.public boolean hasProduct(java.lang.String code)
code
- (String) The product code to check.true
if the product exists, otherwise
false
.public boolean hasProduct(java.lang.String code, java.lang.String uom)
code
- (String) The product code to check.uom
- (String) The unit of measure code to check.true
if the product exists, otherwise
false
.public boolean hasUom(java.lang.String code)
code
- (String) The unit of measure code to check.true
if the unit of measure exists, otherwise
false
.public void includeLeadtimes(FlashServletContext ctx, java.util.ArrayList<Product> products)
ctx
- (FlashServletContext) The current servlet context.products
- (ArrayList) The collection of products to process.public void setRealtimeInfo(FlashServletContext ctx, java.lang.Object requestor, Product product, boolean force)
ctx
- (FlashServletContext) The current servlet context.requestor
- (Object) The object making the request.product
- (Product) The product to be processed.force
- (boolean) Flag indicates if realtime info should be set
even if the realtime exclude feature says this requestor should
be excluded from setting realtime information.public void setRealtimeInfo(FlashServletContext ctx, java.lang.Object requestor, java.util.ArrayList<Product> products, int indxBeg, int indxEnd, boolean force)
ctx
- (FlashServletContext) The current servlet context.requestor
- (Object) The object making the request.products
- (ArrayList) The products to be processed.indxBeg
- (int) Index of the first product object in the
collection for which calculation needs to be performed.indxEnd
- (int) Index of the last product object in the
collection for which calculation needs to be performed.force
- (boolean) Flag indicates if realtime info should be set
even if the realtime exclude feature says this requestor should
be excluded from setting realtime information.