[
https://jira.jboss.org/browse/JBRULES-2715?page=com.atlassian.jira.plugin...
]
Tihomir Surdilovic edited comment on JBRULES-2715 at 9/29/10 6:07 PM:
----------------------------------------------------------------------
Ugh this was hidden, but yes you can actually do this now. Here is small example:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
Person p = new Person(); // some dummy fact for this test
RuleNameEndsWithAgendaFilter filter = new RuleNameEndsWithAgendaFilter("TEST");
@SuppressWarnings("rawtypes")
List<Command> cmds = new ArrayList<Command>();
cmds.add(CommandFactory.newInsert(p));
cmds.add(new FireAllRulesCommand(filter));
ExecutionResults results = ksession.execute(CommandFactory.newBatchExecution(cmds));
This will only execute rules that end with "TEST"
The Agenda Filter is defined as:
private static class RuleNameEndsWithAgendaFilter implements AgendaFilter {
private final String suffix;
private final boolean accept;
public RuleNameEndsWithAgendaFilter(final String suffix) {
this(suffix, true);
}
public RuleNameEndsWithAgendaFilter(final String suffix,
final boolean accept) {
this.suffix = suffix;
this.accept = accept;
}
public boolean accept(final Activation activation) {
if (activation.getRule().getName().endsWith(this.suffix)) {
return this.accept;
} else {
return !this.accept;
}
}
}
was (Author: tsurdilovic):
Ugh this was hidden, but yes you can actually do this now. Here is small example:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
Person p = new Person(); // some dummy fact for this test
RuleNameEndsWithAgendaFilter filter = new RuleNameEndsWithAgendaFilter("TEST");
@SuppressWarnings("rawtypes")
List<Command> cmds = new ArrayList<Command>();
cmds.add(CommandFactory.newInsert(p));
//cmds.add(new FireAllRulesCommand(filter));
ExecutionResults results = ksession.execute(CommandFactory.newBatchExecution(cmds));
This will only execute rules that end with "TEST"
The Agenda Filter is defined as:
private static class RuleNameEndsWithAgendaFilter implements AgendaFilter {
private final String suffix;
private final boolean accept;
public RuleNameEndsWithAgendaFilter(final String suffix) {
this(suffix, true);
}
public RuleNameEndsWithAgendaFilter(final String suffix,
final boolean accept) {
this.suffix = suffix;
this.accept = accept;
}
public boolean accept(final Activation activation) {
if (activation.getRule().getName().endsWith(this.suffix)) {
return this.accept;
} else {
return !this.accept;
}
}
}
Ability to add AgendaFilter to a stateless session
---------------------------------------------------
Key: JBRULES-2715
URL:
https://jira.jboss.org/browse/JBRULES-2715
Project: Drools
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: drools-api
Affects Versions: 5.1.1.FINAL
Reporter: Arnaud Simon
Assignee: Tihomir Surdilovic
It is currently not possible to use AgendaFilter with a stateless session. It would be
nice if the stateless session execute method would also be able to take in the
agendafilter argument just like fireAllRules does.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira