[rules-users] Camel Endpoint usage strategy

2011-11-21 Thread esstrata
Hi,

  we're refactoring a standalone application (Spring 3.0.5, Drool 5.1.1) to
use Apache Camel 2.8.0. As seen in other post, there is very little
information available about (
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-integration/html/index.html
 
Drools Endpoint or Camel integration ). We don't want to use drools-server
as having a web container is not an option.

The app basically loads from large CSV files, processes each row with lots
of rules and inserts the result in a DB. It is therefore a pretty demanding
process.

Here is an excerpt of what it does without Camel:
/
while (scanner.hasNextLine()) {
...
FactHandle trafficHandle = session.insert(row);
session.fireAllRules();
session.retract(trafficHandle);
}
/
What we'd like to achieve is performing the above loop content in an
endpoint/processor (?) and configure it to use multiple threads so several
rows can be handled simultaneously.

Any sugestions?.

Thank you

--
View this message in context: 
http://drools.46999.n3.nabble.com/Camel-Endpoint-usage-strategy-tp3524173p3524173.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] match longest matching Long in WM

2011-07-21 Thread esstrata
Hi,

  I hope you can help me out here with a way to implement this rule:

1) I have String WM
2) I have beans in WM with a property called 'code' 
public class MyBean {
  private String code;
  ...

3) I want a rule of the type Process MyBean with the longest-matching,
not-null code

Let explain myself a little further with an example.

I have the following MyBean objects in WM with the given code properties:
MyBean [code = 44]
MyBean [code = 443]
MyBean [code = 4432]
MyBean [code = 36]
MyBean [code = 7]

What I want to get is a rule where the following samples would assign to a
variable the given results shown:
441 gives MyBean [code = 44]
443 gives MyBean [code = 443]
2 gives null

I think the rule could start like:
rule Process MyBean with the longest-matching, not-null code
dialect mvel  
when
$s : String()
$m : MyBean($s matches /the longest not-null possible 
MyBean.code/)
then
 ..

Thank you

--
View this message in context: 
http://drools.46999.n3.nabble.com/match-longest-matching-Long-in-WM-tp3188343p3188343.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] check whether a key is present in global Map, i.e. mimicking containsKey() behavior

2011-07-05 Thread esstrata
Hi,

  I found a possible cause from StatefulKnowledgeSession API:

/Also, it is a good practice to set your globals before inserting your facts
or starting your processes. Rules engines evaluate rules at fact insertion
time, and so, if you are using a global to constraint a fact pattern, and
the global is not set, you may receive a NullPointerException./

I did so and I no longer get the compilation error. However, 'eval'
construction is not working in LHS. I'm shifting to insert items from maps
into WM directly.

Cheers


esstrata wrote:
 
 Hello,
 
   I'm using Drools 5.1.1 in a JavaSE 6 project.
 
 I can't get running a rule where a value obtained from WM is check for
 existence as a key of a global Map.
 
 I have a map of the type ProductTextCode - Product, where keys are String
 and values Product
 /global Map productMap/
 
 Then in a rule a I want a condition where each String in WM is tested
 against map keyset.
 /
 rule Product ID not in products map
 dialect mvel  
 when
 $pid : String()   
 = Here goes the condition =
 then
 System.out.println(Invalid product id:  + $pid)
   retract ($pid)
 end
 /
 
 So far I've tried with productMap.containsKey($pid) but a get a MVEL error
 as it takes 'containsKey' as a property.
 
 Please help. Thank you.
 

esstrata wrote:
 
 Hello,
 
   I'm using Drools 5.1.1 in a JavaSE 6 project.
 
 I can't get running a rule where a value obtained from WM is check for
 existence as a key of a global Map.
 
 I have a map of the type ProductTextCode - Product, where keys are String
 and values Product
 /global Map productMap/
 
 Then in a rule a I want a condition where each String in WM is tested
 against map keyset.
 /
 rule Product ID not in products map
 dialect mvel  
 when
 $pid : String()   
 = Here goes the condition =
 then
 System.out.println(Invalid product id:  + $pid)
   retract ($pid)
 end
 /
 
 So far I've tried with productMap.containsKey($pid) but a get a MVEL error
 as it takes 'containsKey' as a property.
 
 Please help. Thank you.
 


--
View this message in context: 
http://drools.46999.n3.nabble.com/check-whether-a-key-is-present-in-global-Map-i-e-mimicking-containsKey-behavior-tp3137610p3140218.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] check whether a key is present in global Map, i.e. mimicking containsKey() behavior

2011-07-05 Thread esstrata
Hi,

  I checked and I was correctly using session.setGlobal. No idea why this
happens

Thank you

--
View this message in context: 
http://drools.46999.n3.nabble.com/check-whether-a-key-is-present-in-global-Map-i-e-mimicking-containsKey-behavior-tp3137610p3140225.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] check whether a key is present in global Map, i.e. mimicking containsKey() behavior

2011-07-04 Thread esstrata
Hello,

  I'm using Drools 5.1.1 in a JavaSE 6 project.

I can't get running a rule where a value obtained from WM is check for
existence as a key of a global Map.

I have a map of the type ProductTextCode - Product, where keys are String
and values Product
/global Map productMap/

Then in a rule a I want a condition where each String in WM is tested
against map keyset.
/
rule Product ID not in products map
dialect mvel  
when
$pid : String() 
= Here goes the condition =
then
System.out.println(Invalid product id:  + $pid)
retract ($pid)
end
/

So far I've tried with productMap.containsKey($pid) but a get a MVEL error
as it takes 'containsKey' as a property.

Please help. Thank you.

--
View this message in context: 
http://drools.46999.n3.nabble.com/check-whether-a-key-is-present-in-global-Map-i-e-mimicking-containsKey-behavior-tp3137610p3137610.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] check whether a key is present in global Map, i.e. mimicking containsKey() behavior

2011-07-04 Thread esstrata
Yes, I used eval. 
In fact this is the error I'm getting

org.drools.RuntimeDroolsException: productMap.containsKey($pid) == false :
[Error: unable to access property (null parent): containsKey]
[Near : {... Unknown }]

And this is the line
eval(productMap.containsKey($pid) == false)

--
View this message in context: 
http://drools.46999.n3.nabble.com/check-whether-a-key-is-present-in-global-Map-i-e-mimicking-containsKey-behavior-tp3137610p3137694.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] Accessing ListString with mvel in condition

2011-06-27 Thread esstrata
Hi,

  I've tried several options but none working so I welcome any help.

* I'm using Drools 5.1.1. 
* I succesfully insert several ListString into Working Memory and I'm able
to printout them with a debug rule.
* The problem is, when I try to access a position in a list I get no match
even though I have values that should match. Here is the relevant code:

rule B Number has characters other than numbers
dialect mvel 
when
$traffic_row : List(this[5] matches [^0-9])   

then 
System.out.println(row found + $traffic_row)
end


Thank you in advance


--
View this message in context: 
http://drools.46999.n3.nabble.com/Accessing-List-String-with-mvel-in-condition-tp3113685p3113685.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] Accessing ListString with mvel in condition

2011-06-27 Thread esstrata
It worked. 

Thank you very much Wolfgang

--
View this message in context: 
http://drools.46999.n3.nabble.com/Accessing-List-String-with-mvel-in-condition-tp3113685p3114406.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