Re: [rules-users] Getting hold of the Evaluator Registry

2009-07-16 Thread Jaroslaw Kijanowski
On Linux, when I created my own accumulate functions, I had to put this 
file in my home directory to have it picked up by Eclipse.

Cheers,
  Jarek

Edson Tirelli wrote:
 
root of your project classpath, not root of your project.
 
[]s
Edson
 
 2009/7/15 Asif Iqbal asif.iq...@infor.com mailto:asif.iq...@infor.com
 
 Hi Edson,
 
  
 
 I have gone away and tried the properties method of adding the
 customEvaluator, which worked fine for the code.  But my IDE still
 does not pick it up. Any ideas?
 
  
 
 Do I need to place it in a META-INF folder in the root of the project?
 
  
 
 I have the following in the drools.packagebuilder.conf file.
 
  
 
 
 drools.evaluator.custom=com.infor.audit.bpr.component.validation.impl.drools.CustomComparableEvaluatorsDefinition
 
  
 
 thanks..
 
  
 
  
 
 
 
 *From:* rules-users-boun...@lists.jboss.org
 mailto:rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org
 mailto:rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson
 Tirelli
 
 *Sent:* 15 July 2009 14:57
 *To:* Rules Users List
 *Subject:* Re: [rules-users] Getting hold of the Evaluator Registry
 
  
 
 
Yes, you are in the right track, and I understand this is a bit
 confusing at first. One more reason for people to go to the October
 Rules Fest 2009 where I will give a presentation on all the ways to
 extend the engine to solve specific problems. It will be interesting
 I hope (last year was awesome) and even Charles Forgy will be there
 doing a presentation on Parallel Rete. :)
 
 Meanwhile I will write a tutorial on this, but just to help you
 there, your approach is correct, except that you don't need to setup
 the option for each operator. It works like this:
 
 * One EvaluatorDefinition class implements support to one or more
 evaluators, defined by the method public String[] getEvaluatorIds().
 
 * All you need to do, then, is wire you class once and the engine
 will pick-up all the IDs supported by that class. When you have your
 class wired, you give it a unique string identifier, so that if you
 ever need to replace it, or remove it, you will use that id.
 Sometimes we use the operator as the ID, but usually it is something
 that reminds you of the kind of evaluators that class define. For
 instance, drools registers the ComparableEvaluatorsDefinition in
 this way:
 
 drools.evaluator.comparable =
 org.drools.base.evaluators.ComparableEvaluatorsDefinition
 
   So in this case, comparable is the identifier. Finally, from my
 previous e-mail you will see that the reason that the eclipse IDE is
 still giving you errors is that you are using the API to configure
 the evaluators. Just move the configuration to the configuration
 file and the IDE will pick it up.
 
[]s
Edson
 
 
 2009/7/15 Asif Iqbal asif.iq...@infor.com
 mailto:asif.iq...@infor.com
 
 Edson,
 
  
 
 What I have done so far is created a
 CustomComparableEvaluatorsDefinition, which is exactly the same as
 the default ComparableEvaluatorsDefinition apart form having support
 for strings, which I have done by creating
 StringGreaterOrEqualEvaluators and added that in my custom class,
 using the addEvaluatorFunction :-
 
  
 
 addEvaluator( ValueType.SHORT_TYPE,
 Operator.GREATER, ShortGreaterEvaluator.INSTANCE );
 
 addEvaluator( ValueType.SHORT_TYPE,
 Operator.GREATER_OR_EQUAL,ShortGreaterOrEqualEvaluator.INSTANCE );
 
 addEvaluator( ValueType.PSHORT_TYPE,   
 Operator.LESS,ShortLessEvaluator.INSTANCE );
 
 addEvaluator( ValueType.PSHORT_TYPE,   
 Operator.LESS_OR_EQUAL,   ShortLessOrEqualEvaluator.INSTANCE );
 
 addEvaluator( ValueType.PSHORT_TYPE,   
 Operator.GREATER, ShortGreaterEvaluator.INSTANCE );
 
 addEvaluator( ValueType.PSHORT_TYPE,   
 Operator.GREATER_OR_EQUAL,ShortGreaterOrEqualEvaluator.INSTANCE );
 
 //Custom additions
 
 addEvaluator( ValueType.STRING_TYPE,   
 Operator.LESS,StringLessEvaluator.INSTANCE );
 
 addEvaluator( ValueType.STRING_TYPE,   
 Operator.LESS_OR_EQUAL,   StringLessOrEqualEvaluator.INSTANCE );
 
 addEvaluator( ValueType.STRING_TYPE,   
 Operator.GREATER, StringGreaterEvaluator.INSTANCE );
 
 addEvaluator( ValueType.STRING_TYPE,   
 Operator.GREATER_OR_EQUAL,StringGreaterOrEqualEvaluator.INSTANCE );
 
  
 
 Now Im am trying to wire it, with the following..
 
  
 
   

Re: [rules-users] looking for more information on drools expert

2009-07-16 Thread Gab Aldian
I finally suceeded to get what I wanted using the keyword accumulate
which is really very poweful as said in the doc. Here is the rule:
http://drools.pastebin.com/m4f938e40

It is a little bit complex, but it perfectly works. The only
observation I have is that it seems drools compatible jdk is  1.5,
since I tryed to declare my linkedlist this way: LinkedListAlarm(),
but got warnings about the unexpected ''. One other thing, the
implicit and does not work in the accumulate, you have to put it
clearly.

Now I have something giving me the list I need, all should be easy I
think. Do you have any observation on the way I did it?

Cheers

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


Re: [rules-users] looking for more information on drools expert

2009-07-16 Thread Wolfgang Laun
accumulate is indeed complex; the simpler collect might be applicable
as well in this case.

rule all45_A
when
forall ( Equipment( parent == 0, $id : id )
 Alarm( cause == 45, source == $id ) )
$alarms : ArrayList()
from collect( Alarm( cause == 45, $source : source ) )
then
for( Object o: $alarms ){
retract( o );// or anything else with (Alarm)o
}
insert( new SummaryAlarm( 45 ) );
end

Another solution would be by using 2 rules:

rule all45_B1
when
forall ( Equipment( parent == 0, $id : id )
 Alarm( cause == 45, source == $id ) )
then
insert( new SummaryAlarm( 45 ) );
end

rule all45_B2
when
SummaryAlarm( $cause : cause )
$a : Alarm( cause == $cause, $source : source )
Equipment( parent == 0, id  == $source)
then
retract( $a );  // or anything else with $a
end

-W

