private ActionFieldValue buildFieldValue( boolean isJavaDialect, String field, String value, String dataType ) { if ( value.contains( "wiWorkItem.getResult" ) ) { field = field.substring( 0, 1 ).toUpperCase() + field.substring( 1 ); String wiParam = field.substring( "Results".length() ); if ( wiParam.equals( "BooleanResult" ) ) { return new ActionWorkItemFieldValue( field, DataType.TYPE_BOOLEAN, "WorkItem", wiParam, Boolean.class.getName() ); } else if ( wiParam.equals( "StringResult" ) ) { return new ActionWorkItemFieldValue( field, DataType.TYPE_STRING, "WorkItem", wiParam, String.class.getName() ); } else if ( wiParam.equals( "IntegerResult" ) ) { return new ActionWorkItemFieldValue( field, DataType.TYPE_NUMERIC_INTEGER, "WorkItem", wiParam, Integer.class.getName() ); } else if ( wiParam.equals( "FloatResult" ) ) { return new ActionWorkItemFieldValue( field, DataType.TYPE_NUMERIC_FLOAT, "WorkItem", wiParam, Float.class.getName() ); } } return new ActionFieldValue( field, adjustParam( dataType, value, isJavaDialect ), dataType ); }
public void onChange( ChangeEvent event ) { String fieldName = box.getItemText( box.getSelectedIndex() ); String fieldType = completions.getFieldType( variableClass, fieldName ); model.addFieldValue( new ActionFieldValue( fieldName, "", fieldType ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } );
public void onChange( ChangeEvent event ) { String fieldName = box.getItemText( box.getSelectedIndex() ); String fieldType = completions.getFieldType( model.getFactType(), fieldName ); model.addFieldValue( new ActionFieldValue( fieldName, "", fieldType ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } );
private ActionSetField visitActionFieldList( ActionSetField afl ) { ActionSetField clone = new ActionSetField(); clone.setVariable( afl.getVariable() ); for ( ActionFieldValue afv : afl.getFieldValues() ) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField( afv.getField() ); afvClone.setNature( afv.getNature() ); afvClone.setType( afv.getType() ); afvClone.setValue( afv.getValue() ); clone.addFieldValue( afvClone ); } return clone; }
private ActionUpdateField visitActionFieldList( ActionUpdateField afl ) { ActionUpdateField clone = new ActionUpdateField(); clone.setVariable( afl.getVariable() ); for ( ActionFieldValue afv : afl.getFieldValues() ) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField( afv.getField() ); afvClone.setNature( afv.getNature() ); afvClone.setType( afv.getType() ); afvClone.setValue( afv.getValue() ); clone.addFieldValue( afvClone ); } return clone; }
private ActionInsertFact visitActionFieldList( ActionInsertFact afl ) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType( afl.getFactType() ); clone.setBoundName( afl.getBoundName() ); for ( ActionFieldValue afv : afl.getFieldValues() ) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField( afv.getField() ); afvClone.setNature( afv.getNature() ); afvClone.setType( afv.getType() ); afvClone.setValue( afv.getValue() ); clone.addFieldValue( afvClone ); } return clone; }
@Test public void testAssertWithDSL() throws Exception { RuleModel m = new RuleModel(); DSLSentence sen = new DSLSentence(); sen.setDefinition( "I CAN HAS DSL" ); m.addRhsItem( sen ); ActionInsertFact ins = new ActionInsertFact( "Shizzle" ); ActionFieldValue val = new ActionFieldValue( "goo", "42", "Numeric" ); ins.setFieldValues( new ActionFieldValue[ 1 ] ); ins.getFieldValues()[ 0 ] = val; m.addRhsItem( ins ); ActionInsertLogicalFact insL = new ActionInsertLogicalFact( "Shizzle" ); ActionFieldValue valL = new ActionFieldValue( "goo", "42", "Numeric" ); insL.setFieldValues( new ActionFieldValue[ 1 ] ); insL.getFieldValues()[ 0 ] = valL; m.addRhsItem( insL ); String result = BRDRLPersistence.getInstance().marshal( m ); assertTrue( result.indexOf( ">insert" ) > -1 ); assertTrue( result.indexOf( ">insertLogical" ) > -1 ); }
ai.addFieldValue( new ActionFieldValue( "dob", "31-Jan-2000", DataType.TYPE_DATE ) );
ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name", "Gargamel", DataType.TYPE_STRING );
am.addFieldValue( new ActionFieldValue( "dob", "31-Jan-2000", DataType.TYPE_DATE ) );
au.addFieldValue( new ActionFieldValue( "dob", "31-Jan-2000", DataType.TYPE_DATE ) );
ActionInsertFact aif = new ActionInsertFact( "Person" ); aif.setBoundName( "$aif" ); aif.addFieldValue( new ActionFieldValue( "rating", null, DataType.TYPE_STRING ) );
@Test public void testLiteralBigIntegerJava() { RuleModel m = new RuleModel(); m.name = "test literal biginteger"; m.addAttribute( new RuleAttribute( "dialect", "java" ) ); FactPattern p = new FactPattern( "Person" ); SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldType( DataType.TYPE_NUMERIC_BIGINTEGER ); con.setFieldName( "field1" ); con.setOperator( "==" ); con.setValue( "44" ); con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL ); p.addConstraint( con ); m.addLhsItem( p ); ActionInsertFact ai = new ActionInsertFact( "Person" ); ai.addFieldValue( new ActionFieldValue( "field1", "55", DataType.TYPE_NUMERIC_BIGINTEGER ) ); m.addRhsItem( ai ); String expected = "rule \"test literal biginteger\" \n" + "\tdialect \"java\"\n when \n" + " Person(field1 == 44I ) \n" + " then \n" + "Person fact0 = new Person(); \n" + "fact0.setField1( new java.math.BigInteger( \"55\" ) ); \n" + "insert( fact0 ); \n" + "end"; checkMarshallUnmarshall( expected, m ); }
ActionInsertFact aif1 = new ActionInsertFact( "Person" ); aif1.setBoundName( "$aif" ); aif1.addFieldValue( new ActionFieldValue( "rating", null, DataType.TYPE_STRING ) ); ActionInsertFact aif2 = new ActionInsertFact( "Person" ); aif2.setBoundName( "$aif" ); aif2.addFieldValue( new ActionFieldValue( "rating", null, DataType.TYPE_STRING ) );
@Test public void testLiteralBigDecimalMvel() { RuleModel m = new RuleModel(); m.name = "test literal bigdecimal"; m.addAttribute( new RuleAttribute( "dialect", "mvel" ) ); FactPattern p = new FactPattern( "Person" ); SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldType( DataType.TYPE_NUMERIC_BIGDECIMAL ); con.setFieldName( "field1" ); con.setOperator( "==" ); con.setValue( "44" ); con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL ); p.addConstraint( con ); m.addLhsItem( p ); ActionInsertFact ai = new ActionInsertFact( "Person" ); ai.addFieldValue( new ActionFieldValue( "field1", "55", DataType.TYPE_NUMERIC_BIGDECIMAL ) ); m.addRhsItem( ai ); String expected = "rule \"test literal bigdecimal\" \n" + "\tdialect \"mvel\"\n when \n" + " Person(field1 == 44B) \n" + " then \n" + "Person fact0 = new Person(); \n" + "fact0.setField1( 55B ); \n" + "insert( fact0 ); \n" + "end"; checkMarshallUnmarshall( expected, m ); }
@Test public void testLiteralBigDecimalJava() { RuleModel m = new RuleModel(); m.name = "test literal bigdecimal"; m.addAttribute( new RuleAttribute( "dialect", "java" ) ); FactPattern p = new FactPattern( "Person" ); SingleFieldConstraint con = new SingleFieldConstraint(); con.setFieldType( DataType.TYPE_NUMERIC_BIGDECIMAL ); con.setFieldName( "field1" ); con.setOperator( "==" ); con.setValue( "44" ); con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL ); p.addConstraint( con ); m.addLhsItem( p ); ActionInsertFact ai = new ActionInsertFact( "Person" ); ai.addFieldValue( new ActionFieldValue( "field1", "55", DataType.TYPE_NUMERIC_BIGDECIMAL ) ); m.addRhsItem( ai ); String expected = "rule \"test literal bigdecimal\" \n" + "\tdialect \"java\"\n when \n" + " Person(field1 == 44B) \n" + " then \n" + "Person fact0 = new Person(); \n" + "fact0.setField1( new java.math.BigDecimal( \"55\" ) ); \n" + "insert( fact0 ); \n" + "end"; checkMarshallUnmarshall( expected, m ); }
ai.addFieldValue( new ActionFieldValue( "field1", "55", DataType.TYPE_NUMERIC_BIGINTEGER ) );
ActionInsertFact aif = new ActionInsertFact( "Person" ); aif.setBoundName( "$aif" ); aif.addFieldValue( new ActionFieldValue( "rating", null, DataType.TYPE_STRING ) );
ActionInsertFact aif = new ActionInsertFact( "Person" ); aif.setBoundName( "$aif" ); aif.addFieldValue( new ActionFieldValue( "rating", null, DataType.TYPE_STRING ) );
set.addFieldValue( new ActionFieldValue( "status", "rejected", DataType.TYPE_STRING ) );