Posted by
jonesde on
Jul 06, 2006; 4:42am
URL: http://ofbiz.116.s1.nabble.com/svn-commit-r419428-in-incubator-ofbiz-trunk-applications-ecommerce-data-order-servicedef-product-con-tp208394.html
Author: jonesde
Date: Wed Jul 5 20:42:45 2006
New Revision: 419428
URL:
http://svn.apache.org/viewvc?rev=419428&view=revLog:
Added subscription processing services, which are now enabled by default with an ECA; includes a demo product for a Gizmo Newsletter; also some cleanups of and improvements to the subscription admin UI
Added:
incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/
incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (with props)
Modified:
incubator/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml
incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties
incubator/ofbiz/trunk/applications/product/servicedef/services_subscription.xml
incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionForms.xml
incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionMenus.xml
incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionScreens.xml
Modified: incubator/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml (original)
+++ incubator/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml Wed Jul 5 20:42:45 2006
@@ -194,6 +194,13 @@
<ProductPrice productId="WG-9943" productPricePurposeId="PURCHASE" productPriceTypeId="DEFAULT_PRICE" currencyUomId="USD" productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="549.99" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
<ProductPrice productId="WG-9943" productPricePurposeId="PURCHASE" productPriceTypeId="LIST_PRICE" currencyUomId="USD" productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="550.0" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
<ProductPrice productId="WG-9943" productPricePurposeId="PURCHASE" productPriceTypeId="COMPETITIVE_PRICE" currencyUomId="USD" productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="922.0" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
+
+ <!-- test Subscription product, a Gizmo Newsletter -->
+ <Product productId="GZ-NEWS-1MO" productTypeId="DIGITAL_GOOD" primaryProductCategoryId="101" productName="Gizmo Newsletter 1 Month" internalName="Gizmo Newsletter 1 Month Subscription" description="A 1 month subscription to the Gizmo Newsletter: can be used immediately after purchase." longDescription="This newsletter will give you regular updates on the wonderful world of Gizmos!" taxable="Y" chargeShipping="N" autoCreateKeywords="Y" isVirtual="N" isVariant="N" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
+ <SubscriptionResource subscriptionResourceId="GZ-NEWS" description="Gizmo Newsletter"/>
+ <ProductSubscriptionResource productId="GZ-NEWS-1MO" subscriptionResourceId="GZ-NEWS" fromDate="2001-05-13 12:00:00.0" useTime="1" useTimeUomId="TF_mon"/>
+ <ProductPrice productId="GZ-NEWS-1MO" productPricePurposeId="PURCHASE" productPriceTypeId="DEFAULT_PRICE" currencyUomId="USD" productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="3.99" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
+ <ProductPrice productId="GZ-NEWS-1MO" productPricePurposeId="PURCHASE" productPriceTypeId="LIST_PRICE" currencyUomId="USD" productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="5.0" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
<!-- test Digital Download product -->
<Product productId="GZ-DIG" productTypeId="DIGITAL_GOOD" primaryProductCategoryId="101" productName="Digital Gizmo" internalName="Digital Gizmo" description="A digital gizmo: can be downloaded immediately after purchase." longDescription="This gizmo is part of an exciting new breed that needs no corporeal form: it is all digital! Buy and download it now!" taxable="Y" chargeShipping="N" autoCreateKeywords="Y" isVirtual="N" isVariant="N" createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin" lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
@@ -324,6 +331,7 @@
productIdTo="WG-9943" quantity="1.0" reason="The Giant Widget is much better than the Big Gizmo, so much so that it makes the Big Gizmo obsolete."/>
<ProductCategoryMember productCategoryId="100" productId="GZ-DIG" sequenceNum="4" fromDate="2001-05-13 12:00:00.0"/>
+ <ProductCategoryMember productCategoryId="100" productId="GZ-NEWS-1MO" sequenceNum="5" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="100" productId="GZ-KIT" sequenceNum="5" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="100" productId="GZ-BASKET" sequenceNum="6" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="100" productId="GZ-1000" sequenceNum="10" fromDate="2001-05-13 12:00:00.0"/>
@@ -344,6 +352,7 @@
<ProductCategoryMember productCategoryId="101" productId="GZ-2644" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="101" productId="GZ-5005" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="101" productId="GZ-DIG" fromDate="2001-05-13 12:00:00.0"/>
+ <ProductCategoryMember productCategoryId="101" productId="GZ-NEWS-1MO" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="102" productId="GZ-1004" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="102" productId="GZ-1005" fromDate="2001-05-13 12:00:00.0"/>
<ProductCategoryMember productCategoryId="102" productId="GZ-1006" fromDate="2001-05-13 12:00:00.0"/>
Modified: incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/order/servicedef/secas.xml (original)
+++ incubator/ofbiz/trunk/applications/order/servicedef/secas.xml Wed Jul 5 20:42:45 2006
@@ -77,6 +77,7 @@
<condition field-name="orderTypeId" operator="equals" value="SALES_ORDER"/>
<condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
<action service="updateContentSubscriptionByOrder" mode="sync"/>
+ <action service="processExtendSubscriptionByOrder" mode="sync"/>
</eca>
<!-- create adjustment change -->
Modified: incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties Wed Jul 5 20:42:45 2006
@@ -567,6 +567,7 @@
ProductFindOrdersToPick=Find Orders to pick
ProductFindProduct=Find Product
ProductFindProductWithIdValue=Find Product with ID Value
+ProductFindResourceSubscriptions=Find Subscriptions for Resource
ProductFindRule=Find Rule
ProductFindShipment=Find Shipment(s)
ProductFlagPickingStarted=Flag picking started
@@ -1177,6 +1178,7 @@
ProductStyleSheet=Style Sheet
ProductSubscription=Subscription
ProductSubscriptions=Subscriptions
+ProductSubscriptionResource=Subscription Resources
ProductSubscriptionResources=Subscription Resources
ProductSubProduct=SubProduct
ProductSubTitle=Sub-Title
Modified: incubator/ofbiz/trunk/applications/product/servicedef/services_subscription.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/servicedef/services_subscription.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/product/servicedef/services_subscription.xml (original)
+++ incubator/ofbiz/trunk/applications/product/servicedef/services_subscription.xml Wed Jul 5 20:42:45 2006
@@ -82,4 +82,32 @@
<description>Delete a ProductSubscriptionResource Record</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>
+
+ <service name="processExtendSubscription" engine="java" auth="true"
+ location="org.ofbiz.product.subscription.SubscriptionServices" invoke="processExtendSubscription">
+ <description>Creates or updates Subscription record</description>
+ <attribute name="partyId" type="String" mode="IN" optional="false"/>
+ <attribute name="subscriptionResourceId" type="String" mode="IN" optional="false"/>
+ <attribute name="productId" type="String" mode="IN" optional="true"/>
+ <attribute name="orderId" type="String" mode="IN" optional="true"/>
+ <attribute name="useRoleTypeId" type="String" mode="IN" optional="true"/>
+ <attribute name="useTimeUomId" type="String" mode="IN" optional="false"/>
+ <attribute name="useTime" type="Integer" mode="IN" optional="false"/>
+ <attribute name="alwaysCreateNewRecord" type="String" mode="IN" optional="true"><!-- This defaults to Y (true) which means new Subscription records will be created instead of updating old ones with new thruDates. This keeps a more complete history of subscription activity. --></attribute>
+ <attribute name="subscriptionId" type="String" mode="OUT" optional="false"/>
+ </service>
+ <service name="processExtendSubscriptionByProduct" engine="java" auth="true"
+ location="org.ofbiz.product.subscription.SubscriptionServices" invoke="processExtendSubscriptionByProduct">
+ <description>Creates or updates Subscription record</description>
+ <attribute name="partyId" type="String" mode="IN" optional="false"/>
+ <attribute name="productId" type="String" mode="IN" optional="false"/>
+ <attribute name="orderId" type="String" mode="IN" optional="true"/>
+ <attribute name="orderCreatedDate" type="Timestamp" mode="IN" optional="true" />
+ <attribute name="quantity" type="Integer" mode="IN" optional="false"/>
+ </service>
+ <service name="processExtendSubscriptionByOrder" engine="java" auth="true"
+ location="org.ofbiz.product.subscription.SubscriptionServices" invoke="processExtendSubscriptionByOrder">
+ <description>Creates or updates Subscription record</description>
+ <attribute name="orderId" type="String" mode="IN" optional="false"/>
+ </service>
</services>
Added: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?rev=419428&view=auto==============================================================================
--- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (added)
+++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Wed Jul 5 20:42:45 2006
@@ -0,0 +1,266 @@
+/*
+ * $Id: $
+ *
+ * Copyright 2006-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.product.subscription;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
+
+/**
+ * Subscription Services
+ *
+ * @author <a href="mailto:
[hidden email]">David E. Jones</a>
+ */
+public class SubscriptionServices {
+
+ public static final String module = SubscriptionServices.class.getName();
+
+ public static Map processExtendSubscription(DispatchContext dctx, Map context) throws GenericServiceException{
+ GenericDelegator delegator = dctx.getDelegator();
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
+
+ String partyId = (String) context.get("partyId");
+ String subscriptionResourceId = (String) context.get("subscriptionResourceId");
+ String roleTypeId = (String) context.get("useRoleTypeId");
+ GenericValue userLogin = (GenericValue) context.get("userLogin");
+ Integer useTime = (Integer) context.get("useTime");
+ String useTimeUomId = (String) context.get("useTimeUomId");
+ String alwaysCreateNewRecordStr = (String) context.get("alwaysCreateNewRecord");
+ boolean alwaysCreateNewRecord = !"N".equals(alwaysCreateNewRecordStr);
+
+ GenericValue lastSubscription = null;
+ try {
+ List subscriptionList = delegator.findByAndCache("Subscription", UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId));
+ List listFiltered = EntityUtil.filterByDate(subscriptionList, true);
+ List listOrdered = EntityUtil.orderBy(listFiltered, UtilMisc.toList("-fromDate"));
+ if (listOrdered.size() > 0) {
+ lastSubscription = (GenericValue) listOrdered.get(0);
+ }
+ } catch (GenericEntityException e) {
+ return ServiceUtil.returnError(e.toString());
+ }
+
+ GenericValue newSubscription = null;
+ if (lastSubscription == null || alwaysCreateNewRecord) {
+ newSubscription = delegator.makeValue("Subscription", null);
+ newSubscription.set("subscriptionResourceId", subscriptionResourceId);
+ newSubscription.set("partyId", partyId);
+ newSubscription.set("roleTypeId", roleTypeId);
+ newSubscription.set("productId", context.get("productId"));
+ newSubscription.set("orderId", context.get("orderId"));
+ } else {
+ newSubscription = lastSubscription;
+ }
+
+ Timestamp thruDate = lastSubscription != null ? (Timestamp) lastSubscription.get("thruDate") : null;
+ if (thruDate == null) {
+ // no thruDate? start with NOW
+ thruDate = nowTimestamp;
+ newSubscription.set("fromDate", nowTimestamp);
+ } else {
+ // there is a thru date... if it is in the past, bring it up to NOW before adding on the time period
+ //don't want to penalize for skipping time, in other words if they had a subscription last year for a month and buy another month, we want that second month to start now and not last year
+ if (thruDate.before(nowTimestamp)) {
+ thruDate = nowTimestamp;
+ } else {
+ newSubscription.set("fromDate", thruDate);
+ }
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(thruDate);
+ int field = Calendar.MONTH;
+ if ("TF_day".equals(useTimeUomId)) {
+ field = Calendar.DAY_OF_YEAR;
+ } else if ("TF_wk".equals(useTimeUomId)) {
+ field = Calendar.WEEK_OF_YEAR;
+ } else if ("TF_mon".equals(useTimeUomId)) {
+ field = Calendar.MONTH;
+ } else if ("TF_yr".equals(useTimeUomId)) {
+ field = Calendar.YEAR;
+ } else {
+ Debug.logWarning("Don't know anything about useTimeUomId [" + useTimeUomId + "], defaulting to month", module);
+ }
+ calendar.add(field, useTime.intValue());
+ thruDate = new Timestamp(calendar.getTimeInMillis());
+ newSubscription.set("thruDate", thruDate);
+
+ Map result = ServiceUtil.returnSuccess();
+ try {
+ if (lastSubscription != null && !alwaysCreateNewRecord) {
+ Map updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
+ updateSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system")));
+
+ Map updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap);
+ result.put("subscriptionId", updateSubscriptionMap.get("subscriptionId"));
+ if (ServiceUtil.isError(updateSubscriptionResult)) {
+ return ServiceUtil.returnError("Error processing subscription update with ID [" + updateSubscriptionMap.get("subscriptionId") + "]", null, null, updateSubscriptionResult);
+ }
+ } else {
+ Map createPartyRoleMap = new HashMap();
+ if (UtilValidate.isNotEmpty(roleTypeId)) {
+ createPartyRoleMap.put("partyId", partyId);
+ createPartyRoleMap.put("roleTypeId", roleTypeId);
+ createPartyRoleMap.put("userLogin", userLogin);
+ Map createPartyRoleResult = dispatcher.runSync("createPartyRole", createPartyRoleMap);
+ if (ServiceUtil.isError(createPartyRoleResult)) {
+ return ServiceUtil.returnError("Error creating new PartyRole while processing subscription update with resource ID [" + subscriptionResourceId + "]", null, null, createPartyRoleResult);
+ }
+ }
+ Map createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
+ createSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system")));
+
+ Map createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap);
+ if (ServiceUtil.isError(createSubscriptionResult)) {
+ return ServiceUtil.returnError("Error creating subscription while processing with resource ID [" + subscriptionResourceId + "]", null, null, createSubscriptionResult);
+ }
+ result.put("subscriptionId", createSubscriptionResult.get("subscriptionId"));
+ }
+ } catch (GenericEntityException e) {
+ return ServiceUtil.returnError(e.toString());
+ } catch (GenericServiceException e) {
+ return ServiceUtil.returnError(e.toString());
+ }
+ return result;
+ }
+
+ public static Map processExtendSubscriptionByProduct(DispatchContext dctx, Map context) throws GenericServiceException{
+ GenericDelegator delegator = dctx.getDelegator();
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ String productId = (String) context.get("productId");
+ Integer qty = (Integer) context.get("quantity");
+ if (qty == null) {
+ qty = new Integer(1);
+ }
+
+ Timestamp orderCreatedDate = (Timestamp) context.get("orderCreatedDate");
+ if (orderCreatedDate == null) {
+ orderCreatedDate = UtilDateTime.nowTimestamp();
+ }
+ try {
+ List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
+ productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, null, null, true);
+ productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true);
+
+ if (productSubscriptionResourceList.size() == 0) {
+ String msg = "No ProductSubscriptionResource found for productId: " + productId;
+ Debug.logError(msg, module);
+ return ServiceUtil.returnError(msg);
+ }
+
+ Iterator productSubscriptionResourceIter = productSubscriptionResourceList.iterator();
+ while (productSubscriptionResourceIter.hasNext()) {
+ GenericValue productSubscriptionResource = (GenericValue) productSubscriptionResourceIter.next();
+
+ Long useTime = (Long) productSubscriptionResource.get("useTime");
+ Integer newUseTime = new Integer(useTime.intValue() * qty.intValue());
+ context.put("useTime", newUseTime);
+ context.put("useTimeUomId", productSubscriptionResource.get("useTimeUomId"));
+ context.put("useRoleTypeId", productSubscriptionResource.get("useRoleTypeId"));
+ context.put("subscriptionResourceId", productSubscriptionResource.get("subscriptionResourceId"));
+ context.put("productId", productId);
+ context.put("orderId", context.get("orderId"));
+
+ Map ctx = dctx.getModelService("processExtendSubscription").makeValid(context, ModelService.IN_PARAM);
+ Map processExtendSubscriptionResult = dispatcher.runSync("processExtendSubscription", ctx);
+ if (ServiceUtil.isError(processExtendSubscriptionResult)) {
+ return ServiceUtil.returnError("Error processing subscriptions for Product with ID [" + productId + "]", null, null, processExtendSubscriptionResult);
+ }
+ }
+ } catch(GenericEntityException e) {
+ Debug.logError(e, e.toString(), module);
+ return ServiceUtil.returnError(e.toString());
+ }
+ Map result = ServiceUtil.returnSuccess();
+ return result;
+ }
+
+ public static Map processExtendSubscriptionByOrder(DispatchContext dctx, Map context) throws GenericServiceException{
+ GenericDelegator delegator = dctx.getDelegator();
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ String orderId = (String) context.get("orderId");
+
+ Debug.logInfo("In processExtendSubscriptionByOrder service with orderId: " + orderId, module);
+
+ GenericValue orderHeader = null;
+ try {
+ List orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"));
+ if (orderRoleList.size() > 0 ) {
+ GenericValue orderRole = (GenericValue)orderRoleList.get(0);
+ String partyId = (String) orderRole.get("partyId");
+ context.put("partyId", partyId);
+ } else {
+ String msg = "No OrderRole found for orderId:" + orderId;
+ Debug.logError(msg, module);
+ return ServiceUtil.returnError(msg);
+ }
+ orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", UtilMisc.toMap("orderId", orderId));
+ if (orderHeader == null) {
+ String msg = "No OrderHeader found for orderId:" + orderId;
+ Debug.logError(msg, module);
+ return ServiceUtil.returnError(msg);
+ }
+ Timestamp orderCreatedDate = (Timestamp) orderHeader.get("orderDate");
+ context.put("orderCreatedDate", orderCreatedDate);
+ List orderItemList = orderHeader.getRelated("OrderItem");
+ Iterator orderItemIter = orderItemList.iterator();
+ while (orderItemIter.hasNext()) {
+ GenericValue orderItem = (GenericValue)orderItemIter.next();
+ Double qty = (Double) orderItem.get("quantity");
+ String productId = (String) orderItem.get("productId");
+ if (UtilValidate.isEmpty(productId)) {
+ continue;
+ }
+ List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
+ List productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true);
+ if (productSubscriptionResourceListFiltered.size() > 0) {
+ context.put("productId", productId);
+ context.put("orderId", orderId);
+ context.put("quantity", new Integer(qty.intValue()));
+ Map ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(context, ModelService.IN_PARAM);
+ Map thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx);
+ if (ServiceUtil.isError(thisResult)) {
+ return ServiceUtil.returnError("Error processing subscriptions for Order with ID [" + orderId + "]", null, null, thisResult);
+ }
+ }
+ }
+ } catch(GenericEntityException e) {
+ Debug.logError(e.toString(), module);
+ return ServiceUtil.returnError(e.toString());
+ }
+ Map result = ServiceUtil.returnSuccess();
+ return result;
+ }
+}
Propchange: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionForms.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionForms.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionForms.xml (original)
+++ incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionForms.xml Wed Jul 5 20:42:45 2006
@@ -70,34 +70,56 @@
<field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<form name="ListFindSubscription" default-title-style="tableheadtext" default-tooltip-style="tabletext" default-widget-style="tabletext"
- target="" type="list" paginate-target="FindSubscription" paginate="true">
+ target="" type="list" list-name="listIt" paginate-target="FindSubscription" paginate="true">
<actions>
- <service result-map-list-name="listIt" result-map-name="result" service-name="performFind">
+ <service service-name="performFind" result-map-list-name="listIt" result-map-name="performFindResult">
<field-map field-name="inputFields" env-name="parameters"/>
<field-map field-name="entityName" value="Subscription"/>
</service>
</actions>
<auto-fields-entity entity-name="Subscription" default-field-type="display"/>
- <field name="subscriptionResourceId" widget-style="selectBox">
+ <field name="subscriptionResourceId">
<display-entity entity-name="SubscriptionResource" description="${description}">
<sub-hyperlink target="EditSubscriptionResource?subscriptionResourceId=${subscriptionResourceId}" description="${subscriptionResourceId}" link-style="buttontext"/>
</display-entity>
</field>
- <field name="subscriptionTypeId" title="${uiLabelMap.ProductSubscription} ${uiLabelMap.CommonType}" widget-style="selectBox">
+ <field name="subscriptionTypeId" title="${uiLabelMap.ProductSubscription} ${uiLabelMap.CommonType}">
<display-entity entity-name="SubscriptionType" description="${description}"/>
</field>
- <field name="originatedFromPartyId"><display-entity entity-name="PartyNameView" description="${groupName} ${firstName} ${lastName}" key-field-name="partyId"/></field>
- <field name="originatedFromRoleTypeId"><display-entity entity-name="RoleType" description="${description}" key-field-name="roletypeId"/></field>
+ <field name="originatedFromPartyId">
+ <display-entity entity-name="PartyNameView" description="${groupName} ${firstName} ${lastName}" key-field-name="partyId">
+ <sub-hyperlink target="/partymgr/control/viewprofile?partyId=${originatedFromPartyId}" target-type="inter-app" description="${originatedFromPartyId}" link-style="buttontext"/>
+ </display-entity>
+ </field>
+ <field name="originatedFromRoleTypeId"><display-entity entity-name="RoleType" description="${description}" key-field-name="roleTypeId"/></field>
- <field name="partyId"><display-entity entity-name="PartyNameView" description="${groupName} ${firstName} ${lastName}"/></field>
- <field name="roleTypeId" widget-style="selectBox"><display-entity entity-name="RoleType" description="${description}" key-field-name="roletypeId"/></field>
+ <field name="partyId">
+ <display-entity entity-name="PartyNameView" description="${groupName} ${firstName} ${lastName}">
+ <sub-hyperlink target="/partymgr/control/viewprofile?partyId=${partyId}" target-type="inter-app" description="${partyId}" link-style="buttontext"/>
+ </display-entity>
+ </field>
+ <field name="roleTypeId"><display-entity entity-name="RoleType" description="${description}" key-field-name="roleTypeId"/></field>
- <field name="orderId"><lookup target-form-name="LookupOrderHeader"/></field>
- <field name="productId"><lookup target-form-name="LookupProduct"/></field>
- <field name="productCategoryId"><lookup target-form-name="LookupProductCategory"/></field>
- <field name="communicationEventId"><lookup target-form-name="LookupCommEvent"/></field>
+ <field name="orderId" widget-style="buttontext">
+ <hyperlink target="/ordermgr/control/orderview?orderId=${orderId}" target-type="inter-app" description="${orderId}"/>
+ </field>
+ <field name="productId">
+ <display-entity entity-name="Product" description="${productName}">
+ <sub-hyperlink target="/catalog/control/EditProduct?productId=${productId}" target-type="inter-app" description="${productId}" link-style="buttontext"/>
+ </display-entity>
+ </field>
+ <field name="productCategoryId">
+ <display-entity entity-name="ProductCategory" description="${categoryName}">
+ <sub-hyperlink target="/catalog/control/EditProductCategory?productCategoryId=${productCategoryId}" target-type="inter-app" description="${productCategoryId}" link-style="buttontext"/>
+ </display-entity>
+ </field>
+ <field name="communicationEventId">
+ <display-entity entity-name="CommunicationEvent" description="${subject}">
+ <sub-hyperlink target="/partymgr/control/ViewCommunicationEvent?communicationEventId=${communicationEventId}" target-type="inter-app" description="${communicationEventId}" link-style="buttontext"/>
+ </display-entity>
+ </field>
<field name="partyNeedId"><ignored/></field>
<field name="needTypeId"><ignored/></field>
@@ -130,7 +152,11 @@
</drop-down>
</field>
- <field name="originatedFromPartyId"><lookup target-form-name="LookupPartyName"/></field>
+ <field name="originatedFromPartyId">
+ <lookup target-form-name="LookupPartyName">
+ <sub-hyperlink target="/partymgr/control/viewprofile?partyId=${subscription.originatedFromPartyId}" target-type="inter-app" description="${subscription.originatedFromPartyId}" link-style="buttontext"/>
+ </lookup>
+ </field>
<field name="originatedFromRoleTypeId" widget-style="selectBox">
<drop-down allow-empty="true">
<entity-options entity-name="RoleType" description="${description}" key-field-name="roleTypeId">
@@ -139,7 +165,11 @@
</drop-down>
</field>
- <field name="partyId"><lookup target-form-name="LookupPartyName"/></field>
+ <field name="partyId">
+ <lookup target-form-name="LookupPartyName">
+ <sub-hyperlink target="/partymgr/control/viewprofile?partyId=${subscription.partyId}" target-type="inter-app" description="${subscription.partyId}" link-style="buttontext"/>
+ </lookup>
+ </field>
<field name="roleTypeId" widget-style="selectBox">
<drop-down allow-empty="true">
<entity-options entity-name="RoleType" description="${description}">
@@ -148,10 +178,26 @@
</drop-down>
</field>
- <field name="orderId"><lookup target-form-name="LookupOrderHeader"/></field>
- <field name="productId"><lookup target-form-name="LookupProduct"/></field>
- <field name="productCategoryId"><lookup target-form-name="LookupProductCategory"/></field>
- <field name="communicationEventId"><lookup target-form-name="LookupCommEvent"/></field>
+ <field name="orderId">
+ <lookup target-form-name="LookupOrderHeader">
+ <sub-hyperlink target="/ordermgr/control/orderview?orderId=${subscription.orderId}" target-type="inter-app" description="${subscription.orderId}" link-style="buttontext"/>
+ </lookup>
+ </field>
+ <field name="productId">
+ <lookup target-form-name="LookupProduct">
+ <sub-hyperlink target="/catalog/control/EditProduct?productId=${subscription.productId}" target-type="inter-app" description="${subscription.productId}" link-style="buttontext"/>
+ </lookup>
+ </field>
+ <field name="productCategoryId">
+ <lookup target-form-name="LookupProductCategory">
+ <sub-hyperlink target="/catalog/control/EditProductCategory?productCategoryId=${subscription.productCategoryId}" target-type="inter-app" description="${subscription.productCategoryId}" link-style="buttontext"/>
+ </lookup>
+ </field>
+ <field name="communicationEventId">
+ <lookup target-form-name="LookupCommEvent">
+ <sub-hyperlink target="/partymgr/control/ViewCommunicationEvent?communicationEventId=${subscription.communicationEventId}" target-type="inter-app" description="${subscription.communicationEventId}" link-style="buttontext"/>
+ </lookup>
+ </field>
<field name="partyNeedId"><ignored/></field>
<field name="needTypeId"><ignored/></field>
@@ -174,12 +220,12 @@
<field name="description" title="${uiLabelMap.CommonDescription}"><display/></field>
<field name="contentId">
<display-entity entity-name="Content" description="${contentName}">
- <sub-hyperlink target="/content/control/EditContent?contentId=${contentId}" description="${contentId}" link-style="buttontext"/>
+ <sub-hyperlink target="/content/control/EditContent?contentId=${contentId}" target-type="inter-app" description="${contentId}" link-style="buttontext"/>
</display-entity>
</field>
<field name="webSiteId">
<display-entity entity-name="WebSite" description="${siteName}">
- <sub-hyperlink target="/content/control/EditWebSite?webSiteId=${webSiteId}" description="${webSiteId}" link-style="buttontext"/>
+ <sub-hyperlink target="/content/control/EditWebSite?webSiteId=${webSiteId}" target-type="inter-app" description="${webSiteId}" link-style="buttontext"/>
</display-entity>
</field>
@@ -227,7 +273,7 @@
<field name="productId" widget-style="tabletext"><display/></field>
<field name="useTimeUomId" widget-style="selectBox">
<drop-down allow-empty="true">
- <entity-options entity-name="Uom" description="${description} (${abbreviation})">
+ <entity-options entity-name="Uom" description="${description} (${abbreviation})" key-field-name="uomId">
<entity-constraint name="uomTypeId" value="TIME_FREQ_MEASURE"/>
<entity-order-by field-name="description"/>
</entity-options>
@@ -235,7 +281,7 @@
</field>
<field name="useRoleTypeId" widget-style="selectBox">
<drop-down allow-empty="true">
- <entity-options entity-name="RoleType" description="${description}">
+ <entity-options entity-name="RoleType" description="${description}" key-field-name="roleTypeId">
<entity-order-by field-name="description"/>
</entity-options>
</drop-down>
@@ -256,7 +302,7 @@
<field name="productId"><lookup target-form-name="LookupProduct"/></field>
<field name="useTimeUomId" widget-style="selectBox">
<drop-down allow-empty="true">
- <entity-options entity-name="Uom" description="${description} (${abbreviation})">
+ <entity-options entity-name="Uom" description="${description} (${abbreviation})" key-field-name="uomId">
<entity-constraint name="uomTypeId" value="TIME_FREQ_MEASURE"/>
<entity-order-by field-name="description"/>
</entity-options>
@@ -264,7 +310,7 @@
</field>
<field name="useRoleTypeId" widget-style="selectBox">
<drop-down allow-empty="true">
- <entity-options entity-name="RoleType" description="${description}">
+ <entity-options entity-name="RoleType" description="${description}" key-field-name="roleTypeId">
<entity-order-by field-name="description"/>
</entity-options>
</drop-down>
Modified: incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionMenus.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionMenus.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionMenus.xml (original)
+++ incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionMenus.xml Wed Jul 5 20:42:45 2006
@@ -34,7 +34,7 @@
<menu-item name="EditSubscriptionResource" title="${uiLabelMap.ProductSubscriptionResource}">
<link target="EditSubscriptionResource?subscriptionResourceId=${subscriptionResourceId}"/>
</menu-item>
- <menu-item name="EditSubscriptionResourceProducts" title="${uiLabelMap.ProductSubscriptionResourceProducts}">
+ <menu-item name="EditSubscriptionResourceProducts" title="${uiLabelMap.ProductProducts}">
<link target="EditSubscriptionResourceProducts?subscriptionResourceId=${subscriptionResourceId}"/>
</menu-item>
</menu>
Modified: incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionScreens.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionScreens.xml?rev=419428&r1=419427&r2=419428&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionScreens.xml (original)
+++ incubator/ofbiz/trunk/applications/product/widget/catalog/SubscriptionScreens.xml Wed Jul 5 20:42:45 2006
@@ -162,7 +162,10 @@
</condition>
<widgets>
<include-menu name="EditSubscriptionResource" location="component://product/widget/catalog/SubscriptionMenus.xml"/>
- <container><link target="EditSubscriptionResource" text="${uiLabelMap.ProductNewSubscriptionResource}" style="buttontext"/></container>
+ <container>
+ <link target="EditSubscriptionResource" text="${uiLabelMap.ProductNewSubscriptionResource}" style="buttontext"/>
+ <link target="FindSubscription?subscriptionResourceId=${subscriptionResourceId}" text="${uiLabelMap.ProductFindResourceSubscriptions}" style="buttontext"/>
+ </container>
<container><label style="head1">${uiLabelMap.${titleProperty}}</label><label style="head2"> ${uiLabelMap.CommonFor} "${subscriptionResource.description}" [${subscriptionResourceId}]</label></container>
</widgets>
</section>