Search in sources :

Example 11 with ValueIndexTerm

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

the class RuleFlowGroupFormProvider method getRuleFlowGroupNames.

@SuppressWarnings("unchecked")
private Map<Object, String> getRuleFlowGroupNames() {
    List<RefactoringPageRow> results = queryService.query(FindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, ValueIndexTerm.TermSearchType.WILDCARD));
        }
    });
    Map<Object, String> ruleFlowGroupNames = new TreeMap<Object, String>();
    for (RefactoringPageRow row : results) {
        ruleFlowGroupNames.put(((Map<String, String>) row.getValue()).get("name"), ((Map<String, String>) row.getValue()).get("name"));
    }
    return ruleFlowGroupNames;
}
Also used : ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) TreeMap(java.util.TreeMap) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 12 with ValueIndexTerm

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

the class FindBpmnProcessIdsQueryTest method findBpmnProcessIdsQueryTermsTest.

@Test
public void findBpmnProcessIdsQueryTermsTest() {
    FindBpmnProcessIdsQuery query = new FindBpmnProcessIdsQuery();
    Set<ValueIndexTerm> queryTerms = new HashSet<>();
    try {
        query.validateTerms(queryTerms);
        fail("The required resources term is missing, but no exception was thrown.");
    } catch (IllegalArgumentException iae) {
        assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains("Expected 'ValueResourceIndexTerm' term was not found."));
    }
    queryTerms = new HashSet<>();
    queryTerms.add(new ValueResourceIndexTerm("not-bpmn2-resources", ResourceType.JAVA));
    try {
        query.validateTerms(queryTerms);
        fail("The required resources term is missing, but no exception was thrown.");
    } catch (IllegalArgumentException iae) {
        assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains(ERROR_MSG));
    }
    queryTerms = new HashSet<>();
    queryTerms.add(new ValueResourceIndexTerm("*", ResourceType.BPMN2, ValueIndexTerm.TermSearchType.WILDCARD));
    try {
        query.validateTerms(queryTerms);
    } catch (IllegalArgumentException iae) {
        fail("The activation term is acceptable here, but an exception was thrown.");
    }
}
Also used : ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) FindBpmnProcessIdsQuery(org.kie.workbench.common.stunner.bpmn.backend.query.FindBpmnProcessIdsQuery) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with ValueIndexTerm

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

the class FindDataTypesService method getDataTypeNames.

public List<String> getDataTypeNames() {
    // Query Java resources
    List<RefactoringPageRow> results = queryService.query(FindDataTypesQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new ValueResourceIndexTerm("*", ResourceType.JAVA, ValueIndexTerm.TermSearchType.WILDCARD));
        }
    });
    final List<String> dataTypeNames = new ArrayList<String>();
    for (RefactoringPageRow row : results) {
        dataTypeNames.add((String) row.getValue());
    }
    Collections.sort(dataTypeNames);
    return dataTypeNames;
}
Also used : ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) ArrayList(java.util.ArrayList) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 14 with ValueIndexTerm

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

the class RuleFlowGroupFormProviderTest method findRuleFlowNamesQueryTermsTest.

@Test
public void findRuleFlowNamesQueryTermsTest() {
    FindRuleFlowNamesQuery query = new FindRuleFlowNamesQuery();
    Set<ValueIndexTerm> queryTerms = new HashSet<>();
    try {
        query.validateTerms(queryTerms);
        fail("The required rule-flow term is missing, but no exception was thrown.");
    } catch (IllegalArgumentException iae) {
        assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains("At least 1 term"));
    }
    queryTerms = new HashSet<>();
    queryTerms.add(new ValueSharedPartIndexTerm("not-rule-flow", PartType.ACTIVATION_GROUP));
    try {
        query.validateTerms(queryTerms);
        fail("The required rule-flow term is missing, but no exception was thrown.");
    } catch (IllegalArgumentException iae) {
        assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains(ERROR_MSG));
    }
    queryTerms = new HashSet<>();
    queryTerms.add(new ValueSharedPartIndexTerm("not-rule-flow", PartType.ACTIVATION_GROUP));
    queryTerms.add(new ValueSharedPartIndexTerm("rule-flow", PartType.RULEFLOW_GROUP));
    try {
        query.validateTerms(queryTerms);
        fail("The activation term is not acceptable here, but no exception was thrown.");
    } catch (IllegalArgumentException iae) {
        assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains(ERROR_MSG));
    }
    queryTerms = new HashSet<>();
    queryTerms.add(new ValueSharedPartIndexTerm("rule-flow", PartType.RULEFLOW_GROUP));
    query.validateTerms(queryTerms);
}
Also used : ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) FindRuleFlowNamesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindRuleFlowNamesQuery) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with ValueIndexTerm

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

the class LibraryServiceImpl method buildProjectAssetsQuery.

private HashSet<ValueIndexTerm> buildProjectAssetsQuery(ProjectAssetsQuery query) {
    final HashSet<ValueIndexTerm> queryTerms = new HashSet<>();
    queryTerms.add(new LibraryValueModuleRootPathIndexTerm(query.getProject().getRootPath().toURI()));
    if (query.hasFilter()) {
        queryTerms.add(new LibraryValueFileNameIndexTerm("*" + query.getFilter() + "*", ValueIndexTerm.TermSearchType.WILDCARD));
    }
    if (query.hasExtension()) {
        queryTerms.add(new LibraryValueFileExtensionIndexTerm(query.getExtensions()));
    }
    return queryTerms;
}
Also used : ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueFileNameIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueFileExtensionIndexTerm) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) HashSet(java.util.HashSet)

Aggregations

ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)23 HashSet (java.util.HashSet)13 Test (org.junit.Test)12 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)10 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)8 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)8 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)7 Path (org.uberfire.java.nio.file.Path)6 ArrayList (java.util.ArrayList)5 LibraryValueModuleRootPathIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm)5 ValueSharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm)5 PageResponse (org.uberfire.paging.PageResponse)5 Map (java.util.Map)4 Term (org.apache.lucene.index.Term)4 List (java.util.List)3 Set (java.util.Set)3 BooleanQuery (org.apache.lucene.search.BooleanQuery)3 Query (org.apache.lucene.search.Query)3 TermQuery (org.apache.lucene.search.TermQuery)3 Path (org.uberfire.backend.vfs.Path)3