[rules-users] Uploading rules dynamically

Fnu Mahalakshmi FMahalakshmi at nyx.com
Tue Jun 15 12:32:32 EDT 2010


Hi,

I was just going through how to work with knowledge builder and have some doubts:
Code sample is as follows:

final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",
                                HelloWorldExample.class), ResourceType.DRL);

// Check the builder for errors
if (kbuilder.hasErrors()) {
    System.out.println(kbuilder.getErrors().toString());
    throw new RuntimeException("Unable to compile \"HelloWorld.drl\".");
}

// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);

final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

In the above code: I am manually having to add the .drl file and the classpath to my kbuilder. So don't I just have to end up listing all the files and adding it to my knowledge builder?

Is it that each of the files keeps getting added as and when you update the rule files?
How does the program detect this update?? As I am ending up having to add everything.

Please guide.

Thank you
M






-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of rules-users-request at lists.jboss.org
Sent: Tuesday, June 15, 2010 12:00 PM
To: rules-users at lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 75

Send rules-users mailing list submissions to
        rules-users at lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
        rules-users-request at lists.jboss.org

You can reach the person managing the list at
        rules-users-owner at lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Re: Uploading rules dynamically (Esteban Aliverti)
   2. Re: Dynamic rule file uploading (Fnu Mahalakshmi)


----------------------------------------------------------------------

Message: 1
Date: Tue, 15 Jun 2010 12:12:45 -0300
From: Esteban Aliverti <esteban.aliverti at gmail.com>
Subject: Re: [rules-users] Uploading rules dynamically
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID:
        <AANLkTilRCzG0E9-W6OsVWXHy_kyQNpDdblxitfmg91YZ at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

You can read about Knowledge Agent:
http://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-expert/html_single/index.html#d4e615

Maybe it suits your needs.

2010/6/15 Fnu Mahalakshmi <FMahalakshmi at nyx.com>

>  Hi Guys,
>
>
>
> How can I dynamically upload my rules? Can someone point me towards some
> documentation for the same??
>
>
>
> Thank you.
>
>
>
> M
>
> ------------------------------
>
> *Please consider the environment before printing this email.*
>
> *Visit our website at http://www.nyse.com
> *****************************************************************************
>
> Note: The information contained in this message and any attachment to it is
> privileged, confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify the sender immediately by replying to
> the message, and please delete it from your system. Thank you. NYSE
> Euronext. *
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100615/09ed061f/attachment-0001.html

------------------------------

Message: 2
Date: Tue, 15 Jun 2010 11:58:37 -0400
From: Fnu Mahalakshmi <FMahalakshmi at nyx.com>
Subject: Re: [rules-users] Dynamic rule file uploading
To: "'rules-users at lists.jboss.org'" <rules-users at lists.jboss.org>
Message-ID:
        <994758E35590274E955FA75763C5AA5002D01121 at MTEXMBXP01.ad.NYX.com>
Content-Type: text/plain; charset="us-ascii"

Hi,

Thanks for the quick reply.
But even by using knowledge agent I have to keep specifying each of the files one by one right? Which ever is contained in my folder with all the rule files? As I would keep doing:

kbuilder.add( ResourceFactory.newUrlResource( "file://myrules.drl" ),
                       ResourceType.DRL);

So again I would have to list all my files and pass it to the knowledge agent which would add the new rule to the existing package( created using package builder).
Am I going wrong here??
Please help.

Thank you.
M


-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of rules-users-request at lists.jboss.org
Sent: Tuesday, June 15, 2010 11:13 AM
To: rules-users at lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 74

Send rules-users mailing list submissions to
        rules-users at lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
        rules-users-request at lists.jboss.org

You can reach the person managing the list at
        rules-users-owner at lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Uploading rules dynamically (Fnu Mahalakshmi)
   2. Dynamic rule file uploading (Fnu Mahalakshmi)
   3. Re: Dynamic rule file uploading (PAYET, Manuel)


----------------------------------------------------------------------

Message: 1
Date: Tue, 15 Jun 2010 10:56:42 -0400
From: Fnu Mahalakshmi <FMahalakshmi at nyx.com>
Subject: [rules-users] Uploading rules dynamically
To: "'rules-users at lists.jboss.org'" <rules-users at lists.jboss.org>
Message-ID:
        <994758E35590274E955FA75763C5AA5002D0111F at MTEXMBXP01.ad.NYX.com>
