Search in sources :

Example 11 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class FindAllLibraryAssetsSortedQueryTest method listAllInProjectSorted.

@Test
public void listAllInProjectSorted() throws IOException, InterruptedException {
    setUp(TEST_PROJECT_ROOT1);
    final RefactoringPageRequest request = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new LibraryValueModuleRootPathIndexTerm(TEST_PROJECT_ROOT1, TermSearchType.WILDCARD));
        }
    }, 0, 10);
    final PageResponse<RefactoringPageRow> response = service.query(request);
    assertNotNull(response);
    // Remove duplicates and sort file names alphabetically
    Set<String> resultSet = new TreeSet<>();
    for (RefactoringPageRow row : response.getPageRowList()) {
        String fileName = ((Path) row.getValue()).getFileName();
        System.out.println(fileName);
        resultSet.add(fileName);
    }
    assertArrayEquals(FILE_NAMES, resultSet.toArray());
}
Also used : Path(org.uberfire.backend.vfs.Path) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) TreeSet(java.util.TreeSet) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Test(org.junit.Test)

Example 12 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class BpmnFileIndexerTest method testBpmnIndexing.

@Test
public void testBpmnIndexing() throws Exception {
    List<Path> pathList = new ArrayList<>();
    ioService().startBatch(ioService().getFileSystem(basePath.toUri()));
    for (int i = 0; i < BPMN_FILES.length; ++i) {
        String bpmnFile = BPMN_FILES[i];
        if (bpmnFile.endsWith("bpmn")) {
            Path path = basePath.resolve(bpmnFile);
            pathList.add(path);
            String bpmnStr = loadText(bpmnFile);
            ioService().write(path, bpmnStr);
        }
    }
    ioService().endBatch();
    Path[] paths = pathList.toArray(new Path[pathList.size()]);
    {
        PageResponse<RefactoringPageRow> response = null;
        try {
            for (int i = 0; i < MAX_WAIT_TIMES; i++) {
                Thread.sleep(WAIT_TIME_MILLIS);
                response = queryBPMN2Resources();
                if (response != null && response.getPageRowList() != null && response.getPageRowList().size() >= paths.length) {
                    break;
                }
            }
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
        assertNotNull(response);
        assertEquals(paths.length, response.getPageRowList().size());
    }
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("*", PartType.RULEFLOW_GROUP, ValueIndexTerm.TermSearchType.WILDCARD).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(1, response.size());
            assertResponseContains(response, paths[4]);
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("MySignal", PartType.SIGNAL).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(1, response.size());
            assertResponseContains(response, paths[5]);
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("BrokenSignal", PartType.SIGNAL).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(1, response.size());
            assertResponseContains(response, paths[6]);
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("name", PartType.GLOBAL).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(2, response.size());
            assertResponseContains(response, paths[5]);
            assertResponseContains(response, paths[6]);
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
    {
        final Set<ValueIndexTerm> queryTerms = new HashSet<ValueIndexTerm>() {

            {
                add(new ValueResourceIndexTerm("*", ResourceType.BPMN2, ValueIndexTerm.TermSearchType.WILDCARD));
            }
        };
        try {
            List<RefactoringPageRow> response = service.query(FindBpmnProcessIdsQuery.NAME, queryTerms);
            assertNotNull(response);
            assertEquals(paths.length, response.size());
            for (String expectedId : PROCESS_IDS) {
                boolean foundId = false;
                for (RefactoringPageRow row : response) {
                    Map<String, org.uberfire.backend.vfs.Path> mapRow = (Map<String, org.uberfire.backend.vfs.Path>) row.getValue();
                    for (String rKey : mapRow.keySet()) {
                        assertTrue(PROCESS_IDS.contains(rKey));
                        foundId = true;
                    }
                }
                if (!foundId) {
                    fail("Process with ID <" + expectedId + " not found in results for " + FindBpmnProcessIdsQuery.NAME);
                }
            }
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) HashSet(java.util.HashSet) Set(java.util.Set) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) QueryOperationRequest(org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest) ArrayList(java.util.ArrayList) PageResponse(org.uberfire.paging.PageResponse) ArrayList(java.util.ArrayList) List(java.util.List) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Map(java.util.Map) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest) Test(org.junit.Test)

Example 13 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class CalledElementFormProviderTest method setup.

@Before
public void setup() {
    calledElementFormProvider.setQueryService(queryService);
    List<RefactoringPageRow> results = new ArrayList<RefactoringPageRow>();
    RefactoringMapPageRow refactoringMapPageRow = new RefactoringMapPageRow();
    Map<String, Path> map = new HashMap<String, Path>();
    map.put(ID1, path1);
    map.put(ID2, path2);
    refactoringMapPageRow.setValue(map);
    results.add(refactoringMapPageRow);
    when(queryService.query(anyString(), anyObject())).thenReturn(results);
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RefactoringMapPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringMapPageRow) Matchers.anyString(org.mockito.Matchers.anyString) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Before(org.junit.Before)

Example 14 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow 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 15 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow 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)

Aggregations

RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)26 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)11 Path (org.uberfire.backend.vfs.Path)10 PageResponse (org.uberfire.paging.PageResponse)9 HashSet (java.util.HashSet)8 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)8 Path (org.uberfire.java.nio.file.Path)5 Map (java.util.Map)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)4 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)4 LibraryValueModuleRootPathIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm)4 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)4 Set (java.util.Set)3 Branch (org.guvnor.structure.repositories.Branch)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 AssetInfo (org.kie.workbench.common.screens.library.api.AssetInfo)2