public void addLhsItem(final IPattern pat, boolean append) { this.addLhsItem(pat, append ? this.lhs.length : 0); }
public RuleModelVisitor(IPattern pattern, Map<InterpolationVariable, Integer> vars) { this.vars = vars; this.model.addLhsItem(pattern); }
@Override public void addLhsItem(IPattern pat, boolean append) { model.addLhsItem(pat, append); }
@Override public void addLhsItem(IPattern pat, int position) { model.addLhsItem(pat, position); }
@Override public void addLhsItem(IPattern pat, boolean append) { model.addLhsItem(pat, append); }
public GeneratorContextRuleModelVisitor(final IPattern pattern, final Set<InterpolationVariable> vars) { this.vars = vars; this.model.addLhsItem(pattern); }
@Override public void addLhsItem(IPattern pat, int position) { model.addLhsItem(pat, position); }
private void addNewCE(String s, int position) { this.model.addLhsItem(new CompositeFactPattern(s), position); }
private void addNewDSLLhs(final DSLSentence sentence, int position) { model.addLhsItem(sentence.copy(), position); }
private void addNewFact(String itemText, int position) { this.model.addLhsItem(new FactPattern(itemText), position); }
private int parseDslInLhs(final RuleModel m, final ExpandedDRLInfo expandedDRLInfo, int lineCounter) { if (expandedDRLInfo.hasDsl) { String dslLine = expandedDRLInfo.dslStatementsInLhs.get(lineCounter); while (dslLine != null) { m.addLhsItem(toDSLSentence(expandedDRLInfo.lhsDslPatterns, dslLine)); dslLine = expandedDRLInfo.dslStatementsInLhs.get(++lineCounter); } } return lineCounter; }
private void addNewFact(String itemText, int position) { this.model.addLhsItem(new FactPattern(itemText), position); }
private int parseFreeForm(final RuleModel m, final ExpandedDRLInfo expandedDRLInfo, int lineCounter) { String freeForm = expandedDRLInfo.freeFormStatementsInLhs.get(lineCounter); while (freeForm != null) { FreeFormLine ffl = new FreeFormLine(); ffl.setText(freeForm); m.addLhsItem(ffl); freeForm = expandedDRLInfo.freeFormStatementsInLhs.get(++lineCounter); } return lineCounter; }
private boolean hasVariables(BRLConditionColumn column) { Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>(); RuleModel rm = new RuleModel(); for (IPattern pattern : column.getDefinition()) { rm.addLhsItem(pattern); } RuleModelVisitor rmv = new RuleModelVisitor(ivs); rmv.visit(rm); return ivs.size() > 0; }
public void execute() { model.addLhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
private Set<String> getConditionFactTypesFromRuleModel(final List<IPattern> definition) { final RuleModel rm = new RuleModel(); rm.setPackageName(model.getPackageName()); rm.setImports(model.getImports()); for (IPattern p : definition) { rm.addLhsItem(p); } final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(rm); return visitor.getConsumedModelClasses(); }
@Test public void testValidateCompositeFactPatternFalse() throws Exception { CompositeFactPattern not = new CompositeFactPattern(); not.setType("not"); model.addLhsItem(not); assertFalse(validator.isValid()); assertTrue(validator.getErrors().get(0).equals(MISSING_FACT_PATTERN)); }
@Test public void testValidateFactPattern() throws Exception { model.addLhsItem(new FactPattern()); assertTrue(validator.isValid()); assertTrue(validator.getErrors().isEmpty()); }
@Test public void testCloneWithUnsupportedClass() { RuleModel model = new RuleModel(); model.addLhsItem( new TestFactPattern() ); RuleModelCloneVisitor visitor = new RuleModelCloneVisitor(); thrown.expect( RuntimeException.class ); thrown.expectMessage( TestFactPattern.class.getSimpleName() ); visitor.visitRuleModel( model ); }
@Test public void testValidateCompositeFactPatternTrue() throws Exception { CompositeFactPattern not = new CompositeFactPattern(); not.setType("not"); not.addFactPattern(new FactPattern()); model.addLhsItem(not); assertTrue(validator.isValid()); assertTrue(validator.getErrors().isEmpty()); }