Content-Type: text/plain; charset="us-ascii"

Hi Guys,

How can I dynamically upload my rules? Can someone point me towards some documentation for the same??

Thank you.

M
</pre>

<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a href="http://www.nyse.com">http://www.nyse.com</a> <br>

*****************************************************************************
<br>
Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.

</STRONG></P><pre>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100615/dd42b4f2/attachment-0001.html

------------------------------

Message: 2
Date: Tue, 15 Jun 2010 11:06:32 -0400
From: Fnu Mahalakshmi <FMahalakshmi at nyx.com>
Subject: [rules-users] Dynamic rule file uploading
To: "'rules-users at lists.jboss.org'" <rules-users at lists.jboss.org>
Message-ID:
        <994758E35590274E955FA75763C5AA5002D01120 at MTEXMBXP01.ad.NYX.com>
Content-Type: text/plain; charset="us-ascii"

Hi guys,

I have : {R1.drl,R2.drl,R3.brl}
After conversion and loading I have {R1.drl,R2.drl,R3.brl,R3.drl} files in the same directory where all my rules are stored.

I am using:
    File folder = new File("SRC/MAIN/RULES");
    File[] listOfFiles = folder.listFiles();

for listing all the files in my rules directory.
Now is there anyway that I can just hold on to the required files whenever my rule files are updated rather than having to manually keeping deleting and updating my rules directory?
Is there a more better way to do it rather than just listing all the files in the directory??

Thanks,
M
</pre>

<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a href="http://www.nyse.com">http://www.nyse.com</a> <br>

*****************************************************************************
<br>
Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.

</STRONG></P><pre>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100615/4c210fea/attachment-0001.html

------------------------------

Message: 3
Date: Tue, 15 Jun 2010 17:12:26 +0200
From: "PAYET, Manuel" <manuel.payet at capgemini.com>
Subject: Re: [rules-users] Dynamic rule file uploading
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID:
        <5104F06B63E3164FAEB2F42B920311654CCCA3CE at CORPMAIL05.corp.capgemini.com>

Content-Type: text/plain; charset="iso-8859-1"

you'd probably be interested by
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/builder/KnowledgeBuilder.html

and more particularly the knowledgeAgent, below is a copy/paste of a part of the link above


 <change-set xmlns='http://drools.org/drools-5.0/change-set'
             xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
             xs:schemaLocation='drools-change-set-5.0.xsd' >
  <add>
       <resource source='http:org/domain/myrules.drl' type='DRL' />
       <resource source='classpath:data/IntegrationExampleTest.xls' type="DTABLE">
           <decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
       </resource>
       <resource source='file:org/drools/decisiontable/myflow.drf' type='DRF' />
   </add>
 </change-set>


 KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "test agent", // the name of the agent
                                                                  kaconf );
 kagent.applyChangeSet( ResourceFactory.newUrlResource( url ) ); // resource to the change-set xml for the resources to add


kagent will periodically check if there is difference in the change-set, and upload your knowledge automagically

________________________________
De : rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] De la part de Fnu Mahalakshmi
Envoy? : mardi 15 juin 2010 17:07
? : 'rules-users at lists.jboss.org'
Objet : [rules-users] Dynamic rule file uploading

Hi guys,

I have : {R1.drl,R2.drl,R3.brl}
After conversion and loading I have {R1.drl,R2.drl,R3.brl,R3.drl} files in the same directory where all my rules are stored.

I am using:
    File folder = new File("SRC/MAIN/RULES");
    File[] listOfFiles = folder.listFiles();

for listing all the files in my rules directory.
Now is there anyway that I can just hold on to the required files whenever my rule files are updated rather than having to manually keeping deleting and updating my rules directory?
Is there a more better way to do it rather than just listing all the files in the directory??

Thanks,
M

________________________________

Please consider the environment before printing this email.

Visit our website at http://www.nyse.com
*****************************************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.
</PRE><p style="font-family:arial;color:grey" style="font-size:13px">This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.</p><PRE>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100615/7143bb17/attachment.html

------------------------------

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 43, Issue 74
*******************************************
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.




------------------------------

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 43, Issue 75
*******************************************
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.





More information about the rules-users mailing list