private void visitSingleFieldConstraint( SingleFieldConstraint sfc ) { InterpolationVariable var = new InterpolationVariable( sfc.getValue(), sfc.getFieldType(), factPattern.getFactType(), sfc.getFieldName() ); if ( BaseSingleFieldConstraint.TYPE_TEMPLATE == sfc.getConstraintValueType() && !vars.containsKey( var ) ) { vars.put( var, vars.size() ); } //Visit Connection constraints if ( sfc.getConnectives() != null ) { for ( int i = 0; i < sfc.getConnectives().length; i++ ) { final ConnectiveConstraint cc = sfc.getConnectives()[ i ]; InterpolationVariable ccVar = new InterpolationVariable( cc.getValue(), cc.getFieldType(), factPattern.getFactType(), cc.getFieldName() ); if ( BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.containsKey( ccVar ) ) { vars.put( ccVar, vars.size() ); } } } }
return result; if ( c.getConnectives() != null ) { for ( int j = 0; j < c.getConnectives().length; j++ ) { if ( con == c.getConnectives()[ j ] ) { return result;
private SingleFieldConstraint visitSingleFieldConstraint( SingleFieldConstraint sfc ) { SingleFieldConstraint clone = new SingleFieldConstraint(); clone.setConstraintValueType( sfc.getConstraintValueType() ); clone.setExpressionValue( (ExpressionFormLine) visit( sfc.getExpressionValue() ) ); clone.setFieldBinding( sfc.getFieldBinding() ); clone.setFactType( sfc.getFactType() ); clone.setFieldName( sfc.getFieldName() ); clone.setFieldType( sfc.getFieldType() ); clone.setOperator( sfc.getOperator() ); for ( Map.Entry<String, String> entry : sfc.getParameters().entrySet() ) { clone.setParameter( entry.getKey(), entry.getValue() ); } clone.setValue( sfc.getValue() ); if ( sfc.getConnectives() != null ) { clone.setConnectives( new ConnectiveConstraint[ sfc.getConnectives().length ] ); for ( int i = 0; i < sfc.getConnectives().length; i++ ) { clone.getConnectives()[ i ] = (ConnectiveConstraint) visit( sfc.getConnectives()[ i ] ); } } return clone; }
public Widget connectives( SingleFieldConstraint c, String factClass ) { HorizontalPanel hp = new HorizontalPanel(); if ( c.getConnectives() != null && c.getConnectives().length > 0 ) { hp.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE ); hp.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); for ( int i = 0; i < c.getConnectives().length; i++ ) { ConnectiveConstraint con = c.getConnectives()[ i ]; hp.add( connectiveOperatorDropDown( con ) ); hp.add( connectiveValueEditor( con ) ); if ( !isReadOnly ) { Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall(); clear.setAltText( Constants.INSTANCE.RemoveThisRestriction() ); clear.setTitle( Constants.INSTANCE.RemoveThisRestriction() ); clear.addClickHandler( createClickHandlerForClearImageButton( c, i ) ); hp.add( clear ); } } } return hp; }
if ( constr.getConnectives() != null ) { for ( int j = 0; j < constr.getConnectives().length; j++ ) { final ConnectiveConstraint conn = constr.getConnectives()[ j ];
X.setOperator( "==" ); X.setConnectives( new ConnectiveConstraint[ 1 ] ); X.getConnectives()[ 0 ] = new ConnectiveConstraint(); X.getConnectives()[ 0 ].setConstraintValueType( ConnectiveConstraint.TYPE_LITERAL ); X.getConnectives()[ 0 ].setFieldType( DataType.TYPE_STRING ); X.getConnectives()[ 0 ].setOperator( "|| ==" ); X.getConnectives()[ 0 ].setValue( "bar" ); comp.addConstraint( X );
@Test public void testConnective() { RuleModel m = new RuleModel(); m.name = "test literal strings"; FactPattern p = new FactPattern( "Person" ); SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldType( DataType.TYPE_STRING ); con.setFieldName( "field1" ); con.setOperator( "==" ); con.setValue( "goo" ); con.setConstraintValueType( SingleFieldConstraint.TYPE_VARIABLE ); p.addConstraint( con ); ConnectiveConstraint connective = new ConnectiveConstraint(); connective.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); connective.setFieldType( DataType.TYPE_STRING ); connective.setOperator( "|| ==" ); connective.setValue( "blah" ); con.setConnectives( new ConnectiveConstraint[ 1 ] ); con.getConnectives()[ 0 ] = connective; m.addLhsItem( p ); String expected = "rule \"test literal strings\" " + "\tdialect \"mvel\"\n when " + "Person( field1 == goo || == \"blah\" )" + " then " + "end"; checkMarshallUnmarshall( expected, m ); }