[Proposal ]OR search criteria within performFind

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

[Proposal ]OR search criteria within performFind

Gil Portenseigne
Hello,

In a customer project we met a very specific need in a search screen
that offer search criteria that must unions and not intersect.

I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1 but
i'm wondering if any of you ever met such need ?

Is that worth to be commited in the code base ? I tend to say yes, but
i'd like to hear the community out about this.

Thanks !

Gil


Reply | Threaded
Open this post in threaded view
|

Re: [Proposal ]OR search criteria within performFind

taher
Hi, perhaps if you share the idea of how to translate it to the entity
engine conditions then we'd be better informed?

On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
wrote:

> Hello,
>
> In a customer project we met a very specific need in a search screen that
> offer search criteria that must unions and not intersect.
>
> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1 but
> i'm wondering if any of you ever met such need ?
>
> Is that worth to be commited in the code base ? I tend to say yes, but i'd
> like to hear the community out about this.
>
> Thanks !
>
> Gil
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
Yes, actually using form widget with performFind services do not offer a
way to union two search criteria.

Exemple : i want to find all communicationEvent that are in Bounced
status *or* that contains something in note field. (very specific,
strange, thats why)


By default all search criteria are managed in EntityCondition like :

List<EntityCondition> allDefaultSearchCriteria =
UtilMisc.toList(criteria1Condition, criteria2Condition ...);

The resulting final condition would result as :
EntityCondition.makeCondition(allDefaultSearchCriteria, EntityOperator.AND)


With the enhancement, by regrouping two fields with field1_grp =
'groupKey' and field2_grp = 'groupKey'

the following condition is added to the other default ones like :

allDefaultSearchCriteria.add(EntityCondition.makeCondition(UtilMisc.toList(field1Condition,
field2Condition), EntityOperator.OR));

I hope this will be clearer.

On 01/02/2018 21:07, Taher Alkhateeb wrote:

> Hi, perhaps if you share the idea of how to translate it to the entity
> engine conditions then we'd be better informed?
>
> On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
>> Hello,
>>
>> In a customer project we met a very specific need in a search screen that
>> offer search criteria that must unions and not intersect.
>>
>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1 but
>> i'm wondering if any of you ever met such need ?
>>
>> Is that worth to be commited in the code base ? I tend to say yes, but i'd
>> like to hear the community out about this.
>>
>> Thanks !
>>
>> Gil
>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

taher
So it's not some SQL union but rather just a simple "OR" instead of "AND"
for some conditions.

I was actually thinking of this problem recently but not only for two
options but rather multiple options.

To be more specific, our drop-down form widgets have an attribute
"allow-multiple" or something like that which yields a list of values. This
cannot be currently handled by performFind and the other related search
services. So I think having an automatic "OR" on multiple dropdown values
is an important feature to implement and I would give that a +1.

On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]>
wrote:

Yes, actually using form widget with performFind services do not offer a
way to union two search criteria.

Exemple : i want to find all communicationEvent that are in Bounced status
*or* that contains something in note field. (very specific, strange, thats
why)


By default all search criteria are managed in EntityCondition like :

List<EntityCondition> allDefaultSearchCriteria =
UtilMisc.toList(criteria1Condition, criteria2Condition ...);

The resulting final condition would result as :
EntityCondition.makeCondition(allDefaultSearchCriteria, EntityOperator.AND)


With the enhancement, by regrouping two fields with field1_grp = 'groupKey'
and field2_grp = 'groupKey'

the following condition is added to the other default ones like :

allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));

I hope this will be clearer.


On 01/02/2018 21:07, Taher Alkhateeb wrote:

> Hi, perhaps if you share the idea of how to translate it to the entity
> engine conditions then we'd be better informed?
>
> On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
> Hello,
>>
>> In a customer project we met a very specific need in a search screen that
>> offer search criteria that must unions and not intersect.
>>
>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1 but
>> i'm wondering if any of you ever met such need ?
>>
>> Is that worth to be commited in the code base ? I tend to say yes, but i'd
>> like to hear the community out about this.
>>
>> Thanks !
>>
>> Gil
>>
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
Inline


On 02/02/2018 11:04, Taher Alkhateeb wrote:
> So it's not some SQL union but rather just a simple "OR" instead of "AND"
> for some conditions.
Yes it's that simple, but between different fields.
>
> I was actually thinking of this problem recently but not only for two
> options but rather multiple options.
Nice, so we are not alone meeting this issue. This improvement allow the
"OR" to be used between multiple (2 and more) fields conditions (even
multi-select widget). I took 2 for the example, but you can defined many
different groups, that can contains many fields.
>
> To be more specific, our drop-down form widgets have an attribute
> "allow-multiple" or something like that which yields a list of values. This
> cannot be currently handled by performFind and the other related search
> services.
I confirm that performFind works with multi-select fields, if *no
specific operator* is set :

if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  fieldOp = EntityOperator.IN;
 Â Â Â Â Â Â Â Â Â Â Â  } else {
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  fieldOp = EntityOperator.EQUALS;
 Â Â Â Â Â Â Â Â Â Â Â  }

The condition will be  EntityCondition.makeCondition(myField,
EntityOperator.IN, selectedValues)

