Search in sources :

Example 1 with LimitedEntryActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.

the class LimitedGuidedDecisionTableBuilder method withAction.

public LimitedGuidedDecisionTableBuilder withAction(String boundName, String factField, String typeNumericInteger, DTCellValue52 value) {
    LimitedEntryActionSetFieldCol52 ins = new LimitedEntryActionSetFieldCol52();
    ins.setBoundName(boundName);
    ins.setFactField(factField);
    ins.setValue(value);
    ins.setType(typeNumericInteger);
    table.getActionCols().add(ins);
    return this;
}
Also used : LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)

Example 2 with LimitedEntryActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldsPageViewImpl method makeNewActionColumn.

private ActionSetFieldCol52 makeNewActionColumn(final AvailableField f) {
    final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat();
    if (format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY) {
        final ActionSetFieldCol52 a = new ActionSetFieldCol52();
        a.setBoundName(availablePatternsSelection.getBoundName());
        a.setFactField(f.getName());
        a.setType(f.getType());
        return a;
    } else {
        final LimitedEntryActionSetFieldCol52 a = new LimitedEntryActionSetFieldCol52();
        a.setBoundName(availablePatternsSelection.getBoundName());
        a.setFactField(f.getName());
        a.setType(f.getType());
        return a;
    }
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)

Example 3 with LimitedEntryActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.

the class LimitedEntryActionSetFieldCol52DefinitionBuilderTest method simpleActionUpdateField.

@Test
public void simpleActionUpdateField() {
    final AtomicBoolean calledBack = new AtomicBoolean(false);
    setupLimitedEntryPatternAndCondition();
    final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52();
    asf.setBoundName("$p");
    asf.setFactField("name");
    asf.setValue(new DTCellValue52("Michael"));
    asf.setUpdate(true);
    model.getActionCols().add(asf);
    when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING);
    builder.generateDefinition(dtPresenter, asf, (String definition) -> {
        calledBack.set(true);
        assertEquals("modify( $p ) {<br/>" + "setName( \"Michael\" )<br/>" + "}", definition);
    });
    assertTrue(calledBack.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Test(org.junit.Test)

Example 4 with LimitedEntryActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.

the class LimitedEntryActionSetFieldCol52DefinitionBuilderTest method simpleActionSetField.

@Test
public void simpleActionSetField() {
    final AtomicBoolean calledBack = new AtomicBoolean(false);
    setupPatternAndCondition();
    final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52();
    asf.setBoundName("$p");
    asf.setFactField("name");
    asf.setValue(new DTCellValue52("Michael"));
    model.getActionCols().add(asf);
    when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING);
    builder.generateDefinition(dtPresenter, asf, (String definition) -> {
        calledBack.set(true);
        assertEquals("$p.setName( \"Michael\" );", definition);
    });
    assertTrue(calledBack.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Test(org.junit.Test)

Example 5 with LimitedEntryActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testLimitedEntryActionSet.

@Test
public void testLimitedEntryActionSet() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_BOOLEAN);
    cc1.setFactField("isSmurf");
    cc1.setOperator("==");
    cc1.setValue(new DTCellValue52("true"));
    p1.getChildColumns().add(cc1);
    LimitedEntryActionSetFieldCol52 asf1 = new LimitedEntryActionSetFieldCol52();
    asf1.setBoundName("p1");
    asf1.setFactField("colour");
    asf1.setValue(new DTCellValue52("Blue"));
    dt.getActionCols().add(asf1);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", true, false } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( isSmurf == true )");
    assertTrue(index > -1);
    index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( isSmurf == true )", index + 1);
    assertTrue(index > -1);
    index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
    assertFalse(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Test(org.junit.Test)

Aggregations

LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)8 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)5 Test (org.junit.Test)5 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)3 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)2 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)2 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)1 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)1 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)1 Label (org.gwtbootstrap3.client.ui.Label)1 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)1 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)1