Search in sources :

Example 6 with ValueSharedPartIndexTerm

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) 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 7 with ValueSharedPartIndexTerm

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) 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 8 with ValueSharedPartIndexTerm

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) BooleanQuery(org.apache.lucene.search.BooleanQuery) WildcardQuery(org.apache.lucene.search.WildcardQuery) TermQuery(org.apache.lucene.search.TermQuery) Term(org.apache.lucene.index.Term) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 9 with ValueSharedPartIndexTerm

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) 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 10 with ValueSharedPartIndexTerm

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) 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) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

Test (org.junit.Test)13 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)13 ValueSharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm)13 Path (org.uberfire.java.nio.file.Path)12 Query (org.apache.lucene.search.Query)10 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)10 Term (org.apache.lucene.index.Term)3 BooleanQuery (org.apache.lucene.search.BooleanQuery)3 TermQuery (org.apache.lucene.search.TermQuery)3 Import (org.kie.soup.project.datamodel.imports.Import)2 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)2 Logger (ch.qos.logback.classic.Logger)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 WildcardQuery (org.apache.lucene.search.WildcardQuery)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)1 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)1 SharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm)1