On Thu, Jul 16, 2009 at 10:55 AM, Gab Aldianaldian...@gmail.com wrote:
 I finally suceeded to get what I wanted using the keyword accumulate
 which is really very poweful as said in the doc. Here is the rule:
 http://drools.pastebin.com/m4f938e40

 It is a little bit complex, but it perfectly works. The only
 observation I have is that it seems drools compatible jdk is  1.5,
 since I tryed to declare my linkedlist this way: LinkedListAlarm(),
 but got warnings about the unexpected ''. One other thing, the
 implicit and does not work in the accumulate, you have to put it
 clearly.

 Now I have something giving me the list I need, all should be easy I
 think. Do you have any observation on the way I did it?

 Cheers

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

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


[rules-users] Updating a Boolean object in the WM

2009-07-16 Thread skasab2s

Hi guys,

I've been desperately trying to update a Boolean object, which is in the
working memory.

I have an initial rule that  first inserts it:
rule Insert initial weanable value salience 100
when

then
Boolean $weanable = false;
insert($weanable);
end

and then I try to update it:
   ...
   when
   $weanable: Boolean( )
   ...
   then
$weanable=true;
update($weanable);
end

Which results to this exception : org.drools.FactException: Update error:
handle not found for object: true. Is it in the working memory? 
I checked in the working memory and the Boolean-object was there!


Is it possible to update a boolean that is in the working memory? If not, do
you know some other Java class with setters and getters (behaving as a
drools-fact) that I don't have to create myself and which I can use instead
of Bboolean for this case ? 

Thanks in advance!

Svetlomir

-- 
View this message in context: 
http://www.nabble.com/Updating-a-Boolean-object-in-the-WM-tp24513225p24513225.html
Sent from the drools - user mailing list archive at Nabble.com.

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


[rules-users] Problems with persistence of drools-flow

2009-07-16 Thread Ševčík Martin
I have a simple flow with human task and I want to persist it into database. 
I'm using MSSQL DB. 

My code is like this:

KnowledgeBase kbase = readKnowledgeBase();
// create the entity manager factory and register it in 
the environment
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( 
org.drools.persistence.jpa );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
BitronixTransactionManager btm = 
TransactionManagerServices.getTransactionManager();
env.set( EnvironmentName.TRANSACTION_MANAGER, btm);

StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( 
kbase, null, env );

KnowledgeRuntimeLogger logger = 
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, test);

ksession.getWorkItemManager().registerWorkItemHandler(Human Task, new 
WSHumanTaskHandler());
// start a new process instance
MapString,Object data = new HashMapString,Object();
data.put(data3, new MyTask(1,This is taks 1));
ProcessInstance pi = 
ksession.startProcess(com.sample.ruleflow,data);
logger.close();

But when i run it, it end up with this error and there is nothing in the 
database (the tables were created, but there are all empty):

java.lang.NullPointerException
at 
org.drools.persistence.processinstance.ProcessInstanceInfo.getId(ProcessInstanceInfo.java:70)
at 
org.drools.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:34)
at 
org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1620)
at 
org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:46)
at 
org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:10)
at 
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:229)
at 
org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:163)
at 
com.sample.RuleFlowPersistenceTest.main(RuleFlowPersistenceTest.java:74)
java.lang.RuntimeException: Could not rollback transaction
at 
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)
at 
org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:163)
at 
com.sample.RuleFlowPersistenceTest.main(RuleFlowPersistenceTest.java:74)
Caused by: java.lang.RuntimeException: Could not execute command
at 
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:255)
... 2 more
Caused by: java.lang.NullPointerException
at 
org.drools.persistence.processinstance.ProcessInstanceInfo.getId(ProcessInstanceInfo.java:70)
at 
org.drools.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:34)
at 
org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1620)
at 
org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:46)
at 
org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:10)
at 
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:229)
... 2 more

In JPAProcessInstanceManager.java there this method is called:

public void addProcessInstance(ProcessInstance processInstance) {
ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo( 
processInstance );
EntityManager em = (EntityManager) 
this.workingMemory.getEnvironment().get( EnvironmentName.ENTITY_MANAGER );
em.persist( processInstanceInfo );
((ProcessInstance) processInstance).setId( processInstanceInfo.getId() 
);
processInstanceInfo.updateLastReadDate();
internalAddProcessInstance(processInstance);
}


But em.persist does nothing, no connection do DB is called. And then the  next 
line will fail.




Can anybody help me.

Thanks

Martin Sevcik

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


Re: [rules-users] OFBiz entity engine compatibility with Jackrabbit

2009-07-16 Thread Jaroslaw Kijanowski
Hi

pardeep.ru...@lntinfotech.com wrote:
 
 Hi,
 
 I am using apache OFBiz which uses Entity engine as a persistence layer.
 To know more about Entity engine refer this link
 http://ofbiz.apache.org/docs/entity.html
 Drools Guvnor uses Jackrabbit as a persistence layaer.
 So my question is there a way i can use OFbiz entity engine persistence 
 layer in Drools guvnor in place of
 Jackrabbit.

Jackrabbit is a JCR, OFBiz isn't, right? You should be able to replace 
Jackrabbit with any JCR implementation. IMO OFBiz is not an option.

 Is it feasible to do this and if possible how much effort is needed?

Haven't heard of anybody replacing Jackrabbit with another JCR 
implementation before - share your experience when you try :)

Cheers,
  Jarek

 
 
 Thanks  Regards
 
 Pardeep Ruhil
 LT Infotech Ltd
 Mumbai
 Ph: +919820283884
 *
 Larsen  Toubro Infotech Ltd.*_
 __www.Lntinfotech.com_ http://www.lntinfotech.com/
 
 This Document is classified as:
 
 LT Infotech Proprietary   LT Infotech Confidential   LT Infotech 
 Internal Use Only   LT Infotech General Business  
 
 This Email may contain confidential or privileged information for the 
 intended recipient (s) If you are not the intended recipient, please do 
 not use or disseminate the information, notify the sender and delete it 
 from your system.
 __
 
 
 
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 http://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
http://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Updating a Boolean object in the WM

2009-07-16 Thread Wolfgang Laun
Well, you can't change a Java object Boolean b; assigning another Boolean to b
changes the object reference stored in b. Boolean has no setters.

Notice that the CE
when
Boolean()

always is true irrespective of the Boolean object that's in the WM.

If writing a Java fact class strains you too much, check the Expert
documentation
for declare, to define a suitable fact type in your drl file.

For good obfuscation, you might try java.util.BitSet, (ab)using isEmpty().
   BitSet( empty == true )

-W


