Search in sources :

Example 1 with ActionWorkItemSetFieldCol52

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

the class GuidedDTDRLPersistence method doActions.

void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) {
    List<LabelledAction> actions = new ArrayList<LabelledAction>();
    for (ActionCol52 c : actionCols) {
        if (c instanceof LimitedEntryBRLActionColumn) {
            doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm);
        } else if (c instanceof BRLActionColumn) {
            doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm);
        } else {
            int index = allColumns.indexOf(c);
            DTCellValue52 dcv = row.get(index);
            String cell = "";
            if (c instanceof LimitedEntryCol) {
                if (dcv.getBooleanValue() == true) {
                    LimitedEntryCol lec = (LimitedEntryCol) c;
                    cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue());
                }
            } else {
                cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv);
            }
            if (validCell(cell, dcv.getDataType())) {
                if (c instanceof ActionWorkItemInsertFactCol52) {
                    doAction(actions, (ActionWorkItemInsertFactCol52) c, cell);
                } else if (c instanceof ActionInsertFactCol52) {
                    doAction(actions, (ActionInsertFactCol52) c, cell);
                } else if (c instanceof ActionWorkItemSetFieldCol52) {
                    doAction(actions, (ActionWorkItemSetFieldCol52) c, cell);
                } else if (c instanceof ActionSetFieldCol52) {
                    doAction(actions, (ActionSetFieldCol52) c, cell);
                } else if (c instanceof ActionRetractFactCol52) {
                    doAction(actions, cell);
                } else if (c instanceof ActionWorkItemCol52) {
                    doAction(actions, (ActionWorkItemCol52) c, cell);
                }
            }
        }
    }
    rm.rhs = new IAction[actions.size()];
    for (int i = 0; i < rm.rhs.length; i++) {
        rm.rhs[i] = actions.get(i).action;
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn)

Example 2 with ActionWorkItemSetFieldCol52

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

the class PluginHandler method edit.

public void edit(final ActionCol52 column) {
    final DecisionTableColumnPlugin plugin;
    if (column instanceof ActionWorkItemSetFieldCol52 || column instanceof ActionWorkItemInsertFactCol52) {
        plugin = actionWorkItemSetFieldPlugin.get();
    } else if (column instanceof ActionInsertFactCol52 || column instanceof ActionSetFieldCol52) {
        plugin = actionSetFactPlugin.get();
    } else if (column instanceof ActionRetractFactCol52) {
        plugin = actionRetractFactPlugin.get();
    } else if (column instanceof ActionWorkItemCol52) {
        plugin = actionWorkItemPlugin.get();
    } else if (column instanceof BRLActionColumn) {
        plugin = brlActionColumnPlugin.get();
    } else {
        return;
    }
    plugin.setOriginalColumnConfig52(column);
    openWizard(plugin);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DecisionTableColumnPlugin(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.DecisionTableColumnPlugin) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 3 with ActionWorkItemSetFieldCol52

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

the class ActionWorkItemSetFieldPluginTest method testNewActionWrapperWhenColumnIsAnActionSetFactWrapper.

@Test
public void testNewActionWrapperWhenColumnIsAnActionSetFactWrapper() throws Exception {
    when(model.getTableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    when(presenter.getModel()).thenReturn(model);
    final ActionWorkItemWrapper wrapper = plugin.newActionWorkItemWrapper(mock(ActionWorkItemSetFieldCol52.class));
    assertTrue(wrapper instanceof ActionWorkItemSetWrapper);
}
Also used : ActionWorkItemWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper) ActionWorkItemSetWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemSetWrapper) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) Test(org.junit.Test)

Example 4 with ActionWorkItemSetFieldCol52

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

the class ActionWorkItemSetWrapperTest method testClone.

@Test
public void testClone() throws Exception {
    final ActionWorkItemSetFieldCol52 column = new ActionWorkItemSetFieldCol52();
    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.setParameterClassName("parameterClassName");
    column.setWorkItemName("workItemName");
    column.setWorkItemResultParameterName("workItemResultParameterName");
    final ActionWorkItemSetWrapper wrapper = new ActionWorkItemSetWrapper(plugin, column);
    final ActionWorkItemSetFieldCol52 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("parameterClassName", column.getParameterClassName());
    assertEquals("workItemName", column.getWorkItemName());
    assertEquals("workItemResultParameterName", column.getWorkItemResultParameterName());
    assertNotSame(column, clone);
}
Also used : ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 5 with ActionWorkItemSetFieldCol52

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

the class ActionWorkItemSetFieldColumnSynchronizer method append.

@Override
public void append(final ColumnMetaData metaData) throws VetoException {
    // Check operation is supported
    if (!handlesAppend(metaData)) {
        return;
    }
    final ActionWorkItemSetFieldCol52 column = (ActionWorkItemSetFieldCol52) metaData.getColumn();
    final String workItemName = column.getWorkItemName();
    model.getActionCols().stream().filter(c -> c instanceof ActionWorkItemCol52).map(c -> ((ActionWorkItemCol52) c)).filter(c -> c.getWorkItemDefinition().getName().equals(workItemName)).findFirst().ifPresent(p -> findLastIndexOfWorkItemColumn(p).ifPresent(index -> {
        model.getActionCols().add(index + 1, column);
        synchroniseAppendColumn(column);
    }));
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) Dependent(javax.enterprise.context.Dependent) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Collections(java.util.Collections) BaseColumnFieldDiffImpl(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiffImpl) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)

Aggregations

ActionWorkItemSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)22 Test (org.junit.Test)15 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)6 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)5 ArrayList (java.util.ArrayList)4 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)4 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)4 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)2 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)2 ActionSetField (org.drools.workbench.models.datamodel.rule.ActionSetField)2 ActionWorkItemFieldValue (org.drools.workbench.models.datamodel.rule.ActionWorkItemFieldValue)2 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)2 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)2 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)2 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)2 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)2