Are you sure the AgendaFilter is not causing the Technical Rule to be
excluded?
On 29 October 2012 12:17, Manasi <manasi.a.damle(a)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/GuiK...
");
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...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users