private ExpressionFormLine visitExpressionFormLine(ExpressionFormLine efl) { ExpressionFormLine clone = new ExpressionFormLine(efl); clone.setBinding(efl.getBinding()); return clone; }
@Override public void callback(final ExpressionPart part) { expression.appendPart(part); onChangeSelectionUpdateExpressionWidget(oldType); } });
private String getBoundText() { if (expression.isBound()) { return "[" + expression.getBinding() + "] "; } return "[not bound]"; }
private String getCurrentGenericType() { //If the last ExpressionPart is ExpressionText then we can't show any Fields or Methods from which to select if (expression.getParts().isEmpty()) { return null; } if (expression.getParts().get(expression.getParts().size() - 1) instanceof ExpressionText) { return DataType.TYPE_FINAL_OBJECT; } return expression.getGenericType(); }
index); if (paramValue != null) { final ExpressionFormLine param = new ExpressionFormLine(index); param.appendPart(new ExpressionMethodParameter(paramValue, paramDataType, paramDataType)); expression.appendPart(em); } else { expression.appendPart(new ExpressionText(expressionPart)); expression.appendPart(new ExpressionCollection(expressionPart, currentField.getClassName(), currentField.getType(), ); } else { expression.appendPart(new ExpressionField(expressionPart, currentField.getClassName(), currentField.getType()));
@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()); }
private static ExpressionFormLine buildExpressionFormLine() { ExpressionFormLine efl = new ExpressionFormLine(); efl.setBinding( "eflBinding" ); efl.appendPart( new ExpressionText( "text" ) ); efl.appendPart( new ExpressionCollectionIndex( "collectionIndex", "CT", "GT" ) ); return efl; }
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(); }
ExpressionFormLine makeExpressionFormLine(final String factType) { final ExpressionUnboundFact part = new ExpressionUnboundFact(factType); return new ExpressionFormLine(part); }
ExpressionFormLine expression = new ExpressionFormLine(); fcfp.setExpression(expression); if (i == 0) { String type = boundParams.get(sourcePart); expression.appendPart(new ExpressionVariable(sourcePart, type, DataType.TYPE_NUMERIC)); final String previousClassName = expression.getClassType(); final List<MethodInfo> mis = dmo.getModuleMethodInformation().get(previousClassName); boolean isMethod = false; for (MethodInfo mi : mis) { if (mi.getName().equals(sourcePart)) { expression.appendPart(new ExpressionMethod(mi.getName(), mi.getReturnClassType(), mi.getGenericType(), expression.appendPart(new ExpressionText(sourcePart)); expression.appendPart(new ExpressionField(sourcePart, modelField.getClassName(), modelField.getType()));
private void visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) { String genericType = sfexp.getExpressionLeftSide().getGenericType(); String factType = sfexp.getExpressionLeftSide().getPreviousClassType(); if (factType == null) { factType = sfexp.getExpressionLeftSide().getClassType(); } InterpolationVariable var = new InterpolationVariable(sfexp.getValue(), genericType, factType, sfexp.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfexp.getConstraintValueType() && !vars.containsKey(var)) { vars.put(var, vars.size()); } //Visit Connection constraints if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { final ConnectiveConstraint cc = sfexp.getConnectives()[i]; InterpolationVariable ccVar = new InterpolationVariable(cc.getValue(), genericType, factType, cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.containsKey(ccVar)) { vars.put(ccVar, vars.size()); } } } }
factType = sfexp.getExpressionLeftSide().getPreviousClassType(); if (factType == null) { factType = sfexp.getExpressionLeftSide().getClassType(); fieldName = sfexp.getExpressionLeftSide().getFieldName(); } else { factType = constraint.getFactType();
private boolean isExpressionBindingMissing(final FromCompositeFactPattern fromCompositeFactPattern) { return fromCompositeFactPattern.getExpression().getBinding() == null && fromCompositeFactPattern.getExpression().getParts().isEmpty(); }
public ExpressionFormLine( ExpressionFormLine other ) { this.index = other.getIndex(); CopyExpressionVisitor copier = new CopyExpressionVisitor(); if ( other.getParts().size() == 0 ) { return; } for ( ExpressionPart exp = copier.copy( other.getRootExpression() ); exp != null; exp = exp.getNext() ) { parts.add( exp ); } }
/** * 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 ); } }
expression.removeLast(); onChangeSelectionUpdateExpressionWidget(oldType); } else if (TEXT_VALUE.equals(value)) { expression.appendPart(new ExpressionText("")); onChangeSelectionUpdateExpressionWidget(oldType); } else {
container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container()); for (ExpressionPart expressionPart : expression.getParts()) { if (expressionPart instanceof ExpressionUnboundFact) { continue; final ExpressionFormLine paramValueHolder = emParams.get(index); final String paramDataType = em.getParameterDataType(paramValueHolder); final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder.getRootExpression()); final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType); paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {
protected void buildExpressionFieldValue(final ExpressionFormLine expression, final StringBuilder buf) { if (expression != null) { buf.append(" "); final ToStringExpressionVisitor visitor = new ToStringExpressionVisitor(constraintValueBuilder); buf.append(expression.getText(visitor)); buf.append(" "); } }
@Override public void setFieldBinding( String fieldBinding ) { getExpressionLeftSide().setBinding( fieldBinding ); }