Re: [rules-users] Calling a function from When part

2012-08-06 Thread RulesUsers
Hey laune, I think we are mixing up the things.
My requirement is to call a method in an helper class, that in turn accesses
the db. 


Currently i have done with 
  */evel(functionCall() )/* //The return type of the method is boolean

*But the problem is, once the control enters WHEN part of the rule it making
multiple calls to this method ( checked by putting in SYSO statements). But
i want this call to take place once.*


So it will be very helpful, if any once can suggest me any other way to make
function call from when part.
Also tried with 

/*$A : Boolean() from functionCall( )
eval( $A )*/


But the result is same.

Also please provide your inputs if it is not possible to handle the problem,
where in it make multiple function call.


Regards,
Sam



--
View this message in context: 
http://drools.46999.n3.nabble.com/Calling-a-function-from-When-part-tp4018987p4019024.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Calling a function from When part

2012-08-06 Thread Stephen Masters
Hi Sam,

Probably your best bet would be to create a separate rule, which evaluates the 
function in the RHS and inserts a fact encapsulating the results into working 
memory. That can be set to no-loop or to have a negative match on the fact it 
creates.

rule eval function
no-loop
when
$request : RequestFact()
then
FunctionResult result = functionCall();
insertLogical(result);
end

rule business rule
when
$request : RequestFact()
$functionResult : FunctionResult()
then
// do something
end

… or something vaguely similar. This way your function call is only evaluated 
once, and the business rule does not fire until the function has been evaluated.

Steve

On 6 Aug 2012, at 08:34, RulesUsers wrote:

 Hey laune, I think we are mixing up the things.
 My requirement is to call a method in an helper class, that in turn accesses
 the db. 
 
 
 Currently i have done with 
  */evel(functionCall() )/* //The return type of the method is boolean
 
 *But the problem is, once the control enters WHEN part of the rule it making
 multiple calls to this method ( checked by putting in SYSO statements). But
 i want this call to take place once.*
 
 
 So it will be very helpful, if any once can suggest me any other way to make
 function call from when part.
 Also tried with 
 
 /*$A : Boolean() from functionCall( )
 eval( $A )*/
 
 
 But the result is same.
 
 Also please provide your inputs if it is not possible to handle the problem,
 where in it make multiple function call.
 
 
 Regards,
 Sam
 
 
 
 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Calling-a-function-from-When-part-tp4018987p4019024.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools with Gemfire

2012-08-06 Thread rtella
  I'm looking into integrating Drools with a system that has large (40GB+) 
Gemfire Maps.  The rules would need to access the Gemfire Maps, which can be
updated at any time.I understand I can't access the Gemfire Maps as
global data since they aren't immutable.  Inserting the maps also doesn't
seem like a good idea either since I'd  have to call modify() frequently on
Maps with as many as 1M elements.Is there any alternative for accessing
large amounts of changing data?


thanks for your help,

Rich



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-with-Gemfire-tp4019026.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Matching consecutive events

2012-08-06 Thread Vincent LEGENDRE
May be something with the internal clock and timestamps assigned as events 
dates and inclusive (or not I don't remember) bounds in after/before operators 
evaluation ... in short, I am not sure of the expected result if all your event 
(or 2 among your 3 events) have the same event date. 

But apart from that, may be you can implement a Listener (on insert callback) 
that maintains an explicit insertion order directly inside the event. This way, 
no need to use complex LHS to test that an event is directly preceeded by 
another. 
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Matching consecutive events

2012-08-06 Thread Edson Tirelli
   Hi Jaro,

   This might be a side effect of the temporal reasoning algorithm when
using unbounded intervals like you are doing (i.e., using before and after
operators without an interval parameter). Assuming this is what is
happening, the activation is probably scheduled, but it only happens when
the next activity is about to happen inside the session.

   With the current version, I can only suggest two workarounds. Either:

* Use straight relational operators in your rule (, ). E.g.:

$ev2 : LocalizationEvent( ..., timestamp  $ev1.timestamp ) ...

* Or, try to use bounded temporal operators. E.g.:

$ev2 : LocalizationEvent( ... this after[0,60s] $ev1 ) ...

We know it is not ideal, and for the next Drools release we are
implementing explicit sequence operators where you will be able to just
define [strict] sequencing. E.g.:

when
 $ev1 : LocalizationEvent( ... ) =
 $ev2 : LocalizationEvent( ... )
then
...

 Details here:

https://community.jboss.org/wiki/EventSequencing#4_Definition_Sequence_Conditional_Elements

 Edson
On Wed, Aug 1, 2012 at 5:52 AM, jpullmann 
jaroslav.pullm...@fit.fraunhofer.de wrote:

 Dear contributors,

   this rule is expected to match a sequence of 2 consecutive events:

 rule test
 when
 // a)
 $ev1 : LocalizationEvent( type == TYPE.HINT,  $target : target  )
 from entry-point events/localization
 $ev2 : LocalizationEvent( type == TYPE.HINT, target == $target,
 this
 after $ev1 ) from entry-point events/localization
 // b)
 // Ev1 directly followed by ev2: no other HINT in between
 not( LocalizationEvent( type == TYPE.HINT, target == $target, this
 after $ev1, this before $ev2 )  from entry-point events/localization )
 then
   do()
 end

  The second event is interpreted as a confirmation of the first event
 (a).
  No other (deviating) event is allowed between them (b). With this
 restriction
  in place, the rule requires a sequence of 3 input events for activation,
 otherwise
  2 events are sufficient (as expected). The events are ordered correctly
 and
 it is
  not obvious, why a third event is needed since the interval between ev1
 and
 ev2 is
  closed ? This leads to an unnecessary delay in rule activation.. How could
 this be
  avoided and are there other approaches to match a concrete event sequence
 pattern ?

  Many thanks
Jaro



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Matching-consecutive-events-tp4018980.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Apply role to whole class hierarchy

2012-08-06 Thread Vincent LEGENDRE
I had the same strange problem some time ago (last winter), but I never managed 
to reproduce a small sample 
I checked, and my problematic class hierarchy also lived in different packages 
(and never tried that that for my smaller samples) . 

- Mail original -

De: Joerg Henne hennejg+nab...@googlemail.com 
À: rules-users@lists.jboss.org 
Envoyé: Lundi 30 Juillet 2012 16:04:50 
Objet: Re: [rules-users] Apply role to whole class hierarchy 

After some debugging I was able to shed some light on what causes the 
problem, even if I don't fully understand it. The problem is produced by the 
event base class, which is declared with @role(event), i.e. (VSCPEvent) 
living in a different package than the ButtonEvent. If I move then into the 
same package, everything works just fine. 
The two package instances are merged in PackageBuilder.mergePackage(...), 
but the RuleBuilder still seems to operate on two separate instances, one 
with the declarations and Package.isEvent(...) returning true for the 
ButtonEvent and the other without them. Unfortunately, as I know too little 
about the workings of the various builders, I can't provide you with a 
ready-made idea of how to fix the problem. 

See https://issues.jboss.org/browse/JBRULES-3587 

Thanks 
Joerg 



-- 
View this message in context: 
http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018963.html
 
Sent from the Drools: User forum mailing list archive at Nabble.com. 
___ 
rules-users mailing list 
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users 

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools with Gemfire

2012-08-06 Thread Joe Ammann
Hi Rich

On 08/06/2012 03:26 PM, rtella wrote:
   I'm looking into integrating Drools with a system that has large (40GB+) 
 Gemfire Maps.  The rules would need to access the Gemfire Maps, which can be
 updated at any time.I understand I can't access the Gemfire Maps as
 global data since they aren't immutable.  Inserting the maps also doesn't
 seem like a good idea either since I'd  have to call modify() frequently on
 Maps with as many as 1M elements.Is there any alternative for accessing
 large amounts of changing data?
We had quite a similiar use case (financial instruments, millions of
associated prices in a Gemfire map, need to reason over many (~100'000)
instruments, in some cases taking price data (~300mio) into account).

We ended up asserting the instruments as facts into WM, do the majority
of the reasoning on them, and when really required, accessing the prices
from the Gemfire map with a from conditional expression

For example:

WHEN
i : Instrument ( assetClass == Bond )
ps : PriceSeries ( instrumentId = i.id, priceType = EndOfDay )
price : Price ( ) from ps.getPrices()// her we access the
Gemfire map
.

So instruments and price series (in our case) are facts in WM, while the
prices stay in the Gemfire maps. Of course, that has the drawback that
we can not react directly to new or modified prices. Which in our case
was ok. Only a minority of the rules needed to take prices into account
at all, so we first fired all rules that did not access the maps,
retracting all instruments we could. Then the rules with lower salience
that accessed the maps fired.

-- 
CU, Joe

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Question with Persisting Knowledge Sessions Then Upgrading Drools

2012-08-06 Thread Darin Wilcox
I have been working on persisting knowledge sessions to an H2 database that
are used for long running processes.  The question I have is surrounding
the following description:

-- A stateful knowledge session is created using the
JPAKnowledgeService and persisted to a database.

-- A process is started within the knowledge session.

-- The process contains a human task blocking the completion of the
process.

Because the stateful nature of the knowledge session, an instance of the
process is inserted into the processinstanceinfo table and an instance of
the human task is inserted into the task table.  State is therefore
maintained until the human task is completed and the process can continue
execution.


While the knowledge session, process and human task are awaiting
completion, is it possible to upgrade the version of Drools/jBPM being
used?  Will the upgrade effect the de-serialization of the objects from the
database or will they be able to be retrieved and used as before?  Is there
a best practice for accomplishing upgrading drools versions with knowledge
sessions that may have been previously existing?


Thanks,

-  Darin
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Comparison operation requires compatible types when using Date literal inside nested OR

2012-08-06 Thread Eric Martineau
I'm new to drools, so hopefully I can post enough information to get some help. 
 We are running Drools 5.3.3.Final (though we've seen the same issue with 
5.4.0.Final and 5.3.0.Final)

I'm trying to test some rules created in drl format.  Here's an example of a 
drl that executes fine – it checks a birthday field against a date literal:

--


package drools.rules.funnelid.two


import com.infusionsoft.bpm.services.TestRuleFact;


rule Test Rule

dialect java

when

$testRuleFact : TestRuleFact( ( contactable.contact.birthday  29-Dec-1977 ) )

then

$testRuleFact.setTrue( );

end

---

However, this drl fails compilation with the following error:


package drools.rules.funnelid.two


import com.infusionsoft.bpm.services.TestRuleFact;


rule Test Rule

dialect java

when

$testRuleFact : TestRuleFact( ( contactable.contact.title str[equals] Owner 
 contactable.contact.birthday  01-Jan-1980 ) || ( 
contactable.contact.country str[equals] USA  
contactable.contact.leadSourceIdOverride == 12 ) )

then

$testRuleFact.setTrue( );

End


--


Here's the error I get:

DRL contains errors, no actions will be processed: Unable to Analyse Expression 
str0.evaluate( contactable.contact.title, Owner )  
contactable.contact.birthday  01-Jan-1980 || str1.evaluate( 
contactable.contact.country, USA )  
contactable.contact.leadSourceIdOverride == 12:

[Error: Comparison operation requires compatible types. Found class 
java.util.Date and class java.lang.String]

[Near : {... )  contactable.contact.leadSourceIdOverride == 12 }]

  ^

[Line: 8, Column: 32] : [Rule name='Test Rule']


Some things that cause the error to go away:

 *   Removing the offending clause:  contactable.contact.birthday  
01-Jan-1980
 *   Changing the || to an 

I'm at a loss and would love some help.  Even if I knew which class was raising 
the exception would help, but I can't seem to find it anywhere.

Thanks,
Eric
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Guvnor/Designer: How to assign a global variable to a dataInput?

2012-08-06 Thread xmithj
For Service Task in Guvnor now is possible to add assignments using the
Editor for Data Assignments. Very nice! This editor helps the business
users by showing the process variables defined and Service Task's
dataInputs.
It doesn't show though any defined global variable. Is possible to assign a
global variable to one of the Service Task's dataInput? Will it be included
in future Guvnor/Designer release?

Thanks in advance,
Xmithj



--
View this message in context: 
http://drools.46999.n3.nabble.com/Guvnor-Designer-How-to-assign-a-global-variable-to-a-dataInput-tp4019034.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor/Designer: How to assign a global variable to a dataInput?

2012-08-06 Thread Tihomir Surdilovic
You are right, the editor is not pulling in globals currently - can you 
raise a jBPM Jira for this and I'll make sure it gets added in the next 
release version?

Thanks
Tihomir
On 8/7/12 1:00 AM, xmithj wrote:
 For Service Task in Guvnor now is possible to add assignments using the
 Editor for Data Assignments. Very nice! This editor helps the business
 users by showing the process variables defined and Service Task's
 dataInputs.
 It doesn't show though any defined global variable. Is possible to assign a
 global variable to one of the Service Task's dataInput? Will it be included
 in future Guvnor/Designer release?

 Thanks in advance,
 Xmithj



 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Guvnor-Designer-How-to-assign-a-global-variable-to-a-dataInput-tp4019034.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users