Search in sources :

Example 26 with ActionCol52

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

the class ActionInsertFactFieldsPage method initialise.

@Override
public void initialise() {
    view.init(this);
    view.setValidator(getValidator());
    patternToActionsMap.clear();
    // Set-up validator for the pattern-to-action mapping voodoo
    getValidator().setPatternToActionInsertFactFieldsMap(patternToActionsMap);
    // Set-up a factory for value editors
    view.setDTCellValueWidgetFactory(DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues()));
    // Available types
    final List<String> availableTypes = Arrays.asList(oracle.getFactTypes());
    view.setAvailableFactTypes(availableTypes);
    // Existing ActionInsertFactCols (should be empty for a new Decision Table)
    for (ActionCol52 a : model.getActionCols()) {
        if (a instanceof ActionInsertFactCol52) {
            final ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
            final ActionInsertFactFieldsPattern p = lookupExistingInsertFactPattern(aif.getBoundName());
            final List<ActionInsertFactCol52> actions = patternToActionsMap.get(p);
            getValidator().addActionPattern(p);
            actions.add(aif);
        }
    }
    view.setChosenPatterns(new ArrayList<ActionInsertFactFieldsPattern>());
    view.setAvailableFields(new ArrayList<AvailableField>());
    view.setChosenFields(new ArrayList<ActionInsertFactCol52>());
    content.setWidget(view);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionInsertFactFieldsPattern(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern)

Example 27 with ActionCol52

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

the class ActionSetFieldsPage method initialise.

@Override
public void initialise() {
    view.init(this);
    view.setValidator(getValidator());
    patternToActionsMap.clear();
    // Set-up validator for the pattern-to-action mapping voodoo
    getValidator().setPatternToActionSetFieldsMap(patternToActionsMap);
    // Set-up a factory for value editors
    view.setDTCellValueWidgetFactory(DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues()));
    // Existing ActionSetFieldCols (should be empty for a new Decision Table)
    for (ActionCol52 a : model.getActionCols()) {
        if (a instanceof ActionSetFieldCol52) {
            final ActionSetFieldCol52 asf = (ActionSetFieldCol52) a;
            final Pattern52 p = model.getConditionPattern(asf.getBoundName());
            if (!patternToActionsMap.containsKey(p)) {
                patternToActionsMap.put(p, new ArrayList<ActionSetFieldCol52>());
            }
            final List<ActionSetFieldCol52> actions = patternToActionsMap.get(p);
            actions.add(asf);
        }
    }
    view.setChosenFields(new ArrayList<ActionSetFieldCol52>());
    content.setWidget(view);
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 28 with ActionCol52

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

the class RowExpander method addActionColumns.

private void addActionColumns() {
    for (ActionCol52 a : model.getActionCols()) {
        if (a instanceof ActionSetFieldCol52) {
            ActionSetFieldCol52 afc = (ActionSetFieldCol52) a;
            addColumn(afc);
        } else if (a instanceof ActionInsertFactCol52) {
            ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
            addColumn(aif);
        }
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 29 with ActionCol52

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

the class ActionWorkItemSetFieldPluginTest method testGetAlreadyUsedColumnNames.

@Test
public void testGetAlreadyUsedColumnNames() throws Exception {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    model.getActionCols().add(new ActionCol52() {

        {
            setHeader("a");
        }
    });
    model.getActionCols().add(new ActionCol52() {

        {
            setHeader("b");
        }
    });
    when(presenter.getModel()).thenReturn(model);
    assertEquals(2, plugin.getAlreadyUsedColumnHeaders().size());
    assertTrue(plugin.getAlreadyUsedColumnHeaders().contains("a"));
    assertTrue(plugin.getAlreadyUsedColumnHeaders().contains("b"));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Test(org.junit.Test)

Example 30 with ActionCol52

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

the class ActionWorkItemSetFieldPluginTest method testSetupValuesWhenColumnIsNotNew.

@Test
public void testSetupValuesWhenColumnIsNotNew() throws Exception {
    final DTColumnConfig52 column = mock(DTColumnConfig52.class);
    final ActionWorkItemWrapper actionWrapper = mock(ActionWorkItemWrapper.class);
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    doReturn(model).when(presenter).getModel();
    doReturn(column).when(plugin).getOriginalColumnConfig52();
    doReturn(actionWrapper).when(plugin).newActionWorkItemWrapper(column);
    doReturn(patternWrapper).when(plugin).newPatternWrapper(actionWrapper);
    doReturn("WorkItemName").when(actionWrapper).getWorkItemName();
    doReturn("WorkItemResultParameterName").when(actionWrapper).getWorkItemResultParameterName();
    doReturn(new ArrayList<ActionCol52>()).when(model).getActionCols();
    doReturn(false).when(plugin).isNewColumn();
    plugin.setupValues();
    verify(plugin).setupWorkItems();
    verify(plugin).setWorkItem("WorkItemName:WorkItemResultParameterName");
    verify(plugin).setWorkItemPageAsCompleted();
    verify(plugin).fireChangeEvent(patternPage);
    verify(plugin).fireChangeEvent(fieldPage);
    verify(plugin).fireChangeEvent(additionalInfoPage);
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) ActionWorkItemWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Aggregations

ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)60 Test (org.junit.Test)31 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 ArrayList (java.util.ArrayList)17 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)16 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)13 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)13 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)12 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)11 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)10 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)9 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)8 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)8 List (java.util.List)6 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)6 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)6 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)6