Search in sources :

Example 61 with GuidedDecisionTable52

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

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

the class GuidedDecisionTableFactory method makeTableWithBRLFragmentConditionCol.

public static GuidedDecisionTable52 makeTableWithBRLFragmentConditionCol(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);
    final BRLConditionColumn brl = new BRLConditionColumn();
    final FactPattern fp1 = new FactPattern();
    fp1.setFactType("Applicant");
    final SingleFieldConstraint sfc1 = new SingleFieldConstraint();
    sfc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    sfc1.setFactType("Applicant");
    sfc1.setOperator("==");
    sfc1.setFieldName("age");
    sfc1.setValue("f1");
    fp1.addConstraint(sfc1);
    final FactPattern fp2 = new FactPattern();
    fp2.setFactType("Mortgage");
    final SingleFieldConstraint sfc2 = new SingleFieldConstraint();
    sfc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    sfc2.setFactType("Mortgage");
    sfc2.setOperator("==");
    sfc2.setFieldName("amount");
    sfc2.setValue("f2");
    fp2.addConstraint(sfc2);
    brl.getDefinition().add(fp1);
    brl.getDefinition().add(fp2);
    brl.getChildColumns().add(new BRLConditionVariableColumn("f1", DataType.TYPE_NUMERIC_INTEGER));
    brl.getChildColumns().add(new BRLConditionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER));
    dt.getConditions().add(brl);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "33", "" } }));
    return dt;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 63 with GuidedDecisionTable52

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

the class IndexGuidedDecisionTableAttributesTest method testIndexGuidedDecisionTableAttributes.

@Test
public void testIndexGuidedDecisionTableAttributes() throws IOException, InterruptedException {
    // Add test files
    final Path path = basePath.resolve("dtable1.gdst");
    final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithAttributeCol("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {

        {
            add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
        }
    }, "dtable1");
    final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
    ioService().write(path, xml);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
    // Decision Table defining a RuleFlow-Group named myRuleFlowGroup. This should match dtable1.gdst
    // This checks whether there is a Rule Attribute "ruleflow-group" and its Value is "myRuleflowGroup"
    {
        final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myRuleFlowGroup", PartType.RULEFLOW_GROUP)).build();
        searchFor(index, query, 1, path);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 64 with GuidedDecisionTable52

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

the class IndexGuidedDecisionTableBRLFragmentActionsTest method testIndexGuidedDecisionTableBRLFragmentActions.

@Test
public void testIndexGuidedDecisionTableBRLFragmentActions() throws IOException, InterruptedException {
    // Add test files
    final Path path = basePath.resolve("dtable1.gdst");
    final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentActionCol("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {

        {
            add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
            add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage"));
        }
    }, "dtable1");
    final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
    ioService().write(path, xml);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 65 with GuidedDecisionTable52

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

the class IndexGuidedDecisionTableBRLFragmentConditionsPredicateTest method checkSingleFieldConstraintPredicate.

@Test
public void checkSingleFieldConstraintPredicate() throws IOException, InterruptedException {
    // Add test files
    final Path path = basePath.resolve("dtable1.gdst");
    final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentConditionColWithPredicate("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {

        {
            add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
            add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage"));
        }
    }, "dtable1");
    final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
    ioService().write(path, xml);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(7500);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)262 Test (org.junit.Test)193 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)92 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)74 Path (org.uberfire.backend.vfs.Path)52 ArrayList (java.util.ArrayList)51 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)51 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)47 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)39 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)37 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)35 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)33 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)33 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)33 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)32 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)31 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)27 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)27 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26