Author: hansbak
Date: Wed Oct 21 03:03:33 2009
New Revision: 827878
URL: http://svn.apache.org/viewvc?rev=827878&view=rev
Log:
Let setup component also create the data for the ecommerce store: suggestion of
Chris snow
Modified:
ofbiz/trunk/applications/commonext/script/org/ofbiz/setup/SetupEvents.xml
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/actions/GetProdCatalog.groovy
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/controller.xml
ofbiz/trunk/applications/commonext/widget/ofbizsetup/SetupForms.xml
Modified:
ofbiz/trunk/applications/commonext/script/org/ofbiz/setup/SetupEvents.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/script/org/ofbiz/setup/SetupEvents.xml?rev=827878&r1=827877&r2=827878&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/script/org/ofbiz/setup/SetupEvents.xml
(original)
+++ ofbiz/trunk/applications/commonext/script/org/ofbiz/setup/SetupEvents.xml
Wed Oct 21 03:03:33 2009
@@ -478,20 +478,64 @@
</simple-method>
<simple-method method-name="createProductCategoryAndAddToProdCatalog"
short-description="addProductCategoryToProdCatalog">
- <set-service-fields service-name="createProductCategory"
map="parameters" to-map="createProductCategoryCtx"/>
- <call-service service-name="createProductCategory"
in-map-name="createProductCategoryCtx">
- <result-to-field result-name="productCategoryId"
field="addToProdCatalogCtx.productCategoryId"/>
- <result-to-request result-name="productCategoryId"
request-name="productCategoryId"/>
+ <!-- Create Parent ProductCategory -->
+ <set field="createPrimaryProductCategoryCtx.productCategoryId"
value="${parameters.prodCatalogId}_ROOT"/>
+ <set field="createPrimaryProductCategoryCtx.categoryName"
value="${parameters.prodCatalogId} Browse Root Category"/>
+ <set field="createPrimaryProductCategoryCtx.productCategoryTypeId"
value="CATALOG_CATEGORY"/>
+ <call-service service-name="createProductCategory"
in-map-name="createPrimaryProductCategoryCtx">
+ <result-to-field result-name="productCategoryId"
field="parameters.primaryParentCategoryId"/>
</call-service>
-
+
+ <set field="addToProdCatalogCtx.productCategoryId"
from-field="parameters.primaryParentCategoryId"/>
<set field="addToProdCatalogCtx.prodCatalogId"
from-field="parameters.prodCatalogId"/>
<set field="addToProdCatalogCtx.prodCatalogCategoryTypeId"
value="PCCT_BROWSE_ROOT"/>
+ <set field="addToProdCatalogCtx.sequenceNum" value="1" type="Long"/>
<call-service service-name="addProductCategoryToProdCatalog"
in-map-name="addToProdCatalogCtx"/>
+
+ <!-- Create Promotion ProductCategory -->
+ <call-object-method obj-field="parameters.prodCatalogId"
method-name="toUpperCase" ret-field="catalogUpperCase"/>
+ <set field="createPromotionCategoryCtx.productCategoryId"
value="${catalogUpperCase}_PROMOTIONS"/>
+ <set field="createPromotionCategoryCtx.categoryName"
value="${catalogUpperCase} Promotions"/>
+ <set field="createPromotionCategoryCtx.productCategoryTypeId"
value="CATALOG_CATEGORY"/>
+ <set field="createPromotionCategoryCtx.detailScreen"
value="component://ecommerce/widget/CatalogScreens.xml#categorydetailmatrix"/>
+
+ <call-service service-name="createProductCategory"
in-map-name="createPromotionCategoryCtx">
+ <result-to-field result-name="productCategoryId"
field="promotionCategoryId"/>
+ </call-service>
+ <set field="addPromoCatToProdCatalogCtx.productCategoryId"
from-field="promotionCategoryId"/>
+ <set field="addPromoCatToProdCatalogCtx.prodCatalogId"
from-field="parameters.prodCatalogId"/>
+ <set field="addPromoCatToProdCatalogCtx.prodCatalogCategoryTypeId"
value="PCCT_PROMOTIONS"/>
+ <set field="addPromoCatToProdCatalogCtx.sequenceNum" value="2"
type="Long"/>
+ <call-service service-name="addProductCategoryToProdCatalog"
in-map-name="addPromoCatToProdCatalogCtx"/>
+
+ <!-- Create ProductCategory & ProductCategoryRollup -->
+ <set-service-fields service-name="createProductCategory"
map="parameters" to-map="createProductCategoryCtx"/>
+ <call-service service-name="createProductCategory"
in-map-name="createProductCategoryCtx">
+ <result-to-field result-name="productCategoryId"
field="productCategoryId"/>
+ <result-to-request result-name="productCategoryId"
request-name="productCategoryId"/>
+ </call-service>
+
+ <make-value value-field="newEntity"
entity-name="ProductCategoryRollup"/>
+ <set field="newEntity.parentProductCategoryId"
from-field="parameters.primaryParentCategoryId"/>
+ <set field="newEntity.productCategoryId"
from-field="productCategoryId"/>
+ <set field="newEntity.sequenceNum" value="1" type="Long"/>
+ <if-empty field="newEntity.fromDate">
+ <now-timestamp field="nowTimestamp"/>
+ <set from-field="nowTimestamp" field="newEntity.fromDate"/>
+ </if-empty>
+ <create-value value-field="newEntity"/>
</simple-method>
- <simple-method method-name="updateProductInCategory"
short-description="Update a Product in a Category along with special
information such as prices">
- <set value="updateProductInCategory" field="callingMethodName"/>
- <set field="checkAction" value="UPDATE"/>
+ <simple-method method-name="createUpdateProductInCategory"
short-description="Create/Update a Product in a Category along with special
information such as features">
+ <set value="createUpdateProductInCategory" field="callingMethodName"/>
+ <if-compare field="parameters.productId" operator="equals"
value="${parameters.productCategoryId}">
+ <set field="parameters.productId"
value="${parameters.productId}-001"/>
+ </if-compare>
+ <entity-one entity-name="Product" value-field="product"/>
+ <if-empty field="product">
+ <set field="checkAction" value="CREATE"/>
+ <else><set field="checkAction" value="UPDATE"/></else>
+ </if-empty>
<call-simple-method method-name="checkCategoryRelatedPermission"
xml-resource="component://product/script/org/ofbiz/product/category/CategoryServices.xml"/>
<check-errors/>
@@ -500,12 +544,57 @@
<set field="parameters.currencyUomId" value="USD"/>
</if-empty>
- <!-- create Product -->
- <set-service-fields service-name="updateProduct" map="parameters"
to-map="callUpdateProductMap"/>
- <call-service service-name="updateProduct"
in-map-name="callUpdateProductMap"/>
+ <if-empty field="product">
+ <!-- create Product -->
+ <set-service-fields service-name="createProduct" map="parameters"
to-map="callCreateProductMap"/>
+ <if-empty field="callCreateProductMap.productTypeId">
+ <set field="callCreateProductMap.productTypeId"
value="FINISHED_GOOD"/>
+ </if-empty>
+ <call-service service-name="createProduct"
in-map-name="callCreateProductMap">
+ <result-to-field result-name="productId"/>
+ </call-service>
+
+ <!-- create ProductCategoryMember -->
+ <set field="callCreateProductCategoryMemberMap.productId"
from-field="productId"/>
+ <set field="callCreateProductCategoryMemberMap.productCategoryId"
from-field="parameters.productCategoryId"/>
+ <call-service service-name="addProductToCategory"
in-map-name="callCreateProductCategoryMemberMap"/>
+
+ <set field="callCreateProductCategoryMemberMap.productId"
from-field="productId"/>
+ <set field="callCreateProductCategoryMemberMap.productCategoryId"
from-field="parameters.promoCat"/>
+ <call-service service-name="addProductToCategory"
in-map-name="callCreateProductCategoryMemberMap"/>
+
+ <!-- create ProductFeatureAppl(s) -->
+ <set field="hasSelectableFeatures" value="N"/>
+ <iterate-map map="parameters.productFeatureIdByType"
key="productFeatureTypeId" value="productFeatureId">
+ <log level="info" message="Applying feature
[${productFeatureId}] of type [${productFeatureTypeId}] to product
[${productId}]"/>
+ <set field="createPfaMap.productId" from-field="productId"/>
+ <set field="createPfaMap.productFeatureId"
from-field="productFeatureId"/>
+ <if-compare
field="parameters.productFeatureSelectableByType[productFeatureTypeId]"
operator="equals" value="Y">
+ <set field="createPfaMap.productFeatureApplTypeId"
value="SELECTABLE_FEATURE"/>
+ <set field="hasSelectableFeatures" value="Y"/>
+ <else>
+ <set field="createPfaMap.productFeatureApplTypeId"
value="STANDARD_FEATURE"/>
+ </else>
+ </if-compare>
+ <call-service service-name="applyFeatureToProduct"
in-map-name="createPfaMap"/>
+ <clear-field field="createPfaMap"/>
+ </iterate-map>
+
+ <!-- set isVirtual based on hasSelectableFeatures -->
+ <if-compare field="hasSelectableFeatures" operator="equals"
value="Y">
+ <entity-one entity-name="Product" value-field="newProduct"/>
+ <set field="newProduct.isVirtual" value="Y"/>
+ <store-value value-field="newProduct"/>
+ </if-compare>
+ <else>
+ <!-- update Product -->
+ <set-service-fields service-name="updateProduct"
map="parameters" to-map="callUpdateProductMap"/>
+ <call-service service-name="updateProduct"
in-map-name="callUpdateProductMap"/>
+ <set field="productId" from-field="parameters.productId"/>
+ </else>
+ </if-empty>
+ <field-to-result field="productId"/>
- <set field="productId" from-field="parameters.productId"/>
-
<!-- create/update defaultPrice and averageCost ProductPrice -->
<if-not-empty field="parameters.defaultPrice">
<entity-condition entity-name="ProductPrice"
list="defaultPriceValues" filter-by-date="true">
@@ -567,7 +656,7 @@
<set field="updateAverageCostMap.price"
from-field="parameters.averageCost" type="BigDecimal"/>
<call-service service-name="updateProductPrice"
in-map-name="updateAverageCostMap"/>
</else>
- </if-empty>
+ </if-empty>
</if-not-empty>
</simple-method>
@@ -642,4 +731,10 @@
}
]]></call-bsh>
</simple-method>
+
+ <simple-method method-name="createDefaultWebSite"
short-description="Create a WebSite, default webSiteId is WebStore.">
+ <set field="parameters.webSiteId" value="WebStore"/>
+ <call-service service-name="createWebSite" in-map-name="parameters"/>
+ </simple-method>
+
</simple-methods>
\ No newline at end of file
Modified:
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/actions/GetProdCatalog.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/actions/GetProdCatalog.groovy?rev=827878&r1=827877&r2=827878&view=diff
==============================================================================
---
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/actions/GetProdCatalog.groovy
(original)
+++
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/actions/GetProdCatalog.groovy
Wed Oct 21 03:03:33 2009
@@ -19,6 +19,7 @@
import org.ofbiz.base.util.*
import org.ofbiz.entity.util.EntityUtil;
import javolution.util.FastList;
+ import org.ofbiz.product.catalog.*;
prodCatalog = null;
prodCatalogId = parameters.prodCatalogId;
@@ -68,13 +69,13 @@
errMsgList.add("Product Catalog not set!");
showErrorMsg = "Y";
}
-
- prodCatalogCategory =
EntityUtil.getFirst(delegator.findByAnd("ProdCatalogCategory", [prodCatalogId:
prodCatalogId]));
+ prodCatalogCategory =
EntityUtil.getFirst(delegator.findByAnd("ProdCatalogCategory", [prodCatalogId:
prodCatalogId, sequenceNum: new Long(1)]));
if(prodCatalogCategory){
- productCategory =
prodCatalogCategory.getRelatedOne("ProductCategory");
- productCategoryId = productCategory.productCategoryId;
-
+ productCategory =
EntityUtil.getFirst(delegator.findByAnd("ProductCategory",
[primaryParentCategoryId : prodCatalogCategory.productCategoryId]));
+ if(productCategory){
+ productCategoryId = productCategory.productCategoryId;
+ }
}
context.productCategoryId = productCategoryId;
context.productCategory = productCategory;
@@ -109,8 +110,11 @@
}
}
}
+ // get promotion category
+ promoCat = CatalogWorker.getCatalogPromotionsCategoryId(request,
prodCatalogId);
context.productId = productId;
context.product = product;
+ context.promoCat = promoCat;
}
if (errMsgList) {
Modified:
ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/controller.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/controller.xml?rev=827878&r1=827877&r2=827878&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/controller.xml
(original)
+++ ofbiz/trunk/applications/commonext/webapp/ofbizsetup/WEB-INF/controller.xml
Wed Oct 21 03:03:33 2009
@@ -126,7 +126,7 @@
<request-map uri="EditWebSite"><security https="true"
auth="true"/><response name="success" type="view"
value="EditWebSite"/></request-map>
<request-map uri="createWebSite">
<security https="true" auth="true"/>
- <event type="service" path="" invoke="createWebSite"/>
+ <event type="simple"
path="component://commonext/script/org/ofbiz/setup/SetupEvents.xml"
invoke="createDefaultWebSite"/>
<response name="success" type="view" value="EditWebSite"/>
<response name="error" type="view" value="EditWebSite"/>
</request-map>
@@ -175,15 +175,9 @@
<security https="true" auth="true"/>
<response name="success" type="view" value="EditProduct"/>
</request-map>
- <request-map uri="createProduct">
+ <request-map uri="createUpdateProduct">
<security https="true" auth="true"/>
- <event type="service" path="" invoke="createProductInCategory"/>
- <response name="success" type="view" value="EditProduct"/>
- <response name="error" type="view" value="EditProduct"/>
- </request-map>
- <request-map uri="updateProduct">
- <security https="true" auth="true"/>
- <event type="simple"
path="component://commonext/script/org/ofbiz/setup/SetupEvents.xml"
invoke="updateProductInCategory"/>
+ <event type="simple"
path="component://commonext/script/org/ofbiz/setup/SetupEvents.xml"
invoke="createUpdateProductInCategory"/>
<response name="success" type="view" value="EditProduct"/>
<response name="error" type="view" value="EditProduct"/>
</request-map>
Modified: ofbiz/trunk/applications/commonext/widget/ofbizsetup/SetupForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/widget/ofbizsetup/SetupForms.xml?rev=827878&r1=827877&r2=827878&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/widget/ofbizsetup/SetupForms.xml
(original)
+++ ofbiz/trunk/applications/commonext/widget/ofbizsetup/SetupForms.xml Wed Oct
21 03:03:33 2009
@@ -126,7 +126,7 @@
<field name="payToPartyId"><hidden value="${partyId}"/></field>
<field name="partyId"><hidden value="${partyId}"/></field>
<field name="inventoryFacilityId"><hidden
value="${parameters.facilityId}"/></field>
- <field name="visualThemeId"><hidden value="FLAT_GREY"/></field>
+ <field name="visualThemeId"><hidden value="EC_DEFAULT"/></field>
<field name="manualAuthIsCapture"><hidden value="N"/></field>
<field name="prorateShipping"><hidden value="Y"/></field>
<field name="prorateTaxes"><hidden value="Y"/></field>
@@ -196,8 +196,9 @@
<form name="EditWebSite" extends="EditWebSite"
extends-resource="component://content/webapp/content/website/WebSiteForms.xml">
<actions><set field="webSiteId"
from-field="webSite.webSiteId"/></actions>
- <field use-when="webSite==null&&webSiteId==null"
name="webSiteId" tooltip="${uiLabelMap.CommonRequired}"
widget-style="required"><text default-value="${partyId}"/></field>
+ <field use-when="webSite==null&&webSiteId==null"
name="webSiteId" tooltip="${uiLabelMap.CommonRequired}"
widget-style="required"><text default-value="WebStore"/></field>
<field name="siteName" tooltip="${uiLabelMap.CommonRequired}"
widget-style="required"><text size="30" maxlength="60"/></field>
+ <field name="visualThemeSetId"><hidden value="ECOMMERCE"/></field>
<field name="partyId"><hidden value="${partyId}"/></field>
<field name="httpHost"><hidden/></field>
<field name="httpPort"><hidden/></field>
@@ -240,9 +241,8 @@
<field name="submitButton" title="${uiLabelMap.CommonUpdate}"
widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
- <form name="EditProduct" type="single" target="updateProduct" title=""
default-map-name="product"
+ <form name="EditProduct" type="single" target="createUpdateProduct"
title="" default-map-name="product"
header-row-style="header-row" default-table-style="basic-table">
- <alt-target use-when="product==null" target="createProduct"/>
<field use-when="product==null" name="isCreate"><hidden
value="true"/></field>
<field position="1" use-when="product!=null" name="productId"
title="${uiLabelMap.ProductProductId}"
tooltip="${uiLabelMap.ProductNotModificationRecreatingProduct}"><display/></field>
@@ -251,6 +251,7 @@
<field name="partyId"><hidden value="${partyId}"/></field>
<field name="productCategoryId"><hidden
value="${productCategoryId}"/></field>
+ <field name="promoCat"><hidden value="${promoCat}"/></field>
<field name="productTypeId"><hidden value="FINISHED_GOOD"/></field>
<field name="internalName" title="${uiLabelMap.ProductInternalName}"
tooltip="${uiLabelMap.CommonRequired}" widget-style="required"><text size="30"
maxlength="60"/></field>
<field name="productName" title="${uiLabelMap.ProductProductName}"
><text size="30" maxlength="60"/></field>