Mark,
I think you misunderstood the issue. I know how to set the salience. The problem is
that the way
to *get* the salience of a SalienceInteger is to pass in a Tuple and WorkingMemory and
there is no
explanation of where the Tuple and WorkingMemory are supposed to come from. The only way I
could
figure out how to get the salience as I did in 3.0 is to parse the toString() result value
which
bites but works for now.
As I asked before, will it work to call IntegerSalience.getSalience(null,null) to get a
constant
salience? If so, it would be helpful to say that in the javadocs. Also helpful, perhaps,
would be a
IntegerSalience.getValue() method with no args that would wrap Salience.getSalience( null,
null ).
I find it a little troubling that the API docs are so unreliable that users are
expected to read
the source code to understand how to use it. It would make some sense if I wanted to use
the dynamic
salience programmatically but since I am only concerned with the simple, constant case,
like most
users I expect, it seems like a lot of effort and time for something that should be easy
and quick.
I can see the benefits of dynamic salience, but I would appreciate the feature more if
it hadn't
made the simple, static case more complex.
Thanks,
Scott
Mark Proctor's message received 8/17/2007 5:13 PM:
Integer.parseInt( salienceText ) is only needed if your source is a
string, otherwise new SalienceInteger( 10 ) is fine. Take a look at the
SalienceInteger to understand how it works, tuple, workingMemory are
ignored for non dynamic environments:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-core/src/main/...
Mark
Scott Reed wrote:
> For lack of any better suggestion I am getting the int salience using
> Integer.parse(rule.getPriority().toString()).
> Of course this is a huge hack since it depends on the undocumented
> toString() function returning the string value of the integer salience.
>
> I am still very interested to hear how the designers thought we should
> use the API to get the salience value.
>
> Scott Reed's message received 8/17/2007 8:52 AM:
>> I guess the question here is, where do you get that "salinceText"
from?
>> I am using DRL to define the rules.
>>
>> Manjax23's message received 8/17/2007 1:44 AM:
>>> Salience salience = new SalienceInteger( Integer.parseInt(
>>> salienceText ) );
>>> rule.setSalience( salience );
>>>
>>> Cheers,
>>> manjax23
>>>
>>>
>>> Scott Reed-4 wrote:
>>>> My 3.1 app has a mechanism that allowed the user to change the
>>>> salience of
>>>> some rules before running them, before loading up WorkingMemory.
>>>> This was quite simple,
>>>> rule.getSalience() returned a rule's int salience value and
>>>> rule.setSalience(int) set it. Now in 4.0 I see
>>>> salience is no longer just an int, but a Salience object with a
>>>> simple constructor and complicated
>>>> getValue(Tuple,WorkingMemory) method to access the int value.
>>>>
>>>> It appears to be still easy to set the salience of a rule:
>>>> rule.setSalience( new SalienceInteger(int)) but getting the int
>>>> salience from a Salience object
>>>> seems to have been removed from joe-blow coder's reach.
>>>>
>>>> I would be very grateful if someone would provide me with an
>>>> example that
>>>> gets the int salience associated with a rule. I have no idea where
>>>> or why I need to get the
>>>> Tuple and WorkingMemory. Can I just pass nulls in for those two
>>>> arguments?
>>>>
>>>> Thanks,
>>>> Scott
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users