昨天我在将不同类型的参数传递给函数时发布了一个关于严格模式的问题,一个 laune 找到了解决方案。按照建议,我现在使用 drools 5.6 版。
现在,我仍然有严格模式错误,但对于另一种情况。不幸的是,我不能应用相同的解决方案。函数 creerAction() 返回不同类型的对象。有人对这种情况有想法吗?
这是错误
Unable to Analyse Expression $noeud = creerAction($action,"EvaluerMessageActivable",drools); $action.noeud = $noeud;
$noeud.prochaineActionSiBlocage = obtenirValeurParametre($noeud.prochaineActionSiBlocage, "CN_Raccrocher");
$noeud.message = obtenirValeurParametre($noeud.message, '$MessageUrgenceGlobal'):
[Error: unable to resolve method using strict-mode: java.lang.Object.prochaineActionSiBlocage()]
[Near : {... $noeud.prochaineActionSiBlocage = obt ....}]
[Line: 34, Column: 0] : [Rule name='Row 1 DT-625 Evaluer blocage general']
这是我的流口水文件。
package com.desjardins.gtd.dpsccc.routage.vpa.actionsdialogue
import org.drools.spi.KnowledgeHelper;
function Object creerAction(Action actionCourante, String type, KnowledgeHelper drools) {
if(actionCourante.getNoeud()!=null){
String nomActionCourante = actionCourante.getNoeud().getClass().getSimpleName();
if(!nomActionCourante .equals(type))
throw new RuntimeException("Ne peut pas redéfinir le type de " + actionCourante.getNom() + ". Le type était: " + nomActionCourante + " spécifié: " + type);
return actionCourante.getNoeud();
}
else if("EvaluerMessageActivable".equals(type)) return new EvaluerMessageActivable();
else if("Terminer".equals(type)) return new Terminer();
return null;
}
declare Action
nom: String
noeud: java.lang.Object
compteur: Integer
end
declare EvaluerMessageActivable
message: String
prochaineActionSiBlocage: String
end
declare Terminer
nom: String
end
rule "Row 1 DT-625 Evaluer blocage general"
salience 100079
agenda-group "level0"
dialect "mvel"
when
$action:Action(nom =='EM_UrgenceGlobal')
then
$noeud = creerAction($action,'EvaluerMessageActivable',drools); $action.noeud = $noeud
$noeud.prochaineActionSiBlocage = obtenirValeurParametre($noeud.prochaineActionSiBlocage, 'CN_Raccrocher')
$noeud.message = obtenirValeurParametre($noeud.message, '$MessageUrgenceGlobal')
end
谢谢你的帮助。