public RuleModelVisitor( IAction action, Map<InterpolationVariable, Integer> vars ) { this.vars = vars; this.model.addRhsItem( action ); }
public void addRhsItem( final IAction action, boolean append ) { this.addRhsItem( action, append ? this.rhs.length : 0 ); }
public void addRhsItem( final IAction action ) { this.addRhsItem( action, true ); }
private void addModify( String itemText, int position ) { this.model.addRhsItem( new ActionUpdateField( itemText ), position ); }
private void addActionSetField( String itemText, int position ) { this.model.addRhsItem( new ActionSetField( itemText ), position ); }
private void addRetract( String var, int position ) { this.model.addRhsItem( new ActionRetractFact( var ), position ); }
private void addNewDSLRhs( DSLSentence sentence, int position ) { this.model.addRhsItem( sentence.copy(), position ); }
private void addCallMethod( String itemText, int position ) { this.model.addRhsItem( new ActionCallMethod( itemText ), position ); }
private List<IAction> cloneDefinition( List<IAction> definition ) { RuleModelCloneVisitor visitor = new RuleModelCloneVisitor(); RuleModel rm = new RuleModel(); for ( IAction action : definition ) { rm.addRhsItem( action ); } RuleModel rmClone = visitor.visitRuleModel( rm ); List<IAction> clone = new ArrayList<IAction>(); for ( IAction action : rmClone.rhs ) { clone.add( action ); } return clone; }
private List<IAction> cloneDefinition( List<IAction> definition ) { RuleModelCloneVisitor visitor = new RuleModelCloneVisitor(); RuleModel rm = new RuleModel(); for ( IAction action : definition ) { rm.addRhsItem( action ); } RuleModel rmClone = visitor.visitRuleModel( rm ); List<IAction> clone = new ArrayList<IAction>(); for ( IAction action : rmClone.rhs ) { clone.add( action ); } return clone; }
public void execute() { model.addRhsItem( new FreeFormLine(), Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) ); hide(); } } );
public void execute() { model.addRhsItem( new ActionInsertLogicalFact( item ), Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) ); hide(); } } );
public void execute() { model.addRhsItem( new ActionInsertFact( item ), Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) ); hide(); } } );
public void execute() { ActionGlobalCollectionAdd gca = new ActionGlobalCollectionAdd(); gca.setGlobalName( glob ); gca.setFactName( var ); model.addRhsItem( gca, Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) ); hide(); } } );
@Test public void testAddItemRhs() { final RuleModel model = new RuleModel(); final IAction a0 = new ActionSetField(); final IAction a1 = new ActionSetField(); model.addRhsItem( a0 ); assertEquals( 1, model.rhs.length ); model.addRhsItem( a1 ); assertEquals( 2, model.rhs.length ); assertEquals( a0, model.rhs[0] ); assertEquals( a1, model.rhs[1] ); }
@Test public void testAddGlobal() { String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" + "\t\tAccident( )\n\tthen\n\t\tinsert( new Report() );\n\t\tresults.add(f);\nend\n"; final RuleModel m = new RuleModel(); m.addLhsItem( new FactPattern( "Person" ) ); m.addLhsItem( new FactPattern( "Accident" ) ); m.addAttribute( new RuleAttribute( "no-loop", "true" ) ); m.addRhsItem( new ActionInsertFact( "Report" ) ); ActionGlobalCollectionAdd add = new ActionGlobalCollectionAdd(); add.setGlobalName( "results" ); add.setFactName( "f" ); m.addRhsItem( add ); m.name = "my rule"; checkMarshallUnmarshall( expected, m ); }
@Test public void testInsertLogical() { String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" + "\t\tAccident( )\n\tthen\n\t\tinsertLogical( new Report() );\nend\n"; final RuleModel m = new RuleModel(); m.addLhsItem( new FactPattern( "Person" ) ); m.addLhsItem( new FactPattern( "Accident" ) ); m.addAttribute( new RuleAttribute( "no-loop", "true" ) ); m.addRhsItem( new ActionInsertLogicalFact( "Report" ) ); m.name = "my rule"; checkMarshallUnmarshall( expected, m ); }
@Test public void testBasics() { String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" + "\t\tAccident( )\n\tthen\n\t\tinsert( new Report() );\nend\n"; RuleModel m = new RuleModel(); m.addLhsItem( new FactPattern( "Person" ) ); m.addLhsItem( new FactPattern( "Accident" ) ); m.addAttribute( new RuleAttribute( "no-loop", "true" ) ); m.addRhsItem( new ActionInsertFact( "Report" ) ); m.name = "my rule"; checkMarshallUnmarshall( expected, m ); }
@Test public void testEnumNoType() { //A legacy "Guvnor" enums (i.e pick-list of underlying field data-type) String expected = "rule \"my rule\"\n\tdialect \"mvel\"\n\twhen\n\t\tCheese( type == \"CheeseType.CHEDDAR\" )\n" + "\tthen\n\t\tinsert( new Report() );\nend\n"; final RuleModel m = new RuleModel(); final FactPattern pat = new FactPattern( "Cheese" ); m.addLhsItem( pat ); final SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldName( "type" ); con.setOperator( "==" ); con.setValue( "CheeseType.CHEDDAR" ); con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_ENUM ); pat.addConstraint( con ); m.addRhsItem( new ActionInsertFact( "Report" ) ); m.name = "my rule"; checkMarshallUnmarshall( expected, m ); }
@Test public void testEnumTypeString() { //A legacy "Guvnor" enums (i.e pick-list of underlying field data-type) String expected = "rule \"my rule\"\n\tdialect \"mvel\"\n\twhen\n\t\tCheese( type == \"CHEDDAR\" )\n" + "\tthen\n\t\tinsert( new Report() );\nend\n"; final RuleModel m = new RuleModel(); final FactPattern pat = new FactPattern( "Cheese" ); m.addLhsItem( pat ); final SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldName( "type" ); con.setOperator( "==" ); con.setValue( "CHEDDAR" ); con.setFieldType( DataType.TYPE_STRING ); con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_ENUM ); pat.addConstraint( con ); m.addRhsItem( new ActionInsertFact( "Report" ) ); m.name = "my rule"; checkMarshallUnmarshall( expected, m ); }