You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@unomi.apache.org by Michael Ghen <mi...@mikeghen.com> on 2018/11/11 21:31:48 UTC

Rule Evaluation Problem

Hello again,

I am trying to get a proof of concept setup and I'm really struggling with
how rules work. It seems that this simple rule is not being evaluated and
I've tried a lot of combinations but still this won't perform as expected,
I was hoping someone could just glance at the JSON I'm working with and let
me know if there's something I'm missing.

I have a rule and a profile attached and I don't understand why the rule
work update the property on the profile as expected. I've tried to make
updated to the annualIncome property thinking it would trigger the rule but
that doesn't seem to work.

I would like to provide more docs to this project but I can't seem to
figure any of the features beyond updating profiles out enough to document
them.

Please let me know what you think of this profile and rule, I expected the
eligibility property to be set to "yes" for the profile.

Re: Rule Evaluation Problem

Posted by Serge Huber <sh...@apache.org>.
It should work as you expected. You can have a look at the code here :

https://github.com/apache/incubator-unomi/blob/769129894feee8452e95df163c9807e87c606122/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java

Regards,
  Serge

On Tue, Nov 13, 2018 at 12:07 AM Michael Ghen <mi...@mikeghen.com> wrote:
>
> I think the main thing was I had the clause backwards, seems to work when I went to “greaterThan”
>
> Yes, the Int was a mistake too, thanks so much for looking it over
>
> On Mon, Nov 12, 2018 at 12:33 PM Serge Huber <sh...@apache.org> wrote:
>>
>> It should work as you expect in the first scenario, but I noticed that
>> you use propertyValueInt instead of propertyValueInteger. Maybe this
>> is the problem ?
>>
>> Regards,
>>   Serge...
>> On Sun, Nov 11, 2018 at 11:11 PM Michael Ghen <mi...@mikeghen.com> wrote:
>> >
>> > I think I may have figured out why this wasn't working after playing some more.
>> >
>> > First, I went to just and "exists" comparisonOperator to simplify that. Then, I added a profileUpdatedEventCondition to my condition. These two conditions work and my action occured.
>> >
>> > Second thing, I realize the lessThan and greaterThan must work backward to how I expected it.
>> >
>> > For example, consider properties.annualIncome = 4800. I expected that this condition would be true:
>> >
>> >        {
>> >           "parameterValues": {
>> >             "propertyName": "properties.annualIncome",
>> >             "comparisonOperator": "lessThan",
>> >             "propertyValueInt": 12000
>> >           },
>> >           "type": "profilePropertyCondition"
>> >         }
>> >
>> > Really this must be: "12000 < properties.annualncomes == False"
>> >
>> > When I switch to greaterThan, suddenly everything work: "12000 > properties.annualIncomes == True"
>> >
>> > So I had to do to things: 1) invert the comparisonOperator and 2) add a subcondition for profileUpdatedEventCondition. Not sure why this worked but it seems to work OK.
>> >
>> > On Sun, Nov 11, 2018 at 4:31 PM Michael Ghen <mi...@mikeghen.com> wrote:
>> >>
>> >> Hello again,
>> >>
>> >> I am trying to get a proof of concept setup and I'm really struggling with how rules work. It seems that this simple rule is not being evaluated and I've tried a lot of combinations but still this won't perform as expected, I was hoping someone could just glance at the JSON I'm working with and let me know if there's something I'm missing.
>> >>
>> >> I have a rule and a profile attached and I don't understand why the rule work update the property on the profile as expected. I've tried to make updated to the annualIncome property thinking it would trigger the rule but that doesn't seem to work.
>> >>
>> >> I would like to provide more docs to this project but I can't seem to figure any of the features beyond updating profiles out enough to document them.
>> >>
>> >> Please let me know what you think of this profile and rule, I expected the eligibility property to be set to "yes" for the profile.
>> >>

Re: Rule Evaluation Problem

Posted by Michael Ghen <mi...@mikeghen.com>.
I think the main thing was I had the clause backwards, seems to work when I
went to “greaterThan”

Yes, the Int was a mistake too, thanks so much for looking it over

On Mon, Nov 12, 2018 at 12:33 PM Serge Huber <sh...@apache.org> wrote:

