[rules-users] Re: 4.0.0.MR3 Problems

Ronald R. DiFrango ron.difrango at gmail.com
Tue Jul 3 16:45:10 EDT 2007


And just for completeness here is my DRL file that compiles fine in the IDE:

#created on: Apr 10, 2007
package com.circuitcity.rtvcrms.rules

#list any import classes here.
import java.math.BigDecimal;

import com.circuitcity.rtvcrms.bw.ModelDiscrepancyOutput;
import com.circuitcity.rtvcrms.bw.StatusConstants;
import com.circuitcity.rtvcrms.AdjustmentDocument.Adjustment;
import com.circuitcity.rtvcrms.RepaymentCodeDocument.RepaymentCode;
import org.drools.WorkingMemory;
import org.drools.QueryResults;
import org.drools.QueryResult;
import java.util.Iterator;

#declare any global variables here

rule "Sum CM"
    salience 90

    when
        mdOutput : ModelDiscrepancyOutput ()
        repaymentCode : RepaymentCodeDocument.RepaymentCode( code == "MD")
        cmAdjustment : Adjustment(cmNumber != null, lineNumber != null,
originalRepaymentCode == "MD" )
    then
        System.out.println("Sum CM");
        mdOutput.setSumCmAndRnr(cmAdjustment.getAvailableQuantity());
end

rule "Sum RTV"
    salience 80

    when
        mdOutput : ModelDiscrepancyOutput ()
        repaymentCode : RepaymentCode( code == "MD")
        rtvAdjustment : Adjustment(rtvNumber != null, lineNumber != null,
originalRepaymentCode == "MD" )
    then
        System.out.println("Sum RTV");
        mdOutput.addSumRTVQty(rtvAdjustment.getAvailableQuantity());
end

rule "Sum RNR"
    salience 70

    when
        mdOutput : ModelDiscrepancyOutput ()
        repaymentCode : RepaymentCode( code == "MD")
        rnrAdjustment : Adjustment(keyRecNo != null, lineNumber != null,
originalRepaymentCode == "MD" )
    then
        System.out.println("Sum RNR");
        mdOutput.setSumCmAndRnr(rnrAdjustment.getAvailableQuantity());
end

rule "Repayment Code Requires Approval"
    salience 60

    when
        repaymentCode : RepaymentCode( code == "MD", matchApprv == "Y" )
        mdOutput : ModelDiscrepancyOutput( $amt1 : sumRTVQty, $amt2 :
sumCmAndRnr)
        eval($amt1.doubleValue() == $amt2.doubleValue())
    then
        System.out.println("Repayment Code Requires Approval");
        processMDAdjustments(drools.getQueryResults( "MD Adjustments" ),
StatusConstants.APPROVAL);
        System.out.println("mdOutput: " + mdOutput);
end

rule "Repayment Code Does Not Requires Approval"
    salience 60

    when
        repaymentCode : RepaymentCode( code == "MD", matchApprv != "Y"  )
        mdOutput : ModelDiscrepancyOutput( $amt1 : sumRTVQty, $amt2 :
sumCmAndRnr)
        eval($amt1.doubleValue() == $amt2.doubleValue())
    then
        System.out.println("Repayment Code Does Not Requires Approval");
        processMDAdjustments(drools.getQueryResults( "MD Adjustments" ),
StatusConstants.MATCHED);
        System.out.println("mdOutput: " + mdOutput);

end

rule "MD QTY do not match"
    salience 60

    when
        repaymentCode : RepaymentCode( code == "MD")
        mdOutput : ModelDiscrepancyOutput( $amt1 : sumRTVQty, $amt2 :
sumCmAndRnr)
        eval($amt1.doubleValue() != $amt2.doubleValue())
    then
        System.out.println("MD QTY's do not match");
        processMDAdjustments(drools.getQueryResults( "MD Adjustments" ),
StatusConstants.OPEN);
end

rule "No MD Repayment Code"
    salience 60

    when
        mdOutput : ModelDiscrepancyOutput( )
        repaymentCode : RepaymentCode( code != "MD" )
    then
        System.out.println("No MD Repayment code");
        mdOutput.setLineStatus(StatusConstants.OPEN);
        System.out.println("mdOutput: " + mdOutput);
end

query "MD Adjustments"
    adj : Adjustment(originalRepaymentCode == "MD" )
end

function void processMDAdjustments(QueryResults results, String status)
{
    System.out.println( "we have " + results.size() + " MD Adjustments" );
    for ( Iterator it = results.iterator(); it.hasNext(); ) {
        QueryResult result = ( QueryResult ) it.next();
        Adjustment adj = ( Adjustment ) result.get( "adj" );
        adj.setStatus(status);
    }
}

On 7/3/07, Ronald R. DiFrango <ron.difrango at gmail.com> wrote:
>
> OK, I got this workinkg now, by adding the jar file
> core-3.2.3.v_686_R32x.jar from the distribution to my project.
>
> Now though when I run it, I get the following error:
>
> The method getQueryResults(String) is undefined for the type
> KnowledgeHelper
>
> has getQueryResults been removd in 4.x or renamed?
>
> On 7/3/07, Ronald R. DiFrango <ron.difrango at gmail.com> wrote:
> >
> > All,
> >
> > I am in the process of migrating my 3.0. project to the 4.x series and
> > when I attempt to run my code I get the following exception when I attempt
> > to load my .drl files:
> >
> > Caused by: org.drools.RuntimeDroolsException : Unable to load dialect '
> > org.drools.rule.builder.dialect.java.JavaDialect:java'
> >
> > Here is my package builder code:
> >
> > static
> >     {
> >         try
> >         {
> >             builder = new PackageBuilder();
> >             builder.addPackageFromDrl( new InputStreamReader(
> > RtvDecisionEngine.class.getResourceAsStream("rtv.drl" ) ) );
> >             builder.addPackageFromDrl( new InputStreamReader(
> > RtvDecisionEngine.class.getResourceAsStream ("modelDiscrepancyRules.drl"
> > ) ) );
> >             ruleBase = RuleBaseFactory.newRuleBase();
> >             ruleBase.addPackage( builder.getPackage() );
> >         }
> >         catch(Exception e)
> >         {
> >             throw new RuntimeException("Failure loading the Rules", e);
> >         }
> >     }
> >
> >
> > Any thoughts appreciated.
> >
> > Ron
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070703/6cac67e1/attachment.html 


More information about the rules-users mailing list