use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueCompositionTest method testIndexDrlRuleAttributeNameAndValues.
@Test
public void testIndexDrlRuleAttributeNameAndValues() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.rdrl");
final String drl = loadText("drl1.rdrl");
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 IndexGuidedDecisionTableGraphFileTest method testIndexGuidedDecisionTableGraphEntries.
@Test
public void testIndexGuidedDecisionTableGraphEntries() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable-graph1.gdst-set");
final Path dtable1Path = basePath.resolve("dtable1.gdst");
final Path dtable2Path = basePath.resolve("dtable2.gdst");
final org.uberfire.backend.vfs.Path vfsDtable1Path = Paths.convert(dtable1Path);
final org.uberfire.backend.vfs.Path vfsDtable2Path = Paths.convert(dtable2Path);
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable1Path, vfsDtable1Path));
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable2Path, vfsDtable2Path));
final String xml = GuidedDTGraphXMLPersistence.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 ValueSharedPartIndexTerm(vfsDtable1Path.toURI(), PartType.PATH)).build();
searchFor(index, query, 1, path);
}
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm(vfsDtable2Path.toURI(), PartType.PATH)).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 IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValues.
@Test
public void testIndexDrlRuleAttributeNameAndValues() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.rdrl");
final String drl = loadText("drl1.rdrl");
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();
ValueSharedPartIndexTerm indexTerm = new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP);
queryBuilder.add(new WildcardQuery(new Term(indexTerm.getTerm(), indexTerm.getValue())), BooleanClause.Occur.MUST);
queryBuilder.add(new WildcardQuery(new Term("shared:nonexistend", "*")), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 0);
}
{
// This could also just be a TermQuery..
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueSharedPartIndexTerm indexTerm = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
queryBuilder.add(new TermQuery(new Term(indexTerm.getTerm(), indexTerm.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.rdrl");
final String drl = loadText("drl1.rdrl");
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);
}
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexGuidedRuleTemplateAttributesTest method testIndexGuidedRuleTemplateAttributes.
@Test
public void testIndexGuidedRuleTemplateAttributes() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("template1.template");
final TemplateModel model = GuidedRuleTemplateFactory.makeModelWithAttributes("org.drools.workbench.screens.guided.template.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Mortgage"));
}
}, "template1");
final String xml = RuleTemplateModelXMLPersistenceImpl.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 ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)).build();
searchFor(index, query, 1, path);
}
// Rule Template defining a RuleFlow-Group named myRuleFlowGroup. This should match template1.template
// 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);
}
}
Aggregations