public FactPattern makeFactPattern() { final FactPattern factPattern = new FactPattern(); factPattern.setBoundName(getBoundName()); factPattern.setFactType(getFactType()); return factPattern; }
public FactPattern makeFactPattern() { final FactPattern factPattern = new FactPattern(); factPattern.setBoundName(getBoundName()); factPattern.setFactType(getFactType()); return factPattern; }
protected BRLConditionColumn whenThereIsABRLFactPattern(final String factType, final String binding) { final FactPattern fp = new FactPattern(factType); fp.setBoundName(binding); final BRLConditionColumn brl = new BRLConditionColumn(); brl.getDefinition().add(fp); dtable.getConditions().add(brl); return brl; }
public void onClick(ClickEvent event) { String var = varTxt.getText(); if (modeller.isVariableNameUsed(var)) { Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var)); return; } pattern.setBoundName(varTxt.getText()); modeller.refreshWidget(); popup.hide(); } });
public void onClick(ClickEvent event) { String var = varTxt.getText(); if (modeller.isVariableNameUsed(var)) { Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var)); return; } pattern.setBoundName(varTxt.getText()); modeller.refreshWidget(); popup.hide(); } });
protected BRLConditionColumn whenThereIsABRLFromCompositeFactPattern(final String factType, final String binding) { final FromCompositeFactPattern fcfp = new FromCompositeFactPattern(); final FactPattern fp = new FactPattern(factType); fp.setBoundName(binding); fcfp.setFactPattern(fp); final BRLConditionColumn brl = new BRLConditionColumn(); brl.getDefinition().add(fcfp); dtable.getConditions().add(brl); return brl; }
@Test public void testMissingValueInFromCollect() throws Exception { FactPattern pattern = new FactPattern("Person"); pattern.setBoundName("person"); FromCompositeFactPattern fromCompositeFactPattern = new FromCollectCompositeFactPattern(); fromCompositeFactPattern.setFactPattern(pattern); model.lhs = new IPattern[]{fromCompositeFactPattern}; assertFalse(validator.isValid()); assertEquals(1, validator.getErrors().size()); assertEquals(MISSING_FACT_PATTERN, validator.getErrors().get(0)); verify(constants).AreasMarkedWithRedAreMandatoryPleaseSetAValueBeforeSaving(); }
@Test public void testMissingValueInFromCollect() throws Exception { FactPattern pattern = new FactPattern("Person"); pattern.setBoundName("person"); FromCompositeFactPattern fromCompositeFactPattern = new FromCollectCompositeFactPattern(); fromCompositeFactPattern.setFactPattern(pattern); model.lhs = new IPattern[]{fromCompositeFactPattern}; assertFalse(validator.isValid()); assertEquals(1, validator.getErrors().size()); assertEquals(MISSING_FACT_PATTERN, validator.getErrors().get(0)); verify(constants).AreasMarkedWithRedAreMandatoryPleaseSetAValueBeforeSaving(); }
private FactPattern visitFactPattern(FactPattern pattern) { FactPattern clone = new FactPattern(); clone.setBoundName(pattern.getBoundName()); clone.setFactType(pattern.getFactType()); clone.setNegated(pattern.isNegated()); CEPWindow cloneCEPWindow = new CEPWindow(); cloneCEPWindow.setOperator(pattern.getWindow().getOperator()); cloneCEPWindow.setParameters(cloneCEPWindowParameters(pattern.getWindow())); clone.setWindow(cloneCEPWindow); for (FieldConstraint fc : pattern.getFieldConstraints()) { clone.addConstraint((FieldConstraint) visit(fc)); } return clone; }
private FactPattern visitFactPattern(FactPattern pattern) { FactPattern clone = new FactPattern(); clone.setBoundName(pattern.getBoundName()); clone.setFactType(pattern.getFactType()); clone.setNegated(pattern.isNegated()); CEPWindow cloneCEPWindow = new CEPWindow(); cloneCEPWindow.setOperator(pattern.getWindow().getOperator()); cloneCEPWindow.setParameters(cloneCEPWindowParameters(pattern.getWindow())); clone.setWindow(cloneCEPWindow); for (FieldConstraint fc : pattern.getFieldConstraints()) { clone.addConstraint((FieldConstraint) visit(fc)); } return clone; }
private static FactPattern buildFactPattern() { FactPattern fp = new FactPattern(); fp.setBoundName( "$f" ); fp.setFactType( "FactType" ); fp.setNegated( true ); CEPWindow win = new CEPWindow(); win.setOperator( "winOp" ); win.setParameter( "winKey", "winPar" ); fp.setWindow( win ); fp.addConstraint( buildSingleFieldConstraint() ); return fp; }
@Test public void testValidFromCompositeFactPattern() throws Exception { FactPattern factPattern = new FactPattern("SomeList"); factPattern.setBoundName("list"); FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern(); fromCompositeFactPattern.setFactPattern(new FactPattern("Person")); ExpressionFormLine expression = new ExpressionFormLine(); expression.appendPart(new ExpressionVariable("list", "SomeList", "SomeList")); fromCompositeFactPattern.setExpression(expression); model.lhs = new IPattern[]{fromCompositeFactPattern}; assertTrue(validator.isValid()); }
@Test public void testValidFromCompositeFactPattern() throws Exception { FactPattern factPattern = new FactPattern("SomeList"); factPattern.setBoundName("list"); FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern(); fromCompositeFactPattern.setFactPattern(new FactPattern("Person")); ExpressionFormLine expression = new ExpressionFormLine(); expression.appendPart(new ExpressionVariable("list", "SomeList", "SomeList")); fromCompositeFactPattern.setExpression(expression); model.lhs = new IPattern[]{fromCompositeFactPattern}; assertTrue(validator.isValid()); }
@Test public void testEmptyLiteralStringFieldConstraints() throws Exception { FactPattern f1 = new FactPattern("Applicant"); f1.setBoundName("$a"); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); constraint.setFieldType(DataType.TYPE_STRING); constraint.setFactType("Applicant"); constraint.setOperator("=="); constraint.setFieldName("name"); f1.addConstraint(constraint); model.lhs = new IPattern[]{f1}; assertTrue(validator.isValid()); }
@Test public void testEmptyLiteralNonStringFieldConstraints() throws Exception { FactPattern f1 = new FactPattern("Applicant"); f1.setBoundName("$a"); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); constraint.setFieldType(DataType.TYPE_NUMERIC_INTEGER); constraint.setFactType("Applicant"); constraint.setOperator("=="); constraint.setFieldName("age"); f1.addConstraint(constraint); model.lhs = new IPattern[]{f1}; assertFalse(validator.isValid()); }
@Test public void testEmptyLiteralStringFieldConstraints() throws Exception { FactPattern f1 = new FactPattern("Applicant"); f1.setBoundName("$a"); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); constraint.setFieldType(DataType.TYPE_STRING); constraint.setFactType("Applicant"); constraint.setOperator("=="); constraint.setFieldName("name"); f1.addConstraint(constraint); model.lhs = new IPattern[]{f1}; assertTrue(validator.isValid()); }
@Test public void testComparingFieldToExpression() throws Exception { FactPattern f1 = new FactPattern(); f1.setBoundName("f1"); FactPattern f2 = new FactPattern(); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setOperator("=="); constraint.getExpressionValue().appendPart(new ExpressionVariable("field", "java.lang.Number", "Number")); f2.addConstraint(constraint); model.lhs = new IPattern[]{f1, f2}; assertTrue(validator.isValid()); }
@Test public void testEmptyLiteralNonStringFieldConstraints() throws Exception { FactPattern f1 = new FactPattern("Applicant"); f1.setBoundName("$a"); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); constraint.setFieldType(DataType.TYPE_NUMERIC_INTEGER); constraint.setFactType("Applicant"); constraint.setOperator("=="); constraint.setFieldName("age"); f1.addConstraint(constraint); model.lhs = new IPattern[]{f1}; assertFalse(validator.isValid()); }
@Test public void testComparingFieldToExpression() throws Exception { FactPattern f1 = new FactPattern(); f1.setBoundName("f1"); FactPattern f2 = new FactPattern(); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setOperator("=="); constraint.getExpressionValue().appendPart(new ExpressionVariable("field", "java.lang.Number", "Number")); f2.addConstraint(constraint); model.lhs = new IPattern[]{f1, f2}; assertTrue(validator.isValid()); }
@Test public void testWorkingFrom() throws Exception { FactPattern boundPattern = new FactPattern("Person"); boundPattern.setBoundName("person"); boundPattern.addConstraint(new SingleFieldConstraint("addresses")); FactPattern pattern = new FactPattern("Address"); SingleFieldConstraint constraint = new SingleFieldConstraint("street"); pattern.addConstraint(constraint); FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern(); fromCompositeFactPattern.setFactPattern(pattern); ExpressionFormLine expression = new ExpressionFormLine(); expression.setBinding("person.addresses"); fromCompositeFactPattern.setExpression(expression); model.lhs = new IPattern[]{boundPattern, fromCompositeFactPattern}; assertTrue(validator.isValid()); }