[rules-users] How to access Guvnor Rules based on versions from Java?

Jervis Liu jliu at redhat.com
Fri Oct 19 04:55:20 EDT 2012


On 2012/10/16 19:47, Ravikiran wrote:
> Hi Jarvis,
>
> Thanks for your reply. Looks like i have posted my intension unclearly. To
> elaborate bit more, currently i am using Rest API to create KnowledgeBase
> from my java client. I have changeset-loans.xml, where my guvnor package
> with drl is defined. My java client will this to fire all rules of that
> package. In such a case, when i have more one version created for the
> package and the rule assets within it, how i can i call specific version
> based package along with the drl file to fire all the rule assets belongs to
> it? In the same passion, is there any way i can mentioned the rule asset
> name in the changeset xml file to fire specific version of rule asset from
> java?
Yes, it is possible to specify a specific version of asset in changeset. 
though this is not supported by Change-set editor at the moment, you 
have to edit the content of change-set xml file manually. For example, 
below is generated by change-set editor:

<change-set xmlns='http://drools.org/drools-5.0/change-set'
     xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
     xs:schemaLocation='http://drools.org/drools-5.0/change-set 
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' 
 >
     <add>
          <resource 
source='http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/assets/sss/source' 
type='DRL' />
     </add>
</change-set>

If you want to use a specific version of asset "sss", what you need to 
do is to modify the source URL, make it pointing to the specific version 
of the asset source. eg:

          <resource 
source='http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/assets/sss/versions/2/source' 
type='DRL' />

This is to get version 2 of asset "sss" source.


Cheers,
Jervis

>
> I can only get the package or rule asset's metadata using the urls that you
> have mentioned in your post. But i can't fire the rules...please suggest if
> i am doing something wrong.
>
> changeset-loans.xml
> -------------------------
> <change-set xmlns='http://drools.org/drools-5.0/change-set'
>      xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
>      xs:schemaLocation='http://drools.org/drools-5.0/change-set
>     
> http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd'
>     <add>
>        <resource
>       
> source='http://localhost:9080/guvnor-5.2.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/package/loans/loans_demo.drl'
>        type='DRL' basicAuthentication="enabled" username="admin"
> password="admin" />
>     </add>
> </change-set>
>
> Thanks
> Ravi
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/How-to-access-Guvnor-Rules-based-on-versions-from-Java-tp4020285p4020301.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121019/e6e54f48/attachment.html 


More information about the rules-users mailing list