You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2016/09/04 06:41:20 UTC

svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Author: ashish
Date: Sun Sep  4 06:41:20 2016
New Revision: 1759147

URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
Log:
Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code in Groovy for Order. Thanks Aman for the contribution.

Modified:
    ofbiz/trunk/applications/order/groovyScripts/entry/OptionSettings.groovy
    ofbiz/trunk/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy
    ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Category.groovy
    ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy
    ofbiz/trunk/applications/order/groovyScripts/order/FilterOrderList.groovy
    ofbiz/trunk/applications/order/groovyScripts/quote/ViewQuoteProfit.groovy

Modified: ofbiz/trunk/applications/order/groovyScripts/entry/OptionSettings.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/OptionSettings.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/OptionSettings.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/OptionSettings.groovy Sun Sep  4 06:41:20 2016
@@ -60,7 +60,6 @@ context.beforeDateStr = fromStr;
 // create the afterDate for calendar
 toCal = Calendar.getInstance();
 toCal.setTime(new java.util.Date());
-//toCal.set(Calendar.DAY_OF_WEEK, toCal.getActualMaximum(Calendar.DAY_OF_WEEK));
 toCal.set(Calendar.HOUR_OF_DAY, toCal.getActualMaximum(Calendar.HOUR_OF_DAY));
 toCal.set(Calendar.MINUTE, toCal.getActualMaximum(Calendar.MINUTE));
 toCal.set(Calendar.SECOND, toCal.getActualMaximum(Calendar.SECOND));

Modified: ofbiz/trunk/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy Sun Sep  4 06:41:20 2016
@@ -35,8 +35,6 @@ productPromoCategoryAlwaysList = EntityU
 productIdsCond = [] as Set;
 productIdsAction = [] as Set;
 ProductPromoWorker.makeProductPromoCondActionIdSets(productPromoId, productIdsCond, productIdsAction, delegator, null);
-// Debug.logInfo("productIdsCond=" + productIdsCond.toString(), "showProductPromoDetails.bsh");
-// Debug.logInfo("productIdsAction=" + productIdsAction.toString(), "showProductPromoDetails.bsh");
 
 productIds = new TreeSet(productIdsCond);
 productIds.addAll(productIdsAction);

Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Category.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Category.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Category.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Category.groovy Sun Sep  4 06:41:20 2016
@@ -41,25 +41,6 @@ pageTitle = null;
 metaDescription = null;
 metaKeywords = null;
 
