Filter duplicates method

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

Filter duplicates method

Stephen Rufle-2
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?

Reply | Threaded
Open this post in threaded view
|

Re: Filter duplicates method

Rishi Solanki
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 <[hidden email]> 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?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Filter duplicates method

Scott Gray-2
In reply to this post by Stephen Rufle-2
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?
>


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

Re: Filter duplicates method

Stephen Rufle-2
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?
>>
>