[OFBiz] SVN: r7861 - in trunk/applications/product: servicedef src/org/ofbiz/product/product

jacopo@svn.ofbiz.org jacopo at svn.ofbiz.org
Sun Jun 25 04:26:43 CDT 2006


Author: jacopo
Date: 2006-06-25 04:26:27 -0500 (Sun, 25 Jun 2006)
New Revision: 7861

Modified:
   trunk/applications/product/servicedef/services.xml
   trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
Log:
Added ability to specify a sequence num when creating a variant of a product; sequence nums can be used to sort the variants of a given virtual product.
Based on part of a patch contributed by Scott Gray (Apache OFBIZ-51).


Modified: trunk/applications/product/servicedef/services.xml
===================================================================
--- trunk/applications/product/servicedef/services.xml	2006-06-24 21:20:40 UTC (rev 7860)
+++ trunk/applications/product/servicedef/services.xml	2006-06-25 09:26:27 UTC (rev 7861)
@@ -105,6 +105,7 @@
         <attribute name="productId" type="String" mode="IN" optional="false"/>
         <attribute name="productFeatureIds" type="String" mode="IN" optional="false"/>
         <attribute name="productVariantId" type="String" mode="INOUT" optional="false"/>
+        <attribute name="sequenceNum" type="Long" mode="IN" optional="true"/>
     </service>
 
     <service name="quickCreateVirtualWithVariants" engine="java"

Modified: trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
===================================================================
--- trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java	2006-06-24 21:20:40 UTC (rev 7860)
+++ trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java	2006-06-25 09:26:27 UTC (rev 7861)
@@ -677,7 +677,8 @@
         String productId = (String) context.get("productId");
         String variantProductId = (String) context.get("productVariantId");
         String productFeatureIds = (String) context.get("productFeatureIds");
-        
+        Long prodAssocSeqNum = (Long) context.get("sequenceNum");
+
         try {
             // read the product, duplicate it with the given id
             GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
@@ -708,7 +709,6 @@
                 //update entry
                 variantProduct.store();
             }
-            GenericValue variantProductAssoc = null;
             if (variantProductExists) {
                 // Since the variant product is already a variant, first of all we remove the old features
                 // and the associations of type PRODUCT_VARIANT: a given product can be a variant of only one product.
@@ -718,9 +718,13 @@
                                                                            "productFeatureApplTypeId", "STANDARD_FEATURE"));
             }
             // add an association from productId to variantProductId of the PRODUCT_VARIANT
-            GenericValue productAssoc = delegator.makeValue("ProductAssoc",
-                                                            UtilMisc.toMap("productId", productId, "productIdTo", variantProductId,
-                                                                           "productAssocTypeId", "PRODUCT_VARIANT", "fromDate", UtilDateTime.nowTimestamp()));
+            Map productAssocMap = UtilMisc.toMap("productId", productId, "productIdTo", variantProductId,
+                                                 "productAssocTypeId", "PRODUCT_VARIANT",
+                                                 "fromDate", UtilDateTime.nowTimestamp());
+            if (prodAssocSeqNum != null) {
+                productAssocMap.put("sequenceNum", prodAssocSeqNum);
+            }
+            GenericValue productAssoc = delegator.makeValue("ProductAssoc", productAssocMap);
             productAssoc.create();
 
             // add the selected standard features to the new product given the productFeatureIds



More information about the Svn mailing list