Search in sources :

Example 36 with ConditionCol52

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

the class ModelMetaDataEnhancerTest method conditionCol52Column.

@Test
public void conditionCol52Column() throws Exception {
    final ArrayList<BaseColumn> columns = new ArrayList<>();
    final ConditionCol52 conditionCol52 = new ConditionCol52();
    final Pattern52 pattern52 = new Pattern52();
    columns.add(conditionCol52);
    when(model.getExpandedColumns()).thenReturn(columns);
    when(model.getPattern(conditionCol52)).thenReturn(pattern52);
    final Map<Integer, ModelMetaData> metaData = new ModelMetaDataEnhancer(model).getHeaderMetaData().getPatternsByColumnNumber();
    assertEquals(1, metaData.size());
    assertEquals(pattern52, metaData.get(0).getPattern());
    assertEquals(PatternType.LHS, metaData.get(0).getPatternType());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ModelMetaData(org.drools.workbench.services.verifier.plugin.client.api.ModelMetaData) Test(org.junit.Test)

Example 37 with ConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 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 38 with ConditionCol52

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

the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey.

@Test
public void fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey() {
    // Columns: Row#[0], Description[1], Action[2]
    final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
    final BRLActionColumn brl = new BRLActionColumn();
    final ActionInsertFact aif = new ActionInsertFact();
    aif.setFactType("Fact");
    aif.addFieldValue(new ActionFieldValue() {

        {
            setField("field");
            setValue("10");
            setNature(FieldNatureType.TYPE_LITERAL);
        }
    });
    brl.setDefinition(new ArrayList<IAction>() {

        {
            add(aif);
        }
    });
    brl.getChildColumns().add(new BRLActionVariableColumn("", DataType.TYPE_BOOLEAN));
    dt1.getActionCols().add(brl);
    // Columns: Row#[0], Description[1], Condition[2]
    final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
    final Pattern52 p2 = new Pattern52();
    p2.setBoundName("$f");
    p2.setFactType("Fact");
    final ConditionCol52 p2c1 = new ConditionCol52();
    p2c1.setFactField("field");
    p2.getChildColumns().add(p2c1);
    dt2.getConditions().add(p2);
    manager.link(dt1, dt2, (s, t) -> {
        assertEquals(2, s);
        assertEquals(2, t);
    });
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 39 with ConditionCol52

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

the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintLinksToActionUpdateField.

@Test
public void fieldConstraintLinksToActionUpdateField() {
    // Columns: Row#[0], Description[1], Condition[2], Action[3]
    final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
    final Pattern52 p1 = new Pattern52();
    p1.setBoundName("$f");
    p1.setFactType("Fact");
    final ConditionCol52 p1c1 = new ConditionCol52();
    p1c1.setFactField("field");
    p1.getChildColumns().add(p1c1);
    dt1.getConditions().add(p1);
    final ActionSetFieldCol52 asf = new ActionSetFieldCol52();
    asf.setBoundName("$f");
    asf.setFactField("field");
    dt1.getActionCols().add(asf);
    // Columns: Row#[0], Description[1], Condition[2]
    final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
    final Pattern52 p2 = new Pattern52();
    p2.setBoundName("$f");
    p2.setFactType("Fact");
    final ConditionCol52 p2c1 = new ConditionCol52();
    p2c1.setFactField("field");
    p2.getChildColumns().add(p2c1);
    dt2.getConditions().add(p2);
    manager.link(dt1, dt2, (s, t) -> {
        assertEquals(3, s);
        assertEquals(2, t);
    });
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 40 with ConditionCol52

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

the class GuidedDecisionTableFactory method makeTableWithConditionCol.

public static GuidedDecisionTable52 makeTableWithConditionCol(final String packageName, final Collection<Import> imports, final String tableName) {
    final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setPackageName(packageName);
    dt.getImports().getImports().addAll(imports);
    dt.setTableName(tableName);
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("$a");
    p1.setFactType("Applicant");
    ConditionCol52 con1 = new ConditionCol52();
    con1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con1.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    con1.setFactField("age");
    con1.setHeader("Applicant age");
    con1.setOperator("==");
    p1.getChildColumns().add(con1);
    dt.getConditions().add(p1);
    Pattern52 p2 = new Pattern52();
    p2.setBoundName("$m");
    p2.setFactType("Mortgage");
    ConditionCol52 con2 = new ConditionCol52();
    con2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    con2.setFactField("amount");
    con2.setHeader("Mortgage amount");
    con2.setOperator("==");
    p2.getChildColumns().add(con2);
    dt.getConditions().add(p2);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "33", "" } }));
    return dt;
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52)

Aggregations

ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)229 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)184 Test (org.junit.Test)170 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)74 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)59 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)38 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)34 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 ArrayList (java.util.ArrayList)27 Path (org.uberfire.backend.vfs.Path)27 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)25 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)25 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)24 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)23