0

我可能在这里走错了路,所以如果是这样,请纠正我。

我有一个名为 enum 的成员的action数据模型。所以看起来像这样:

合同类:

public class Contract {

    public Action action;

    public Action getAction() {
        return action;
    }

    public void setAction(Action action) {
        this.action = action;
    }
}

动作类:

public enum Action {

    CREATE, AMEND, RENEWAL

}

现在,问题是我无法在 Kie Workbench 中复制此数据模型,因为它似乎不支持枚举?或者也许我不知道如何实现它们?

这反过来意味着当我通过 Kie 执行服务器获取规则时,因为我不能拥有Action类型的操作成员(它是一个枚举),所以将永远不会触发以下规则:

rule "Contract rule"
when
    $c : Contract ( action.equals("CREATE") ) 
then
    System.out.println("This order action is: " + $c.getAction());
end

这里有解决方法吗?我错过了什么吗?

如果您想查看我在实现以下代码时遇到的错误,这里是:

java.lang.NoSuchMethodError: com.heg.projectdelta.contractcreator.model.Contract.getAction()Lcom/heg/projectdelta/contractcreator/model/Action;
    at com.heg.projectdelta.contractcreator.model.Rule_Contract_rule116883127.defaultConsequence(Rule_Contract_rule116883127.java:7)
    at com.heg.projectdelta.contractcreator.model.Rule_Contract_rule116883127DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at com.heg.projectdelta.contractcreator.model.Rule_Contract_rule116883127DefaultConsequenceInvoker.evaluate(Unknown Source)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1114)
    at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:160)
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:108)
    at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1016)
    at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1302)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1289)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1262)
    at com.heg.projectdelta.cedroolscore.service.DroolsService.fireAllRules(DroolsService.java:115)
    at com.heg.projectdelta.contractcreator.service.impl.DroolsWebServiceImpl.fireRules(DroolsWebServiceImpl.java:66)
    at com.heg.projectdelta.contractcreator.integration.DroolsWebServiceTest.testFireRules(DroolsWebServiceTest.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

4

1 回答 1

1

我不知道工作台将如何允许或拒绝使用枚举类,但如果你要用普通的 DRL 编写规则,它必须是

规则“合同规则”
什么时候
    $c : 合约 ( action == Action.CREATE )
然后
    System.out.println("这个订单动作是:" + $c.getAction());
结尾
于 2015-10-29T11:32:52.863 回答