On Thu, Jul 16, 2009 at 11:31 AM, skasab2sskasa...@smail.inf.fh-brs.de wrote:

 Hi guys,

 I've been desperately trying to update a Boolean object, which is in the
 working memory.

 I have an initial rule that  first inserts it:
 rule Insert initial weanable value salience 100
        when

        then
                Boolean $weanable = false;
                insert($weanable);
 end

 and then I try to update it:
       ...
       when
               $weanable: Boolean( )
               ...
       then
                $weanable=true;
                update($weanable);
 end

 Which results to this exception : org.drools.FactException: Update error:
 handle not found for object: true. Is it in the working memory?
 I checked in the working memory and the Boolean-object was there!


 Is it possible to update a boolean that is in the working memory? If not, do
 you know some other Java class with setters and getters (behaving as a
 drools-fact) that I don't have to create myself and which I can use instead
 of Bboolean for this case ?

 Thanks in advance!

 Svetlomir

 --
 View this message in context: 
 http://www.nabble.com/Updating-a-Boolean-object-in-the-WM-tp24513225p24513225.html
 Sent from the drools - user mailing list archive at Nabble.com.

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


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


Re: [rules-users] Drools Govnor DB configuration

2009-07-16 Thread Jaroslaw Kijanowski
Hi,

pardeep.ru...@lntinfotech.com wrote:
 
 Hi,
 I am using Apache OFBiz and had successfully integrated Drools Guvnor 
 war file with OFBiz.
 By default Drools Guvnor supports Embedded derby, but in OFBiz i am 
 using MYSql , so i changed
 the default embedded derby to MySql using repository.xml file by the 
 following code.
 
 PersistenceManager 
 class=org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager
  
 
   param name=url 
 value=jdbc:mysql://localhost:3306/drools/
   param name=user value=root /
   param name=password value=Newuser123 /
   param name=schema value=mysql/
   param name=schemaObjectPrefix value=${wsp.name}_/
 /PersistenceManager
 
 Using this I successfully integrated Drools guvnor with same database as 
 I am using for OFBiz(MySql).
 
 Now I have created a new user in Drools guvnor to create permission for 
 that user, but I am not able to see
 where that username is stored in the database and in which entity or 
 table of MySql.
 
 Also if i want to use the users available in OFBiz MySql database 
  entity say 'Userlogin' where i am storing all the list of userlogins, 
 how can
 I retrieve the same and use this table data in drools Guvnor.

This can be done via JAAS - you just need to configure it to use a 
particular table in mysql for retrieving user logins/passwords.
Keep in mind that this is just for authentication (to login).
Here's a list of all available login modules:
http://www.jboss.org/community/wiki/LoginModule
http://www.jboss.org/community/wiki/DatabaseServerLoginModule

 Also when 
 I make a new user in Drools Govnor through
 administrator, my data of new user should go to  table 'UserLogin'.

AFAICT that's not possible and you need to synch your Guvnor user list 
with the OFBiz user list by yourself.

Cheers,
  Jarek
 
 Please help me how this can be achieved in Drools Guvnor.
 
 Thanks  Regards
 
 Pardeep Ruhil
 LT Infotech Ltd
 Mumbai
 Ph: +919820283884
 *
 Larsen  Toubro Infotech Ltd.*_
 __www.Lntinfotech.com_ http://www.lntinfotech.com/
 
 This Document is classified as:
 
 LT Infotech Proprietary   LT Infotech Confidential   LT Infotech 
 Internal Use Only   LT Infotech General Business  
 
 This Email may contain confidential or privileged information for the 
 intended recipient (s) If you are not the intended recipient, please do 
 not use or disseminate the information, notify the sender and delete it 
 from your system.
 __
 
 
 
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 http://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
http://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Updating a Boolean object in the WM

2009-07-16 Thread skasab2s

Thanks Wolfgang!

It worked great! The Declare-Command did it perfectly! Nice job! :)

Svetlomir.
-- 
View this message in context: 
http://www.nabble.com/Updating-a-Boolean-object-in-the-WM-tp24513225p24515020.html
Sent from the drools - user mailing list archive at Nabble.com.

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


Re: [rules-users] looking for more information on drools expert

2009-07-16 Thread Gab Aldian
After some more investigation, I managed also to make it work with
collect: http://drools.pastebin.com/m14f0e329

I would rather not multiplicate rules, because we probably will have
dozens for our system which is very big and can supervise around a
thousand equipements in some cases

Thank you very much for the advices

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


[rules-users] StatefulKnowledgeSession leaves threads running

2009-07-16 Thread Rafael Ribeiro

Hi all,

 I've downloaded Drools fusion sample and started to make some changes to
the code (first of all wipe out the UI so I can test it easier).
 I tried to get to a minimal set so I can run a console main class and see
what happens but I am facing a strange behaviour.
 As soon as I start pushing events into the WorkingMemoryEntryPoint
(StockTick stream) a Thread - not daemonized since it blocks shutdown from
ending - is spawned and this prevents my JVM from shutting down (obviously
if I call System.exit(0) it will but I am avoiding this).
 I've tried both to halt and dispose the session that this entry point
belongs but with no success. Does anyone know how could I get rid of this
thread?

best regards,
-- 
View this message in context: 
http://www.nabble.com/StatefulKnowledgeSession-leaves-threads-running-tp24503855p24503855.html
Sent from the drools - user mailing list archive at Nabble.com.

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


[rules-users] Using variables as map keys in MVEL in LHS

2009-07-16 Thread Steve Ronderos
Hello,

Again, I'm working on converting my project that used Drools 4.0.7 to 
5.0.1.

I've run across a problem with a rule that accesses a map in the LHS using 
a variable as the key.  When MVEL tries to resolve this, it appears that 
it is not evaluating the variable before accessing the map.  I've modified 
the Shopping example from the Drools 5.0.1 Examples to recreate the issue 
in a simpler setting.

This is the rule (I removed all the other rules for this example)
rule Cart notification
salience 10

when
$p : Product( $productName : name)
$c : Customer( cart[$productName] == $p) 
then
System.out.println( Customer  + $c.name +  has  + $p.name +  
in cart);
end 

I added the following to the Customer class:

private MapString,Product cart = new HashMapString, Product();
public MapString, Product getCart() {
return cart;
}

and I modified the main method to be:

public static final void main(String[] args) throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.
newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( Shopping.drl, 
ShoppingExample.class ),
  ResourceType.DRL );

final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

final StatefulKnowledgeSession ksession = 
kbase.newStatefulKnowledgeSession();

Customer mark = new Customer( mark,
  0 );
ksession.insert( mark );

Product shoes = new Product( shoes,
 60 );
ksession.insert( shoes );
 
mark.getCart().put(shoes, shoes);
 
ksession.fireAllRules();
}

So basically, I added a map to Customer, inserted one item and made a rule 
that will use a variable as a key for that map. 
What I would expect to happen is:
  the Product pattern would match the shoes Product that is inserted into 
the ksession, the $productName variable would contain the value shoes
  the Customer fact, mark, would be matched with the second pattern in the 
rule because cart[shoes] should resolve to the shoes fact which is $p in 
the rule
  The message should print

What actually happens is an error message:

