private ActionInsertFactCol52ActionInsertLogicalFactAdaptor(ActionInsertFactCol52 action) { if ( action == null ) { throw new NullPointerException( "action cannot be null" ); } this.action = action; this.factType = action.getFactType(); ActionFieldValue afv = new ActionFieldValue(); afv.field = action.getFactField(); afv.nature = BaseSingleFieldConstraint.TYPE_LITERAL; afv.type = action.getType(); super.addFieldValue( afv ); }
private void doAction(List<LabelledAction> actions, ActionWorkItemInsertFactCol52 ac, String cell) { if ( Boolean.TRUE.equals( Boolean.parseBoolean( cell ) ) ) { LabelledAction a = findByLabelledAction( actions, ac.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if ( !ac.isInsertLogical() ) { ActionInsertFact ins = new ActionInsertFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } actions.add( a ); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionWorkItemFieldValue val = new ActionWorkItemFieldValue( ac.getFactField(), ac.getType(), ac.getWorkItemName(), ac.getWorkItemResultParameterName(), ac.getParameterClassName() ); ins.addFieldValue( val ); } }
@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.fieldValues = new ActionFieldValue[ 1 ]; ins.fieldValues[ 0 ] = val; m.addRhsItem( ins ); ActionInsertLogicalFact insL = new ActionInsertLogicalFact( "Shizzle" ); ActionFieldValue valL = new ActionFieldValue( "goo", "42", "Numeric" ); insL.fieldValues = new ActionFieldValue[ 1 ]; insL.fieldValues[ 0 ] = valL; m.addRhsItem( insL ); String result = BRDRLPersistence.getInstance().marshal( m ); assertTrue( result.indexOf( ">insert" ) > -1 ); assertTrue( result.indexOf( ">insertLogical" ) > -1 ); }
private void doAction(List<LabelledAction> actions, ActionWorkItemInsertFactCol52 ac, String cell) { if ( Boolean.TRUE.equals( Boolean.parseBoolean( cell ) ) ) { LabelledAction a = findByLabelledAction( actions, ac.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if ( !ac.isInsertLogical() ) { ActionInsertFact ins = new ActionInsertFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } actions.add( a ); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionWorkItemFieldValue val = new ActionWorkItemFieldValue( ac.getFactField(), ac.getType(), ac.getWorkItemName(), ac.getWorkItemResultParameterName(), ac.getParameterClassName() ); ins.addFieldValue( val ); } }
@Test public void testInsertLogical() { String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" + "\t\tAccident( )\n\tthen\n\t\tinsertLogical( new Report() );\nend\n"; final RuleModel m = new RuleModel(); m.addLhsItem( new FactPattern( "Person" ) ); m.addLhsItem( new FactPattern( "Accident" ) ); m.addAttribute( new RuleAttribute( "no-loop", "true" ) ); m.addRhsItem( new ActionInsertLogicalFact( "Report" ) ); m.name = "my rule"; final String drl = brlPersistence.marshal( m ); assertEquals( expected, drl ); }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction( actions, ac.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if ( !ac.isInsertLogical() ) { ActionInsertFact ins = new ActionInsertFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } actions.add( a ); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue( ac.getFactField(), cell, ac.getType() ); ins.addFieldValue( val ); }
private ActionInsertFactCol52ActionInsertLogicalFactAdaptor(ActionInsertFactCol52 action) { if ( action == null ) { throw new NullPointerException( "action cannot be null" ); } this.action = action; this.factType = action.getFactType(); ActionFieldValue afv = new ActionFieldValue(); afv.field = action.getFactField(); afv.nature = BaseSingleFieldConstraint.TYPE_LITERAL; afv.type = action.getType(); super.addFieldValue( afv ); }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction( actions, ac.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if ( !ac.isInsertLogical() ) { ActionInsertFact ins = new ActionInsertFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact( ac.getFactType() ); ins.setBoundName( ac.getBoundName() ); a.action = ins; } actions.add( a ); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue( ac.getFactField(), cell, ac.getType() ); ins.addFieldValue( val ); }