> It should work as you expect in the first scenario, but I noticed that
> you use propertyValueInt instead of propertyValueInteger. Maybe this
> is the problem ?
>
> Regards,
>   Serge...
> On Sun, Nov 11, 2018 at 11:11 PM Michael Ghen <mi...@mikeghen.com> wrote:
> >
> > I think I may have figured out why this wasn't working after playing
> some more.
> >
> > First, I went to just and "exists" comparisonOperator to simplify that.
> Then, I added a profileUpdatedEventCondition to my condition. These two
> conditions work and my action occured.
> >
> > Second thing, I realize the lessThan and greaterThan must work backward
> to how I expected it.
> >
> > For example, consider properties.annualIncome = 4800. I expected that
> this condition would be true:
> >
> >        {
> >           "parameterValues": {
> >             "propertyName": "properties.annualIncome",
> >             "comparisonOperator": "lessThan",
> >             "propertyValueInt": 12000
> >           },
> >           "type": "profilePropertyCondition"
> >         }
> >
> > Really this must be: "12000 < properties.annualncomes == False"
> >
> > When I switch to greaterThan, suddenly everything work: "12000 >
> properties.annualIncomes == True"
> >
> > So I had to do to things: 1) invert the comparisonOperator and 2) add a
> subcondition for profileUpdatedEventCondition. Not sure why this worked but
> it seems to work OK.
> >
> > On Sun, Nov 11, 2018 at 4:31 PM Michael Ghen <mi...@mikeghen.com> wrote:
> >>
> >> Hello again,
> >>
> >> I am trying to get a proof of concept setup and I'm really struggling
> with how rules work. It seems that this simple rule is not being evaluated
> and I've tried a lot of combinations but still this won't perform as
> expected, I was hoping someone could just glance at the JSON I'm working
> with and let me know if there's something I'm missing.
> >>
> >> I have a rule and a profile attached and I don't understand why the
> rule work update the property on the profile as expected. I've tried to
> make updated to the annualIncome property thinking it would trigger the
> rule but that doesn't seem to work.
> >>
> >> I would like to provide more docs to this project but I can't seem to
> figure any of the features beyond updating profiles out enough to document
> them.
> >>
> >> Please let me know what you think of this profile and rule, I expected
> the eligibility property to be set to "yes" for the profile.
> >>
>

Re: Rule Evaluation Problem

Posted by Serge Huber <sh...@apache.org>.
It should work as you expect in the first scenario, but I noticed that
you use propertyValueInt instead of propertyValueInteger. Maybe this
is the problem ?

Regards,
  Serge...
On Sun, Nov 11, 2018 at 11:11 PM Michael Ghen <mi...@mikeghen.com> wrote:
>
> I think I may have figured out why this wasn't working after playing some more.
>
> First, I went to just and "exists" comparisonOperator to simplify that. Then, I added a profileUpdatedEventCondition to my condition. These two conditions work and my action occured.
>
> Second thing, I realize the lessThan and greaterThan must work backward to how I expected it.
>
> For example, consider properties.annualIncome = 4800. I expected that this condition would be true:
>
>        {
>           "parameterValues": {
>             "propertyName": "properties.annualIncome",
>             "comparisonOperator": "lessThan",
>             "propertyValueInt": 12000
>           },
>           "type": "profilePropertyCondition"
>         }
>
> Really this must be: "12000 < properties.annualncomes == False"
>
> When I switch to greaterThan, suddenly everything work: "12000 > properties.annualIncomes == True"
>
> So I had to do to things: 1) invert the comparisonOperator and 2) add a subcondition for profileUpdatedEventCondition. Not sure why this worked but it seems to work OK.
>
> On Sun, Nov 11, 2018 at 4:31 PM Michael Ghen <mi...@mikeghen.com> wrote:
>>
>> Hello again,
>>
>> I am trying to get a proof of concept setup and I'm really struggling with how rules work. It seems that this simple rule is not being evaluated and I've tried a lot of combinations but still this won't perform as expected, I was hoping someone could just glance at the JSON I'm working with and let me know if there's something I'm missing.
>>
>> I have a rule and a profile attached and I don't understand why the rule work update the property on the profile as expected. I've tried to make updated to the annualIncome property thinking it would trigger the rule but that doesn't seem to work.
>>
>> I would like to provide more docs to this project but I can't seem to figure any of the features beyond updating profiles out enough to document them.
>>
>> Please let me know what you think of this profile and rule, I expected the eligibility property to be set to "yes" for the profile.
>>

Re: Rule Evaluation Problem

Posted by Michael Ghen <mi...@mikeghen.com>.
I think I may have figured out why this wasn't working after playing some
more.

First, I went to just and "exists" comparisonOperator to simplify that.
Then, I added a profileUpdatedEventCondition to my condition. These two
conditions work and my action occured.

Second thing, I realize the lessThan and greaterThan must work backward to
how I expected it.

For example, consider properties.annualIncome = 4800. I expected that this
condition would be true:

       {
          "parameterValues": {
            "propertyName": "properties.annualIncome",
            "comparisonOperator": "lessThan",
            "propertyValueInt": 12000
          },
          "type": "profilePropertyCondition"
        }

Really this must be: "12000 < properties.annualncomes == False"

When I switch to greaterThan, suddenly everything work: "12000 >
properties.annualIncomes == True"

So I had to do to things: 1) invert the comparisonOperator and 2) add a
subcondition for profileUpdatedEventCondition. Not sure why this worked but
it seems to work OK.

On Sun, Nov 11, 2018 at 4:31 PM Michael Ghen <mi...@mikeghen.com> wrote:

> Hello again,
>
> I am trying to get a proof of concept setup and I'm really struggling with
> how rules work. It seems that this simple rule is not being evaluated and
> I've tried a lot of combinations but still this won't perform as expected,
> I was hoping someone could just glance at the JSON I'm working with and let
> me know if there's something I'm missing.
>
> I have a rule and a profile attached and I don't understand why the rule
> work update the property on the profile as expected. I've tried to make
> updated to the annualIncome property thinking it would trigger the rule but
> that doesn't seem to work.
>
> I would like to provide more docs to this project but I can't seem to
> figure any of the features beyond updating profiles out enough to document
> them.
>
> Please let me know what you think of this profile and rule, I expected the
> eligibility property to be set to "yes" for the profile.
>
>