I haven't been able to get "ResourceType.BRL" to work. This is how I do it .. 

String curDir = System.getProperty("user.dir"); 
String fileName = curDir + "\\src\\main\\rules\\drools.package";
String rulePackageContent = FileUtils.readFileToString(new File(fileName)); 
fileName = curDir + "\\src\\main\\rules\\eligibility.brl";
String brl = FileUtils.readFileToString(new File(fileName)); 
BRLPersistence read = BRXMLPersistence.getInstance(); 
BRLPersistence write = BRDRLPersistence.getInstance();
String outputDRL = rulePackageContent + write.marshal(read.unmarshal(brl)); 
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newReaderResource(new StringReader(outputDRL)), 
ResourceType.DRL);


Try this.


-abhay

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Sumeet Karawal
Sent: Wednesday, May 18, 2011 11:47 AM
To: Rules Users List
Subject: Re: [rules-users] Facing Problem in BRL

This is the brl that I have created:


(Embedded image moved to file: pic18001.jpg)


Regards,
Sumeet Karawal
Mailto: [email protected]


                                                                                
                                       
  From:       "Abhay B. Chaware" <[email protected]>                
                                       
                                                                                
                                       
  To:         Rules Users List <[email protected]>                    
                                       
                                                                                
                                       
  Date:       05/18/2011 11:42 AM                                               
                                       
                                                                                
                                       
  Subject:    Re: [rules-users] Facing Problem in BRL                           
                                       
                                                                                
                                       
  Sent by:    [email protected]                               
                                       
                                                                                
                                       





Could you post your rule content here ?


-----Original Message-----
From: [email protected] [
mailto:[email protected]] On Behalf Of Sumeet Karawal
Sent: Wednesday, May 18, 2011 11:38 AM
To: [email protected]
Subject: [rules-users] Facing Problem in BRL


Hi,

I am using Drools-Expert. I am having a class "Person" with data members as
age and discount.
I am trying to create a .brl. I have these statements in drools.package
package com.rules;

import com.model.PersonDetails;


and in the example.brl I am providing the details of when and then
conditions

but on execution I am getting the following error :

java.lang.RuntimeException: [4] Unable to expand: PersonDetails( age <
"20" )[6] Unable to expand:                              PersonDetails fact0 = 
new
PersonDetails
();[7] Unable to expand:                                 fact0.setDiscount
( 10 );[8] Unable to
expand:                                  insert(fact0 );


It would be helpful is somebody guide me on how execute it.

Also, I am creating the knowledgebase as:

private static KnowledgeBase createKnowledgeBase() {
 KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    builder.add (ResourceFactory.newClassPathResource(
"com/rules/example.brl"),ResourceType.BRL);
    if (builder.hasErrors()) {
      throw new RuntimeException (builder.getErrors().toString ());
    }
    KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
    knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages ());
    return knowledgeBase;}


Thanks & Regards,
Sumeet Karawal
CEG - Open Source Technology Group
Tata Consultancy Services
Ph:- +912267782556
Cell:- +919833236440
Mailto: [email protected]
Website: http://www.tcs.com
____________________________________________
Experience certainty.            IT Services
                                                 Business Solutions
                                                 Outsourcing
____________________________________________

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you



_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to