>   So I think having an automatic "OR" on multiple dropdown values
> is an important feature to implement and I would give that a +1.
The improvement concern OR condition between differents fields :)

Thanks !

Gil

>
> On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]>
> wrote:
>
> Yes, actually using form widget with performFind services do not offer a
> way to union two search criteria.
>
> Exemple : i want to find all communicationEvent that are in Bounced status
> *or* that contains something in note field. (very specific, strange, thats
> why)
>
>
> By default all search criteria are managed in EntityCondition like :
>
> List<EntityCondition> allDefaultSearchCriteria =
> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>
> The resulting final condition would result as :
> EntityCondition.makeCondition(allDefaultSearchCriteria, EntityOperator.AND)
>
>
> With the enhancement, by regrouping two fields with field1_grp = 'groupKey'
> and field2_grp = 'groupKey'
>
> the following condition is added to the other default ones like :
>
> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>
> I hope this will be clearer.
>
>
> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>
>> Hi, perhaps if you share the idea of how to translate it to the entity
>> engine conditions then we'd be better informed?
>>
>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
>> wrote:
>>
>> Hello,
>>> In a customer project we met a very specific need in a search screen that
>>> offer search criteria that must unions and not intersect.
>>>
>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1 but
>>> i'm wondering if any of you ever met such need ?
>>>
>>> Is that worth to be commited in the code base ? I tend to say yes, but i'd
>>> like to hear the community out about this.
>>>
>>> Thanks !
>>>
>>> Gil
>>>
>>>
>>>
>>>

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

taher
Oh okay I understand. Well .. in that case how do you "OR" conditions in
the form? Do you do it selectively or do you want all "OR" or all "AND"?

On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
wrote:

> Inline
>
>
> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>
>> So it's not some SQL union but rather just a simple "OR" instead of "AND"
>> for some conditions.
>>
> Yes it's that simple, but between different fields.
>
>>
>> I was actually thinking of this problem recently but not only for two
>> options but rather multiple options.
>>
> Nice, so we are not alone meeting this issue. This improvement allow the
> "OR" to be used between multiple (2 and more) fields conditions (even
> multi-select widget). I took 2 for the example, but you can defined many
> different groups, that can contains many fields.
>
>>
>> To be more specific, our drop-down form widgets have an attribute
>> "allow-multiple" or something like that which yields a list of values.
>> This
>> cannot be currently handled by performFind and the other related search
>> services.
>>
> I confirm that performFind works with multi-select fields, if *no specific
> operator* is set :
>
> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>                 fieldOp = EntityOperator.IN;
>             } else {
>                 fieldOp = EntityOperator.EQUALS;
>             }
>
> The condition will be  EntityCondition.makeCondition(myField,
> EntityOperator.IN, selectedValues)
>
>   So I think having an automatic "OR" on multiple dropdown values
>> is an important feature to implement and I would give that a +1.
>>
> The improvement concern OR condition between differents fields :)
>
> Thanks !
>
> Gil
>
>
>> On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]>
>> wrote:
>>
>> Yes, actually using form widget with performFind services do not offer a
>> way to union two search criteria.
>>
>> Exemple : i want to find all communicationEvent that are in Bounced status
>> *or* that contains something in note field. (very specific, strange, thats
>> why)
>>
>>
>> By default all search criteria are managed in EntityCondition like :
>>
>> List<EntityCondition> allDefaultSearchCriteria =
>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>
>> The resulting final condition would result as :
>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>> EntityOperator.AND)
>>
>>
>> With the enhancement, by regrouping two fields with field1_grp =
>> 'groupKey'
>> and field2_grp = 'groupKey'
>>
>> the following condition is added to the other default ones like :
>>
>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>
>> I hope this will be clearer.
>>
>>
>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>
>> Hi, perhaps if you share the idea of how to translate it to the entity
>>> engine conditions then we'd be better informed?
>>>
>>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
>>> wrote:
>>>
>>> Hello,
>>>
>>>> In a customer project we met a very specific need in a search screen
>>>> that
>>>> offer search criteria that must unions and not intersect.
>>>>
>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>> but
>>>> i'm wondering if any of you ever met such need ?
>>>>
>>>> Is that worth to be commited in the code base ? I tend to say yes, but
>>>> i'd
>>>> like to hear the community out about this.
>>>>
>>>> Thanks !
>>>>
>>>> Gil
>>>>
>>>>
>>>>
>>>>
>>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
In a widget form to "OR" a condition between x fields you have to :

<field name="field1"><text-find/></field>
<field name="field1_grp"><hidden value="unionKey"/></field>
<field name="field2"><text-find/></field>
<field name="field2_grp"><hidden value="unionKey"/></field>
<field name="field3"><text-find/></field>
<field name="field3_grp"><hidden value="unionKey"/></field>
<field name="field4"><text-find/></field>
<field name="field4_grp"><hidden value="unionKey2"/></field>
<field name="field5"><text-find/></field>
<field name="field5_grp"><hidden value="unionKey2"/></field
<field name="field6"><text-find/></field>
<field name="field7"><text-find/></field>

You'll get

