use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm 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.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexDecisionTableXLSAttributeNameAndValueCompositionTest method testIndexDecisionTableXLSAttributeNameAndValueComposition.
@Test
public void testIndexDecisionTableXLSAttributeNameAndValueComposition() throws IOException, InterruptedException {
// Add test files
final Path path1 = loadXLSFile(basePath, "dtable3.xls");
// 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 dtable3.xls
// 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, path1);
}
// Decision Table defining a RuleFlow-Group named myAgendaGroup. This should *NOT* match dtable3.xls
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myAgendaGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 0);
}
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueCompositionTest method testIndexDrlRuleAttributeNameAndValueComposition.
@Test
public void testIndexDrlRuleAttributeNameAndValueComposition() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl5.drl");
final String drl = loadText("drl5.drl");
ioService().write(path, drl);
// 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());
// DRL defining a RuleFlow-Group named myRuleFlowGroup. This should match drl5.drl
// 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);
}
// DRL defining a RuleFlow-Group named myAgendaGroup. This should *NOT* match drl5.drl
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myAgendaGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 0);
}
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValue.
@Test
public void testIndexDrlRuleAttributeNameAndValue() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.drl");
final String drl = loadText("drl1.drl");
ioService().write(path, drl);
// 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 BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
queryBuilder.add(new TermQuery(new Term((new SharedPartIndexTerm(PartType.RULEFLOW_GROUP)).getTerm())), BooleanClause.Occur.MUST);
queryBuilder.add(new TermQuery(new Term("nonexistent")), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 0);
}
// This note replaces an earlier note, if it doesn't make sense, delete or ignore it.
// Both pieces of info (that it's a ruleflow group, and that the ruleflow group is called "myruleflowgroup")
// are present in the same field ("shared:ruleflowgroup" => "myruleflowgroup"), so this only returns
// documents that match that field (as opposed to the structure we had before).
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueIndexTerm termVals = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
queryBuilder.add(new TermQuery(new Term(termVals.getTerm(), termVals.getValue())), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 1);
}
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameTest method testIndexDrlRuleAttributeNames.
@Test
public void testIndexDrlRuleAttributeNames() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.drl");
final String drl = loadText("drl1.drl");
ioService().write(path, drl);
// 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 ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)).build();
searchFor(index, query, 1);
}
}
Aggregations