private void setUpSingleFieldConstraintEBLeftSide(SingleFieldConstraintEBLeftSide sfexp) { this.factType = sfexp.getExpressionLeftSide().getPreviousClassType(); if (this.factType == null) { this.factType = sfexp.getExpressionLeftSide().getClassType(); } this.fieldName = sfexp.getExpressionLeftSide().getFieldName(); this.fieldType = sfexp.getExpressionLeftSide().getGenericType(); }
@Override public void setFieldBinding( String fieldBinding ) { getExpressionLeftSide().setBinding( fieldBinding ); }
@Override public String getFieldType() { return getExpressionLeftSide().getClassType(); }
private void setUpSingleFieldConstraintEBLeftSide(SingleFieldConstraintEBLeftSide sfexp) { this.factType = sfexp.getExpressionLeftSide().getPreviousClassType(); if (this.factType == null) { this.factType = sfexp.getExpressionLeftSide().getClassType(); } this.fieldName = sfexp.getExpressionLeftSide().getFieldName(); this.fieldType = sfexp.getExpressionLeftSide().getGenericType(); }
@Override public String getFieldBinding() { return getExpressionLeftSide().getBinding(); }
@Override public String getFieldName() { return getExpressionLeftSide().getFieldName(); }
static String extractFactType(final FactPattern factPattern, final BaseSingleFieldConstraint con) { if (con instanceof SingleFieldConstraintEBLeftSide) { return ((SingleFieldConstraintEBLeftSide) con).getExpressionLeftSide().getPreviousClassType(); } return factPattern.getFactType(); }
static String extractFieldName(final BaseSingleFieldConstraint con) { if (con instanceof SingleFieldConstraintEBLeftSide) { return ((SingleFieldConstraintEBLeftSide) con).getExpressionLeftSide().getFieldName(); } else if (con instanceof SingleFieldConstraint) { return ((SingleFieldConstraint) con).getFieldName(); } else if (con instanceof ConnectiveConstraint) { return ((ConnectiveConstraint) con).getFieldName(); } return null; }
private Set<String> visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) { final Set<String> factTypes = new HashSet<String>(); if (sfexp.getFactType() != null) { factTypes.add(sfexp.getFactType()); } factTypes.addAll(visit(sfexp.getExpressionValue())); factTypes.addAll(visit(sfexp.getExpressionLeftSide())); if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { factTypes.addAll(visit(sfexp.getConnectives()[i])); } } return factTypes; } }
private Set<String> visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) { final Set<String> factTypes = new HashSet<String>(); if (sfexp.getFactType() != null) { factTypes.add(sfexp.getFactType()); } factTypes.addAll(visit(sfexp.getExpressionValue())); factTypes.addAll(visit(sfexp.getExpressionLeftSide())); if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { factTypes.addAll(visit(sfexp.getConnectives()[i])); } } return factTypes; } }
/** * This adds a new connective. */ @Override public void addNewConnective() { String factType = getExpressionLeftSide().getPreviousGenericType(); if ( factType == null ) { factType = getExpressionLeftSide().getGenericType(); } String fieldName = getExpressionLeftSide().getFieldName(); String fieldType = getExpressionLeftSide().getGenericType(); if ( this.getConnectives() == null ) { this.setConnectives( new ConnectiveConstraint[]{ new ConnectiveConstraint( factType, fieldName, fieldType ) } ); } else { final ConnectiveConstraint[] newList = new ConnectiveConstraint[ this.getConnectives().length + 1 ]; for ( int i = 0; i < this.getConnectives().length; i++ ) { newList[ i ] = this.getConnectives()[ i ]; } newList[ this.getConnectives().length ] = new ConnectiveConstraint( factType, fieldName, fieldType ); this.setConnectives( newList ); } }
private void visitSingleFieldConstraint(final SingleFieldConstraintEBLeftSide sfexp) { visit(sfexp.getExpressionLeftSide()); visit(sfexp.getExpressionValue()); if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { visit(sfexp.getConnectives()[i]); } } }
private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide(final RuleModel m, final FactPattern factPattern, String fieldName, final String operator, final String value) { SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide(); fieldName = setFieldBindingOnContraint(factPattern.getFactType(), fieldName, m, con, boundParams); String classType = RuleModelPersistenceHelper.getFQFactType(m, factPattern.getFactType(), dmo); con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(factPattern.getFactType())); parseExpression(m, classType, fieldName, con.getExpressionLeftSide()); setOperatorAndValueOnConstraint(m, operator, value, factPattern, con); return con; }
private void visitSingleFieldConstraint(final SingleFieldConstraintEBLeftSide sfexp) { visit(sfexp.getExpressionLeftSide()); visit(sfexp.getExpressionValue()); if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { visit(sfexp.getConnectives()[i]); } } }
private HorizontalPanel expressionBuilderLS(final SingleFieldConstraintEBLeftSide con, boolean showBinding) { HorizontalPanel ab = new HorizontalPanel(); ab.setStyleName("modeller-field-Label"); if (!con.isBound()) { if (bindable && showBinding && !this.readOnly) { ab.add(new ExpressionBuilder(getModeller(), getEventBus(), con.getExpressionLeftSide())); } else { final DRLConstraintValueBuilder constraintValueBuilder = DRLConstraintValueBuilder.getBuilder(getRuleDialect()); final ToStringExpressionVisitor visitor = new ToStringExpressionVisitor(constraintValueBuilder); ab.add(new SmallLabel(con.getExpressionLeftSide().getText(visitor))); } } else { ab.add(new ExpressionBuilder(getModeller(), getEventBus(), con.getExpressionLeftSide())); } return ab; }
private HorizontalPanel expressionBuilderLS(final SingleFieldConstraintEBLeftSide con, boolean showBinding) { HorizontalPanel ab = new HorizontalPanel(); ab.setStyleName("modeller-field-Label"); if (!con.isBound()) { if (bindable && showBinding && !this.readOnly) { ab.add(new ExpressionBuilder(getModeller(), getEventBus(), con.getExpressionLeftSide())); } else { final DRLConstraintValueBuilder constraintValueBuilder = DRLConstraintValueBuilder.getBuilder(getRuleDialect()); final ToStringExpressionVisitor visitor = new ToStringExpressionVisitor(constraintValueBuilder); ab.add(new SmallLabel(con.getExpressionLeftSide().getText(visitor))); } } else { ab.add(new ExpressionBuilder(getModeller(), getEventBus(), con.getExpressionLeftSide())); } return ab; }
@Test public void testMakeSingleFieldConstraintEBLeftSide() { final String expectedFactType = "factType"; final ExpressionFormLine expectedExpressionFormLine = mock(ExpressionFormLine.class); final int expectedConstraintValueType = SingleFieldConstraint.TYPE_UNDEFINED; doReturn(expectedExpressionFormLine).when(popupCreator).makeExpressionFormLine(expectedFactType); final SingleFieldConstraintEBLeftSide constraint = popupCreator.makeSingleFieldConstraintEBLeftSide(expectedFactType); assertEquals(expectedConstraintValueType, constraint.getConstraintValueType()); assertEquals(expectedExpressionFormLine, constraint.getExpressionLeftSide()); assertEquals(expectedFactType, constraint.getFactType()); }
@Test public void testMakeSingleFieldConstraintEBLeftSide() { final String expectedFactType = "factType"; final ExpressionFormLine expectedExpressionFormLine = mock(ExpressionFormLine.class); final int expectedConstraintValueType = SingleFieldConstraint.TYPE_UNDEFINED; doReturn(expectedExpressionFormLine).when(popupCreator).makeExpressionFormLine(expectedFactType); final SingleFieldConstraintEBLeftSide constraint = popupCreator.makeSingleFieldConstraintEBLeftSide(expectedFactType); assertEquals(expectedConstraintValueType, constraint.getConstraintValueType()); assertEquals(expectedExpressionFormLine, constraint.getExpressionLeftSide()); assertEquals(expectedFactType, constraint.getFactType()); }
private SingleFieldConstraintEBLeftSide visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) { SingleFieldConstraintEBLeftSide clone = new SingleFieldConstraintEBLeftSide(); clone.setConstraintValueType(sfexp.getConstraintValueType()); clone.setExpressionLeftSide((ExpressionFormLine) visit(sfexp.getExpressionLeftSide())); clone.setExpressionValue((ExpressionFormLine) visit(sfexp.getExpressionValue())); clone.setFactType(sfexp.getFactType()); // skip setting fieldBinding, fieldName and fieldType, these are computed from expressionLeftSide clone.setId(sfexp.getId()); clone.setOperator(sfexp.getOperator()); for (Map.Entry<String, String> entry : sfexp.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setParent(sfexp.getParent()); clone.setValue(sfexp.getValue()); if (sfexp.getConnectives() != null) { clone.setConnectives(new ConnectiveConstraint[sfexp.getConnectives().length]); for (int i = 0; i < sfexp.getConnectives().length; i++) { clone.getConnectives()[i] = (ConnectiveConstraint) visit(sfexp.getConnectives()[i]); } } return clone; } }
private void generateNormalFieldRestriction(final SingleFieldConstraint constr, final Map<String, String> parameters) { if (constr instanceof SingleFieldConstraintEBLeftSide) { SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constr; addFieldRestriction(buf, sfexp.getConstraintValueType(), sfexp.getExpressionLeftSide().getGenericType(), sfexp.getOperator(), parameters, sfexp.getValue(), sfexp.getExpressionValue(), true); } else { addFieldRestriction(buf, constr.getConstraintValueType(), constr.getFieldType(), constr.getOperator(), parameters, constr.getValue(), constr.getExpressionValue(), true); } }