EntityCondition.makeCondition(
 Â Â Â  UtilMisc.toList(field1Condition, field2Condition, field3Condition),
EntityOperator.OR)

EntityCondition.makeCondition(
 Â Â Â  UtilMisc.toList(field4Condition, field5Condition), EntityOperator.OR)

These will be "AND" with the others... (6 and 7)

Indeed that's a bit ugly... but that do the job, and like I said, it's a
pretty rare need.


On 02/02/2018 12:14, Taher Alkhateeb wrote:

> Oh okay I understand. Well .. in that case how do you "OR" conditions in
> the form? Do you do it selectively or do you want all "OR" or all "AND"?
>
> On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
>> Inline
>>
>>
>> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>>
>>> So it's not some SQL union but rather just a simple "OR" instead of "AND"
>>> for some conditions.
>>>
>> Yes it's that simple, but between different fields.
>>
>>> I was actually thinking of this problem recently but not only for two
>>> options but rather multiple options.
>>>
>> Nice, so we are not alone meeting this issue. This improvement allow the
>> "OR" to be used between multiple (2 and more) fields conditions (even
>> multi-select widget). I took 2 for the example, but you can defined many
>> different groups, that can contains many fields.
>>
>>> To be more specific, our drop-down form widgets have an attribute
>>> "allow-multiple" or something like that which yields a list of values.
>>> This
>>> cannot be currently handled by performFind and the other related search
>>> services.
>>>
>> I confirm that performFind works with multi-select fields, if *no specific
>> operator* is set :
>>
>> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>>                  fieldOp = EntityOperator.IN;
>>              } else {
>>                  fieldOp = EntityOperator.EQUALS;
>>              }
>>
>> The condition will be  EntityCondition.makeCondition(myField,
>> EntityOperator.IN, selectedValues)
>>
>>    So I think having an automatic "OR" on multiple dropdown values
>>> is an important feature to implement and I would give that a +1.
>>>
>> The improvement concern OR condition between differents fields :)
>>
>> Thanks !
>>
>> Gil
>>
>>
>>> On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]>
>>> wrote:
>>>
>>> Yes, actually using form widget with performFind services do not offer a
>>> way to union two search criteria.
>>>
>>> Exemple : i want to find all communicationEvent that are in Bounced status
>>> *or* that contains something in note field. (very specific, strange, thats
>>> why)
>>>
>>>
>>> By default all search criteria are managed in EntityCondition like :
>>>
>>> List<EntityCondition> allDefaultSearchCriteria =
>>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>>
>>> The resulting final condition would result as :
>>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>>> EntityOperator.AND)
>>>
>>>
>>> With the enhancement, by regrouping two fields with field1_grp =
>>> 'groupKey'
>>> and field2_grp = 'groupKey'
>>>
>>> the following condition is added to the other default ones like :
>>>
>>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>>
>>> I hope this will be clearer.
>>>
>>>
>>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>>
>>> Hi, perhaps if you share the idea of how to translate it to the entity
>>>> engine conditions then we'd be better informed?
>>>>
>>>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <[hidden email]>
>>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>>> In a customer project we met a very specific need in a search screen
>>>>> that
>>>>> offer search criteria that must unions and not intersect.
>>>>>
>>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>>> but
>>>>> i'm wondering if any of you ever met such need ?
>>>>>
>>>>> Is that worth to be commited in the code base ? I tend to say yes, but
>>>>> i'd
>>>>> like to hear the community out about this.
>>>>>
>>>>> Thanks !
>>>>>
>>>>> Gil
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
I'll try to improve xml widget integration adding a field like :

<field name="field1" group-find-condition="unionKey"><text-find/></field>

WDYT ?


On 02/02/2018 14:16, gil portenseigne wrote:

