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;
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations