作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可能在这里走错了路,如果是的话请纠正我。
我有一个数据模型,其中有一个名为 action
的成员,它是一个枚举。所以看起来像这样:
契约(Contract)类别:
public class Contract {
public Action action;
public Action getAction() {
return action;
}
public void setAction(Action action) {
this.action = action;
}
}
Action 类:
public enum Action {
CREATE, AMEND, RENEWAL
}
现在的问题是我无法在 Kie Workbench 中复制此数据模型,因为它似乎不支持枚举?或者也许我不知道如何实现它们?
这反过来意味着当我通过 Kie 执行服务器获取规则时,因为我不能拥有 Action 类型的 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)
塔
最佳答案
我不知道工作台如何允许或拒绝使用枚举类,但如果您要以简单的 DRL 编写规则,则必须是
rule "Contract rule"when $c : Contract ( action == Action.CREATE ) then System.out.println("This order action is: " + $c.getAction());end
关于java - 如何在 kie workbecnh/Drools 6.2 中进行枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412164/
我可能在这里走错了路,如果是的话请纠正我。 我有一个数据模型,其中有一个名为 action 的成员,它是一个枚举。所以看起来像这样: 契约(Contract)类别: public class Cont
我是一名优秀的程序员,十分优秀!