> In a widget form to "OR" a condition between x fields you have to :
>
> <field name="field1"><text-find/></field>
> <field name="field1_grp"><hidden value="unionKey"/></field>
> <field name="field2"><text-find/></field>
> <field name="field2_grp"><hidden value="unionKey"/></field>
> <field name="field3"><text-find/></field>
> <field name="field3_grp"><hidden value="unionKey"/></field>
> <field name="field4"><text-find/></field>
> <field name="field4_grp"><hidden value="unionKey2"/></field>
> <field name="field5"><text-find/></field>
> <field name="field5_grp"><hidden value="unionKey2"/></field
> <field name="field6"><text-find/></field>
> <field name="field7"><text-find/></field>
>
> You'll get
>
> EntityCondition.makeCondition(
>     UtilMisc.toList(field1Condition, field2Condition,
> field3Condition), EntityOperator.OR)
>
> EntityCondition.makeCondition(
>     UtilMisc.toList(field4Condition, field5Condition), EntityOperator.OR)
>
> These will be "AND" with the others... (6 and 7)
>
> Indeed that's a bit ugly... but that do the job, and like I said, it's
> a pretty rare need.
>
>
> On 02/02/2018 12:14, Taher Alkhateeb wrote:
>> Oh okay I understand. Well .. in that case how do you "OR" conditions in
>> the form? Do you do it selectively or do you want all "OR" or all "AND"?
>>
>> On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
>> wrote:
>>
>>> Inline
>>>
>>>
>>> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>>>
>>>> So it's not some SQL union but rather just a simple "OR" instead of
>>>> "AND"
>>>> for some conditions.
>>>>
>>> Yes it's that simple, but between different fields.
>>>
>>>> I was actually thinking of this problem recently but not only for two
>>>> options but rather multiple options.
>>>>
>>> Nice, so we are not alone meeting this issue. This improvement allow
>>> the
>>> "OR" to be used between multiple (2 and more) fields conditions (even
>>> multi-select widget). I took 2 for the example, but you can defined
>>> many
>>> different groups, that can contains many fields.
>>>
>>>> To be more specific, our drop-down form widgets have an attribute
>>>> "allow-multiple" or something like that which yields a list of values.
>>>> This
>>>> cannot be currently handled by performFind and the other related
>>>> search
>>>> services.
>>>>
>>> I confirm that performFind works with multi-select fields, if *no
>>> specific
>>> operator* is set :
>>>
>>> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>>>                  fieldOp = EntityOperator.IN;
>>>              } else {
>>>                  fieldOp = EntityOperator.EQUALS;
>>>              }
>>>
>>> The condition will be  EntityCondition.makeCondition(myField,
>>> EntityOperator.IN, selectedValues)
>>>
>>>    So I think having an automatic "OR" on multiple dropdown values
>>>> is an important feature to implement and I would give that a +1.
>>>>
>>> The improvement concern OR condition between differents fields :)
>>>
>>> Thanks !
>>>
>>> Gil
>>>
>>>
>>>> On Feb 2, 2018 11:44 AM, "gil portenseigne"
>>>> <[hidden email]>
>>>> wrote:
>>>>
>>>> Yes, actually using form widget with performFind services do not
>>>> offer a
>>>> way to union two search criteria.
>>>>
>>>> Exemple : i want to find all communicationEvent that are in Bounced
>>>> status
>>>> *or* that contains something in note field. (very specific,
>>>> strange, thats
>>>> why)
>>>>
>>>>
>>>> By default all search criteria are managed in EntityCondition like :
>>>>
>>>> List<EntityCondition> allDefaultSearchCriteria =
>>>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>>>
>>>> The resulting final condition would result as :
>>>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>>>> EntityOperator.AND)
>>>>
>>>>
>>>> With the enhancement, by regrouping two fields with field1_grp =
>>>> 'groupKey'
>>>> and field2_grp = 'groupKey'
>>>>
>>>> the following condition is added to the other default ones like :
>>>>
>>>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>>>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>>>
>>>> I hope this will be clearer.
>>>>
>>>>
>>>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>>>
>>>> Hi, perhaps if you share the idea of how to translate it to the entity
>>>>> engine conditions then we'd be better informed?
>>>>>
>>>>> On Feb 1, 2018 6:30 PM, "gil portenseigne"
>>>>> <[hidden email]>
>>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>>> In a customer project we met a very specific need in a search screen
>>>>>> that
>>>>>> offer search criteria that must unions and not intersect.
>>>>>>
>>>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>>>> but
>>>>>> i'm wondering if any of you ever met such need ?
>>>>>>
>>>>>> Is that worth to be commited in the code base ? I tend to say
>>>>>> yes, but
>>>>>> i'd
>>>>>> like to hear the community out about this.
>>>>>>
>>>>>> Thanks !
>>>>>>
>>>>>> Gil
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

taher
May I try to share a design that might be a bit more generic? Here is one
idea:

<field name="field1" search-group="group1"><text-find/></field>
<field name="field2" search-group="group1"><text-find/></field>
<field name="field3" search-group="group2"><text-find/></field>
<field name="field4" search-group="group2"><text-find/></field>

Then we change the find services so that each group "AND" its members and
the groups are "OR"ed together.

So in this example the find service would have the condition: (field1 AND
field2) OR (field3 AND field4)

I think this is simple enough but maybe provides more flexibility?

On Feb 2, 2018 4:22 PM, "gil portenseigne" <[hidden email]>
wrote:

I'll try to improve xml widget integration adding a field like :

<field name="field1" group-find-condition="unionKey"><text-find/></field>

WDYT ?



On 02/02/2018 14:16, gil portenseigne wrote:

> In a widget form to "OR" a condition between x fields you have to :
>
> <field name="field1"><text-find/></field>
> <field name="field1_grp"><hidden value="unionKey"/></field>
> <field name="field2"><text-find/></field>
> <field name="field2_grp"><hidden value="unionKey"/></field>
> <field name="field3"><text-find/></field>
> <field name="field3_grp"><hidden value="unionKey"/></field>
> <field name="field4"><text-find/></field>
> <field name="field4_grp"><hidden value="unionKey2"/></field>
> <field name="field5"><text-find/></field>
> <field name="field5_grp"><hidden value="unionKey2"/></field
> <field name="field6"><text-find/></field>
> <field name="field7"><text-find/></field>
>
> You'll get
>
> EntityCondition.makeCondition(
>     UtilMisc.toList(field1Condition, field2Condition, field3Condition),
> EntityOperator.OR)
>
> EntityCondition.makeCondition(
>     UtilMisc.toList(field4Condition, field5Condition), EntityOperator.OR)
>
> These will be "AND" with the others... (6 and 7)
>
> Indeed that's a bit ugly... but that do the job, and like I said, it's a
> pretty rare need.
>
>
> On 02/02/2018 12:14, Taher Alkhateeb wrote:
>
>> Oh okay I understand. Well .. in that case how do you "OR" conditions in
>> the form? Do you do it selectively or do you want all "OR" or all "AND"?
>>
>> On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
>> wrote:
>>
>> Inline
>>>
>>>
>>> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>>>
>>> So it's not some SQL union but rather just a simple "OR" instead of "AND"
>>>> for some conditions.
>>>>
>>>> Yes it's that simple, but between different fields.
>>>
>>> I was actually thinking of this problem recently but not only for two
>>>> options but rather multiple options.
>>>>
>>>> Nice, so we are not alone meeting this issue. This improvement allow the
>>> "OR" to be used between multiple (2 and more) fields conditions (even
>>> multi-select widget). I took 2 for the example, but you can defined many
>>> different groups, that can contains many fields.
>>>
>>> To be more specific, our drop-down form widgets have an attribute
>>>> "allow-multiple" or something like that which yields a list of values.
>>>> This
>>>> cannot be currently handled by performFind and the other related search
>>>> services.
>>>>
>>>> I confirm that performFind works with multi-select fields, if *no
>>> specific
>>> operator* is set :
>>>
>>> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>>>                  fieldOp = EntityOperator.IN;
>>>              } else {
>>>                  fieldOp = EntityOperator.EQUALS;
>>>              }
>>>
>>> The condition will be  EntityCondition.makeCondition(myField,
>>> EntityOperator.IN, selectedValues)
>>>
>>>    So I think having an automatic "OR" on multiple dropdown values
>>>
>>>> is an important feature to implement and I would give that a +1.
>>>>
>>>> The improvement concern OR condition between differents fields :)
>>>
>>> Thanks !
>>>
>>> Gil
>>>
>>>
>>> On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]
>>>> >
>>>> wrote:
>>>>
>>>> Yes, actually using form widget with performFind services do not offer a
>>>> way to union two search criteria.
>>>>
>>>> Exemple : i want to find all communicationEvent that are in Bounced
>>>> status
>>>> *or* that contains something in note field. (very specific, strange,
>>>> thats
>>>> why)
>>>>
>>>>
>>>> By default all search criteria are managed in EntityCondition like :
>>>>
>>>> List<EntityCondition> allDefaultSearchCriteria =
>>>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>>>
>>>> The resulting final condition would result as :
>>>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>>>> EntityOperator.AND)
>>>>
>>>>
>>>> With the enhancement, by regrouping two fields with field1_grp =
>>>> 'groupKey'
>>>> and field2_grp = 'groupKey'
>>>>
>>>> the following condition is added to the other default ones like :
>>>>
>>>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>>>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>>>
>>>> I hope this will be clearer.
>>>>
>>>>
>>>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>>>
>>>> Hi, perhaps if you share the idea of how to translate it to the entity
>>>>
>>>>> engine conditions then we'd be better informed?
>>>>>
>>>>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <
>>>>> [hidden email]>
>>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> In a customer project we met a very specific need in a search screen
>>>>>> that
>>>>>> offer search criteria that must unions and not intersect.
>>>>>>
>>>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>>>> but
>>>>>> i'm wondering if any of you ever met such need ?
>>>>>>
>>>>>> Is that worth to be commited in the code base ? I tend to say yes, but
>>>>>> i'd
>>>>>> like to hear the community out about this.
>>>>>>
>>>>>> Thanks !
>>>>>>
>>>>>> Gil
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
Ok then I see the limitation of my implementation ! I can't solve your
example...

But the existing default behaviour in performFind is "AND"ed every
conditions (that is the more common way to search something in my
opinion, each user input restrain the result).

That make this design impossible without adding another key or changing
global logic of performFind service, which I guess is not really what we
want.

I think managing more complex cases (like the one you gave me) without
rewriting the performFind could be too complicate, and i'd propose
another way to solve such needs.

We could add the ability to put an EntityCondition in inputFields map
that will be specified in a script just before calling performFind service.
This entityCondition will be "AND"ed to the default ones (i already got
a working patch with unit test working :) ).

Then we willl get for simple OR condition a way to do it within widget,
and for more complex case, resolve it through specific script/action.

On 02/02/2018 15:47, Taher Alkhateeb wrote:

