private ActionRetractFact visitActionRetractFact( ActionRetractFact arf ) { ActionRetractFact clone = new ActionRetractFact(); clone.setVariableName( arf.getVariableName() ); return clone; }
private void addRetract( String var, int position ) { this.model.addRhsItem( new ActionRetractFact( var ), position ); }
public void visitActionRetractFact( final ActionRetractFact action ) { buf.append( indentation ); if ( isDSLEnhanced ) { buf.append( ">" ); } buf.append( "retract( " ); buf.append( action.getVariableName() ); buf.append( " );\n" ); }
@Test public void testRemoveItemRhs() { final RuleModel model = new RuleModel(); model.rhs = new IAction[3]; final ActionRetractFact r0 = new ActionRetractFact( "x" ); final ActionRetractFact r1 = new ActionRetractFact( "y" ); final ActionRetractFact r2 = new ActionRetractFact( "z" ); model.rhs[0] = r0; model.rhs[1] = r1; model.rhs[2] = r2; model.removeRhsItem( 1 ); assertEquals( 2, model.rhs.length ); assertEquals( r0, model.rhs[0] ); assertEquals( r2, model.rhs[1] ); } /*
/** * @param binding The name of the LHS fact binding. * @return Returns true if the specified binding is used on the RHS. */ public boolean isBoundFactUsed( final String binding ) { if ( this.rhs == null ) { return false; } for ( int i = 0; i < this.rhs.length; i++ ) { if ( this.rhs[ i ] instanceof ActionSetField ) { final ActionSetField set = (ActionSetField) this.rhs[ i ]; if ( set.getVariable().equals( binding ) ) { return true; } } else if ( this.rhs[ i ] instanceof ActionRetractFact ) { final ActionRetractFact ret = (ActionRetractFact) this.rhs[ i ]; if ( ret.getVariableName().equals( binding ) ) { return true; } } } return false; }
} else if ( line.startsWith( "retract" ) ) { String variable = unwrapParenthesis( line ); m.addRhsItem( new ActionRetractFact( variable ) ); } else if ( line.startsWith( "org.kie.internal.process.instance.impl.WorkItemImpl wiWorkItem" ) ) { ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
public ActionRetractFactWidget( RuleModeller modeller, EventBus eventBus, ActionRetractFact model, Boolean readOnly ) { super( modeller, eventBus ); HorizontalPanel layout = new HorizontalPanel(); layout.setWidth( "100%" ); layout.setStyleName( "model-builderInner-Background" ); this.isFactTypeKnown = modeller.getSuggestionCompletions().isFactTypeRecognized( modeller.getModel().getLHSBindingType( model.getVariableName() ) ); if ( readOnly == null ) { this.readOnly = !this.isFactTypeKnown; } else { this.readOnly = readOnly; } if ( this.readOnly ) { layout.addStyleName( "editor-disabled-widget" ); } String desc = modeller.getModel().getLHSBindingType( model.getVariableName() ) + " [" + model.getVariableName() + "]"; layout.add( new SmallLabel( HumanReadable.getActionDisplayName("retract") + " <b>" + desc + "</b>" ) ); //This widget couldn't be modified. this.setModified( false ); initWidget( layout ); }
model.lhs.length ); final ActionRetractFact fact = new ActionRetractFact( "q" ); model.rhs[0] = fact; assertTrue( model.isBoundFactUsed( "q" ) );
m.addRhsItem( set ); final ActionRetractFact ret = new ActionRetractFact( "p1" ); m.addRhsItem( ret );