[rules-users] how to declare an identifier and use it?

vysrinivas vysrinivas at gmail.com
Wed Jun 13 04:13:16 EDT 2012


Hi,


Requirement:

i have a function which will return a value. Say for example String
getInfo().

In header level, i have a tag called as TType. possible values in this tag
are Online/offline.

In line level, i have a validation which should be executed based on TType.

if i get TType = online, line level validation has to be executed.

if i get TType = offline, then line level validation has to be skipped. No
validation should happen.


Solution:

I have to call getInfo() function in linelevel  <java:condition> so that it
will return me the TType value.

based on TType, validation will happen / can be skipped.


Issue:

As i am declaring given below.

    <rule name="12_Line_Validation">

                        <parameter identifier="THeader">
                                <java:class>THeaderType</java:class>
                        </parameter>

                        <parameter identifier="TReqLine">
                                <java:class>TLineType</java:class>
                        </parameter>

                        <java:condition>
                                getQType(TReqHeader) != null
                                || !getInfo(TReqHeader).equals("Online")
                        </java:condition>


                        <java:condition>
                                getOffType(TReqLine).equals("Local")
                        </java:condition>


As show above, i am having two java conditions.

1. it will verify whether TType is online / offline.
2. it will verify whether offtype is Local or not

when i test with valid data, it never perform above validations. it just
skip both the validations irrespective whether TType is online/ offline.



Suggestion:

Can anyone let me know what might be the issue?

1. Is it that i am having both header and line program calls in one rule?

2. is it that i cannot use header value in line level validation?



work around:

is there any work around as given below

can i declare a variable/identifier in line and invoke the method and have
the return value in the declared identifier?

                        <parameter identifier="TType">
                               
<java:method>getInfo(TReqHeader)</java:method>
                        </parameter>


so that i can use this TType within the line <java:condition>.



Please verify and suggest possible way to fix this issue.

let me know if you need any other info. 

--
View this message in context: http://drools.46999.n3.nabble.com/how-to-declare-an-identifier-and-use-it-tp4017888.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list