> May I try to share a design that might be a bit more generic? Here is one
> idea:
>
> <field name="field1" search-group="group1"><text-find/></field>
> <field name="field2" search-group="group1"><text-find/></field>
> <field name="field3" search-group="group2"><text-find/></field>
> <field name="field4" search-group="group2"><text-find/></field>
>
> Then we change the find services so that each group "AND" its members and
> the groups are "OR"ed together.
>
> So in this example the find service would have the condition: (field1 AND
> field2) OR (field3 AND field4)
>
> I think this is simple enough but maybe provides more flexibility?
>
> On Feb 2, 2018 4:22 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
> I'll try to improve xml widget integration adding a field like :
>
> <field name="field1" group-find-condition="unionKey"><text-find/></field>
>
> WDYT ?
>
>
>
> On 02/02/2018 14:16, gil portenseigne wrote:
>
>> In a widget form to "OR" a condition between x fields you have to :
>>
>> <field name="field1"><text-find/></field>
>> <field name="field1_grp"><hidden value="unionKey"/></field>
>> <field name="field2"><text-find/></field>
>> <field name="field2_grp"><hidden value="unionKey"/></field>
>> <field name="field3"><text-find/></field>
>> <field name="field3_grp"><hidden value="unionKey"/></field>
>> <field name="field4"><text-find/></field>
>> <field name="field4_grp"><hidden value="unionKey2"/></field>
>> <field name="field5"><text-find/></field>
>> <field name="field5_grp"><hidden value="unionKey2"/></field
>> <field name="field6"><text-find/></field>
>> <field name="field7"><text-find/></field>
>>
>> You'll get
>>
>> EntityCondition.makeCondition(
>>      UtilMisc.toList(field1Condition, field2Condition, field3Condition),
>> EntityOperator.OR)
>>
>> EntityCondition.makeCondition(
>>      UtilMisc.toList(field4Condition, field5Condition), EntityOperator.OR)
>>
>> These will be "AND" with the others... (6 and 7)
>>
>> Indeed that's a bit ugly... but that do the job, and like I said, it's a
>> pretty rare need.
>>
>>
>> On 02/02/2018 12:14, Taher Alkhateeb wrote:
>>
>>> Oh okay I understand. Well .. in that case how do you "OR" conditions in
>>> the form? Do you do it selectively or do you want all "OR" or all "AND"?
>>>
>>> On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
>>> wrote:
>>>
>>> Inline
>>>>
>>>> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>>>>
>>>> So it's not some SQL union but rather just a simple "OR" instead of "AND"
>>>>> for some conditions.
>>>>>
>>>>> Yes it's that simple, but between different fields.
>>>> I was actually thinking of this problem recently but not only for two
>>>>> options but rather multiple options.
>>>>>
>>>>> Nice, so we are not alone meeting this issue. This improvement allow the
>>>> "OR" to be used between multiple (2 and more) fields conditions (even
>>>> multi-select widget). I took 2 for the example, but you can defined many
>>>> different groups, that can contains many fields.
>>>>
>>>> To be more specific, our drop-down form widgets have an attribute
>>>>> "allow-multiple" or something like that which yields a list of values.
>>>>> This
>>>>> cannot be currently handled by performFind and the other related search
>>>>> services.
>>>>>
>>>>> I confirm that performFind works with multi-select fields, if *no
>>>> specific
>>>> operator* is set :
>>>>
>>>> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>>>>                   fieldOp = EntityOperator.IN;
>>>>               } else {
>>>>                   fieldOp = EntityOperator.EQUALS;
>>>>               }
>>>>
>>>> The condition will be  EntityCondition.makeCondition(myField,
>>>> EntityOperator.IN, selectedValues)
>>>>
>>>>     So I think having an automatic "OR" on multiple dropdown values
>>>>
>>>>> is an important feature to implement and I would give that a +1.
>>>>>
>>>>> The improvement concern OR condition between differents fields :)
>>>> Thanks !
>>>>
>>>> Gil
>>>>
>>>>
>>>> On Feb 2, 2018 11:44 AM, "gil portenseigne" <[hidden email]
>>>>> wrote:
>>>>>
>>>>> Yes, actually using form widget with performFind services do not offer a
>>>>> way to union two search criteria.
>>>>>
>>>>> Exemple : i want to find all communicationEvent that are in Bounced
>>>>> status
>>>>> *or* that contains something in note field. (very specific, strange,
>>>>> thats
>>>>> why)
>>>>>
>>>>>
>>>>> By default all search criteria are managed in EntityCondition like :
>>>>>
>>>>> List<EntityCondition> allDefaultSearchCriteria =
>>>>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>>>>
>>>>> The resulting final condition would result as :
>>>>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>>>>> EntityOperator.AND)
>>>>>
>>>>>
>>>>> With the enhancement, by regrouping two fields with field1_grp =
>>>>> 'groupKey'
>>>>> and field2_grp = 'groupKey'
>>>>>
>>>>> the following condition is added to the other default ones like :
>>>>>
>>>>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>>>>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>>>>
>>>>> I hope this will be clearer.
>>>>>
>>>>>
>>>>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>>>>
>>>>> Hi, perhaps if you share the idea of how to translate it to the entity
>>>>>
>>>>>> engine conditions then we'd be better informed?
>>>>>>
>>>>>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <
>>>>>> [hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> In a customer project we met a very specific need in a search screen
>>>>>>> that
>>>>>>> offer search criteria that must unions and not intersect.
>>>>>>>
>>>>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>>>>> but
>>>>>>> i'm wondering if any of you ever met such need ?
>>>>>>>
>>>>>>> Is that worth to be commited in the code base ? I tend to say yes, but
>>>>>>> i'd
>>>>>>> like to hear the community out about this.
>>>>>>>
>>>>>>> Thanks !
>>>>>>>
>>>>>>> Gil
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

taher
Hi Gil, inline ...

On Feb 2, 2018 6:55 PM, "gil portenseigne" <[hidden email]>
wrote:

Ok then I see the limitation of my implementation ! I can't solve your
example...

But the existing default behaviour in performFind is "AND"ed every
conditions (that is the more common way to search something in my opinion,
each user input restrain the result).

Yes absolutely, and perhaps we should keep the default behavior the way it
is without even altering the logic.


That make this design impossible without adding another key or changing
global logic of performFind service, which I guess is not really what we
want.

Not really, you just add an if condition to check if any search groups
exist, and if they do then apply the additional search logic.


I think managing more complex cases (like the one you gave me) without
rewriting the performFind could be too complicate, and i'd propose another
way to solve such needs.

If you like I can help out, but I actually think it is not too complex to
apply the logic in my proposal, and you will have a permanent powerful
solution where you can design complex custom search and dashboard screens.
I can already imagine most of the implementation in a few lines of code,
and it would help us refactor the code base.


We could add the ability to put an EntityCondition in inputFields map that
will be specified in a script just before calling performFind service.
This entityCondition will be "AND"ed to the default ones (i already got a
working patch with unit test working :) ).

