[rules-users] Calling Technical rule assets in Guvnor

Michael Anstis michael.anstis at gmail.com
Tue Oct 30 11:45:56 EDT 2012


Are you sure the AgendaFilter is not causing the Technical Rule to be
excluded?

On 29 October 2012 12:17, Manasi <manasi.a.damle at capgemini.com> wrote:

> Hi,
>
> How to call Technical rule assets stored in Guvnor from Java application?
>
> Currently I have one drl rule which is stored in Technical rule assets
> section.
>
> But I am not able to call it from my Java application.
>
> I am using following code to call my rules stored in Guvnor :
>
> UrlResource urlResource = (UrlResource)
> ResourceFactory.newUrlResource(
> http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/GuiKontrolKiss.FeltKnapRestriktionerKundeMedAnl/LATEST
> ");
> urlResource     .setBasicAuthentication("enabled");
> urlResource.setUsername("admin");
> urlResource.setPassword("admin");
> urlResource.setResourceType(ResourceType.PKG);
>
> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
> try {
>         kbuilder.add(ResourceFactory.newInputStreamResource(urlResource
>                                         .getInputStream()),
> ResourceType.PKG);
>     } catch (IOException e) {
>                         e.printStackTrace();
>         }
> KnowledgeBase kbase = kbuilder.newKnowledgeBase();
> // create session
> StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
> NyssCaseSO caseSO = droolsRequest.getNyssCaseSO();
> NyssCaseStateSO caseState = caseSO.getNyssCaseStateSO();
> NyssOfferSO offerSO = droolsRequest.getNyssOfferSO();
>
> session.insert(caseSO);
> session.insert(offerSO);
> session.insert(caseState);
>
> AgendaFilter filter = new AgendaFilter() {
>         public boolean accept(Activation activation) {
>                 if (activation.getRule().getName().contains("testDrl")) {
>                                 return true;
>                 }
>                 return false;
>         }
> };
> session.fireAllRules(filter);
>
> for (Object o : session.getObjects()) {
>                 if (o instanceof ResultSO) {
>                         ResultSO resultSO = (ResultSO) o;
>                         reply.setResultSO(resultSO);
>                 }
> }
> session.dispose();
>
> With above I am able to call my rules stored in *"Business rule assets"*
> section.
>
> Thanks,
> Manasi
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Calling-Technical-rule-assets-in-Guvnor-tp4020537.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/20121030/462e053c/attachment-0001.html 


More information about the rules-users mailing list