-/* NOTE DEJ20070220: this is a weird way to do this and caused unacceptable side effects as described in the related
- * comment in the Main.groovy file
- *
- * NOTE JLR 20070221 this should be done using the same method than in add to cart. I will do it like that and remove all this after.
- *
-if (productCategoryId) {
-    session.setAttribute("productCategoryId", productCategoryId);// for language change
-    previousParams = session.getAttribute("_PREVIOUS_PARAMS_");
-    if (previousParams) {
-        previousParams = UtilHttp.stripNamedParamsFromQueryString(previousParams, ["category_id"]);
-        previousParams += "&category_id=" + productCategoryId;
-    } else {
-        previousParams = "category_id=" + productCategoryId;
-    }
-    session.setAttribute("_PREVIOUS_PARAMS_", previousParams);    // for login
-    context.previousParams = previousParams;
-}
- */
-
 category = from("ProductCategory").where("productCategoryId", productCategoryId).cache(true).queryOne();
 if (category) {
     if (category.detailScreen) {

Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy Sun Sep  4 06:41:20 2016
@@ -213,10 +213,6 @@ if (product) {
     // if order is purchase then don't calculate available inventory for product. 
     if (cart.isSalesOrder()) {
         facilityId = productStore.inventoryFacilityId;
-        /*
-        productFacility = delegator.findOne("ProductFacility", [productId : productId, facilityId : facilityId, true);
-        context.daysToShip = productFacility?.daysToShip
-        */
 
         resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facilityId, useCache : false]);
         totalAvailableToPromise = resultOutput.availableToPromiseTotal;
@@ -593,49 +589,6 @@ if (product) {
     accessoryProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_ACCESSORY", checkViewAllow : true, prodCatalogId : currentCatalogId]);
     context.accessoryProducts = accessoryProducts.assocProducts;
 
-    /*
-      The following code is commented out because it is just an example of the business logic to retrieve products with a similar feature.
-
-    // get other cross-sell information: product with a common feature
-    commonProductFeatureId = "SYMPTOM";
-    // does this product have that feature?
-    commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", [productId : productId, productFeatureTypeId : commonProductFeatureId], ["sequenceNum", "defaultSequenceNum"], false);
-    if (commonProductFeatureAndAppls) {
-        commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(commonProductFeatureAndAppls, "productFeatureId", true);
-
-        // now search for other products that have this feature
-        visitId = VisitHandler.getVisitId(session);
-
-        productSearchConstraintList = [];
-        productSearchConstraintList.add(new ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
-        // make sure the view allow category is included
-        productSearchConstraintList = ProductSearchSession.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator);
-
-        // don't care about the sort on this one
-        resultSortOrder = null;
-
-        commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
-        commonFeatureResultIds = [];
-        commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator();
-        while (commonFeatureResultIdIter.hasNext()) {
-            commonFeatureResultId = commonFeatureResultIdIter.next();
-            // filter out the current product
-            if (commonFeatureResultId.equals(productId)) {
-                continue;
-            }
-            // filter out all variants
-            commonProduct = delegator.findOne("Product", [productId : commonFeatureResultId], true);
-            if ("Y".equals(commonProduct?.isVariant)) {
-                continue;
-            }
-            commonFeatureResultIds.add(commonFeatureResultId);
-        }
-        if (commonFeatureResultIds) {
-            context.commonFeatureResultIds = commonFeatureResultIds;
-        }
-    }
-    */
-
     // get the DIGITAL_DOWNLOAD related Content records to show the contentName/description
     downloadProductContentAndInfoList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DIGITAL_DOWNLOAD").cache(true).queryList();
     context.downloadProductContentAndInfoList = downloadProductContentAndInfoList;

Modified: ofbiz/trunk/applications/order/groovyScripts/order/FilterOrderList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/order/FilterOrderList.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/order/FilterOrderList.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/order/FilterOrderList.groovy Sun Sep  4 06:41:20 2016
@@ -44,7 +44,6 @@ filterPOsWithRejectedItems = [];
 filterPartiallyReceivedPOs = [];
 
 state = OrderListState.getInstance(request);
-//print("### " + state.toString());
 
 if ((state.hasFilter("filterPartiallyReceivedPOs") ||
         state.hasFilter("filterPOsOpenPastTheirETA") ||

Modified: ofbiz/trunk/applications/order/groovyScripts/quote/ViewQuoteProfit.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/quote/ViewQuoteProfit.groovy?rev=1759147&r1=1759146&r2=1759147&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/quote/ViewQuoteProfit.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/quote/ViewQuoteProfit.groovy Sun Sep  4 06:41:20 2016
@@ -62,7 +62,6 @@ quoteItems.each { quoteItem ->
                 averageCost = productPrice.price * selectedAmount;
             }
         }
-        //defaultQuoteUnitPrice = averageCost * costToPriceMult * selectedAmount;
         totalCost += (averageCost * quantity);
         totalPrice += (unitPrice * quantity * selectedAmount);
     } catch (Exception exc) {



Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Michael Brohl <mi...@ecomify.de>.
We have something similar for simple methods and Groovy: 
https://cwiki.apache.org/confluence/display/OFBIZ/Simple-methods+examples+using+Groovy


Am 02.10.16 um 12:25 schrieb Michael Brohl:
> We could put this in the Wiki, maybe a page and sub-pages with 
> business logic examples and some documentation.
>
> I agree with Taher, code examples do not belong in the code.
>
> Regards,
>
> Michael
>
>
> Am 02.10.16 um 12:17 schrieb Jacques Le Roux:
>> Then how to keep this interesting code example?
>>
>> Jacques
>>
>>
>> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>>> Commented out code should always be removed as a general programming
>>> guideline
>>>
>>> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
>>> jacques.le.roux@les7arts.com> wrote:
>>>
>>>> Hi Ashish,
>>>>
>>>> I think we should keep this example
>>>>
>>>> Thanks
>>>>
>>>> Jacques
>>>>
>>>>
>>>> Le 04/09/2016 à 08:41, ashish@apache.org a écrit :
>>>>
>>>>> Author: ashish
>>>>> Date: Sun Sep  4 06:41:20 2016
>>>>> New Revision: 1759147
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>>>> Log:
>>>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented 
>>>>> out code
>>>>> in Groovy for Order. Thanks Aman for the contribution.
>>>>>
>>>>>    -    /*
>>>>> -      The following code is commented out because it is just an 
>>>>> example
>>>>> of the business logic to retrieve products with a similar feature.
>>>>> -
>>>>> -    // get other cross-sell information: product with a common 
>>>>> feature
>>>>> -    commonProductFeatureId = "SYMPTOM";
>>>>> -    // does this product have that feature?
>>>>> -    commonProductFeatureAndAppls = 
>>>>> delegator.findByAnd("ProductFeatureAndAppl",
>>>>> [productId : productId, productFeatureTypeId : 
>>>>> commonProductFeatureId],
>>>>> ["sequenceNum", "defaultSequenceNum"], false);
>>>>> -    if (commonProductFeatureAndAppls) {
>>>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>>>> -
>>>>> -        // now search for other products that have this feature
>>>>> -        visitId = VisitHandler.getVisitId(session);
>>>>> -
>>>>> -        productSearchConstraintList = [];
>>>>> -        productSearchConstraintList.add(new
>>>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>>>> -        // make sure the view allow category is included
>>>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>>>> delegator);
>>>>> -
>>>>> -        // don't care about the sort on this one
>>>>> -        resultSortOrder = null;
>>>>> -
>>>>> -        commonFeatureResultIdsOrig = 
>>>>> ProductSearch.searchProducts(productSearchConstraintList,
>>>>> resultSortOrder, delegator, visitId);
>>>>> -        commonFeatureResultIds = [];
>>>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>>>> rator();
>>>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>>>> -            commonFeatureResultId = 
>>>>> commonFeatureResultIdIter.next();
>>>>> -            // filter out the current product
>>>>> -            if (commonFeatureResultId.equals(productId)) {
>>>>> -                continue;
>>>>> -            }
>>>>> -            // filter out all variants
>>>>> -            commonProduct = delegator.findOne("Product", 
>>>>> [productId :
>>>>> commonFeatureResultId], true);
>>>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>>>> -                continue;
>>>>> -            }
>>>>> - commonFeatureResultIds.add(commonFeatureResultId);
>>>>> -        }
>>>>> -        if (commonFeatureResultIds) {
>>>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>>>> -        }
>>>>> -    }
>>>>> -    */
>>>>> -
>>>>>        // get the DIGITAL_DOWNLOAD related Content records to show 
>>>>> the
>>>>> contentName/description
>>>>>
>>>>
>>
>
>



Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Michael Brohl <mi...@ecomify.de>.
We could put this in the Wiki, maybe a page and sub-pages with business 
logic examples and some documentation.

I agree with Taher, code examples do not belong in the code.

Regards,

Michael


Am 02.10.16 um 12:17 schrieb Jacques Le Roux:
> Then how to keep this interesting code example?
>
> Jacques
>
>
> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>> Commented out code should always be removed as a general programming
>> guideline
>>
>> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
>> jacques.le.roux@les7arts.com> wrote:
>>
>>> Hi Ashish,
>>>
>>> I think we should keep this example
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>>
>>> Le 04/09/2016 à 08:41, ashish@apache.org a écrit :
>>>
>>>> Author: ashish
>>>> Date: Sun Sep  4 06:41:20 2016
>>>> New Revision: 1759147
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>>> Log:
>>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out 
>>>> code
>>>> in Groovy for Order. Thanks Aman for the contribution.
>>>>
>>>>    -    /*
>>>> -      The following code is commented out because it is just an 
>>>> example
>>>> of the business logic to retrieve products with a similar feature.
>>>> -
>>>> -    // get other cross-sell information: product with a common 
>>>> feature
>>>> -    commonProductFeatureId = "SYMPTOM";
>>>> -    // does this product have that feature?
>>>> -    commonProductFeatureAndAppls = 
>>>> delegator.findByAnd("ProductFeatureAndAppl",
>>>> [productId : productId, productFeatureTypeId : 
>>>> commonProductFeatureId],
>>>> ["sequenceNum", "defaultSequenceNum"], false);
>>>> -    if (commonProductFeatureAndAppls) {
>>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>>> -
>>>> -        // now search for other products that have this feature
>>>> -        visitId = VisitHandler.getVisitId(session);
>>>> -
>>>> -        productSearchConstraintList = [];
>>>> -        productSearchConstraintList.add(new
>>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>>> -        // make sure the view allow category is included
>>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>>> delegator);
>>>> -
>>>> -        // don't care about the sort on this one
>>>> -        resultSortOrder = null;
>>>> -
>>>> -        commonFeatureResultIdsOrig = 
>>>> ProductSearch.searchProducts(productSearchConstraintList,
>>>> resultSortOrder, delegator, visitId);
>>>> -        commonFeatureResultIds = [];
>>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>>> rator();
>>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>>> -            commonFeatureResultId = commonFeatureResultIdIter.next();
>>>> -            // filter out the current product
>>>> -            if (commonFeatureResultId.equals(productId)) {
>>>> -                continue;
>>>> -            }
>>>> -            // filter out all variants
>>>> -            commonProduct = delegator.findOne("Product", [productId :
>>>> commonFeatureResultId], true);
>>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>>> -                continue;
>>>> -            }
>>>> - commonFeatureResultIds.add(commonFeatureResultId);
>>>> -        }
>>>> -        if (commonFeatureResultIds) {
>>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>>> -        }
>>>> -    }
>>>> -    */
>>>> -
>>>>        // get the DIGITAL_DOWNLOAD related Content records to show the
>>>> contentName/description
>>>>
>>>
>



Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Paul Foxworthy <pa...@cohsoft.com.au>.
Hi all,

Can I turn the proposition around? If I was looking for example code to
find products with a feature, I would be looking in the wiki and other
documentation. In other words, I would look in places where examples are to
be found. I would not look in the source code. So putting an example in the
code would make it obscure and hard to find.

Cheers

Paul Foxworthy


On 2 October 2016 at 21:55, Jacques Le Roux <ja...@les7arts.com>
wrote:

> Despite the possible decay, I still think the best place is in the
> context. But it's up to the community.
>
> Jacques
>
>
>
> Le 02/10/2016 à 12:25, Taher Alkhateeb a écrit :
>
>> Put it somewhere in documentation if you want to. Live code is not a place
>> for commented out code snippets, it's bad coding practice and it adds to
>> the entropy and chaos. Commented out code with time decays and eventually
>> becomes broken and does not even work (changing dependencies, API
>> signatures, etc ...). Also, usually when committers see commented out code
>> they think someone put it there because they're working on it and it is
>> important somehow. No code should be important and everything should be
>> subject to refactoring and improvement.
>>
>> I think places where example code is suitable are: documentation and
>> tests.
>> Beyond that, it is just dead weight
>>
>> On Sun, Oct 2, 2016 at 1:17 PM, Jacques Le Roux <
>> jacques.le.roux@les7arts.com> wrote:
>>
>> Then how to keep this interesting code example?
>>>
>>> Jacques
>>>
>>>
>>>
>>> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>>>
>>> Commented out code should always be removed as a general programming
>>>> guideline
>>>>
>>>> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
>>>> jacques.le.roux@les7arts.com> wrote:
>>>>
>>>> Hi Ashish,
>>>>
>>>>> I think we should keep this example
>>>>>
>>>>> Thanks
>>>>>
>>>>> Jacques
>>>>>
>>>>>
>>>>> Le 04/09/2016 à 08:41, ashish@apache.org a écrit :
>>>>>
>>>>> Author: ashish
>>>>>
>>>>>> Date: Sun Sep  4 06:41:20 2016
>>>>>> New Revision: 1759147
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>>>>> Log:
>>>>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out
>>>>>> code
>>>>>> in Groovy for Order. Thanks Aman for the contribution.
>>>>>>
>>>>>>     -    /*
>>>>>> -      The following code is commented out because it is just an
>>>>>> example
>>>>>> of the business logic to retrieve products with a similar feature.
>>>>>> -
>>>>>> -    // get other cross-sell information: product with a common
>>>>>> feature
>>>>>> -    commonProductFeatureId = "SYMPTOM";
>>>>>> -    // does this product have that feature?
>>>>>> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFe
>>>>>> atureAndAppl",
>>>>>> [productId : productId, productFeatureTypeId :
>>>>>> commonProductFeatureId],
>>>>>> ["sequenceNum", "defaultSequenceNum"], false);
>>>>>> -    if (commonProductFeatureAndAppls) {
>>>>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>>>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>>>>> -
>>>>>> -        // now search for other products that have this feature
>>>>>> -        visitId = VisitHandler.getVisitId(session);
>>>>>> -
>>>>>> -        productSearchConstraintList = [];
>>>>>> -        productSearchConstraintList.add(new
>>>>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>>>>> -        // make sure the view allow category is included
>>>>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>>>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>>>>> delegator);
>>>>>> -
>>>>>> -        // don't care about the sort on this one
>>>>>> -        resultSortOrder = null;
>>>>>> -
>>>>>> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(p
>>>>>> roductSearchConstraintList,
>>>>>> resultSortOrder, delegator, visitId);
>>>>>> -        commonFeatureResultIds = [];
>>>>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>>>>> rator();
>>>>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>>>>> -            commonFeatureResultId = commonFeatureResultIdIter.next
>>>>>> ();
>>>>>> -            // filter out the current product
>>>>>> -            if (commonFeatureResultId.equals(productId)) {
>>>>>> -                continue;
>>>>>> -            }
>>>>>> -            // filter out all variants
>>>>>> -            commonProduct = delegator.findOne("Product", [productId :
>>>>>> commonFeatureResultId], true);
>>>>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>>>>> -                continue;
>>>>>> -            }
>>>>>> -            commonFeatureResultIds.add(commonFeatureResultId);
>>>>>> -        }
>>>>>> -        if (commonFeatureResultIds) {
>>>>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>>>>> -        }
>>>>>> -    }
>>>>>> -    */
>>>>>> -
>>>>>>         // get the DIGITAL_DOWNLOAD related Content records to show
>>>>>> the
>>>>>> contentName/description
>>>>>>
>>>>>>
>>>>>>
>


-- 
Coherent Software Australia Pty Ltd
PO Box 2773
Cheltenham Vic 3192
Australia

Phone: +61 3 9585 6788
Web: http://www.coherentsoftware.com.au/
Email: info@coherentsoftware.com.au

Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Jacques Le Roux <ja...@les7arts.com>.
Despite the possible decay, I still think the best place is in the context. But it's up to the community.

Jacques


Le 02/10/2016 � 12:25, Taher Alkhateeb a �crit :
> Put it somewhere in documentation if you want to. Live code is not a place
> for commented out code snippets, it's bad coding practice and it adds to
> the entropy and chaos. Commented out code with time decays and eventually
> becomes broken and does not even work (changing dependencies, API
> signatures, etc ...). Also, usually when committers see commented out code
> they think someone put it there because they're working on it and it is
> important somehow. No code should be important and everything should be
> subject to refactoring and improvement.
>
> I think places where example code is suitable are: documentation and tests.
> Beyond that, it is just dead weight
>
> On Sun, Oct 2, 2016 at 1:17 PM, Jacques Le Roux <
> jacques.le.roux@les7arts.com> wrote:
>
>> Then how to keep this interesting code example?
>>
>> Jacques
>>
>>
>>
>> Le 02/10/2016 � 12:12, Taher Alkhateeb a �crit :
>>
>>> Commented out code should always be removed as a general programming
>>> guideline
>>>
>>> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
>>> jacques.le.roux@les7arts.com> wrote:
>>>
>>> Hi Ashish,
>>>> I think we should keep this example
>>>>
>>>> Thanks
>>>>
>>>> Jacques
>>>>
>>>>
>>>> Le 04/09/2016 � 08:41, ashish@apache.org a �crit :
>>>>
>>>> Author: ashish
>>>>> Date: Sun Sep  4 06:41:20 2016
>>>>> New Revision: 1759147
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>>>> Log:
>>>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code
>>>>> in Groovy for Order. Thanks Aman for the contribution.
>>>>>
>>>>>     -    /*
>>>>> -      The following code is commented out because it is just an example
>>>>> of the business logic to retrieve products with a similar feature.
>>>>> -
>>>>> -    // get other cross-sell information: product with a common feature
>>>>> -    commonProductFeatureId = "SYMPTOM";
>>>>> -    // does this product have that feature?
>>>>> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFe
>>>>> atureAndAppl",
>>>>> [productId : productId, productFeatureTypeId : commonProductFeatureId],
>>>>> ["sequenceNum", "defaultSequenceNum"], false);
>>>>> -    if (commonProductFeatureAndAppls) {
>>>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>>>> -
>>>>> -        // now search for other products that have this feature
>>>>> -        visitId = VisitHandler.getVisitId(session);
>>>>> -
>>>>> -        productSearchConstraintList = [];
>>>>> -        productSearchConstraintList.add(new
>>>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>>>> -        // make sure the view allow category is included
>>>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>>>> delegator);
>>>>> -
>>>>> -        // don't care about the sort on this one
>>>>> -        resultSortOrder = null;
>>>>> -
>>>>> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(p
>>>>> roductSearchConstraintList,
>>>>> resultSortOrder, delegator, visitId);
>>>>> -        commonFeatureResultIds = [];
>>>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>>>> rator();
>>>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>>>> -            commonFeatureResultId = commonFeatureResultIdIter.next();
>>>>> -            // filter out the current product
>>>>> -            if (commonFeatureResultId.equals(productId)) {
>>>>> -                continue;
>>>>> -            }
>>>>> -            // filter out all variants
>>>>> -            commonProduct = delegator.findOne("Product", [productId :
>>>>> commonFeatureResultId], true);
>>>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>>>> -                continue;
>>>>> -            }
>>>>> -            commonFeatureResultIds.add(commonFeatureResultId);
>>>>> -        }
>>>>> -        if (commonFeatureResultIds) {
>>>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>>>> -        }
>>>>> -    }
>>>>> -    */
>>>>> -
>>>>>         // get the DIGITAL_DOWNLOAD related Content records to show the
>>>>> contentName/description
>>>>>
>>>>>


Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Taher Alkhateeb <sl...@gmail.com>.
Put it somewhere in documentation if you want to. Live code is not a place
for commented out code snippets, it's bad coding practice and it adds to
the entropy and chaos. Commented out code with time decays and eventually
becomes broken and does not even work (changing dependencies, API
signatures, etc ...). Also, usually when committers see commented out code
they think someone put it there because they're working on it and it is
important somehow. No code should be important and everything should be
subject to refactoring and improvement.

I think places where example code is suitable are: documentation and tests.
Beyond that, it is just dead weight

On Sun, Oct 2, 2016 at 1:17 PM, Jacques Le Roux <
jacques.le.roux@les7arts.com> wrote:

> Then how to keep this interesting code example?
>
> Jacques
>
>
>
> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>
>> Commented out code should always be removed as a general programming
>> guideline
>>
>> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
>> jacques.le.roux@les7arts.com> wrote:
>>
>> Hi Ashish,
>>>
>>> I think we should keep this example
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>>
>>> Le 04/09/2016 à 08:41, ashish@apache.org a écrit :
>>>
>>> Author: ashish
>>>> Date: Sun Sep  4 06:41:20 2016
>>>> New Revision: 1759147
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>>> Log:
>>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code
>>>> in Groovy for Order. Thanks Aman for the contribution.
>>>>
>>>>    -    /*
>>>> -      The following code is commented out because it is just an example
>>>> of the business logic to retrieve products with a similar feature.
>>>> -
>>>> -    // get other cross-sell information: product with a common feature
>>>> -    commonProductFeatureId = "SYMPTOM";
>>>> -    // does this product have that feature?
>>>> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFe
>>>> atureAndAppl",
>>>> [productId : productId, productFeatureTypeId : commonProductFeatureId],
>>>> ["sequenceNum", "defaultSequenceNum"], false);
>>>> -    if (commonProductFeatureAndAppls) {
>>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>>> -
>>>> -        // now search for other products that have this feature
>>>> -        visitId = VisitHandler.getVisitId(session);
>>>> -
>>>> -        productSearchConstraintList = [];
>>>> -        productSearchConstraintList.add(new
>>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>>> -        // make sure the view allow category is included
>>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>>> delegator);
>>>> -
>>>> -        // don't care about the sort on this one
>>>> -        resultSortOrder = null;
>>>> -
>>>> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(p
>>>> roductSearchConstraintList,
>>>> resultSortOrder, delegator, visitId);
>>>> -        commonFeatureResultIds = [];
>>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>>> rator();
>>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>>> -            commonFeatureResultId = commonFeatureResultIdIter.next();
>>>> -            // filter out the current product
>>>> -            if (commonFeatureResultId.equals(productId)) {
>>>> -                continue;
>>>> -            }
>>>> -            // filter out all variants
>>>> -            commonProduct = delegator.findOne("Product", [productId :
>>>> commonFeatureResultId], true);
>>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>>> -                continue;
>>>> -            }
>>>> -            commonFeatureResultIds.add(commonFeatureResultId);
>>>> -        }
>>>> -        if (commonFeatureResultIds) {
>>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>>> -        }
>>>> -    }
>>>> -    */
>>>> -
>>>>        // get the DIGITAL_DOWNLOAD related Content records to show the
>>>> contentName/description
>>>>
>>>>
>>>
>

Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Jacques Le Roux <ja...@les7arts.com>.
Then how to keep this interesting code example?

Jacques


Le 02/10/2016 � 12:12, Taher Alkhateeb a �crit :
> Commented out code should always be removed as a general programming
> guideline
>
> On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
> jacques.le.roux@les7arts.com> wrote:
>
>> Hi Ashish,
>>
>> I think we should keep this example
>>
>> Thanks
>>
>> Jacques
>>
>>
>> Le 04/09/2016 � 08:41, ashish@apache.org a �crit :
>>
>>> Author: ashish
>>> Date: Sun Sep  4 06:41:20 2016
>>> New Revision: 1759147
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>>> Log:
>>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code
>>> in Groovy for Order. Thanks Aman for the contribution.
>>>
>>>    -    /*
>>> -      The following code is commented out because it is just an example
>>> of the business logic to retrieve products with a similar feature.
>>> -
>>> -    // get other cross-sell information: product with a common feature
>>> -    commonProductFeatureId = "SYMPTOM";
>>> -    // does this product have that feature?
>>> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl",
>>> [productId : productId, productFeatureTypeId : commonProductFeatureId],
>>> ["sequenceNum", "defaultSequenceNum"], false);
>>> -    if (commonProductFeatureAndAppls) {
>>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>>> -
>>> -        // now search for other products that have this feature
>>> -        visitId = VisitHandler.getVisitId(session);
>>> -
>>> -        productSearchConstraintList = [];
>>> -        productSearchConstraintList.add(new
>>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>>> -        // make sure the view allow category is included
>>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>>> delegator);
>>> -
>>> -        // don't care about the sort on this one
>>> -        resultSortOrder = null;
>>> -
>>> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList,
>>> resultSortOrder, delegator, visitId);
>>> -        commonFeatureResultIds = [];
>>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>>> rator();
>>> -        while (commonFeatureResultIdIter.hasNext()) {
>>> -            commonFeatureResultId = commonFeatureResultIdIter.next();
>>> -            // filter out the current product
>>> -            if (commonFeatureResultId.equals(productId)) {
>>> -                continue;
>>> -            }
>>> -            // filter out all variants
>>> -            commonProduct = delegator.findOne("Product", [productId :
>>> commonFeatureResultId], true);
>>> -            if ("Y".equals(commonProduct?.isVariant)) {
>>> -                continue;
>>> -            }
>>> -            commonFeatureResultIds.add(commonFeatureResultId);
>>> -        }
>>> -        if (commonFeatureResultIds) {
>>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>>> -        }
>>> -    }
>>> -    */
>>> -
>>>        // get the DIGITAL_DOWNLOAD related Content records to show the
>>> contentName/description
>>>
>>


Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Taher Alkhateeb <sl...@gmail.com>.
Commented out code should always be removed as a general programming
guideline

On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
jacques.le.roux@les7arts.com> wrote:

> Hi Ashish,
>
> I think we should keep this example
>
> Thanks
>
> Jacques
>
>
> Le 04/09/2016 à 08:41, ashish@apache.org a écrit :
>
>> Author: ashish
>> Date: Sun Sep  4 06:41:20 2016
>> New Revision: 1759147
>>
>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>> Log:
>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code
>> in Groovy for Order. Thanks Aman for the contribution.
>>
>>   -    /*
>> -      The following code is commented out because it is just an example
>> of the business logic to retrieve products with a similar feature.
>> -
>> -    // get other cross-sell information: product with a common feature
>> -    commonProductFeatureId = "SYMPTOM";
>> -    // does this product have that feature?
>> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl",
>> [productId : productId, productFeatureTypeId : commonProductFeatureId],
>> ["sequenceNum", "defaultSequenceNum"], false);
>> -    if (commonProductFeatureAndAppls) {
>> -        commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>> -
>> -        // now search for other products that have this feature
>> -        visitId = VisitHandler.getVisitId(session);
>> -
>> -        productSearchConstraintList = [];
>> -        productSearchConstraintList.add(new
>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>> -        // make sure the view allow category is included
>> -        productSearchConstraintList = ProductSearchSession.ensureVie
>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>> delegator);
>> -
>> -        // don't care about the sort on this one
>> -        resultSortOrder = null;
>> -
>> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList,
>> resultSortOrder, delegator, visitId);
>> -        commonFeatureResultIds = [];
>> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>> rator();
>> -        while (commonFeatureResultIdIter.hasNext()) {
>> -            commonFeatureResultId = commonFeatureResultIdIter.next();
>> -            // filter out the current product
>> -            if (commonFeatureResultId.equals(productId)) {
>> -                continue;
>> -            }
>> -            // filter out all variants
>> -            commonProduct = delegator.findOne("Product", [productId :
>> commonFeatureResultId], true);
>> -            if ("Y".equals(commonProduct?.isVariant)) {
>> -                continue;
>> -            }
>> -            commonFeatureResultIds.add(commonFeatureResultId);
>> -        }
>> -        if (commonFeatureResultIds) {
>> -            context.commonFeatureResultIds = commonFeatureResultIds;
>> -        }
>> -    }
>> -    */
>> -
>>       // get the DIGITAL_DOWNLOAD related Content records to show the
>> contentName/description
>>
>
>

Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Ashish,

I think we should keep this example

Thanks

Jacques


Le 04/09/2016 � 08:41, ashish@apache.org a �crit :
> Author: ashish
> Date: Sun Sep  4 06:41:20 2016
> New Revision: 1759147
>
> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
> Log:
> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out code in Groovy for Order. Thanks Aman for the contribution.
>
>   
> -    /*
> -      The following code is commented out because it is just an example of the business logic to retrieve products with a similar feature.
> -
> -    // get other cross-sell information: product with a common feature
> -    commonProductFeatureId = "SYMPTOM";
> -    // does this product have that feature?
> -    commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", [productId : productId, productFeatureTypeId : commonProductFeatureId], ["sequenceNum", "defaultSequenceNum"], false);
> -    if (commonProductFeatureAndAppls) {
> -        commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(commonProductFeatureAndAppls, "productFeatureId", true);
> -
> -        // now search for other products that have this feature
> -        visitId = VisitHandler.getVisitId(session);
> -
> -        productSearchConstraintList = [];
> -        productSearchConstraintList.add(new ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
> -        // make sure the view allow category is included
> -        productSearchConstraintList = ProductSearchSession.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator);
> -
> -        // don't care about the sort on this one
> -        resultSortOrder = null;
> -
> -        commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
> -        commonFeatureResultIds = [];
> -        commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator();
> -        while (commonFeatureResultIdIter.hasNext()) {
> -            commonFeatureResultId = commonFeatureResultIdIter.next();
> -            // filter out the current product
> -            if (commonFeatureResultId.equals(productId)) {
> -                continue;
> -            }
> -            // filter out all variants
> -            commonProduct = delegator.findOne("Product", [productId : commonFeatureResultId], true);
> -            if ("Y".equals(commonProduct?.isVariant)) {
> -                continue;
> -            }
> -            commonFeatureResultIds.add(commonFeatureResultId);
> -        }
> -        if (commonFeatureResultIds) {
> -            context.commonFeatureResultIds = commonFeatureResultIds;
> -        }
> -    }
> -    */
> -
>       // get the DIGITAL_DOWNLOAD related Content records to show the contentName/description