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...
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!