Search in sources :

Example 41 with Pattern52

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

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

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

use of org.drools.workbench.models.guided.dtable.shared.model.Pattern52 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)

Example 45 with Pattern52

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

the class ConditionColumnSynchronizer method doMovePattern.

private void doMovePattern(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final ConditionCol52 srcModelColumn = (ConditionCol52) md.getColumn();
    final Pattern52 srcModelPattern = model.getPattern(srcModelColumn);
    if (srcModelPattern == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<ConditionCol52> srcModelPatternConditionColumns = srcModelPattern.getChildColumns();
    final int srcModelPatternConditionColumnCount = srcModelPatternConditionColumns.size();
    if (srcModelPatternConditionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelPatternConditionColumnCount != metaData.size()) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final int tgtPatternIndex = findTargetPatternIndex(md);
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelPatternConditionColumns.get(0)), allModelColumns.indexOf(srcModelPatternConditionColumns.get(0)) + srcModelPatternConditionColumnCount - 1);
    model.getConditions().remove(srcModelPattern);
    model.getConditions().add(tgtPatternIndex, srcModelPattern);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Aggregations

Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)243 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)184 Test (org.junit.Test)180 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)92 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)66 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)45 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)39 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)34 ArrayList (java.util.ArrayList)31 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)28 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 Path (org.uberfire.backend.vfs.Path)27 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)26 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)26 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)24 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24