BRLActionColumn brl1 = new BRLActionColumn();
//BRL Column definition
List<IAction> brl1Definition = new ArrayList<IAction>();
ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact( "Smurf" );
ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name",
"$name",
SuggestionCompletionEngine.TYPE_STRING );
brl1DefinitionAction1FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue1 );
ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue( "age",
"$age",
SuggestionCompletionEngine.TYPE_NUMERIC );
brl1DefinitionAction1FieldValue2.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue2 );
brl1Definition.add( brl1DefinitionAction1 );
brl1.setDefinition( brl1Definition );
//Setup BRL column bindings
BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn( "$name",
SuggestionCompletionEngine.TYPE_STRING,
"Person",
"name" );
brl1.getChildColumns().add( brl1Variable1 );
BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn( "$age",
SuggestionCompletionEngine.TYPE_NUMERIC,
"Person",
"age" );
brl1.getChildColumns().add( brl1Variable2 );
dtable.getActionCols().add( brl1 );
//Now to test conversion
RuleModel rm = new RuleModel();
List<BaseColumn> allColumns = dtable.getExpandedColumns();
List<ActionCol52> allActions = dtable.getActionCols();
//Row 0
List<DTCellValue52> dtRowData0 = upgrader.makeDataRowList( data[0] );
TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
dtRowData0 );
p.doActions( allColumns,
allActions,
rowDataProvider0,
dtRowData0,
rm );
assertEquals( 2,
rm.rhs.length );
assertEquals( "Baddie",
((ActionInsertFact) rm.rhs[0]).factType );
assertEquals( "Smurf",
((ActionInsertFact) rm.rhs[1]).factType );
// examine the first action
ActionInsertFact result0Action1 = (ActionInsertFact) rm.rhs[0];
assertEquals( 1,
result0Action1.fieldValues.length );
ActionFieldValue result0Action1FieldValue1 = (ActionFieldValue) result0Action1.fieldValues[0];
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
result0Action1FieldValue1.type );
assertEquals( "name",
result0Action1FieldValue1.field );
assertEquals( "Gargamel",
result0Action1FieldValue1.value );
// examine the second action
ActionInsertFact result0Action2 = (ActionInsertFact) rm.rhs[1];
assertEquals( 2,
result0Action2.fieldValues.length );
ActionFieldValue result0Action2FieldValue1 = (ActionFieldValue) result0Action2.fieldValues[0];
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
result0Action2FieldValue1.type );
assertEquals( "name",
result0Action2FieldValue1.field );
assertEquals( "$name",
result0Action2FieldValue1.value );
ActionFieldValue result0Action2FieldValue2 = (ActionFieldValue) result0Action2.fieldValues[1];
assertEquals( SuggestionCompletionEngine.TYPE_NUMERIC,
result0Action2FieldValue2.type );
assertEquals( "age",
result0Action2FieldValue2.field );
assertEquals( "$age",
result0Action2FieldValue2.value );
//Row 1
List<DTCellValue52> dtRowData1 = upgrader.makeDataRowList( data[1] );
TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
dtRowData1 );
p.doActions( allColumns,
allActions,
rowDataProvider1,
dtRowData1,
rm );
assertEquals( 1,
rm.rhs.length );
assertEquals( "Baddie",
((ActionInsertFact) rm.rhs[0]).factType );
// examine the first action
ActionInsertFact result1Action1 = (ActionInsertFact) rm.rhs[0];
assertEquals( 1,
result1Action1.fieldValues.length );
ActionFieldValue result1Action1FieldValue1 = (ActionFieldValue) result1Action1.fieldValues[0];
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
result1Action1FieldValue1.type );
assertEquals( "name",
result1Action1FieldValue1.field );
assertEquals( "Gargamel",
result1Action1FieldValue1.value );
//Row 2
List<DTCellValue52> dtRowData2 = upgrader.makeDataRowList( data[2] );
TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider( allColumns,
dtRowData2 );
p.doActions( allColumns,
allActions,
rowDataProvider2,
dtRowData2,
rm );
assertEquals( 1,
rm.rhs.length );
assertEquals( "Baddie",
((ActionInsertFact) rm.rhs[0]).factType );
// examine the first action
ActionInsertFact result2Action1 = (ActionInsertFact) rm.rhs[0];
assertEquals( 1,
result2Action1.fieldValues.length );
ActionFieldValue result2Action1FieldValue1 = (ActionFieldValue) result2Action1.fieldValues[0];
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
result2Action1FieldValue1.type );
assertEquals( "name",
result2Action1FieldValue1.field );
assertEquals( "Gargamel",