[rules-users] Need help with Decision Table Conditions
Tihomir Surdilovic
tsurdilo at redhat.com
Tue Jan 4 23:10:37 EST 2011
You can view the drl from a decision table with:
SpreadsheetCompiler sc = new SpreadsheetCompiler();
String drlstr = sc.compile(
ResourceFactory.newClassPathResource("mydecisiontable.xls").getInputStream()
, InputType.XLS);
// print drlstr...
which helps during debugging.
Was able to produce following rule with a DT (see attached screenshot):
rule "SampleRule_11"
when
$pageMeta:PageMeta()
$bodyLines : LineMeta( pageMeta == $pageMeta, lineType ==
LineType.BODY ) from $pageMeta.getLineMetas()
$bodyLine : LineMeta( previousPageMetaComponent != null,
previousPageMetaComponent == previousLineMeta, previousLineMeta.lineType
== LineType.SECTION_HEAD, verticalSpacingToPreviousPageMetaComponent <
5.9525 ) from $bodyLines
then
System.out.println(123);
end
Hope this helps.
Tihomir
On 1/4/11 6:14 PM, Jason Mihalick wrote:
> I have a decision table with the conditions shown in the graphic below. When
> Drools attempts to compile the spreadsheet I get the following errors:
>
> nested exception is java.lang.RuntimeException: Unable to return Declaration
> for identifier '$pgMeta' : [Rule name='Section Head Spacing_18']
> Unable to create restriction '[VariableRestriction: == $pgMeta ]' for field
> 'pageMeta' in the rule 'Section Head Spacing_18' : [Rule name='Section Head
> Spacing_18']
> Unable to build expression for 'from' : [Error: Failed to compile: 2
> compilation error(s):
> - (1,7) unqualified type in strict mode for: $pgMeta
> - (1,22) unable to resolve method using strict-mode:
> java.lang.Object.getLineMetas()]
> [Near : {... Unknown ....}]
> ^
> [Line: 1, Column: 0] '$pgMeta.getLineMetas()' : [Rule name='Section Head
> Spacing_18']
>
>
> http://drools-java-rules-engine.46999.n3.nabble.com/file/n2195003/Picture_2.png
>
> The LHS of a hand-coded rule for this, is as follows:
>
> when
> $pageMeta : PageMeta()
> $bodyLines : LineMeta( pageMeta == $pageMeta, lineType == LineType.BODY
> )
> from $pageMeta.getLineMetas()
> $bodyLine : LineMeta( previousPageMetaComponent != null,
> previousPageMetaComponent == previousLineMeta,
> previousLineMeta.lineType ==
> LineType.SECTION_HEAD,
> verticalSpacingToPreviousPageMetaComponent<
> 5.9525 ) from $bodyLines
>
> Can this rule be created in a Decision table or not? Your help is most
> appreciated!
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtsample.png
Type: image/png
Size: 41100 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20110104/ce57bfb5/attachment.png
More information about the rules-users
mailing list