svn commit: r534188 - in /ofbiz/trunk/applications/product: config/ data/ servicedef/ src/org/ofbiz/product/product/ src/org/ofbiz/product/subscription/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r534188 - in /ofbiz/trunk/applications/product: config/ data/ servicedef/ src/org/ofbiz/product/product/ src/org/ofbiz/product/subscription/

jaz-3
Author: jaz
Date: Tue May  1 11:35:31 2007
New Revision: 534188

URL: http://svn.apache.org/viewvc?view=rev&rev=534188
Log:
included patch from Joe Eckard JIRA issue OFBIZ-952; also changed content wrapper to use virtual data if no variant data existed (thought this was already implemented)

Modified:
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    ofbiz/trunk/applications/product/data/ProductTypeData.xml
    ofbiz/trunk/applications/product/servicedef/services_subscription.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=534188&r1=534187&r2=534188
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Tue May  1 11:35:31 2007
@@ -1285,7 +1285,7 @@
 ProductSubscription=Subscription
 ProductSubscriptionAttributes= Subscription Attributes
 ProductSubscriptions=Subscriptions
-ProductSubscriptionResource=Subscription Resources
+ProductSubscriptionResource=Subscription Resource
 ProductSubscriptionResources=Subscription Resources
 ProductSubscriptionCommEvent= Subscription Communication Event
 ProductSubProduct=SubProduct

Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?view=diff&rev=534188&r1=534187&r2=534188
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Tue May  1 11:35:31 2007
@@ -491,4 +491,7 @@
     <!-- Supplier preference order for SupplierProduct entries -->
     <SupplierPrefOrder supplierPrefOrderId="10_MAIN_SUPPL" description="Main Supplier"/>
     <SupplierPrefOrder supplierPrefOrderId="90_ALT_SUPPL" description="Alternative Supplier"/>
+
+    <!-- product subscription type -->
+    <SubscriptionType description="Product" hasTable="N" parentTypeId="" subscriptionTypeId="PRODUCT_SUBSCR"/>
 </entity-engine-xml>

Modified: ofbiz/trunk/applications/product/servicedef/services_subscription.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_subscription.xml?view=diff&rev=534188&r1=534187&r2=534188
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_subscription.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_subscription.xml Tue May  1 11:35:31 2007
@@ -93,6 +93,7 @@
         <attribute name="productId" type="String" mode="IN" optional="true"/>
         <attribute name="orderId" type="String" mode="IN" optional="true"/>
         <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+        <attribute name="inventoryItemId" 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"/>
@@ -106,6 +107,7 @@
         <attribute name="productId" type="String" mode="IN" optional="false"/>
         <attribute name="orderId" type="String" mode="IN" optional="true"/>
         <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+        <attribute name="inventoryItemId" 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>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?view=diff&rev=534188&r1=534187&r2=534188
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java Tue May  1 11:35:31 2007
@@ -156,6 +156,17 @@
                 if (UtilValidate.isNotEmpty(candidateValue)) {
                     outWriter.write(candidateValue);
                     return;
+                } else if ("Y".equals(product.getString("isVariant"))) {
+                    // look up the virtual product
+                    GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
+                    Debug.log("Parent product: " + parent, module);
+                    if (parent != null) {
+                        candidateValue = parent.getString(candidateFieldName);
+                        if (UtilValidate.isNotEmpty(candidateValue)) {
+                            outWriter.write(candidateValue);
+                            return;
+                        }
+                    }
                 }
             }
         }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?view=diff&rev=534188&r1=534187&r2=534188
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Tue May  1 11:35:31 2007
@@ -38,6 +38,7 @@
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.common.uom.UomWorker;
 
 /**
  * Subscription Services
@@ -84,7 +85,8 @@
         } else {
             newSubscription = lastSubscription;
         }
-        
+        newSubscription.set("inventoryItemId", context.get("inventoryItemId"));
+
         Timestamp thruDate = lastSubscription != null ? (Timestamp) lastSubscription.get("thruDate") : null;
         if (thruDate == null) {
             // no thruDate? start with NOW
@@ -101,19 +103,13 @@
         }
         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;  
+        int[] times = UomWorker.uomTimeToCalTime(useTimeUomId);
+        if (times != null) {
+            calendar.add(times[0], (useTime.intValue() * times[1]));
         } 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);
         
@@ -193,8 +189,6 @@
                 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);
@@ -206,8 +200,8 @@
             Debug.logError(e, e.toString(), module);
             return ServiceUtil.returnError(e.toString());
         }
-        Map result = ServiceUtil.returnSuccess();
-        return result;
+        
+        return ServiceUtil.returnSuccess();
     }
     
     public static Map processExtendSubscriptionByOrder(DispatchContext dctx, Map context) throws GenericServiceException{
@@ -249,9 +243,11 @@
                 List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
                 List productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true);
                 if (productSubscriptionResourceListFiltered.size() > 0) {
+                    context.put("subscriptionTypeId", "PRODUCT_SUBSCR");
                     context.put("productId", productId);
                     context.put("orderId", orderId);
                     context.put("orderItemSeqId", orderItem.get("orderItemSeqId"));
+                    context.put("inventoryItemId", orderItem.get("fromInventoryItemId"));
                     context.put("quantity", new Integer(qty.intValue()));
                     Map ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(context, ModelService.IN_PARAM);
                     Map thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx);
@@ -264,7 +260,7 @@
             Debug.logError(e.toString(), module);
             return ServiceUtil.returnError(e.toString());
         }
-        Map result = ServiceUtil.returnSuccess();
-        return result;
+
+        return ServiceUtil.returnSuccess();
     }
 }