2017-10-10 10 views
0

私は1つのプロジェクトで2つのガイド付きデシジョンテーブルを持っています。私の要件は、任意の時点で1つのデシジョン・テーブルに属するルールだけを実行することです。私はFireAllRulesCommandクラスでRuleNameEndsWithAgendaFilter( "some suffix")を使用しようとしましたが、Kieサーバは渡されたAgendaFilterに基づいてルールをフィルタリングしていません。毎回すべてのルールを実行します。Drools KieサーバーがAgendaFilterを無視する

Drools Workbenchバージョン7.2.0.FinalおよびDrools Kie Serverバージョン7.2.0.Final。

以下

は同じのためのコードスニペットです:一つのテーブルからのルールは同じ結末を持っていないので、

KieServicesConfiguration configuration = KieServicesFactory.newRestConfiguration(serverUrl, user, password); 
Set<Class<?>> allClasses = new HashSet<Class<?>>(); 
allClasses.add(OrderItem.class); 
configuration.addExtraClasses(allClasses); 
configuration.setMarshallingFormat(MarshallingFormat.JAXB); 

OrderItem oi = new OrderItem("Mobile", 7000.00, 0.00, ""); 

KieServicesClient client = KieServicesFactory.newKieServicesClient(configuration); 

// work with rules 
List<ExecutableCommand<?>> commands = new ArrayList<ExecutableCommand<?>>(); 
BatchExecutionCommandImpl executionCommand = new BatchExecutionCommandImpl(commands, "defaultKieSession"); 

InsertObjectCommand insertObjectCommand = new InsertObjectCommand(); 
insertObjectCommand.setOutIdentifier("orderItem"); 
insertObjectCommand.setObject(oi); 

FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand(); 
fireAllRulesCommand.setAgendaFilter(new RuleNameEndsWithAgendaFilter("MyRuleSuffix", true)); 

commands.add(insertObjectCommand); 
commands.add(fireAllRulesCommand); 

RuleServicesClient ruleClient = client.getServicesClient(RuleServicesClient.class); 

ServiceResponse<String> response = ruleClient.executeCommands(containerId, executionCommand); 
System.out.println(response.getResult()); 
+0

アジェンダフィルタのコードを入力しない限り、これが正しいかどうかをどのように判断できますか?また、ルール表の最上位の行(おそらくCSVテキスト)。 – laune

+0

デフォルトの実装はdrools-core jar(バージョン:7.2.0.Final) –

答えて

0

あなたは、判定テーブルのルールをフィルタリングするための標準クラスRuleNameEndsWithAgendaFilterを使用することはできません。

RuleNameStartsWithAgendaFilterテーブルの名前を変更した後に試してください。

+0

が私の場合、RuleNameEndsWithAgendaFilterはルール名が "Row 1 MyProject"、 "Row 2 MyProject"、 "Row 3 MyProject ".." Row n MyProject "を選択します。したがって、RuleNameEndsWithAgendaFilter( "MyProject")が動作するはずです。 –

+0

あなたがすべてをよく知っているなら、なぜあなたは質問をしますか? - 実際のルール名を 'RuleNameEndsWithAgendaFilter'の修正バージョンで表示しようとしましたか? - ルールテーブルのテキストが実際にどのように見えるのか、ルール名がどのように生成されるのかはわかりません。 – laune

関連する問題