Search in sources :

Example 26 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.

the class RefactorOperationBuilderFactory method newResourceBasedInstance.

public static <T extends AbstractOperationRequest> RefactorOperationBuilder<T> newResourceBasedInstance(String resourceName, ResourceType type, OperationType operation) {
    RefactorOperationBuilder<T> builder = newInstance(operation);
    builder.getQueryTerms().add(new ValueReferenceIndexTerm(resourceName, type));
    return builder;
}
Also used : ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)

Example 27 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.

the class RefactorOperationBuilderFactory method newResourceBasedInstance.

public static <T extends AbstractOperationRequest> RefactorOperationBuilder<T> newResourceBasedInstance(String resourceName, ResourceType type, TermSearchType searchType, OperationType operation) {
    RefactorOperationBuilder<T> builder = newInstance(operation);
    builder.getQueryTerms().add(new ValueReferenceIndexTerm(resourceName, type, searchType));
    return builder;
}
Also used : ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)

Example 28 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.

the class FindResourcePartsQueryValidIndexTermsTest method initExpectedValues.

private List<Pair<String, String>> initExpectedValues() {
    List<Pair<String, String>> expectedValues = new ArrayList<Pair<String, String>>();
    expectedValues.add(new Pair<String, String>(ResourceType.JAVA.toString(), "org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Pojo1"));
    // identifying info
    String[] fieldNames = new String[] { "o_BigDecimal", "o_BigInteger", "o_Boolean", "o_Byte", "o_Character", "o_Date", "o_Double", "o_Float", "o_Integer", "o_Long", "o_Short", "o_String", "p_boolean", "p_byte", "p_char", "p_double", "p_float", "p_int", "p_long", "p_short" };
    for (String className : fieldNames) {
        ValuePartIndexTerm partTerm = new ValuePartIndexTerm(className, PartType.FIELD);
        expectedValues.add(new Pair<String, String>(partTerm.getTerm(), partTerm.getValue()));
    }
    // references
    String[] referencedClasses = new String[] { "java.util.Date", "java.io.Serializable", "java.math.BigDecimal", "java.lang.Boolean", "java.lang.Byte", "java.lang.Character", "java.lang.Double", "java.lang.Float", "java.lang.Integer", "java.lang.Long", "boolean", "byte", "char", "double", "float", "long", "short" };
    for (String className : referencedClasses) {
        ValueReferenceIndexTerm refTerm = new ValueReferenceIndexTerm(className, ResourceType.JAVA);
        expectedValues.add(new Pair<String, String>(refTerm.getTerm(), refTerm.getValue()));
    }
    return expectedValues;
}
Also used : ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) ArrayList(java.util.ArrayList) ValuePartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartIndexTerm) Pair(org.uberfire.commons.data.Pair)

Example 29 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.

the class IndexDrlLHSTypeExpressionFieldTypeTest method testIndexDrlLHSTypeExpressionFieldType.

@Test
public void testIndexDrlLHSTypeExpressionFieldType() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("drl6.drl");
    final String drl1 = loadText("drl6.drl");
    ioService().write(path1, drl1);
    // 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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path1);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path1);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 30 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.

the class IndexDrlLHSTypeTest method testIndexDrlLHSType.

@Test
public void testIndexDrlLHSType() throws IOException, InterruptedException {
    ioService().startBatch(ioService().getFileSystem(basePath.toUri()));
    // Add test files
    final Path path1 = basePath.resolve("drl1.drl");
    final String drl1 = loadText("drl1.drl");
    ioService().write(path1, drl1);
    final Path path2 = basePath.resolve("drl2.drl");
    final String drl2 = loadText("drl2.drl");
    ioService().write(path2, drl2);
    final Path path3 = basePath.resolve("drl3.drl");
    final String drl3 = loadText("drl3.drl");
    ioService().write(path3, drl3);
    ioService().endBatch();
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(12000);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
    // Check type extraction (with wildcards)
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("*.Applicant", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
        searchFor(index, query, 3, path1, path2, path3);
    }
    // Check type extraction (without wildcards)
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 3, path1, path2, path3);
    }
    // Check type extraction (with wildcards)
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("*.Mortgage", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
        searchFor(index, query, 2, path2, path3);
    }
    // Check type extraction (without wildcards)
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
        searchFor(index, query, 2, path2, path3);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)39 Test (org.junit.Test)35 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)35 Path (org.uberfire.java.nio.file.Path)32 Query (org.apache.lucene.search.Query)31 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)31 Import (org.kie.soup.project.datamodel.imports.Import)9 ValuePartReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm)7 Logger (ch.qos.logback.classic.Logger)5 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)5 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)5 HashSet (java.util.HashSet)4 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)4 ArrayList (java.util.ArrayList)2 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)2 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 TopScoreDocCollector (org.apache.lucene.search.TopScoreDocCollector)1 ScoreCardModel (org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1