Search in sources :

Example 6 with LimitedEntryActionSetFieldCol52

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

the class ActionSetFieldsPageViewImpl method initialiseChosenFields.

private void initialiseChosenFields() {
    chosenFieldsContainer.add(chosenFieldsWidget);
    chosenFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    chosenFieldsWidget.setMinimumWidth(170);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenFields());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    chosenFieldsWidget.setEmptyListWidget(lstEmpty);
    final MultiSelectionModel<ActionSetFieldCol52> selectionModel = new MultiSelectionModel<ActionSetFieldCol52>(System::identityHashCode);
    chosenFieldsWidget.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            chosenFieldsSelections = selectionModel.getSelectedSet();
            chosenConditionsSelected(chosenFieldsSelections);
        }

        private void chosenConditionsSelected(final Set<ActionSetFieldCol52> cws) {
            btnRemove.setEnabled(true);
            if (cws.size() == 1) {
                chosenFieldsSelection = cws.iterator().next();
                fieldDefinition.setVisible(true);
                validateFieldHeader();
                populateFieldDefinition();
            } else {
                chosenFieldsSelection = null;
                fieldDefinition.setVisible(false);
                txtColumnHeader.setEnabled(false);
                txtValueList.setEnabled(false);
                defaultValueContainer.setVisible(false);
                chkUpdateEngine.setEnabled(false);
            }
        }

        private void populateFieldDefinition() {
            // Fields common to all table formats
            txtColumnHeader.setEnabled(true);
            chkUpdateEngine.setEnabled(true);
            txtColumnHeader.setText(chosenFieldsSelection.getHeader());
            chkUpdateEngine.setValue(chosenFieldsSelection.isUpdate());
            criteriaExtendedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
            criteriaLimitedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
            // Fields specific to the table format
            switch(presenter.getTableFormat()) {
                case EXTENDED_ENTRY:
                    txtValueList.setEnabled(!presenter.hasEnums(chosenFieldsSelection));
                    txtValueList.setText(chosenFieldsSelection.getValueList());
                    makeDefaultValueWidget();
                    defaultValueContainer.setVisible(true);
                    break;
                case LIMITED_ENTRY:
                    makeLimitedValueWidget();
                    limitedEntryValueContainer.setVisible(true);
                    break;
            }
        }

        private void makeLimitedValueWidget() {
            if (!(chosenFieldsSelection instanceof LimitedEntryActionSetFieldCol52)) {
                return;
            }
            final LimitedEntryActionSetFieldCol52 lea = (LimitedEntryActionSetFieldCol52) chosenFieldsSelection;
            if (lea.getValue() == null) {
                lea.setValue(factory.makeNewValue(availablePatternsSelection, chosenFieldsSelection));
            }
            limitedEntryValueWidgetContainer.setWidget(factory.getWidget(availablePatternsSelection, chosenFieldsSelection, lea.getValue()));
        }
    });
}
Also used : MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)

Example 7 with LimitedEntryActionSetFieldCol52

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

the class RowExpanderTests method testExpansionWithLimitedEntry.

@Test
@SuppressWarnings("serial")
public void testExpansionWithLimitedEntry() {
    GuidedDecisionTable52 model = new GuidedDecisionTable52();
    model.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    final ModuleDataModelOracle projectLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addFact("Driver").addField(new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER)).addField(new ModelField("name", String.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING)).addField(new ModelField("dateOfBirth", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_DATE)).addField(new ModelField("approved", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_BOOLEAN)).end().build();
    // Emulate server-to-client conversions
    final AsyncPackageDataModelOracle oracle = getOracle();
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    dataModel.setModelFields(projectLoader.getModuleModelFields());
    populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("c1");
    p1.setFactType("Driver");
    LimitedEntryConditionCol52 c1 = new LimitedEntryConditionCol52();
    c1.setFactField("name");
    c1.setOperator("==");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setValue(new DTCellValue52("Mike"));
    p1.getChildColumns().add(c1);
    model.getConditions().add(p1);
    Pattern52 p2 = new Pattern52();
    p2.setBoundName("c2");
    p2.setFactType("Driver");
    LimitedEntryConditionCol52 c2 = new LimitedEntryConditionCol52();
    c2.setFactField("age");
    c2.setOperator("==");
    c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setValue(new DTCellValue52(25));
    p2.getChildColumns().add(c2);
    model.getConditions().add(p2);
    LimitedEntryActionSetFieldCol52 a1 = new LimitedEntryActionSetFieldCol52();
    a1.setBoundName("c1");
    a1.setFactField("name");
    a1.setValue(new DTCellValue52("a1name"));
    model.getActionCols().add(a1);
    LimitedEntryActionInsertFactCol52 a2 = new LimitedEntryActionInsertFactCol52();
    a2.setBoundName("a2");
    a2.setFactType("Driver");
    a2.setFactField("name");
    a2.setValue(new DTCellValue52("a2name"));
    model.getActionCols().add(a2);
    RowExpander re = new RowExpander(model, oracle);
    List<RowExpander.ColumnValues> columns = re.getColumns();
    assertEquals(6, columns.size());
    assertEquals(1, columns.get(0).values.size());
    assertEquals(1, columns.get(1).values.size());
    assertEquals(2, columns.get(2).values.size());
    assertEquals(2, columns.get(3).values.size());
    assertEquals(1, columns.get(4).values.size());
    assertEquals(1, columns.get(5).values.size());
    assertEquals(Boolean.TRUE, columns.get(2).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(2).values.get(1).getBooleanValue());
    assertEquals(Boolean.TRUE, columns.get(3).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(3).values.get(1).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(4).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(5).values.get(0).getBooleanValue());
    RowExpander.RowIterator i = re.iterator();
    List<List<DTCellValue52>> rows = new ArrayList<List<DTCellValue52>>();
    while (i.hasNext()) {
        List<DTCellValue52> row = i.next();
        rows.add(row);
    }
    assertEquals(4, rows.size());
    assertEquals("", rows.get(0).get(0).getStringValue());
    assertEquals("", rows.get(0).get(1).getStringValue());
    assertEquals(Boolean.TRUE, rows.get(0).get(2).getBooleanValue());
    assertEquals(Boolean.TRUE, rows.get(0).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(0).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(0).get(5).getBooleanValue());
    assertEquals("", rows.get(1).get(0).getStringValue());
    assertEquals("", rows.get(1).get(1).getStringValue());
    assertEquals(Boolean.TRUE, rows.get(1).get(2).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(5).getBooleanValue());
    assertEquals("", rows.get(2).get(0).getStringValue());
    assertEquals("", rows.get(2).get(1).getStringValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(2).getBooleanValue());
    assertEquals(Boolean.TRUE, rows.get(2).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(5).getBooleanValue());
    assertEquals("", rows.get(3).get(0).getStringValue());
    assertEquals("", rows.get(3).get(1).getStringValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(2).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(5).getBooleanValue());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) ArrayList(java.util.ArrayList) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ArrayList(java.util.ArrayList) List(java.util.List) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) Test(org.junit.Test)

Example 8 with LimitedEntryActionSetFieldCol52

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

the class ActionSetFactWrapperTest method testCloneALimitedEntryActionInsert.

@Test
public void testCloneALimitedEntryActionInsert() throws Exception {
    doReturn(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY).when(model).getTableFormat();
    final LimitedEntryActionSetFieldCol52 column = new LimitedEntryActionSetFieldCol52();
    column.setFactField("factField");
    column.setBoundName("boundName");
    column.setValueList("valueList");
    column.setHeader("header");
    column.setUpdate(false);
    column.setDefaultValue(new DTCellValue52("defaultValue"));
    column.setHideColumn(false);
    column.setType("type");
    column.setValue(new DTCellValue52("value"));
    final ActionSetFactWrapper wrapper = new ActionSetFactWrapper(plugin, column);
    final ActionSetFieldCol52 clone = wrapper.getActionCol52();
    assertEquals("factField", column.getFactField());
    assertEquals("boundName", column.getBoundName());
    assertEquals("valueList", column.getValueList());
    assertEquals("header", column.getHeader());
    assertEquals(false, column.isUpdate());
    assertEquals(new DTCellValue52("defaultValue"), column.getDefaultValue());
    assertEquals(false, column.isHideColumn());
    assertEquals("type", column.getType());
    assertEquals(new DTCellValue52("value"), column.getValue());
    assertNotSame(column, clone);
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) 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) 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