Search in sources :

Example 1 with ValueSharedPartIndexTerm

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);
    }
}
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 2 with ValueSharedPartIndexTerm

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);
    }
}
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 3 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 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);
    }
}
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 4 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 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);
    }
}
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) TermQuery(org.apache.lucene.search.TermQuery) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) SharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Term(org.apache.lucene.index.Term) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) SharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 5 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.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);
    }
}
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)

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