Search in sources :

Example 6 with ActionCol52

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

the class GuidedDTDRLPersistenceTest method testRHSExecuteWorkItemWithBindings.

@Test
public void testRHSExecuteWorkItemWithBindings() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "true" };
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    List<ActionCol52> cols = new ArrayList<ActionCol52>();
    ActionWorkItemCol52 awi = new ActionWorkItemCol52();
    PortableWorkDefinition pwd = new PortableWorkDefinition();
    pwd.setName("work-item");
    awi.setWorkItemDefinition(pwd);
    PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
    p1.setName("BooleanParameter");
    p1.setValue(Boolean.TRUE);
    p1.setBinding("$b");
    pwd.addParameter(p1);
    PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
    p2.setName("FloatParameter");
    p2.setValue(123.456f);
    p2.setBinding("$f");
    pwd.addParameter(p2);
    PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
    p3.setName("IntegerParameter");
    p3.setValue(123);
    p3.setBinding("$i");
    pwd.addParameter(p3);
    PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
    p4.setName("StringParameter");
    p4.setValue("hello");
    p4.setBinding("$s");
    pwd.addParameter(p4);
    cols.add(awi);
    RuleModel rm = new RuleModel();
    allColumns.addAll(cols);
    List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
    TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
    p.doActions(allColumns, cols, rowDataProvider, rowData, rm);
    assertEquals(1, rm.rhs.length);
    // Examine RuleModel action
    ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
    assertNotNull(aw);
    PortableWorkDefinition mpwd = aw.getWorkDefinition();
    assertNotNull(mpwd);
    assertEquals(4, mpwd.getParameters().size());
    PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter("BooleanParameter");
    assertNotNull(mp1);
    assertEquals(Boolean.TRUE, mp1.getValue());
    assertEquals("$b", mp1.getBinding());
    PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter("FloatParameter");
    assertNotNull(mp2);
    assertEquals(new Float(123.456f), mp2.getValue());
    assertEquals("$f", mp2.getBinding());
    PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter("IntegerParameter");
    assertNotNull(mp3);
    assertEquals(new Integer(123), mp3.getValue());
    assertEquals("$i", mp3.getBinding());
    PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter("StringParameter");
    assertNotNull(mp4);
    assertEquals("hello", mp4.getValue());
    assertEquals("$s", mp4.getBinding());
}
Also used : PortableIntegerParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition) ActionExecuteWorkItem(org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) Test(org.junit.Test)

Example 7 with ActionCol52

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

the class RuleBuilder method resolveColumns.

private void resolveColumns() throws BuildException {
    int columnIndex = 0;
    for (final BaseColumn baseColumn : model.getExpandedColumns()) {
        if (baseColumn instanceof ConditionCol52) {
            final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
            rule.getConditions().add(condition);
        } else if (baseColumn instanceof ActionCol52) {
            final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
            rule.getActions().add(action);
        }
        columnIndex++;
    }
}
Also used : Condition(org.drools.workbench.services.verifier.api.client.index.Condition) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Action(org.drools.workbench.services.verifier.api.client.index.Action) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 8 with ActionCol52

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

the class GuidedDecisionTablePresenter method onDeleteSelectedColumns.

@Override
public void onDeleteSelectedColumns() {
    if (isReadOnly()) {
        return;
    }
    final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes();
    final Set<BaseColumn> columnsToDelete = new HashSet<>();
    for (int selectedColumnIndex : selectedColumnIndexes) {
        final int columnIndex = findUiColumnIndex(selectedColumnIndex);
        final BaseColumn column = model.getExpandedColumns().get(columnIndex);
        if (!(column instanceof RowNumberCol52 || column instanceof DescriptionCol52)) {
            columnsToDelete.add(column);
        }
    }
    for (BaseColumn columnToDelete : columnsToDelete) {
        if (columnToDelete instanceof AttributeCol52) {
            try {
                deleteColumn((AttributeCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showGenericVetoMessage();
            }
        } else if (columnToDelete instanceof MetadataCol52) {
            try {
                deleteColumn((MetadataCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showGenericVetoMessage();
            }
        } else if (columnToDelete instanceof ConditionCol52) {
            try {
                deleteColumn((ConditionCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showUnableToDeleteColumnMessage((ConditionCol52) columnsToDelete);
            }
        } else if (columnToDelete instanceof ActionCol52) {
            try {
                deleteColumn((ActionCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showUnableToDeleteColumnMessage((ActionCol52) columnsToDelete);
            }
        }
    }
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) HashSet(java.util.HashSet) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 9 with ActionCol52

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

the class GuidedDecisionTableModelVisitor method getConsumedModelClasses.

public Set<String> getConsumedModelClasses() {
    final Set<String> factTypes = new HashSet<String>();
    // Extract Fact Types from model
    for (CompositeColumn<?> cc : model.getConditions()) {
        if (cc instanceof BRLConditionColumn) {
            final List<IPattern> definition = ((BRLConditionColumn) cc).getDefinition();
            factTypes.addAll(getConditionFactTypesFromRuleModel(definition));
        } else if (cc instanceof Pattern52) {
            factTypes.add(((Pattern52) cc).getFactType());
        }
    }
    for (ActionCol52 c : model.getActionCols()) {
        if (c instanceof BRLActionColumn) {
            final List<IAction> definition = ((BRLActionColumn) c).getDefinition();
            factTypes.addAll(getActionFactTypesFromRuleModel(definition));
        } else if (c instanceof ActionInsertFactCol52) {
            factTypes.add(((ActionInsertFactCol52) c).getFactType());
        }
    }
    // Convert Fact Types into Fully Qualified Class Names
    final Set<String> fullyQualifiedClassNames = new HashSet<String>();
    for (String factType : factTypes) {
        fullyQualifiedClassNames.add(convertToFullyQualifiedClassName(factType));
    }
    return fullyQualifiedClassNames;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) HashSet(java.util.HashSet)

Example 10 with ActionCol52

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

the class GuidedDecisionTableTheme method getModelColumnType.

ModelColumnType getModelColumnType(final GridColumn<?> uiColumn) {
    final int uiColumnIndex = uiModel.getColumns().indexOf(uiColumn);
    final BaseColumn modelColumn = model.getExpandedColumns().get(uiColumnIndex);
    if (modelColumn instanceof RowNumberCol52) {
        return ModelColumnType.ROW_NUMBER;
    } else if (modelColumn instanceof DescriptionCol52) {
        return ModelColumnType.DESCRIPTION;
    } else if (modelColumn instanceof MetadataCol52) {
        return ModelColumnType.METADATA;
    } else if (modelColumn instanceof AttributeCol52) {
        return ModelColumnType.ATTRIBUTE;
    } else if (modelColumn instanceof ConditionCol52) {
        return ModelColumnType.CONDITION;
    } else if (modelColumn instanceof ActionCol52) {
        return ModelColumnType.ACTION;
    }
    // proof rendering than throw an exception.
    return ModelColumnType.UNKNOWN;
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

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