Interesting, let's take a look at that then, maybe you have a simpler
powerful solution.


Then we willl get for simple OR condition a way to do it within widget, and
for more complex case, resolve it through specific script/action.

Cool, I'll wait for your work, if you need extra hands for anything just
holler.



On 02/02/2018 15:47, Taher Alkhateeb wrote:

> May I try to share a design that might be a bit more generic? Here is one
> idea:
>
> <field name="field1" search-group="group1"><text-find/></field>
> <field name="field2" search-group="group1"><text-find/></field>
> <field name="field3" search-group="group2"><text-find/></field>
> <field name="field4" search-group="group2"><text-find/></field>
>
> Then we change the find services so that each group "AND" its members and
> the groups are "OR"ed together.
>
> So in this example the find service would have the condition: (field1 AND
> field2) OR (field3 AND field4)
>
> I think this is simple enough but maybe provides more flexibility?
>
> On Feb 2, 2018 4:22 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
> I'll try to improve xml widget integration adding a field like :
>
> <field name="field1" group-find-condition="unionKey"><text-find/></field>
>
> WDYT ?
>
>
>
> On 02/02/2018 14:16, gil portenseigne wrote:
>
> In a widget form to "OR" a condition between x fields you have to :
>>
>> <field name="field1"><text-find/></field>
>> <field name="field1_grp"><hidden value="unionKey"/></field>
>> <field name="field2"><text-find/></field>
>> <field name="field2_grp"><hidden value="unionKey"/></field>
>> <field name="field3"><text-find/></field>
>> <field name="field3_grp"><hidden value="unionKey"/></field>
>> <field name="field4"><text-find/></field>
>> <field name="field4_grp"><hidden value="unionKey2"/></field>
>> <field name="field5"><text-find/></field>
>> <field name="field5_grp"><hidden value="unionKey2"/></field
>> <field name="field6"><text-find/></field>
>> <field name="field7"><text-find/></field>
>>
>> You'll get
>>
>> EntityCondition.makeCondition(
>>      UtilMisc.toList(field1Condition, field2Condition, field3Condition),
>> EntityOperator.OR)
>>
>> EntityCondition.makeCondition(
>>      UtilMisc.toList(field4Condition, field5Condition),
>> EntityOperator.OR)
>>
>> These will be "AND" with the others... (6 and 7)
>>
>> Indeed that's a bit ugly... but that do the job, and like I said, it's a
>> pretty rare need.
>>
>>
>> On 02/02/2018 12:14, Taher Alkhateeb wrote:
>>
>> Oh okay I understand. Well .. in that case how do you "OR" conditions in
>>> the form? Do you do it selectively or do you want all "OR" or all "AND"?
>>>
>>> On Feb 2, 2018 1:26 PM, "gil portenseigne" <[hidden email]>
>>> wrote:
>>>
>>> Inline
>>>
>>>>
>>>> On 02/02/2018 11:04, Taher Alkhateeb wrote:
>>>>
>>>> So it's not some SQL union but rather just a simple "OR" instead of
>>>> "AND"
>>>>
>>>>> for some conditions.
>>>>>
>>>>> Yes it's that simple, but between different fields.
>>>>>
>>>> I was actually thinking of this problem recently but not only for two
>>>>
>>>>> options but rather multiple options.
>>>>>
>>>>> Nice, so we are not alone meeting this issue. This improvement allow
>>>>> the
>>>>>
>>>> "OR" to be used between multiple (2 and more) fields conditions (even
>>>> multi-select widget). I took 2 for the example, but you can defined many
>>>> different groups, that can contains many fields.
>>>>
>>>> To be more specific, our drop-down form widgets have an attribute
>>>>
>>>>> "allow-multiple" or something like that which yields a list of values.
>>>>> This
>>>>> cannot be currently handled by performFind and the other related search
>>>>> services.
>>>>>
>>>>> I confirm that performFind works with multi-select fields, if *no
>>>>>
>>>> specific
>>>> operator* is set :
>>>>
>>>> if(UtilValidate.isNotEmpty(UtilGenerics.toList(fieldValue))){
>>>>                   fieldOp = EntityOperator.IN;
>>>>               } else {
>>>>                   fieldOp = EntityOperator.EQUALS;
>>>>               }
>>>>
>>>> The condition will be  EntityCondition.makeCondition(myField,
>>>> EntityOperator.IN, selectedValues)
>>>>
>>>>     So I think having an automatic "OR" on multiple dropdown values
>>>>
>>>> is an important feature to implement and I would give that a +1.
>>>>>
>>>>> The improvement concern OR condition between differents fields :)
>>>>>
>>>> Thanks !
>>>>
>>>> Gil
>>>>
>>>>
>>>> On Feb 2, 2018 11:44 AM, "gil portenseigne" <
>>>> [hidden email]
>>>>
>>>>> wrote:
>>>>>
>>>>> Yes, actually using form widget with performFind services do not offer
>>>>> a
>>>>> way to union two search criteria.
>>>>>
>>>>> Exemple : i want to find all communicationEvent that are in Bounced
>>>>> status
>>>>> *or* that contains something in note field. (very specific, strange,
>>>>> thats
>>>>> why)
>>>>>
>>>>>
>>>>> By default all search criteria are managed in EntityCondition like :
>>>>>
>>>>> List<EntityCondition> allDefaultSearchCriteria =
>>>>> UtilMisc.toList(criteria1Condition, criteria2Condition ...);
>>>>>
>>>>> The resulting final condition would result as :
>>>>> EntityCondition.makeCondition(allDefaultSearchCriteria,
>>>>> EntityOperator.AND)
>>>>>
>>>>>
>>>>> With the enhancement, by regrouping two fields with field1_grp =
>>>>> 'groupKey'
>>>>> and field2_grp = 'groupKey'
>>>>>
>>>>> the following condition is added to the other default ones like :
>>>>>
>>>>> allDefaultSearchCriteria.add(EntityCondition.makeCondition(U
>>>>> tilMisc.toList(field1Condition, field2Condition), EntityOperator.OR));
>>>>>
>>>>> I hope this will be clearer.
>>>>>
>>>>>
>>>>> On 01/02/2018 21:07, Taher Alkhateeb wrote:
>>>>>
>>>>> Hi, perhaps if you share the idea of how to translate it to the entity
>>>>>
>>>>> engine conditions then we'd be better informed?
>>>>>>
>>>>>> On Feb 1, 2018 6:30 PM, "gil portenseigne" <
>>>>>> [hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> In a customer project we met a very specific need in a search screen
>>>>>>
>>>>>>> that
>>>>>>> offer search criteria that must unions and not intersect.
>>>>>>>
>>>>>>> I propose this improvement in OFBIZ-10195, https://s.apache.org/sjW1
>>>>>>> but
>>>>>>> i'm wondering if any of you ever met such need ?
>>>>>>>
>>>>>>> Is that worth to be commited in the code base ? I tend to say yes,
>>>>>>> but
>>>>>>> i'd
>>>>>>> like to hear the community out about this.
>>>>>>>
>>>>>>> Thanks !
>>>>>>>
>>>>>>> Gil
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Gil Portenseigne
After reanalysing the performFind mechanism, i realized that i was
mistaken and just write down the logic you proposed, i will make it
available for review, with I hope a little test, when i'll find the time.

Just letting you know i am on it :).

