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 FreeFormLine visitFreeFormLine(FreeFormLine ffl) { FreeFormLine clone = new FreeFormLine(); clone.setText(ffl.getText()); return clone; }
private FreeFormLine visitFreeFormLine(FreeFormLine ffl) { FreeFormLine clone = new FreeFormLine(); clone.setText(ffl.getText()); return clone; }
@Override public void visitFreeFormLine(final FreeFormLine ffl) { StringBuffer interpolatedResult = new StringBuffer(); final Matcher matcherTemplateKey = patternTemplateKey.matcher(ffl.getText()); while (matcherTemplateKey.find()) { String varName = matcherTemplateKey.group(1); String value = rowDataProvider.getTemplateKeyValue(varName); // All vars must be populated for a single FreeFormLine if (StringUtils.isEmpty(value)) { return; } matcherTemplateKey.appendReplacement(interpolatedResult, value); } matcherTemplateKey.appendTail(interpolatedResult); //Don't update the original FreeFormLine object FreeFormLine fflClone = new FreeFormLine(); fflClone.setText(interpolatedResult.toString()); super.visitFreeFormLine(fflClone); }
public void execute() { model.addRhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
public void execute() { model.addLhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
private static FreeFormLine buildFreeFormLine() { FreeFormLine ffl = new FreeFormLine(); ffl.setText( "text" ); return ffl; }
public void execute() { model.addRhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
public void execute() { model.addLhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
private void unmarshalUsingExtension(final RuleModel ruleModel, final RuleModelIActionPersistenceExtension extension, final String line) { try { ruleModel.addRhsItem(extension.unmarshal(line)); } catch (RuleModelDRLPersistenceException e) { FreeFormLine freeFormLine = new FreeFormLine(); freeFormLine.setText(line); ruleModel.addRhsItem(freeFormLine); } }
@Test public void testValidateModifyScoreAction() throws Exception { final Path path = mock(Path.class); final FreeFormLine modifyAction = new FreeFormLine(); modifyAction.setText(MODIFY_SCORE_ACTION); final RuleModel model = new RuleModel(); model.addRhsItem(modifyAction); service.validate(path, model); final ArgumentCaptor<String> capturedFileContent = ArgumentCaptor.forClass(String.class); verify(genericValidator).validate(eq(path), capturedFileContent.capture()); Assertions.assertThat(capturedFileContent.getValue()).contains(MODIFY_SCORE_ACTION); }
@Test public void testValidateModifyScoreAction() throws Exception { final Path path = mock(Path.class); final FreeFormLine modifyAction = new FreeFormLine(); modifyAction.setText(MODIFY_SCORE_ACTION); final RuleModel model = new RuleModel(); model.addRhsItem(modifyAction); service.validate(path, model); final ArgumentCaptor<String> capturedFileContent = ArgumentCaptor.forClass(String.class); verify(genericValidator).validate(eq(path), capturedFileContent.capture()); Assertions.assertThat(capturedFileContent.getValue()).contains(MODIFY_SCORE_ACTION); }
public void onClick(ClickEvent event) { Widget sender = (Widget) event.getSource(); if (sender == fromBtn) { getFromCollectPattern().setRightPattern(new FromCompositeFactPattern()); } else if (sender == fromAccumulateBtn) { getFromCollectPattern().setRightPattern(new FromAccumulateCompositeFactPattern()); } else if (sender == fromCollectBtn) { getFromCollectPattern().setRightPattern(new FromCollectCompositeFactPattern()); } else if (sender == freeFormDRLBtn) { getFromCollectPattern().setRightPattern(new FreeFormLine()); } else if (sender == fromEntryPointBtn) { getFromCollectPattern().setRightPattern(new FromEntryPointFactPattern()); } else { throw new IllegalArgumentException("Unknown sender: " + sender); } setModified(true); getModeller().refreshWidget(); popup.hide(); } };
@Test public void testActionFreeFormLineSecondValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("System.println( \"@{f1}\" + \"@{f2}\" );"); m.addRhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end"; m.addRow(new String[]{null, "bar"}); checkMarshall(expected, m); }
@Test public void testFreeFormLineBothValues() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )"); m.addLhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "Person( field1 == \"foo\", field2 == \"bar\" ) \n" + "then\n" + "end"; m.addRow(new String[]{"foo", "bar"}); checkMarshall(expected, m); }
@Test public void testActionFreeFormLineFirstValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("System.println( \"@{f1}\" + \"@{f2}\" );"); m.addRhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end"; m.addRow(new String[]{"foo", null}); checkMarshall(expected, m); }
@Test public void testFreeFormLineSecondValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )"); m.addLhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end"; m.addRow(new String[]{null, "bar"}); checkMarshall(expected, m); }
@Test public void testFreeFormLineFirstValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )"); m.addLhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end"; m.addRow(new String[]{"foo", null}); checkMarshall(expected, m); }
@Test public void testActionFreeFormLineBothValues() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("System.println( \"@{f1}\" + \"@{f2}\" );"); m.addRhsItem(ffl); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "System.println( \"foo\" + \"bar\" );" + "end"; m.addRow(new String[]{"foo", "bar"}); checkMarshall(expected, m); }
@Test public void testFromCollectFreeFormLineSecondValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FreeFormLine ffl = new FreeFormLine(); ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )"); FactPattern fp = new FactPattern("java.util.List"); FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern(); fac.setRightPattern(ffl); fac.setFactPattern(fp); m.addLhsItem(fac); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end"; m.addRow(new String[]{null, "foo"}); checkMarshall(expected, m); }