private ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.variable = afl.variable; for ( ActionFieldValue afv : afl.fieldValues ) { 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 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 testRemove() { final ActionSetField set = new ActionSetField(); set.fieldValues = new ActionFieldValue[2]; final ActionFieldValue v0 = new ActionFieldValue( "x", "42", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); final ActionFieldValue v1 = new ActionFieldValue( "y", "43", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); set.fieldValues[0] = v0; set.fieldValues[1] = v1; set.removeField( 1 ); assertEquals( 1, set.fieldValues.length ); assertEquals( v0, set.fieldValues[0] ); }
public void addFieldValue(final ActionFieldValue val) { if (val instanceof ActionFieldFunction) { super.addFieldValue(val); } else { throw new IllegalArgumentException( "Cannot assign field values of types other than ActionFieldFunction."); } } }
final ActionSetField set = new ActionSetField(); set.variable = "x"; model.rhs[0] = set;
public void addFieldValue(final ActionFieldValue val) { if (val instanceof ActionFieldFunction) { super.addFieldValue(val); } else { throw new IllegalArgumentException( "Cannot assign field values of types other than ActionFieldFunction."); } } }
private ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.variable = afl.variable; for ( ActionFieldValue afv : afl.fieldValues ) { 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; }
final RuleModel model = new RuleModel(); final ActionSetField a = new ActionSetField(); model.addRhsItem( a ); model.rhs.length ); final ActionSetField b = new ActionSetField(); model.addRhsItem( b ); model.rhs.length ); final ActionSetField c = new ActionSetField(); model.addRhsItem( c, true ); final ActionSetField d = new ActionSetField(); model.addRhsItem( d, false ); final ActionSetField e = new ActionSetField(); model.addRhsItem( e, 2 ); final ActionSetField f = new ActionSetField(); final ActionSetField g = new ActionSetField(); model.addRhsItem( f, -1 );
a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); sf.getWorkItemResultParameterName(), sf.getParameterClassName() ); asf.addFieldValue( val );
final ActionSetField set = new ActionSetField(); set.variable = "x"; model.rhs[0] = set;
a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); sf.getWorkItemResultParameterName(), sf.getParameterClassName() ); asf.addFieldValue( val );
@Test public void testIsDSLEnhanced() throws Exception { RuleModel m = new RuleModel(); assertFalse( m.hasDSLSentences() ); m.addLhsItem( new FactPattern() ); assertFalse( m.hasDSLSentences() ); m.addRhsItem( new ActionSetField( "q" ) ); assertFalse( m.hasDSLSentences() ); m.addLhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m.addRhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m = new RuleModel(); m.addLhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m = new RuleModel(); m.addRhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); }
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction( actions, sf.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); } actions.add( a ); } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField( sf.getBoundName() ); update.fieldValues = old.fieldValues; a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue( sf.getFactField(), cell, sf.getType() ); asf.addFieldValue( val ); }
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction( actions, sf.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); } actions.add( a ); } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField( sf.getBoundName() ); update.fieldValues = old.fieldValues; a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue( sf.getFactField(), cell, sf.getType() ); asf.addFieldValue( val ); }
@Test public void testAdd() { final ActionSetField set = new ActionSetField(); set.fieldValues = new ActionFieldValue[2]; final ActionFieldValue v0 = new ActionFieldValue( "x", "42", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); final ActionFieldValue v1 = new ActionFieldValue( "y", "43", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); set.fieldValues[0] = v0; set.fieldValues[1] = v1; final ActionFieldValue q = new ActionFieldValue( "q", "q", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); set.addFieldValue( q ); assertEquals( 3, set.fieldValues.length ); assertEquals( q, set.fieldValues[2] ); assertEquals( v0, set.fieldValues[0] ); }
ActionSetField au = new ActionSetField( "$p" ); au.addFieldValue( new ActionFieldValue( "dob", "31-Jan-2000", SuggestionCompletionEngine.TYPE_DATE ) );
ActionSetField asf = new ActionSetField(); asf.variable = "$r"; ActionWorkItemFieldValue fv1 = new ActionWorkItemFieldValue( "ResultsBooleanResult", "BooleanResult", Boolean.class.getName() ); asf.addFieldValue( fv1 ); ActionWorkItemFieldValue fv2 = new ActionWorkItemFieldValue( "ResultsFloatResult", SuggestionCompletionEngine.TYPE_NUMERIC_FLOAT, "FloatResult", Float.class.getName() ); asf.addFieldValue( fv2 ); ActionWorkItemFieldValue fv3 = new ActionWorkItemFieldValue( "ResultsIntegerResult", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER, "IntegerResult", Integer.class.getName() ); asf.addFieldValue( fv3 ); ActionWorkItemFieldValue fv4 = new ActionWorkItemFieldValue( "ResultsStringResult", SuggestionCompletionEngine.TYPE_STRING, "StringResult", String.class.getName() ); asf.addFieldValue( fv4 );
ActionSetField asf0 = new ActionSetField( "ASF0" ); ActionFieldValue asf0f0 = new ActionFieldValue( "ASF0F0", "ASF0F0Value", SuggestionCompletionEngine.TYPE_STRING ); asf0f0.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE ); asf0.addFieldValue( asf0f0 ); ActionFieldValue asf0f1 = new ActionFieldValue( "ASF0F1", "ASF0F1Value", SuggestionCompletionEngine.TYPE_STRING ); asf0f1.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE ); asf0.addFieldValue( asf0f1 ); model.rhs[0] = asf0; ActionSetField asf1 = new ActionSetField( "ASF1" ); ActionFieldValue asf1f0 = new ActionFieldValue( "ASF1F0", "ASF1F0Value", SuggestionCompletionEngine.TYPE_STRING ); asf1f0.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE ); asf1.addFieldValue( asf1f0 ); ActionFieldValue asf1f1 = new ActionFieldValue( "ASF1F1", "ASF1F1Value", SuggestionCompletionEngine.TYPE_STRING ); asf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL ); asf1.addFieldValue( asf1f1 ); model.rhs[1] = asf1;
ActionSetField asf0 = new ActionSetField( "ASF0" ); asf0.variable = "$t0"; ActionFieldValue asf0f0 = new ActionFieldValue( "ASF0F0", SuggestionCompletionEngine.TYPE_STRING ); asf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL ); asf0.addFieldValue( asf0f0 ); ActionFieldValue asf0f1 = new ActionFieldValue( "ASF0F1", "ASF0F1Value", SuggestionCompletionEngine.TYPE_STRING ); asf0f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL ); asf0.addFieldValue( asf0f1 ); model.rhs[0] = asf0; ActionSetField asf1 = new ActionSetField( "ASF1" ); asf1.variable = "$t1"; ActionFieldValue asf1f0 = new ActionFieldValue( "ASF1F0", SuggestionCompletionEngine.TYPE_STRING ); asf1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL ); asf1.addFieldValue( asf1f0 ); ActionFieldValue asf1f1 = new ActionFieldValue( "ASF1F1", "ASF1F1Value", SuggestionCompletionEngine.TYPE_STRING ); asf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL ); asf1.addFieldValue( asf1f1 ); model.rhs[1] = asf1;