Gil


On 03/02/2018 10:17, Taher Alkhateeb wrote:
> Not really, you just add an if condition to check if any search groups
> exist, and if they do then apply the additional search logic.

Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

taher
Awesome Gil, you rock! Rubbing hands in anticipation :)

On Feb 7, 2018 1:52 PM, "gil portenseigne" <[hidden email]>
wrote:

After reanalysing the performFind mechanism, i realized that i was mistaken
and just write down the logic you proposed, i will make it available for
review, with I hope a little test, when i'll find the time.

Just letting you know i am on it :).

Gil



On 03/02/2018 10:17, Taher Alkhateeb wrote:

> Not really, you just add an if condition to check if any search groups
> exist, and if they do then apply the additional search logic.
>
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] OR search criteria within performFind

Scott Gray-3
A little bit off topic but I recently wrote an EntityCondition converter
for use with the rsql-parser[1] library.  Using it on an html client to
write free-form queries would need some javascript wizardry but it's worth
looking at if we ever wanted to implement something like Jira's JQL
capability.

Regards
Scott

[1] https://github.com/jirutka/rsql-parser

On 8 February 2018 at 00:11, Taher Alkhateeb <[hidden email]>
wrote:

> Awesome Gil, you rock! Rubbing hands in anticipation :)
>
> On Feb 7, 2018 1:52 PM, "gil portenseigne" <[hidden email]>
> wrote:
>
> After reanalysing the performFind mechanism, i realized that i was mistaken
> and just write down the logic you proposed, i will make it available for
> review, with I hope a little test, when i'll find the time.
>
> Just letting you know i am on it :).
>
> Gil
>
>
>
> On 03/02/2018 10:17, Taher Alkhateeb wrote:
>
> > Not really, you just add an if condition to check if any search groups
> > exist, and if they do then apply the additional search logic.
> >
>