/** * This adds a new connective. */ public void addNewConnective() { String fieldName = this.fieldName; String fieldType = this.fieldType; String factType = this.factType; if ( this.connectives == null ) { this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint( factType, fieldName, fieldType )}; } else { final ConnectiveConstraint[] newList = new ConnectiveConstraint[this.connectives.length + 1]; for ( int i = 0; i < this.connectives.length; i++ ) { newList[i] = this.connectives[i]; } newList[this.connectives.length] = new ConnectiveConstraint( factType, fieldName, fieldType ); this.connectives = newList; } }
/** * This adds a new connective. */ public void addNewConnective() { String fieldName = this.fieldName; String fieldType = this.fieldType; String factType = this.factType; if ( this.connectives == null ) { this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint( factType, fieldName, fieldType )}; } else { final ConnectiveConstraint[] newList = new ConnectiveConstraint[this.connectives.length + 1]; for ( int i = 0; i < this.connectives.length; i++ ) { newList[i] = this.connectives[i]; } newList[this.connectives.length] = new ConnectiveConstraint( factType, fieldName, fieldType ); this.connectives = newList; } }
/** * This adds a new connective. */ @Override public void addNewConnective() { String factType = getExpressionLeftSide().getPreviousGenericType(); if ( factType == null ) { factType = getExpressionLeftSide().getGenericType(); } String fieldName = getExpressionLeftSide().getFieldName(); String fieldType = getExpressionLeftSide().getGenericType(); if ( this.connectives == null ) { this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint( factType, fieldName, fieldType )}; } else { final ConnectiveConstraint[] newList = new ConnectiveConstraint[this.connectives.length + 1]; for ( int i = 0; i < this.connectives.length; i++ ) { newList[i] = this.connectives[i]; } newList[this.connectives.length] = new ConnectiveConstraint( factType, fieldName, fieldType ); this.connectives = newList; } }
/** * This adds a new connective. */ @Override public void addNewConnective() { String factType = getExpressionLeftSide().getPreviousGenericType(); if ( factType == null ) { factType = getExpressionLeftSide().getGenericType(); } String fieldName = getExpressionLeftSide().getFieldName(); String fieldType = getExpressionLeftSide().getGenericType(); if ( this.connectives == null ) { this.connectives = new ConnectiveConstraint[]{new ConnectiveConstraint( factType, fieldName, fieldType )}; } else { final ConnectiveConstraint[] newList = new ConnectiveConstraint[this.connectives.length + 1]; for ( int i = 0; i < this.connectives.length; i++ ) { newList[i] = this.connectives[i]; } newList[this.connectives.length] = new ConnectiveConstraint( factType, fieldName, fieldType ); this.connectives = newList; } }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType( cc.getConstraintValueType() ); clone.setExpressionValue( (ExpressionFormLine) visit( cc.getExpressionValue() ) ); clone.setFieldName( cc.getFieldName() ); clone.setFieldType( cc.getFieldType() ); clone.setOperator( cc.getOperator() ); for ( Map.Entry<String, String> entry : cc.getParameters().entrySet() ) { clone.setParameter( entry.getKey(), entry.getValue() ); } clone.setValue( cc.getValue() ); return clone; }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType( cc.getConstraintValueType() ); clone.setExpressionValue( (ExpressionFormLine) visit( cc.getExpressionValue() ) ); clone.setFieldName( cc.getFieldName() ); clone.setFieldType( cc.getFieldType() ); clone.setOperator( cc.getOperator() ); for ( Map.Entry<String, String> entry : cc.getParameters().entrySet() ) { clone.setParameter( entry.getKey(), entry.getValue() ); } clone.setValue( cc.getValue() ); return clone; }
cons[0].setFieldType( "String" ); cons[0].connectives = new ConnectiveConstraint[1]; cons[0].connectives[0] = new ConnectiveConstraint( "Car", "age", "String", cons[1].setFieldType( "Long" ); cons[1].connectives = new ConnectiveConstraint[1]; cons[1].connectives[0] = new ConnectiveConstraint( "Car", "make", "Long",
cons[0].setFieldBinding( "qbc" ); cons[0].connectives = new ConnectiveConstraint[1]; cons[0].connectives[0] = new ConnectiveConstraint( "Car", "age", null,
con.setFieldType( "String" ); con.connectives = new ConnectiveConstraint[1]; con.connectives[0] = new ConnectiveConstraint( "Car", "age", "String",
cons[0].setFieldType( "String" ); cons[0].connectives = new ConnectiveConstraint[1]; cons[0].connectives[0] = new ConnectiveConstraint( "Car", "age", "String", cons[1].setFieldType( "Long" ); cons[1].connectives = new ConnectiveConstraint[1]; cons[1].connectives[0] = new ConnectiveConstraint( "Car", "make", "Long",
@Test public void testConnective() { RuleModel m = new RuleModel(); m.name = "test literal strings"; FactPattern p = new FactPattern( "Person" ); SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldType( SuggestionCompletionEngine.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( SuggestionCompletionEngine.TYPE_STRING ); connective.setOperator( "|| ==" ); connective.setValue( "blah" ); con.connectives = new ConnectiveConstraint[ 1 ]; con.connectives[ 0 ] = connective; m.addLhsItem( p ); String result = BRDRLPersistence.getInstance().marshal( m ); String expected = "rule \"test literal strings\" " + "\tdialect \"mvel\"\n when " + "Person( field1 == goo || == \"blah\" )" + " then " + "end"; assertEqualsIgnoreWhitespace( expected, result ); }
X.setOperator( "==" ); X.connectives = new ConnectiveConstraint[1]; X.connectives[0] = new ConnectiveConstraint(); X.connectives[0].setConstraintValueType( ConnectiveConstraint.TYPE_LITERAL ); X.connectives[0].setOperator( "|| ==" );
X.setOperator( "==" ); X.connectives = new ConnectiveConstraint[ 1 ]; X.connectives[ 0 ] = new ConnectiveConstraint(); X.connectives[ 0 ].setConstraintValueType( ConnectiveConstraint.TYPE_LITERAL ); X.connectives[ 0 ].setFieldType( SuggestionCompletionEngine.TYPE_STRING );