I was basically trying a few different constructs but the following is not
valid:

package testing

import testing.AddressDetail

expander crm.dsl

function void doSomething(String s) {
    System.out.println(s);
}

rule "MandatoryStreet1AddressNotNull"

    when
        The first street address line is empty
        Send 'in when' to doSomething <-- If I take this line out then it's
legal but with it in I get the stack trace below
    then
        Add the message that the first street address cannot be empty
        Send 'do something' to doSomething
end

-------------------------------------------------------------------------------------------------------------------------
org.drools.rule.InvalidRulePackage: Unable to resolve ObjectType
'doSomething'

    at org.drools.rule.Package.checkValidity(Package.java:370)
    at org.drools.reteoo.RuleBaseImpl.addPackage(RuleBaseImpl.java:247)
    at testing.FunctionTest.testFunction(FunctionTest.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:478)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)

The .dsl file is as follows:

#Customer Relationship Management domain specific language.
[when]The first street address line is empty=$ad : AddressDetail(street1 ==
"")
[when]The postcode is empty=$ad : AddressDetail(postcode == " ")
[then]Add the message that the first street address cannot be empty=
System.out.println("Enter the street address dummy");
Send '{s}' to doSomething=doSomething("{s}");


I realise it's a bit of dumb example but for arguments sake, doSomething may
be performing a bit more of a complex evaluation.

On 4/4/06, Michael Neale <[EMAIL PROTECTED]> wrote:
>
> my mistake, you should be able to call it, there are a fair few
> integration
> tests that cover that (Mark tells me).
>
>
>
> On 4/4/06, Michael Neale <[EMAIL PROTECTED]> wrote:
> >
> > When in the "when" (he heee) do you want to call it? The only places are
> > in an eval, or predicate or return value... I am not sure if they are
> > allowed in there by design.
> >
> >
> > On 4/4/06, Paul Smith <[EMAIL PROTECTED]> wrote:
> > >
> > > I don't seem to be able to call functions from within the 'when'
> clause
> > > of a
> > > drl in Drools 3.0. Is this by design or a flaw?
> > >
> > >
> >
>
>

Reply via email to