It would be nice if the code could be enhanced so that the new ASSET_USAGE_OUT_IN type and the old ASSET_USAGE are children of a common type, e.g.:
ASSET
|___________> ASSET_USAGE
|
|___________> ASSET_USAGE_OUT_IN
and then, when specific behavior is required, the EntityTypeUtil.hasParentType(...) is used.
For example, instead of:
if ("ASSET_USAGE".equals(_product.getString("productTypeId"))) {
this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records
} else if ("ASSET_USAGE_OUT_IN".equals(_product.getString("productTypeId"))) {
this.itemType = "RENTAL_ORDER_ITEM";
} ...
the code could be:
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", _product.getString("productTypeId"), "parentTypeId", "ASSET_USAGE")) {
this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records
} else if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", _product.getString("productTypeId"), "parentTypeId", "ASSET_USAGE_OUT_IN")) {
this.itemType = "RENTAL_ORDER_ITEM";
} ...
and instead of code like:
if ("ASSET_USAGE".equals(_product.getString("productTypeId")) || "ASSET_USAGE_OUT_IN".equals(_product.getString("productTypeId"))) {
// will create additional workeffort/asset usage records...
} ...
the code could be like:
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", _product.getString("productTypeId"), "parentTypeId", "ASSET")) {
// will create additional workeffort/asset usage records...
} ...
The existing code already works in this way for marketing packages.
The main advantage is that it is easier to "extend" the system by adding a new product type that automatically inherits the behaviour of the parent type (it will be just a matter to add a new children type) and then add specific behavior only where needed.
Jacopo
On Sep 9, 2011, at 8:40 AM,
[hidden email] wrote:
> Author: hansbak
> Date: Fri Sep 9 06:40:28 2011
> New Revision: 1167015
>
> URL:
http://svn.apache.org/viewvc?rev=1167015&view=rev> Log:
> New product type: Fixed Asset Usage For Rental of an asset which is shipped from and returned to inventory. Including Junit test and demo data. More explanation will follow in a blog on the 'what is new page'