Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

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

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
To be clear, I'd like to introduce a dependent dropdows mechanism in widgets.
I'm quite sure it's not easy, not sure it's even feasible at this stage...

Jacques

From: <[hidden email]>

> Author: jleroux
> Date: Thu Jul  1 14:05:21 2010
> New Revision: 959673
>
> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
> Log:
> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product application.
> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
> Freemarker way already used.
>
> Modified:
>    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>
> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
> import org.ofbiz.entity.condition.EntityCondition;
> import org.ofbiz.entity.condition.EntityExpr;
> import org.ofbiz.entity.condition.EntityOperator;
> +import org.ofbiz.entity.util.EntityUtil;
>
> /**
>  * Common Workers
> @@ -135,6 +136,35 @@ public class CommonWorkers {
>         return geoList;
>     }
>
> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
> +        return getAssociatedProductsList(delegator, productCategoryId, null);
> +    }
> +
> +    /**
> +     * Returns a list of active related products for a product category
> +     */
> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String listOrderBy)
> {
> +        List<GenericValue> products = FastList.newInstance();
> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
> +
> +            if (UtilValidate.isEmpty(listOrderBy)) {
> +                listOrderBy = "sequenceNum";
> +            }
> +            List<String> sortList = UtilMisc.toList(listOrderBy);
> +
> +            try {
> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
> +                products = EntityUtil.filterByDate(products);
> +            } catch (GenericEntityException e) {
> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
> +            }
> +        }
> +
> +        return products;
> +    }
> +
>     /**
>      * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>      * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Anil Patel-3
I have complete something similar using javascript. Here is good description and example

http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz-tutorial-dependent-selects-for-prototype/

I am using it for Country/State lists.


Thanks and Regards
Anil Patel
HotWax Media Inc
Find us on the web at www.hotwaxmedia.com or Google Keyword "ofbiz"

On Jul 1, 2010, at 7:47 PM, Jacques Le Roux wrote:

> To be clear, I'd like to introduce a dependent dropdows mechanism in widgets.
> I'm quite sure it's not easy, not sure it's even feasible at this stage...
>
> Jacques
>
> From: <[hidden email]>
>> Author: jleroux
>> Date: Thu Jul  1 14:05:21 2010
>> New Revision: 959673
>>
>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>> Log:
>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product application.
>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>> Freemarker way already used.
>>
>> Modified:
>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>
>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
>> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
>> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
>> import org.ofbiz.entity.condition.EntityCondition;
>> import org.ofbiz.entity.condition.EntityExpr;
>> import org.ofbiz.entity.condition.EntityOperator;
>> +import org.ofbiz.entity.util.EntityUtil;
>>
>> /**
>> * Common Workers
>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>        return geoList;
>>    }
>>
>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>> +    }
>> +
>> +    /**
>> +     * Returns a list of active related products for a product category
>> +     */
>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String listOrderBy)
>> {
>> +        List<GenericValue> products = FastList.newInstance();
>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>> +
>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>> +                listOrderBy = "sequenceNum";
>> +            }
>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>> +
>> +            try {
>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>> +                products = EntityUtil.filterByDate(products);
>> +            } catch (GenericEntityException e) {
>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>> +            }
>> +        }
>> +
>> +        return products;
>> +    }
>> +
>>    /**
>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Scott Gray-2
In reply to this post by Jacques Le Roux
Why is this in common instead of product?  I'm also willing to bet that a method already exists that does this.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 2/07/2010, at 2:05 AM, [hidden email] wrote:

> Author: jleroux
> Date: Thu Jul  1 14:05:21 2010
> New Revision: 959673
>
> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
> Log:
> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product application.
> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the Freemarker way already used.
>
> Modified:
>    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>
> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
> import org.ofbiz.entity.condition.EntityCondition;
> import org.ofbiz.entity.condition.EntityExpr;
> import org.ofbiz.entity.condition.EntityOperator;
> +import org.ofbiz.entity.util.EntityUtil;
>
> /**
>  * Common Workers
> @@ -135,6 +136,35 @@ public class CommonWorkers {
>         return geoList;
>     }
>
> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
> +        return getAssociatedProductsList(delegator, productCategoryId, null);
> +    }
> +
> +    /**
> +     * Returns a list of active related products for a product category
> +     */
> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String listOrderBy) {
> +        List<GenericValue> products = FastList.newInstance();
> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
> +    
> +            if (UtilValidate.isEmpty(listOrderBy)) {
> +                listOrderBy = "sequenceNum";
> +            }
> +            List<String> sortList = UtilMisc.toList(listOrderBy);
> +    
> +            try {
> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
> +                products = EntityUtil.filterByDate(products);
> +            } catch (GenericEntityException e) {
> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
> +            }
> +        }
> +
> +        return products;
> +    }
> +
>     /**
>      * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>      * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
Scott Gray wrote:
> Why is this in common instead of product?

You are very curious :o)

Because I quickly followed the path already opened by getAssociatedStateList.

Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient to
temporary put it there .

>I'm also willing to bet that a method already exists that does this.

I'd more than happy to use it if it already exists, just show me the way...

Jacques

>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>
>> Author: jleroux
>> Date: Thu Jul  1 14:05:21 2010
>> New Revision: 959673
>>
>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>> Log:
>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>> application.
>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>> Freemarker way already used.
>>
>> Modified:
>>    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>
>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>> ============================================================================== ---
>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>> org.ofbiz.entity.GenericValue;
>> import org.ofbiz.entity.condition.EntityCondition;
>> import org.ofbiz.entity.condition.EntityExpr;
>> import org.ofbiz.entity.condition.EntityOperator;
>> +import org.ofbiz.entity.util.EntityUtil;
>>
>> /**
>>  * Common Workers
>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>         return geoList;
>>     }
>>
>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>> +    }
>> +
>> +    /**
>> +     * Returns a list of active related products for a product category
>> +     */
>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>> listOrderBy) { +        List<GenericValue> products = FastList.newInstance();
>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>> +
>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>> +                listOrderBy = "sequenceNum";
>> +            }
>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>> +
>> +            try {
>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>> +                products = EntityUtil.filterByDate(products);
>> +            } catch (GenericEntityException e) {
>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>> +            }
>> +        }
>> +
>> +        return products;
>> +    }
>> +
>>     /**
>>      * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>      * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Scott Gray-2
On 2/07/2010, at 9:05 AM, Jacques Le Roux wrote:

> Scott Gray wrote:
>> Why is this in common instead of product?
>
> You are very curious :o)
>
> Because I quickly followed the path already opened by getAssociatedStateList.

Geo is a framework level entity, that's why a method such as this is in common.

> Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
> I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient to
> temporary put it there .

I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.

>> I'm also willing to bet that a method already exists that does this.
>
> I'd more than happy to use it if it already exists, just show me the way...

Is that really how you intend on proceeding?  Just duplicate functionality as you need to instead of checking if something already exists?  It's not my job to do your work for you.

> Jacques
>
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>>
>>> Author: jleroux
>>> Date: Thu Jul  1 14:05:21 2010
>>> New Revision: 959673
>>>
>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>> Log:
>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>> application.
>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>> Freemarker way already used.
>>>
>>> Modified:
>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>
>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>> ============================================================================== ---
>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>>> org.ofbiz.entity.GenericValue;
>>> import org.ofbiz.entity.condition.EntityCondition;
>>> import org.ofbiz.entity.condition.EntityExpr;
>>> import org.ofbiz.entity.condition.EntityOperator;
>>> +import org.ofbiz.entity.util.EntityUtil;
>>>
>>> /**
>>> * Common Workers
>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>        return geoList;
>>>    }
>>>
>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>> +    }
>>> +
>>> +    /**
>>> +     * Returns a list of active related products for a product category
>>> +     */
>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>> listOrderBy) { +        List<GenericValue> products = FastList.newInstance();
>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>> +
>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>> +                listOrderBy = "sequenceNum";
>>> +            }
>>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>>> +
>>> +            try {
>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>> +                products = EntityUtil.filterByDate(products);
>>> +            } catch (GenericEntityException e) {
>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>> +            }
>>> +        }
>>> +
>>> +        return products;
>>> +    }
>>> +
>>>    /**
>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

BJ Freeman
[ I'm sure it doesn't need to be stated but the trunk is not dumping
ground for you to stash incomplete work in.]
I find that a curious statement since I have seen this type of process
in ofbiz for a long time.

It is also something I commented on, like you, and got told that was the
way it was done



=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation  <http://www.businessesnetwork.com/automation/viewforum.php?f=52>
Specialtymarket.com  <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Scott Gray sent the following on 7/1/2010 2:47 PM:

> On 2/07/2010, at 9:05 AM, Jacques Le Roux wrote:
>
>> Scott Gray wrote:
>>> Why is this in common instead of product?
>>
>> You are very curious :o)
>>
>> Because I quickly followed the path already opened by getAssociatedStateList.
>
> Geo is a framework level entity, that's why a method such as this is in common.
>
>> Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
>> I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient to
>> temporary put it there .
>
> I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.
>
>>> I'm also willing to bet that a method already exists that does this.
>>
>> I'd more than happy to use it if it already exists, just show me the way...
>
> Is that really how you intend on proceeding?  Just duplicate functionality as you need to instead of checking if something already exists?  It's not my job to do your work for you.
>
>> Jacques
>>
>>>
>>> Regards
>>> Scott
>>>
>>> HotWax Media
>>> http://www.hotwaxmedia.com
>>>
>>> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>>>
>>>> Author: jleroux
>>>> Date: Thu Jul  1 14:05:21 2010
>>>> New Revision: 959673
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>> Log:
>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>> application.
>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>> Freemarker way already used.
>>>>
>>>> Modified:
>>>>    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>
>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>> ============================================================================== ---
>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>>>> org.ofbiz.entity.GenericValue;
>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>
>>>> /**
>>>> * Common Workers
>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>         return geoList;
>>>>     }
>>>>
>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns a list of active related products for a product category
>>>> +     */
>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>> listOrderBy) { +        List<GenericValue>  products = FastList.newInstance();
>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>> +
>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>> +                listOrderBy = "sequenceNum";
>>>> +            }
>>>> +            List<String>  sortList = UtilMisc.toList(listOrderBy);
>>>> +
>>>> +            try {
>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>> +                products = EntityUtil.filterByDate(products);
>>>> +            } catch (GenericEntityException e) {
>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>> +            }
>>>> +        }
>>>> +
>>>> +        return products;
>>>> +    }
>>>> +
>>>>     /**
>>>>      * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>      * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Scott Gray-2
On 2/07/2010, at 9:56 AM, BJ Freeman wrote:

> [ I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.]
> I find that a curious statement since I have seen this type of process in ofbiz for a long time.
>
> It is also something I commented on, like you, and got told that was the way it was done

I can't respond to a general statement, if you have a link to your previous discussions I'd be glad to give my opinion.
I have no problem with code being committed even if it's not feature complete, what I do have a problem with is code being rushed in "because I need it in the trunk" (what does that even mean?) and "it was convenient to temporary put it there".

[snip, ever considered shortening your footer?]

>
> Scott Gray sent the following on 7/1/2010 2:47 PM:
>> On 2/07/2010, at 9:05 AM, Jacques Le Roux wrote:
>>
>>> Scott Gray wrote:
>>>> Why is this in common instead of product?
>>>
>>> You are very curious :o)
>>>
>>> Because I quickly followed the path already opened by getAssociatedStateList.
>>
>> Geo is a framework level entity, that's why a method such as this is in common.
>>
>>> Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
>>> I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient to
>>> temporary put it there .
>>
>> I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.
>>
>>>> I'm also willing to bet that a method already exists that does this.
>>>
>>> I'd more than happy to use it if it already exists, just show me the way...
>>
>> Is that really how you intend on proceeding?  Just duplicate functionality as you need to instead of checking if something already exists?  It's not my job to do your work for you.
>>
>>> Jacques
>>>
>>>>
>>>> Regards
>>>> Scott
>>>>
>>>> HotWax Media
>>>> http://www.hotwaxmedia.com
>>>>
>>>> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>>>>
>>>>> Author: jleroux
>>>>> Date: Thu Jul  1 14:05:21 2010
>>>>> New Revision: 959673
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>>> Log:
>>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>>> application.
>>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>>> Freemarker way already used.
>>>>>
>>>>> Modified:
>>>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>
>>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>>> ============================================================================== ---
>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>>>>> org.ofbiz.entity.GenericValue;
>>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>
>>>>> /**
>>>>> * Common Workers
>>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>>        return geoList;
>>>>>    }
>>>>>
>>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns a list of active related products for a product category
>>>>> +     */
>>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>>> listOrderBy) { +        List<GenericValue>  products = FastList.newInstance();
>>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>>> +
>>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>>> +                listOrderBy = "sequenceNum";
>>>>> +            }
>>>>> +            List<String>  sortList = UtilMisc.toList(listOrderBy);
>>>>> +
>>>>> +            try {
>>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>>> +                products = EntityUtil.filterByDate(products);
>>>>> +            } catch (GenericEntityException e) {
>>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>>> +            }
>>>>> +        }
>>>>> +
>>>>> +        return products;
>>>>> +    }
>>>>> +
>>>>>    /**
>>>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>>
>>>
>>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
I reverted at r959943, I will use getCategoryMembers service instead (see comment in commit if interested by details)

Jacques

Scott Gray wrote:

> On 2/07/2010, at 9:56 AM, BJ Freeman wrote:
>
>> [ I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.]
>> I find that a curious statement since I have seen this type of process in ofbiz for a long time.
>>
>> It is also something I commented on, like you, and got told that was the way it was done
>
> I can't respond to a general statement, if you have a link to your previous discussions I'd be glad to give my opinion.
> I have no problem with code being committed even if it's not feature complete, what I do have a problem with is code being rushed
> in "because I need it in the trunk" (what does that even mean?) and "it was convenient to temporary put it there".
>
> [snip, ever considered shortening your footer?]
>
>>
>> Scott Gray sent the following on 7/1/2010 2:47 PM:
>>> On 2/07/2010, at 9:05 AM, Jacques Le Roux wrote:
>>>
>>>> Scott Gray wrote:
>>>>> Why is this in common instead of product?
>>>>
>>>> You are very curious :o)
>>>>
>>>> Because I quickly followed the path already opened by getAssociatedStateList.
>>>
>>> Geo is a framework level entity, that's why a method such as this is in common.
>>>
>>>> Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
>>>> I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient
>>>> to temporary put it there .
>>>
>>> I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.
>>>
>>>>> I'm also willing to bet that a method already exists that does this.
>>>>
>>>> I'd more than happy to use it if it already exists, just show me the way...
>>>
>>> Is that really how you intend on proceeding?  Just duplicate functionality as you need to instead of checking if something
>>> already exists?  It's not my job to do your work for you.
>>>
>>>> Jacques
>>>>
>>>>>
>>>>> Regards
>>>>> Scott
>>>>>
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>>
>>>>> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>>>>>
>>>>>> Author: jleroux
>>>>>> Date: Thu Jul  1 14:05:21 2010
>>>>>> New Revision: 959673
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>>>> Log:
>>>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>>>> application.
>>>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>>>> Freemarker way already used.
>>>>>>
>>>>>> Modified:
>>>>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>>>> ============================================================================== ---
>>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>>>>>> org.ofbiz.entity.GenericValue;
>>>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>>
>>>>>> /**
>>>>>> * Common Workers
>>>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>>>        return geoList;
>>>>>>    }
>>>>>>
>>>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns a list of active related products for a product category
>>>>>> +     */
>>>>>> +    public static List<GenericValue>  getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>>>> listOrderBy) { +        List<GenericValue>  products = FastList.newInstance();
>>>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>>>> +
>>>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>>>> +                listOrderBy = "sequenceNum";
>>>>>> +            }
>>>>>> +            List<String>  sortList = UtilMisc.toList(listOrderBy);
>>>>>> +
>>>>>> +            try {
>>>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>>>> +                products = EntityUtil.filterByDate(products);
>>>>>> +            } catch (GenericEntityException e) {
>>>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>>>> +            }
>>>>>> +        }
>>>>>> +
>>>>>> +        return products;
>>>>>> +    }
>>>>>> +
>>>>>>    /**
>>>>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
In reply to this post by Anil Patel-3
Thanks Anil,

I will consider your work, and I even wonder, now that we want to embedd/replace by jQuery, if we should not do it there (I mean in
the jQuery branch)

For now I have commited a 1st phase at revision: 959951. It already usable without too much work even if all in not completly in
place (due to the fact that, AFAIK, we don't use category/products dependent dropdowns in OFBiz... yet...)

Thanks also to Scott, our scrutinizer! (yes, I learned this word from Zappa's Joe Garage, a long time ago :o)

Jacques

From: "Anil Patel" <[hidden email]>

>I have complete something similar using javascript. Here is good description and example
>
> http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz-tutorial-dependent-selects-for-prototype/
>
> I am using it for Country/State lists.
>
>
> Thanks and Regards
> Anil Patel
> HotWax Media Inc
> Find us on the web at www.hotwaxmedia.com or Google Keyword "ofbiz"
>
> On Jul 1, 2010, at 7:47 PM, Jacques Le Roux wrote:
>
>> To be clear, I'd like to introduce a dependent dropdows mechanism in widgets.
>> I'm quite sure it's not easy, not sure it's even feasible at this stage...
>>
>> Jacques
>>
>> From: <[hidden email]>
>>> Author: jleroux
>>> Date: Thu Jul  1 14:05:21 2010
>>> New Revision: 959673
>>>
>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>> Log:
>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>> application.
>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>> Freemarker way already used.
>>>
>>> Modified:
>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>
>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
>>> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
>>> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
>>> import org.ofbiz.entity.condition.EntityCondition;
>>> import org.ofbiz.entity.condition.EntityExpr;
>>> import org.ofbiz.entity.condition.EntityOperator;
>>> +import org.ofbiz.entity.util.EntityUtil;
>>>
>>> /**
>>> * Common Workers
>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>        return geoList;
>>>    }
>>>
>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>> +    }
>>> +
>>> +    /**
>>> +     * Returns a list of active related products for a product category
>>> +     */
>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>> listOrderBy)
>>> {
>>> +        List<GenericValue> products = FastList.newInstance();
>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>> +
>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>> +                listOrderBy = "sequenceNum";
>>> +            }
>>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>>> +
>>> +            try {
>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>> +                products = EntityUtil.filterByDate(products);
>>> +            } catch (GenericEntityException e) {
>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>> +            }
>>> +        }
>>> +
>>> +        return products;
>>> +    }
>>> +
>>>    /**
>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
Ha... also I wanted to internationalize the service (when they are no products).
I will do it for country/states also...

Jacques

From: "Jacques Le Roux" <[hidden email]>

> Thanks Anil,
>
> I will consider your work, and I even wonder, now that we want to embedd/replace by jQuery, if we should not do it there (I mean
> in the jQuery branch)
>
> For now I have commited a 1st phase at revision: 959951. It already usable without too much work even if all in not completly in
> place (due to the fact that, AFAIK, we don't use category/products dependent dropdowns in OFBiz... yet...)
>
> Thanks also to Scott, our scrutinizer! (yes, I learned this word from Zappa's Joe Garage, a long time ago :o)
>
> Jacques
>
> From: "Anil Patel" <[hidden email]>
>>I have complete something similar using javascript. Here is good description and example
>>
>> http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz-tutorial-dependent-selects-for-prototype/
>>
>> I am using it for Country/State lists.
>>
>>
>> Thanks and Regards
>> Anil Patel
>> HotWax Media Inc
>> Find us on the web at www.hotwaxmedia.com or Google Keyword "ofbiz"
>>
>> On Jul 1, 2010, at 7:47 PM, Jacques Le Roux wrote:
>>
>>> To be clear, I'd like to introduce a dependent dropdows mechanism in widgets.
>>> I'm quite sure it's not easy, not sure it's even feasible at this stage...
>>>
>>> Jacques
>>>
>>> From: <[hidden email]>
>>>> Author: jleroux
>>>> Date: Thu Jul  1 14:05:21 2010
>>>> New Revision: 959673
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>> Log:
>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>> application.
>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>> Freemarker way already used.
>>>>
>>>> Modified:
>>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>
>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
>>>> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
>>>> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>
>>>> /**
>>>> * Common Workers
>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>        return geoList;
>>>>    }
>>>>
>>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns a list of active related products for a product category
>>>> +     */
>>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>> listOrderBy)
>>>> {
>>>> +        List<GenericValue> products = FastList.newInstance();
>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>> +
>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>> +                listOrderBy = "sequenceNum";
>>>> +            }
>>>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>>>> +
>>>> +            try {
>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>> +                products = EntityUtil.filterByDate(products);
>>>> +            } catch (GenericEntityException e) {
>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>> +            }
>>>> +        }
>>>> +
>>>> +        return products;
>>>> +    }
>>>> +
>>>>    /**
>>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Jacques Le Roux
Administrator
Done at r959984

Jacques

From: "Jacques Le Roux" <[hidden email]>

> Ha... also I wanted to internationalize the service (when they are no products).
> I will do it for country/states also...
>
> Jacques
>
> From: "Jacques Le Roux" <[hidden email]>
>> Thanks Anil,
>>
>> I will consider your work, and I even wonder, now that we want to embedd/replace by jQuery, if we should not do it there (I mean
>> in the jQuery branch)
>>
>> For now I have commited a 1st phase at revision: 959951. It already usable without too much work even if all in not completly in
>> place (due to the fact that, AFAIK, we don't use category/products dependent dropdowns in OFBiz... yet...)
>>
>> Thanks also to Scott, our scrutinizer! (yes, I learned this word from Zappa's Joe Garage, a long time ago :o)
>>
>> Jacques
>>
>> From: "Anil Patel" <[hidden email]>
>>>I have complete something similar using javascript. Here is good description and example
>>>
>>> http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz-tutorial-dependent-selects-for-prototype/
>>>
>>> I am using it for Country/State lists.
>>>
>>>
>>> Thanks and Regards
>>> Anil Patel
>>> HotWax Media Inc
>>> Find us on the web at www.hotwaxmedia.com or Google Keyword "ofbiz"
>>>
>>> On Jul 1, 2010, at 7:47 PM, Jacques Le Roux wrote:
>>>
>>>> To be clear, I'd like to introduce a dependent dropdows mechanism in widgets.
>>>> I'm quite sure it's not easy, not sure it's even feasible at this stage...
>>>>
>>>> Jacques
>>>>
>>>> From: <[hidden email]>
>>>>> Author: jleroux
>>>>> Date: Thu Jul  1 14:05:21 2010
>>>>> New Revision: 959673
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>>> Log:
>>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>>> application.
>>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>>> Freemarker way already used.
>>>>>
>>>>> Modified:
>>>>>   ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>
>>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
>>>>> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010
>>>>> @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue;
>>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>
>>>>> /**
>>>>> * Common Workers
>>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>>        return geoList;
>>>>>    }
>>>>>
>>>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns a list of active related products for a product category
>>>>> +     */
>>>>> +    public static List<GenericValue> getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>>> listOrderBy)
>>>>> {
>>>>> +        List<GenericValue> products = FastList.newInstance();
>>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>>> +
>>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>>> +                listOrderBy = "sequenceNum";
>>>>> +            }
>>>>> +            List<String> sortList = UtilMisc.toList(listOrderBy);
>>>>> +
>>>>> +            try {
>>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>>> +                products = EntityUtil.filterByDate(products);
>>>>> +            } catch (GenericEntityException e) {
>>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>>> +            }
>>>>> +        }
>>>>> +
>>>>> +        return products;
>>>>> +    }
>>>>> +
>>>>>    /**
>>>>>     * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>>     * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r959673 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

BJ Freeman
In reply to this post by Scott Gray-2
short enough
:D

=========================
BJ Freeman  <http://bjfreeman.elance.com>
Strategic Power Office with Supplier Automation  <http://www.businessesnetwork.com/automation/viewforum.php?f=52>
Specialtymarket.com  <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man


Scott Gray sent the following on 7/1/2010 3:34 PM:

> On 2/07/2010, at 9:56 AM, BJ Freeman wrote:
>
>> [ I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.]
>> I find that a curious statement since I have seen this type of process in ofbiz for a long time.
>>
>> It is also something I commented on, like you, and got told that was the way it was done
>
> I can't respond to a general statement, if you have a link to your previous discussions I'd be glad to give my opinion.
> I have no problem with code being committed even if it's not feature complete, what I do have a problem with is code being rushed in "because I need it in the trunk" (what does that even mean?) and "it was convenient to temporary put it there".
>
> [snip, ever considered shortening your footer?]
>
>>
>> Scott Gray sent the following on 7/1/2010 2:47 PM:
>>> On 2/07/2010, at 9:05 AM, Jacques Le Roux wrote:
>>>
>>>> Scott Gray wrote:
>>>>> Why is this in common instead of product?
>>>>
>>>> You are very curious :o)
>>>>
>>>> Because I quickly followed the path already opened by getAssociatedStateList.
>>>
>>> Geo is a framework level entity, that's why a method such as this is in common.
>>>
>>>> Tomorrow I will commit the related service and js script in Product and will then move it to Product too.
>>>> I committed as is for now because I had bigger fish to fry this evening but needed this in trunk already and it was convenient to
>>>> temporary put it there .
>>>
>>> I'm sure it doesn't need to be stated but the trunk is not dumping ground for you to stash incomplete work in.
>>>
>>>>> I'm also willing to bet that a method already exists that does this.
>>>>
>>>> I'd more than happy to use it if it already exists, just show me the way...
>>>
>>> Is that really how you intend on proceeding?  Just duplicate functionality as you need to instead of checking if something already exists?  It's not my job to do your work for you.
>>>
>>>> Jacques
>>>>
>>>>>
>>>>> Regards
>>>>> Scott
>>>>>
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>>
>>>>> On 2/07/2010, at 2:05 AM, [hidden email] wrote:
>>>>>
>>>>>> Author: jleroux
>>>>>> Date: Thu Jul  1 14:05:21 2010
>>>>>> New Revision: 959673
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=959673&view=rev
>>>>>> Log:
>>>>>> Adds a getAssociatedProductsList method. I will certainly add the companions service and request later in the Product
>>>>>> application.
>>>>>> I have also the vague desire to generalize this more, as I have been able to quickly use it in a widget form following the
>>>>>> Freemarker way already used.
>>>>>>
>>>>>> Modified:
>>>>>>    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=959673&r1=959672&r2=959673&view=diff
>>>>>> ============================================================================== ---
>>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++
>>>>>> ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Thu Jul  1 14:05:21 2010 @@ -33,6 +33,7 @@ import
>>>>>> org.ofbiz.entity.GenericValue;
>>>>>> import org.ofbiz.entity.condition.EntityCondition;
>>>>>> import org.ofbiz.entity.condition.EntityExpr;
>>>>>> import org.ofbiz.entity.condition.EntityOperator;
>>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>>
>>>>>> /**
>>>>>> * Common Workers
>>>>>> @@ -135,6 +136,35 @@ public class CommonWorkers {
>>>>>>         return geoList;
>>>>>>     }
>>>>>>
>>>>>> +    public static List<GenericValue>   getAssociatedProductsList(Delegator delegator, String productCategoryId) {
>>>>>> +        return getAssociatedProductsList(delegator, productCategoryId, null);
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns a list of active related products for a product category
>>>>>> +     */
>>>>>> +    public static List<GenericValue>   getAssociatedProductsList(Delegator delegator, String productCategoryId, String
>>>>>> listOrderBy) { +        List<GenericValue>   products = FastList.newInstance();
>>>>>> +        if (UtilValidate.isNotEmpty(productCategoryId)) {
>>>>>> +            EntityCondition productsFindCond = EntityCondition.makeCondition(
>>>>>> +                    EntityCondition.makeCondition("productCategoryId", productCategoryId));
>>>>>> +
>>>>>> +            if (UtilValidate.isEmpty(listOrderBy)) {
>>>>>> +                listOrderBy = "sequenceNum";
>>>>>> +            }
>>>>>> +            List<String>   sortList = UtilMisc.toList(listOrderBy);
>>>>>> +
>>>>>> +            try {
>>>>>> +                products = delegator.findList("ProductCategoryMember", productsFindCond, null, sortList, null, true);
>>>>>> +                products = EntityUtil.filterByDate(products);
>>>>>> +            } catch (GenericEntityException e) {
>>>>>> +                Debug.logError(e, "Cannot lookup ProductCategoryMember", module);
>>>>>> +            }
>>>>>> +        }
>>>>>> +
>>>>>> +        return products;
>>>>>> +    }
>>>>>> +
>>>>>>     /**
>>>>>>      * A generic method to be used on Type enities, e.g. ProductType.  Recurse to the root level in the type hierarchy
>>>>>>      * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
>>>>
>>>>
>>>
>>
>