[rules-users] Problem with existing drl and dsl from drools 3

Paul Smith paul.t.smith at gmail.com
Tue Sep 4 06:06:28 EDT 2007


Forgive me if this one comes through a second time but I seem to be having a
few difficulties getting my mails to go through.

Hi Guys,

I've decided to bite the bullet and try and move up to 4.01 but I'm having
trouble getting the rules to compile. I have the following drl

/*******************
Code type rules
********************/
package au.com.codeprotechnology.online.ejb3.logic.common

import au.com.codeprotechnology.online.bi.exception.ValidationError
import
au.com.codeprotechnology.online.ejb3.logic.constants.CodeTypeConstants
import au.com.codeprotechnology.online.persistence.ejb.core.CodeType

expander common.dsl

rule "Code type is mandatory"

    when
        The code types type is null or empty
    then
        Send the message that the code types type is mandatory
end

rule "Long name is mandatory"

    when
        The code types long name is null or empty
    then
        Send the message that the code types long name is mandatory

end

rule "Short name is mandatory"

    when
        The code types short name is null or empty
    then
        Send the message that the code types short name is mandatory

end

rule "Short name too long"

    when
        The short name for the code type is too long
    then
        Send the message that the code types short name is too long

end

rule "Sort order is mandatory"

    when
        The code types sort order is null or zero
    then
        Send the message that the code types sort order is mandatory

end


With the corresponding dsl

#Common domain specific language.
[when]The code types type=$obj : CodeType(val : codeType)
[when]The code types long name=$obj : CodeType(val : longName)
[when]The code types short name=$obj : CodeType(val : shortName)
[when]The short name for the code type is too long=$obj : CodeType(val :
shortName -> (val != null && val.trim().length() >
CodeTypeConstants.MAX_SHORT_NAME_LENGTH))
[when]The code types sort order=$obj : CodeType(val : sortOrder)
[when]The documentation text=$obj : Documentation(val : documentationText)
[when]The documentation type is null=$obj : Documentation(val : type -> (val
== null))
[when]is null or empty=eval(val == null || val.trim ().length() == 0);
[when]is null or zero=eval(val == null || val.longValue() == 0);
[when]is not null=eval($obj != null);
[when]is not numeric=eval(!isNumeric(val));
[when]is not a valid expiry date=eval(!isValidExpiry(val));
[when]length is greater than {len}=eval(val.length() > {len});
[when]length is less than {len}=eval(val.length() < {len});
[then]Print the message '{msg}'=System.out.println("{msg}");
[then]Send the message that the code types type is
mandatory=$obj.addValidationError(new ValidationError(
CodeTypeConstants.MSG_KEY_CODE_TYPE_MANDATORY,
CodeTypeConstants.MSG_CODE_TYPE_MANDATORY));
[then]Send the message that the code types long name is
mandatory=$obj.addValidationError(new ValidationError(
CodeTypeConstants.MSG_KEY_LONG_NAME_MANDATORY,
CodeTypeConstants.MSG_LONG_NAME_MANDATORY));
[then]Send the message that the code types short name is
mandatory=$obj.addValidationError(new ValidationError(
CodeTypeConstants.MSG_KEY_SHORT_NAME_MANDATORY ,
CodeTypeConstants.MSG_SHORT_NAME_MANDATORY));
[then]Send the message that the code types short name is too
long=$obj.addValidationError(new ValidationError(
CodeTypeConstants.MSG_KEY_SHORT_NAME_TOO_LONG,
CodeTypeConstants.MSG_SHORT_NAME_TOO_LONG ));
[then]Send the message that the code types sort order is
mandatory=$obj.addValidationError(new ValidationError(
CodeTypeConstants.MSG_KEY_SORT_ORDER_MANDATORY,
CodeTypeConstants.MSG_SORT_ORDER_MANDATORY));
[then]Send the message that the documentation text is
mandatory=$obj.addValidationError(new ValidationError(
DocumentationConstants.MSG_KEY_TEXT_MANDATORY,
DocumentationConstants.MSG_TEXT_MANDATORY));
[then]Send the message that the documentation type is
mandatory=$obj.addValidationError(new ValidationError(
DocumentationConstants.MSG_KEY_TYPE_MANDATORY ,
DocumentationConstants.MSG_TYPE_MANDATORY));

But I keep getting the following errors when trying to build the package

unknown:14:36 Unexpected token 'val'
unknown:14:60 Unexpected token ')'
unknown:14:61 Unexpected token '.'
unknown:14:71 mismatched token: [@106,457:458='==',<75>,14:71]; expecting
type THEN
unknown:23:36 Unexpected token 'val'
unknown:23:60 Unexpected token ')'
unknown:23:61 Unexpected token '.'
unknown:23:71 mismatched token: [@171,723:724='==',<75>,23:71]; expecting
type THEN
unknown:33:37 Unexpected token 'val'
unknown:33:61 Unexpected token ')'
unknown:33:62 Unexpected token '.'
unknown:33:72 mismatched token: [@236,995:996='==',<75>,33:72]; expecting
type THEN
unknown:53:37 Unexpected token 'val'
unknown:53:66 Unexpected token ')'
unknown:53:68 Unexpected token '=='

These are the errors from PackageBuilder. Used to work fine with 3 and I
can't see any drastic differences between this and your examples in the
documentation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070904/f65b4afc/attachment.html 


More information about the rules-users mailing list