0

昨日、さまざまなタイプのパラメーターを関数に渡すときに厳密モードで質問を投稿し、解決策を見つけました。推奨されるように、私は現在 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

助けてくれてありがとう。

4

2 に答える 2

0

このコード行

$noeud = creerAction(...);

の戻り値をcreerAction宣言されていない変数に代入します。関数は を返すのでjava.lang.Object

Object $noeud = creerAction(...);

これを修正します。もちろん、その後の の使用で$noeudは、キャストを使用して、コンパイラが正しいメソッドなどを見つけられるようにする必要がある場合があります。

Drools や MVEL が Java の型システムをすべて廃止するとは思わないでください。(デュー・メルシー!)

于 2015-05-06T19:45:57.060 に答える