Exception in thread main org.drools.RuntimeDroolsException: Exception 
executing predicate cart[$productName] == $p
at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(
PredicateConstraint.java:302)
at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(
SingleBetaConstraints.java:138)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:114)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(
SingleLeftTupleSinkAdapter.java:117)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(
SingleLeftTupleSinkAdapter.java:78)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(
LeftInputAdapterNode.java:142)
at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(
SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(
ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(
EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(
AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.insert(
AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(
AbstractWorkingMemory.java:788)
at org.drools.impl.StatefulKnowledgeSessionImpl.insert(
StatefulKnowledgeSessionImpl.java:216)
at org.drools.examples.ShoppingExample.main(
ShoppingExample.java:32)
Caused by: [Error: unable to resolve method: 
java.util.HashMap.$productName() [arglength=0]]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(
ReflectiveAccessorOptimizer.java:906)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(
ReflectiveAccessorOptimizer.java:585)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(
ReflectiveAccessorOptimizer.java:313)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(
ReflectiveAccessorOptimizer.java:138)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(
ASTNode.java:133)
at org.mvel2.compiler.ExecutableAccessor.getValue(
ExecutableAccessor.java:37)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(
ReflectiveAccessorOptimizer.java:633)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(
ReflectiveAccessorOptimizer.java:319)
at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(
ReflectiveAccessorOptimizer.java:138)
at 

Re: [rules-users] Getting hold of the Evaluator Registry

2009-07-16 Thread Edson Tirelli
There are several places that drools looks for configuration files,
including your home directory. Although, IMO it makes more sense to keep it
confined to the project itself. If you create a dir in your project, like:

src/resources/META-INF

And then configure the eclipse project to use the folde src/resources
as a source folder, it will pick it up.

[]s
Edson

2009/7/16 Jaroslaw Kijanowski kijanow...@gmail.com

 On Linux, when I created my own accumulate functions, I had to put this
 file in my home directory to have it picked up by Eclipse.

 Cheers,
  Jarek

 Edson Tirelli wrote:
 
 root of your project classpath, not root of your project.
 
 []s
 Edson
 
  2009/7/15 Asif Iqbal asif.iq...@infor.com mailto:asif.iq...@infor.com
 
 
  Hi Edson,
 
 
 
  I have gone away and tried the properties method of adding the
  customEvaluator, which worked fine for the code.  But my IDE still
  does not pick it up. Any ideas?
 
 
 
  Do I need to place it in a META-INF folder in the root of the
 project?
 
 
 
  I have the following in the drools.packagebuilder.conf file.
 
 
 
 
 drools.evaluator.custom=com.infor.audit.bpr.component.validation.impl.drools.CustomComparableEvaluatorsDefinition
 
 
 
  thanks..
 
 
 
 
 
 
 
 
  *From:* rules-users-boun...@lists.jboss.org
  mailto:rules-users-boun...@lists.jboss.org
  [mailto:rules-users-boun...@lists.jboss.org
  mailto:rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson
  Tirelli
 
  *Sent:* 15 July 2009 14:57
  *To:* Rules Users List
  *Subject:* Re: [rules-users] Getting hold of the Evaluator Registry
 
 
 
 
 Yes, you are in the right track, and I understand this is a bit
  confusing at first. One more reason for people to go to the October
  Rules Fest 2009 where I will give a presentation on all the ways to
  extend the engine to solve specific problems. It will be interesting
  I hope (last year was awesome) and even Charles Forgy will be there
  doing a presentation on Parallel Rete. :)
 
  Meanwhile I will write a tutorial on this, but just to help you
  there, your approach is correct, except that you don't need to setup
  the option for each operator. It works like this:
 
  * One EvaluatorDefinition class implements support to one or more
  evaluators, defined by the method public String[] getEvaluatorIds().
 
  * All you need to do, then, is wire you class once and the engine
  will pick-up all the IDs supported by that class. When you have your
  class wired, you give it a unique string identifier, so that if you
  ever need to replace it, or remove it, you will use that id.
  Sometimes we use the operator as the ID, but usually it is something
  that reminds you of the kind of evaluators that class define. For
  instance, drools registers the ComparableEvaluatorsDefinition in
  this way:
 
  drools.evaluator.comparable =
  org.drools.base.evaluators.ComparableEvaluatorsDefinition
 
So in this case, comparable is the identifier. Finally, from my
  previous e-mail you will see that the reason that the eclipse IDE is
  still giving you errors is that you are using the API to configure
  the evaluators. Just move the configuration to the configuration
  file and the IDE will pick it up.
 
 []s
 Edson
 
 
  2009/7/15 Asif Iqbal asif.iq...@infor.com
  mailto:asif.iq...@infor.com
 
  Edson,
 
 
 
  What I have done so far is created a
  CustomComparableEvaluatorsDefinition, which is exactly the same as
  the default ComparableEvaluatorsDefinition apart form having support
  for strings, which I have done by creating
  StringGreaterOrEqualEvaluators and added that in my custom class,
  using the addEvaluatorFunction :-
 
 
 
  addEvaluator( ValueType.SHORT_TYPE,
  Operator.GREATER, ShortGreaterEvaluator.INSTANCE );
 
  addEvaluator( ValueType.SHORT_TYPE,
  Operator.GREATER_OR_EQUAL,ShortGreaterOrEqualEvaluator.INSTANCE
 );
 
  addEvaluator( ValueType.PSHORT_TYPE,
  Operator.LESS,ShortLessEvaluator.INSTANCE );
 
  addEvaluator( ValueType.PSHORT_TYPE,
  Operator.LESS_OR_EQUAL,   ShortLessOrEqualEvaluator.INSTANCE
 );
 
  addEvaluator( ValueType.PSHORT_TYPE,
  Operator.GREATER, ShortGreaterEvaluator.INSTANCE );
 
  addEvaluator( ValueType.PSHORT_TYPE,
  Operator.GREATER_OR_EQUAL,ShortGreaterOrEqualEvaluator.INSTANCE
 );
 
  //Custom additions
 
  addEvaluator( ValueType.STRING_TYPE,
  Operator.LESS,StringLessEvaluator.INSTANCE );
 
  addEvaluator( ValueType.STRING_TYPE,
  

Re: [rules-users] looking for more information on drools expert

2009-07-16 Thread Edson Tirelli
   Very good! :)

   Just FYI, in the case of accumulate, you could also use the collectList()
function to simplify your rule. This:

$alarmList : LinkedList()
from accumulate (  ($e : Element(parentindex!=0) and
  $a : Alarm( origin matches
$e.name probablecause==45)),
  init( LinkedList alarmList = new
LinkedList();),
  action( alarmList.add($a);),
  reverse( alarmList.remove($a);),
  result( alarmList ) );
   Is the same as:

$alarmList : List()
from accumulate (  ($e : Element(parentindex!=0) and
  $a : Alarm( origin matches
$e.name probablecause==45)),
  collectList( $a ) );

   Also, you can always implement your own functions for accumulate:

http://blog.athico.com/2009/06/how-to-implement-accumulate-functions.html

   Finally, I see you are using matches operator to compare equal strings.
Not sure if that is what you want, because == has different semantics and
better performance than matches if what you really want is compare
equality. Remember that in regexps, some characters have special meaning,
for instance, . is a wildcard for any character. Meaning:

abc matches a.c - true
abc == a.c - false

   Cheers,
   Edson



2009/7/16 Gab Aldian aldian...@gmail.com

 After some more investigation, I managed also to make it work with
 collect: http://drools.pastebin.com/m14f0e329

 I would rather not multiplicate rules, because we probably will have
 dozens for our system which is very big and can supervise around a
 thousand equipements in some cases

 Thank you very much for the advices

 Aldian
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 http://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
http://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using variables as map keys in MVEL in LHS

2009-07-16 Thread Edson Tirelli
   This was a bug in one of the MVEL versions that is fixed. Can you update
your MVEL jar to one of the latest releases? I think it is 2.0.12.

   []s
   Edson

2009/7/16 Steve Ronderos steve.ronde...@ni.com


 Hello,

 Again, I'm working on converting my project that used Drools 4.0.7 to
 5.0.1.

 I've run across a problem with a rule that accesses a map in the LHS using
 a variable as the key.  When MVEL tries to resolve this, it appears that it
 is not evaluating the variable before accessing the map.  I've modified the
 Shopping example from the Drools 5.0.1 Examples to recreate the issue in a
 simpler setting.

 This is the rule (I removed all the other rules for this example)
 *rule* Cart notification
 *salience* 10

 *when*
 $p : Product( $productName : name)
 $c : Customer( cart[$productName] == $p)
 *then*
 System.out.println( Customer  + $c.name +  has  + $p.name + 
 in cart);
 *end*

 I added the following to the Customer class:

 *private* MapString,Product cart = *new* HashMapString, Product();
 *public* MapString, Product getCart() {
 *return* cart;
 }

 and I modified the main method to be:

 *public* *static* *final* *void* main(String[] args) *throws* Exception {
 *final* KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.*
 newKnowledgeBuilder*();
 kbuilder.add( ResourceFactory.*newClassPathResource*( Shopping.drl,
 ShoppingExample.*class* ),
   ResourceType.*DRL* );

 *final* KnowledgeBase kbase = KnowledgeBaseFactory.*newKnowledgeBase*
 ();
 kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

 *final* StatefulKnowledgeSession ksession =
 kbase.newStatefulKnowledgeSession();

 Customer mark = *new* Customer( mark,
   0 );
 ksession.insert( mark );

 Product shoes = *new* Product( shoes,
  60 );
 ksession.insert( shoes );

 mark.getCart().put(shoes, shoes);

 *ksession*.fireAllRules();
 }

 So basically, I added a map to Customer, inserted one item and made a rule
 that will use a variable as a key for that map.
 What I would expect to happen is:
   the Product pattern would match the shoes Product that is inserted into
 the ksession, the $productName variable would contain the value shoes
   the Customer fact, mark, would be matched with the second pattern in the
 rule because cart[shoes] should resolve to the shoes fact which is $p in
 the rule
   The message should print

 What actually happens is an error message:

 Exception in thread main *org.drools.RuntimeDroolsException*: Exception
 executing predicate cart[$productName] == $p
 at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(*
 PredicateConstraint.java:302*)
 at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(*
 SingleBetaConstraints.java:138*)
 at org.drools.reteoo.JoinNode.assertLeftTuple(*JoinNode.java:114*)
 at
 org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(*
 SingleLeftTupleSinkAdapter.java:117*)
 at
 org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(
 *SingleLeftTupleSinkAdapter.java:78*)
 at org.drools.reteoo.LeftInputAdapterNode.assertObject(*
 LeftInputAdapterNode.java:142*)
 at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(
 *SingleObjectSinkAdapter.java:42*)
 at org.drools.reteoo.ObjectTypeNode.assertObject(*
 ObjectTypeNode.java:185*)
 at org.drools.reteoo.EntryPointNode.assertObject(*
 EntryPointNode.java:146*)
 at org.drools.common.AbstractWorkingMemory.insert(*
 AbstractWorkingMemory.java:1046*)
 at org.drools.common.AbstractWorkingMemory.insert(*
 AbstractWorkingMemory.java:1001*)
 at org.drools.common.AbstractWorkingMemory.insert(*
 AbstractWorkingMemory.java:788*)
 at org.drools.impl.StatefulKnowledgeSessionImpl.insert(*
 StatefulKnowledgeSessionImpl.java:216*)
 at org.drools.examples.ShoppingExample.main(*
 ShoppingExample.java:32*)
 Caused by: [Error: unable to resolve method:
 java.util.HashMap.$productName() [arglength=0]]
 [Near : {... Unknown }]
  ^
 [Line: 1, Column: 0]
 at
 org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(*
 ReflectiveAccessorOptimizer.java:906*)
 at
 org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(
 *ReflectiveAccessorOptimizer.java:585*)
 at
 org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(
 *ReflectiveAccessorOptimizer.java:313*)
 at
 org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(
 *ReflectiveAccessorOptimizer.java:138*)
 at org.mvel2.ast.ASTNode.getReducedValueAccelerated(*
 ASTNode.java:133*)
 at org.mvel2.compiler.ExecutableAccessor.getValue(*
 ExecutableAccessor.java:37*)
 at
 

[rules-users] Question regarding Release 5.1

2009-07-16 Thread McDonald, Daniel
Hi,

Does anyone know if there is a roadmap for the next Drools release, an
anticipated, forecast, or suspected date, for Release 5.1?

 

Thank you,

 

Dan

Office phone: (972) 691-6593

Mobile phone (214) 697-8163

_

The information contained in this message is proprietary and/or confidential. 
If you are not the 
intended recipient, please: (i) delete the message and all copies; (ii) do not 
disclose, 
distribute or use the message in any manner; and (iii) notify the sender 
immediately. In addition, 
please be aware that any message addressed to our domain is subject to 
archiving and review by 
persons other than the intended recipient. Thank you.
_
___
rules-users mailing list
rules-users@lists.jboss.org
http://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] StatefulKnowledgeSession leaves threads running

2009-07-16 Thread Edson Tirelli
   Hi Rafael,

   Are you setting the MultithreadEvaluation option or is this using default
options? Do you have an example code that shows this behavior?

   Thanks,
 Edson

2009/7/16 Rafael Ribeiro rafae...@gmail.com


 Hi all,

  I've downloaded Drools fusion sample and started to make some changes to
 the code (first of all wipe out the UI so I can test it easier).
  I tried to get to a minimal set so I can run a console main class and see
 what happens but I am facing a strange behaviour.
  As soon as I start pushing events into the WorkingMemoryEntryPoint
 (StockTick stream) a Thread - not daemonized since it blocks shutdown
 from
 ending - is spawned and this prevents my JVM from shutting down (obviously
 if I call System.exit(0) it will but I am avoiding this).
  I've tried both to halt and dispose the session that this entry point
 belongs but with no success. Does anyone know how could I get rid of this
 thread?

 best regards,
 --

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


Re: [rules-users] StatefulKnowledgeSession leaves threads running

2009-07-16 Thread Rafael Ribeiro
Hi Edson!

 as I've already mentioned I've modified the sample so, if you get the
StockTick sample and replace the Main class this will run fine.
 The sample shuts down fine but as I saw it sets the JFrame uses
frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); which in
turn makes the trick.

 Below the code of my modified main class:

package org.drools.examples.broker;


import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.conf.EventProcessingOption;
import org.drools.examples.broker.model.Company;
import org.drools.examples.broker.model.CompanyRegistry;
import org.drools.examples.broker.model.StockTick;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;

public class Main {
private static final String RULES_FILE = /broker.drl;
static StatefulKnowledgeSession session;
static WorkingMemoryEntryPoint tickStream;

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
// set up and show main window

CompanyRegistry companies = new CompanyRegistry();

KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
try {
builder.add( ResourceFactory.newInputStreamResource(
Main.class.getResourceAsStream( RULES_FILE ) ),
 ResourceType.DRL);
} catch ( Exception e ) {
e.printStackTrace();
}
if( builder.hasErrors() ) {
System.err.println(builder.getErrors());
System.exit( 0 );
}

KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption( EventProcessingOption.STREAM );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( conf );
kbase.addKnowledgePackages( builder.getKnowledgePackages() );

session = kbase.newStatefulKnowledgeSession();

session.setGlobal( services, new BrokerServices() {
public void log(String message) {
System.out.println(message);
}
});

for( Company company : companies.getCompanies() ) {
session.insert( company );
}
session.fireAllRules();

tickStream = session.getWorkingMemoryEntryPoint( StockTick stream
);

for (int i=10;i0;i--) {
tickStream.insert(new StockTick(RHT, i*10,
System.currentTimeMillis()));
session.getAgenda().getAgendaGroup( evaluation ).setFocus();
session.fireAllRules();
}
session.dispose();
session.halt();
System.out.println(Still running...);
}

}


regards,
Rafael Ribeiro

2009/7/16 Edson Tirelli tire...@post.com


Hi Rafael,

Are you setting the MultithreadEvaluation option or is this using
 default options? Do you have an example code that shows this behavior?

Thanks,
  Edson

 2009/7/16 Rafael Ribeiro rafae...@gmail.com


 Hi all,

  I've downloaded Drools fusion sample and started to make some changes to
 the code (first of all wipe out the UI so I can test it easier).
  I tried to get to a minimal set so I can run a console main class and see
 what happens but I am facing a strange behaviour.
  As soon as I start pushing events into the WorkingMemoryEntryPoint
 (StockTick stream) a Thread - not daemonized since it blocks shutdown
 from
 ending - is spawned and this prevents my JVM from shutting down (obviously
 if I call System.exit(0) it will but I am avoiding this).
  I've tried both to halt and dispose the session that this entry point
 belongs but with no success. Does anyone know how could I get rid of this
 thread?

 best regards,
 --



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


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


Re: [rules-users] Drools Govnor DB configuration

2009-07-16 Thread James Owen
Note: I did ask permission before sending this notice to the Drools Developers and Drools Users Groups. Greetings:As both Edson Tirelli and Mark Proctor are presenting two great talks at October Rules Fest (http://www.OctoberRulesFest.org) this year, I thought it might be appropriate to let everyone know about the details. We will have no less than three presentations on CEP (Edson Tirelli, Paul Vincent of Tibco and Luke Voss ) so it should be a really great time for techies of this unique little world of rulebased programmers. Two of the talks have to do with complex implementations of a rulebased system. Dr. Forgy has promised to discuss (in addition to his parallel rulebase presentation) his new Tech algorithm that is 10 times faster than Rete 2 or Rete III. In addition we will haveDr. Forgy (Rete, Rete 2, Rete III, Tech)Gary Riley (CLIPS inventor)John Zachman (Enterprise Architecture guru)Dr. Hafedh Mili (wrote all of the early JRules tutorial manuals)Mark Proctor (Drools Inventor)Dr. Richard Hicks (Validation and Verification guru)Dr. Daniel Levine (One of the Neural Net Godfathers)Daniel Brookshier (UML - Rules inventor)Carole Ann Berlioz-Matignon  Carlos Serrano-Morales (Advisor inventors)Dr. Jacob Feldman (Open Rules inventor)Jason Morris (Jess Answer Man)Luke Voss (former JPL guru)Remember three things: (1) The Early Bird Discount for the October Rules Fest expires at the end of July. (2) There are a limited number of hotel rooms blocked off so, unless you register early, you won't be guaranteed a hotel room. (3) There are a limited number of seats this year so unless you register early there is no guarantee that you will be able to register. Now, the good stuff: We have been blessed with three things that make for a GOOD conference. Four things that make for a GREAT conference. Five things that make for an INSANELY GREAT conference. Six things that make... I just don't have the words for the sixth and seventh thing.1. Great Sponsors	2 Diamond (FICO,No Magic)	2 Gold(PST,KBSC)	1 Silver (Drools)	1 Bronze (BizRules)2. Great Speakers	see those above3. Great Meeting Place	The BEST Hotel in Texas,The Adolphus in Dallas	LocatedinthemiddleoftherestaurantdistrictofDowntownDallas	4. Great Attendees	Uber-geeks, techies, super-nerds, CTOs, CEOs,	(and all of the other terms that drive Jason up the wall)	Business Analysts, Programmers, Research guys,	Ph.D. Candidates, University Professors	HR guys looking for rulebase engineers?5. White Papers will be published after the conference in a collection available either bound, printed format and/or online after the conference.6. Videos will be done properly this year by Greg Barton and Chelanie Israel such that the author will be talking at one corner of the screen and the presentation on the other side of the screen. (Very similar to what you see at parlays.com) These will be available after the conference with a password given at the conference itself or shortly thereafter.7. ConferencePresentations (PPTs or PDFs) will be available both during and after the conference with the assigned password for access during and after the conference.8. Great Location for food!The conference is located in the middle of the restaurant district of downtown Dallas and we will have listing of some of the ones that we know about.SDGJames C. OwenCo-Founder October Rules Festhttp://www.kbsc.comhttp://www.OctoberRulesFest.org"This above all: to thine own self be true,And it must follow, as the night the day,Thou canst not then be false to any man."Hamlet, Act 1, Scene IIIhttp://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html[You can also replyTo:j...@kbsc.com]___
rules-users mailing list
rules-users@lists.jboss.org
http://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] StatefulKnowledgeSession leaves threads running

2009-07-16 Thread Greg Barton

I have seen similar behavior, though at the time I didn't have the opportunity 
to investigate the cause. (Sorry about not reporting it at the time.) Unlike 
the code below it was while calling session.fireUntilHalt(). (In a seperate 
thread.)  After calling session.halt() from another thread the fireUntilHalt() 
would exit, but the VM would not exit due to a non-daemon thread persisting.

--- On Thu, 7/16/09, Rafael Ribeiro rafae...@gmail.com wrote:

 From: Rafael Ribeiro rafae...@gmail.com
 Subject: Re: [rules-users] StatefulKnowledgeSession leaves threads running
 To: Rules Users List rules-users@lists.jboss.org
 Date: Thursday, July 16, 2009, 12:10 PM
 Hi Edson!
 
  as I've already mentioned I've modified the
 sample so, if you get the StockTick sample and replace the
 Main class this will run fine.
  The sample shuts down fine but as I saw it sets the
 JFrame uses frame.setDefaultCloseOperation(
 WindowConstants.EXIT_ON_CLOSE ); which in turn makes the
 trick.
 
 
  Below the code of my modified main class:
 
 package org.drools.examples.broker;
 
 
 import org.drools.KnowledgeBase;
 import org.drools.KnowledgeBaseConfiguration;
 import org.drools.KnowledgeBaseFactory;
 
 import org.drools.builder.KnowledgeBuilder;
 import org.drools.builder.KnowledgeBuilderFactory;
 import org.drools.builder.ResourceType;
 import org.drools.conf.EventProcessingOption;
 import org.drools.examples.broker.model.Company;
 
 import org.drools.examples.broker.model.CompanyRegistry;
 import org.drools.examples.broker.model.StockTick;
 import org.drools.io.ResourceFactory;
 import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
 
 
 public class Main {
     private static final String RULES_FILE =
 /broker.drl;
     static StatefulKnowledgeSession session;
     static WorkingMemoryEntryPoint tickStream;
 
     /**
  * @param args
 
  */
     public static void main(String[] args) throws
 Exception {
     // set up and show main window
     
     CompanyRegistry companies = new
 CompanyRegistry();
     
     KnowledgeBuilder builder =
 KnowledgeBuilderFactory.newKnowledgeBuilder();
 
     try {
     builder.add(
 ResourceFactory.newInputStreamResource(
 Main.class.getResourceAsStream( RULES_FILE ) ),
 
 ResourceType.DRL);
     } catch ( Exception e ) {
     e.printStackTrace();
 
     }
     if( builder.hasErrors() ) {
    
 System.err.println(builder.getErrors());
     System.exit( 0 );
     }
 
     KnowledgeBaseConfiguration conf =
 KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
 
     conf.setOption( EventProcessingOption.STREAM
 );
     KnowledgeBase kbase =
 KnowledgeBaseFactory.newKnowledgeBase( conf );
     kbase.addKnowledgePackages(
 builder.getKnowledgePackages() );
     
 
     session =
 kbase.newStatefulKnowledgeSession();
 
     session.setGlobal( services, new
 BrokerServices() {
             public void log(String message) {
                
 System.out.println(message);                
 
             }
     });
 
     for( Company company :
 companies.getCompanies() ) {
     session.insert( company );
     }
     session.fireAllRules();
     
     tickStream =
 session.getWorkingMemoryEntryPoint( StockTick
 stream );
 
  
     for (int i=10;i0;i--) {
         tickStream.insert(new
 StockTick(RHT, i*10,
 System.currentTimeMillis()));
     session.getAgenda().getAgendaGroup(
 evaluation ).setFocus();
 
     session.fireAllRules();
     }
     session.dispose();
     session.halt();
     System.out.println(Still
 running...);
     }
     
 }
 
 
 regards,
 Rafael Ribeiro
 
 
 2009/7/16 Edson Tirelli tire...@post.com
 
 
    Hi Rafael,
 
    Are you setting the MultithreadEvaluation option or is
 this using default options? Do you have an example code that
 shows this behavior?
 
    Thanks,
  Edson
 
 
 
 2009/7/16 Rafael Ribeiro rafae...@gmail.com
 
 
 
 
 Hi all,
 
 
 
  I've downloaded Drools fusion sample and started to
 make some changes to
 
 the code (first of all wipe out the UI so I can test it
 easier).
 
  I tried to get to a minimal set so I can run a console
 main class and see
 
 what happens but I am facing a strange behaviour.
 
  As soon as I start pushing events into the
 WorkingMemoryEntryPoint
 
 (StockTick stream) a Thread - not daemonized
 since it blocks shutdown from
 
 ending - is spawned and this prevents my JVM from shutting
 down (obviously
 
 if I call System.exit(0) it will but I am avoiding this).
 
  I've tried both to halt and dispose the session that
 this entry point
 
 belongs but with no success. Does anyone know how could I
 get rid of this
 
 thread?
 
 
 
 best regards,
 
 --
 
 
 
 
 ___
 
 rules-users mailing list
 
 rules-users@lists.jboss.org
 
 

Re: [rules-users] Using variables as map keys in MVEL in LHS

2009-07-16 Thread Steve Ronderos
Thanks Edson, worked like a charm!

Steve Ronderos

rules-users-boun...@lists.jboss.org wrote on 07/16/2009 09:09:31 AM:

 [image removed] 
 
 Re: [rules-users] Using variables as map keys in MVEL in LHS
 
 Edson Tirelli 
 
 to:
 
 Rules Users List
 
 07/16/2009 09:11 AM
 
 Sent by:
 
 rules-users-boun...@lists.jboss.org
 
 Please respond to Rules Users List
 
 
This was a bug in one of the MVEL versions that is fixed. Can you
 update your MVEL jar to one of the latest releases? I think it is 
2.0.12.
 
[]s
Edson

 2009/7/16 Steve Ronderos steve.ronde...@ni.com
 
 Hello, 
 
 Again, I'm working on converting my project that used Drools 4.0.7 to 
5.0.1. 
 
 I've run across a problem with a rule that accesses a map in the LHS
 using a variable as the key.  When MVEL tries to resolve this, it 
 appears that it is not evaluating the variable before accessing the 
 map.  I've modified the Shopping example from the Drools 5.0.1 
 Examples to recreate the issue in a simpler setting. 
 
 This is the rule (I removed all the other rules for this example) 
 rule Cart notification 
 salience 10 
 
 when 
 $p : Product( $productName : name) 
 $c : Customer( cart[$productName] == $p)   
 then 
 System.out.println( Customer  + $c.name +  has  + $p.name
 +  in cart); 
 end   
 
 I added the following to the Customer class: 
 
 private MapString,Product cart = new HashMapString, Product(); 
 public MapString, Product getCart() { 
 return cart; 
 } 
 
 and I modified the main method to be: 
 
 public static final void main(String[] args) throws Exception { 
 final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.
 newKnowledgeBuilder(); 
 kbuilder.add( ResourceFactory.newClassPathResource( 
 Shopping.drl, ShoppingExample.class ), 
   ResourceType.DRL ); 
 
 final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); 

 kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); 
 
 final StatefulKnowledgeSession ksession = 
 kbase.newStatefulKnowledgeSession(); 
 
 Customer mark = new Customer( mark, 
   0 ); 
 ksession.insert( mark ); 
 
 Product shoes = new Product( shoes, 
  60 ); 
 ksession.insert( shoes ); 
 
 mark.getCart().put(shoes, shoes); 
 
 ksession.fireAllRules(); 
 } 
 
 So basically, I added a map to Customer, inserted one item and made 
 a rule that will use a variable as a key for that map.   
 What I would expect to happen is: 
   the Product pattern would match the shoes Product that is inserted
 into the ksession, the $productName variable would contain the value 
shoes 
   the Customer fact, mark, would be matched with the second pattern 
 in the rule because cart[shoes] should resolve to the shoes fact 
 which is $p in the rule 
   The message should print 
 
 What actually happens is an error message: 
 
 Exception in thread main org.drools.RuntimeDroolsException: 
 Exception executing predicate cart[$productName] == $p 
 at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(
 PredicateConstraint.java:302) 
 at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(
 SingleBetaConstraints.java:138) 
 at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:114) 

 at 
 org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(
 SingleLeftTupleSinkAdapter.java:117) 
 at 
 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple
 (SingleLeftTupleSinkAdapter.java:78) 
 at org.drools.reteoo.LeftInputAdapterNode.assertObject(
 LeftInputAdapterNode.java:142) 
 at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(
 SingleObjectSinkAdapter.java:42) 
 at org.drools.reteoo.ObjectTypeNode.assertObject(
 ObjectTypeNode.java:185) 
 at org.drools.reteoo.EntryPointNode.assertObject(
 EntryPointNode.java:146) 
 at org.drools.common.AbstractWorkingMemory.insert(
 AbstractWorkingMemory.java:1046) 
 at org.drools.common.AbstractWorkingMemory.insert(
 AbstractWorkingMemory.java:1001) 
 at org.drools.common.AbstractWorkingMemory.insert(
 AbstractWorkingMemory.java:788) 
 at org.drools.impl.StatefulKnowledgeSessionImpl.insert(
 StatefulKnowledgeSessionImpl.java:216) 
 at 
org.drools.examples.ShoppingExample.main(ShoppingExample.java:32) 
 Caused by: [Error: unable to resolve method: java.util.HashMap.
 $productName() [arglength=0]] 
 [Near : {... Unknown }] 
  ^ 
 [Line: 1, Column: 0] 
 at 
 org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(
 ReflectiveAccessorOptimizer.java:906) 
 at 
 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(
 ReflectiveAccessorOptimizer.java:585) 
 at 
 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(
 

[rules-users] Visu Nageswaran is out of the office.

2009-07-16 Thread Viswanathan Nageswaran

I will be out of the office starting  17/07/2009 and will not return until
18/07/2009.

I am in a training today. Response to emails would be delayed. For anything
urgent, please call at +91-9884702390.

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


Re: [rules-users] Drools Govnor DB configuration

2009-07-16 Thread Pardeep . Ruhil
Hi,
Thanks Jarek for your reply. 
Still I have one doubt in my mind, how can I see the data for a newly 
registered user (i.e name  permission )
created through Drools Guvnor  administrator functionality.  Where should 
I find the new user data(i.e. name   permission assigned) , so that 
I can write synch service to synch data from Drools Guvnor table to OFBiz 
table.

Please help me to through out from this problem.

Thanks  Regards

Pardeep Ruhil
LT Infotech Ltd
Mumbai
Ph: +919820283884


pardeep.ru...@lntinfotech.com wrote:
 
 Hi,
 I am using Apache OFBiz and had successfully integrated Drools Guvnor 
 war file with OFBiz.
 By default Drools Guvnor supports Embedded derby, but in OFBiz i am 
 using MYSql , so i changed
 the default embedded derby to MySql using repository.xml file by the 
 following code.
 
 PersistenceManager 
 
class=org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager 

 
   param name=url 
 value=jdbc:mysql://localhost:3306/drools/
   param name=user value=root /
   param name=password value=Newuser123 /
   param name=schema value=mysql/
   param name=schemaObjectPrefix 
value=${wsp.name}_/
 /PersistenceManager
 
 Using this I successfully integrated Drools guvnor with same database as 

 I am using for OFBiz(MySql).
 
 Now I have created a new user in Drools guvnor to create permission for 
 that user, but I am not able to see
 where that username is stored in the database and in which entity or 
 table of MySql.
 
 Also if i want to use the users available in OFBiz MySql database 
  entity say 'Userlogin' where i am storing all the list of userlogins, 
 how can
 I retrieve the same and use this table data in drools Guvnor.

This can be done via JAAS - you just need to configure it to use a 
particular table in mysql for retrieving user logins/passwords.
Keep in mind that this is just for authentication (to login).
Here's a list of all available login modules:
http://www.jboss.org/community/wiki/LoginModule
http://www.jboss.org/community/wiki/DatabaseServerLoginModule

 Also when 
 I make a new user in Drools Govnor through
 administrator, my data of new user should go to  table 'UserLogin'.

AFAICT that's not possible and you need to synch your Guvnor user list 
with the OFBiz user list by yourself.

Cheers,
  Jarek
 
 Please help me how this can be achieved in Drools Guvnor.
 
 Thanks  Regards
 
 Pardeep Ruhil
 LT Infotech Ltd
 Mumbai
 Ph: +919820283884
 *
 Larsen  Toubro Infotech Ltd.*_
 __www.Lntinfotech.com_ http://www.lntinfotech.com/
 
 This Document is classified as:
 
 LT Infotech Proprietary   LT Infotech Confidential   LT Infotech 
 Internal Use Only   LT Infotech General Business 
 
 This Email may contain confidential or privileged information for the 
 intended recipient (s) If you are not the intended recipient, please do 
 not use or disseminate the information, notify the sender and delete it 
 from your system.


_
rules-users mailing list
rules-users@lists.jboss.org
http://lists.jboss.org/mailman/listinfo/rules-users