You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Stephen Rufle <sr...@salmonllc.com> on 2009/11/18 14:17:10 UTC

Filter duplicates method

I have a query that I think require that I join in such a way that the 
resultset has multiple rows with the same id value.

I would like to do something similar to
org.ofbiz.entity.util.EntityUtil.filterByAnd(List<T>, Map<String, ? 
extends Object>)

but maybe called
EntityUtil.filterDuplicates(List<T> values, Map<String, ? extends 
Object> fields)

Does this type of functionality already exist in ofbiz?


Re: Filter duplicates method

Posted by Rishi Solanki <ri...@gmail.com>.
Hi Stephen,

Till now I used to filter the list by checking the value contains in the
list.
It is not in OFBiz, If done should be good utility method.

Rishi Solanki
Enterprise Software Developer
HotWax Media Pvt. Ltd.


On Wed, Nov 18, 2009 at 6:47 PM, Stephen Rufle <sr...@salmonllc.com> wrote:

> I have a query that I think require that I join in such a way that the
> resultset has multiple rows with the same id value.
>
> I would like to do something similar to
> org.ofbiz.entity.util.EntityUtil.filterByAnd(List<T>, Map<String, ? extends
> Object>)
>
> but maybe called
> EntityUtil.filterDuplicates(List<T> values, Map<String, ? extends Object>
> fields)
>
> Does this type of functionality already exist in ofbiz?
>
>

Re: Filter duplicates method

Posted by Stephen Rufle <sr...@salmonllc.com>.
I looked at
org.ofbiz.entity.util.EntityUtil.getFieldListFromEntityList(List<GenericValue>, 
String, boolean)

I think I used the concept, but am unsure how to generalize so I could 
pass in a Map fields to check uniqueness by.
        List<GenericValue> filteredList = FastList.newInstance();
        Set distinctSet = FastSet.newInstance();
        String filterId = null;
        for (GenericValue gv : listWithDuplicates)
        {
            filterId = gv.getString("someId");
            if (!distinctSet.contains(filterId))
            {
                distinctSet.add(filterId);
                filteredList.add(gv);
            }
        }
        listWithDuplicates.clear();
        listWithDuplicates.addAll(filteredList);


Scott Gray wrote:
> Hi Stephen,
>
> Depending on what you plan on doing with the results you may find the 
> getFieldListFromEntityList(List<GenericValue>, String, boolean) method 
> useful.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 19/11/2009, at 2:17 AM, Stephen Rufle wrote:
>
>> I have a query that I think require that I join in such a way that 
>> the resultset has multiple rows with the same id value.
>>
>> I would like to do something similar to
>> org.ofbiz.entity.util.EntityUtil.filterByAnd(List<T>, Map<String, ? 
>> extends Object>)
>>
>> but maybe called
>> EntityUtil.filterDuplicates(List<T> values, Map<String, ? extends 
>> Object> fields)
>>
>> Does this type of functionality already exist in ofbiz?
>>
>


Re: Filter duplicates method

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Stephen,

Depending on what you plan on doing with the results you may find the  
getFieldListFromEntityList(List<GenericValue>, String, boolean) method  
useful.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 19/11/2009, at 2:17 AM, Stephen Rufle wrote:

> I have a query that I think require that I join in such a way that  
> the resultset has multiple rows with the same id value.
>
> I would like to do something similar to
> org.ofbiz.entity.util.EntityUtil.filterByAnd(List<T>, Map<String, ?  
> extends Object>)
>
> but maybe called
> EntityUtil.filterDuplicates(List<T> values, Map<String, ? extends  
> Object> fields)
>
> Does this type of functionality already exist in ofbiz?
>