Search in sources :

Example 1 with ExpressionFieldVariable

use of org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable in project drools by kiegroup.

the class CopyExpressionVisitor method visit.

public void visit(ExpressionFieldVariable part) {
    add(new ExpressionFieldVariable(part.getName(), part.getClassType()));
    moveNext(part);
}
Also used : ExpressionFieldVariable(org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable)

Example 2 with ExpressionFieldVariable

use of org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable in project drools-wb by kiegroup.

the class ExpressionBuilder method onStartPointChange.

private void onStartPointChange(final String value) {
    setModified(true);
    panel.clear();
    final int dotPos = value.indexOf('.');
    final String prefix = value.substring(0, dotPos);
    final String attrib = value.substring(dotPos + 1);
    if (prefix.equals(VARIABLE_VALUE_PREFIX)) {
        FactPattern fact = getRuleModel().getLHSBoundFact(attrib);
        ExpressionPart variable;
        if (fact != null) {
            variable = new ExpressionVariable(fact.getBoundName(), fact.getFactType());
        } else {
            // if the variable is not bound to a Fact Pattern then it must be bound to a Field
            String lhsBindingType = getRuleModel().getLHSBindingType(attrib);
            variable = new ExpressionFieldVariable(attrib, lhsBindingType);
        }
        expression.appendPart(variable);
        onStartPointChangeUpdateWidget();
    } else if (prefix.equals(GLOBAL_VARIABLE_VALUE_PREFIX)) {
        ExpressionPartHelper.getExpressionPartForGlobalVariable(getDataModelOracle(), attrib, new Callback<ExpressionPart>() {

            @Override
            public void callback(final ExpressionPart part) {
                expression.appendPart(part);
                onStartPointChangeUpdateWidget();
            }
        });
    }
}
Also used : ExpressionFieldVariable(org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable) Callback(org.uberfire.client.callbacks.Callback) ExpressionPart(org.drools.workbench.models.datamodel.rule.ExpressionPart) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) ExpressionVariable(org.drools.workbench.models.datamodel.rule.ExpressionVariable)

Example 3 with ExpressionFieldVariable

use of org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable in project drools by kiegroup.

the class CopyExpressionVisitorTest method testExpressionFormLineCopy.

@Test
public void testExpressionFormLineCopy() {
    ExpressionFormLine efl = new ExpressionFormLine();
    efl.appendPart(new ExpressionCollection("collection", "CT", "GT", "PT"));
    efl.appendPart(new ExpressionCollectionIndex("collectionIndex", "CT", "GT"));
    efl.appendPart(new ExpressionField("field", "CT", "FT", "PT"));
    efl.appendPart(new ExpressionFieldVariable("fieldVariable", "Type"));
    efl.appendPart(new ExpressionGlobalVariable("globalVariable", "CT", "GT", "PT"));
    efl.appendPart(new ExpressionMethod("method", "CT", "GT"));
    efl.appendPart(new ExpressionMethodParameter("methodParam", "CT", "GT"));
    efl.appendPart(new ExpressionText("text"));
    efl.appendPart(new ExpressionUnboundFact("FactType"));
    efl.appendPart(new ExpressionVariable("binding", "FactType"));
    // verify that the new instance created with copy constructor is equal to original
    assertEquals(efl, new ExpressionFormLine(efl));
}
Also used : ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) ExpressionFieldVariable(org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable) ExpressionMethod(org.drools.workbench.models.datamodel.rule.ExpressionMethod) ExpressionCollectionIndex(org.drools.workbench.models.datamodel.rule.ExpressionCollectionIndex) ExpressionMethodParameter(org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter) ExpressionCollection(org.drools.workbench.models.datamodel.rule.ExpressionCollection) ExpressionText(org.drools.workbench.models.datamodel.rule.ExpressionText) ExpressionVariable(org.drools.workbench.models.datamodel.rule.ExpressionVariable) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) ExpressionGlobalVariable(org.drools.workbench.models.datamodel.rule.ExpressionGlobalVariable) Test(org.junit.Test)

Aggregations

ExpressionFieldVariable (org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable)3 ExpressionVariable (org.drools.workbench.models.datamodel.rule.ExpressionVariable)2 ExpressionCollection (org.drools.workbench.models.datamodel.rule.ExpressionCollection)1 ExpressionCollectionIndex (org.drools.workbench.models.datamodel.rule.ExpressionCollectionIndex)1 ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)1 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)1 ExpressionGlobalVariable (org.drools.workbench.models.datamodel.rule.ExpressionGlobalVariable)1 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)1 ExpressionMethodParameter (org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter)1 ExpressionPart (org.drools.workbench.models.datamodel.rule.ExpressionPart)1 ExpressionText (org.drools.workbench.models.datamodel.rule.ExpressionText)1 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 Test (org.junit.Test)1 Callback (org.uberfire.client.callbacks.Callback)1