Package org.zanata.webtrans.shared.rpc

Examples of org.zanata.webtrans.shared.rpc.GetTransUnitsNavigationResult


            transIdStateMap.put(transUnitId,
                    textFlow.getTargets().get(hLocale.getId()).getState());
        }

        log.debug("for action {} returned size: {}", action, idIndexList.size());
        return new GetTransUnitsNavigationResult(idIndexList, transIdStateMap);
    }
View Full Code Here


        HLocale hLocale = validateAndGetLocale(action);

        log.info("action: {}", action);
        int targetOffset = action.getOffset();
        int targetPageIndex = targetOffset / action.getCount();
        GetTransUnitsNavigationResult navigationResult = null;
        EditorFilter editorFilter = action.getEditorFilter();
        FilterConstraints constraints =
                FilterConstraints
                        .builder()
                        .filterBy(editorFilter.getTextInContent())
                        .lastModifiedBy(editorFilter.getLastModifiedByUser())
                        .targetChangedBefore(
                                parseDateIfPresent(editorFilter
                                        .getLastModifiedBefore()))
                        .targetChangedAfter(
                                parseDateIfPresent(editorFilter
                                        .getLastModifiedAfter()))
                        .resourceIdIs(editorFilter.getResId())
                        .msgContext(editorFilter.getMsgContext())
                        .sourceCommentContains(editorFilter.getSourceComment())
                        .targetCommentContains(editorFilter.getTransComment())
                        .caseSensitive(false).checkInSource(true)
                        .checkInTarget(true)
                        .includeStates(action.getFilterStates()).build();
        if (action.isNeedReloadIndex()) {
            GetTransUnitsNavigation getTransUnitsNavigation =
                    new GetTransUnitsNavigation(action.getDocumentId(),
                            action.getFilterStates(), action.getEditorFilter(),
                            constraints);
            log.debug("get trans unit navigation action: {}",
                    getTransUnitsNavigation);
            navigationResult =
                    getTransUnitsNavigationService.getNavigationIndexes(
                            getTransUnitsNavigation, hLocale);

            int totalPageIndex =
                    getTotalPageIndex(navigationResult.getIdIndexList().size(),
                            action.getCount());

            if (targetPageIndex > totalPageIndex) {
                targetPageIndex = totalPageIndex;
                targetOffset = action.getCount() * targetPageIndex;
            }

            if (action.getTargetTransUnitId() != null) {
                int targetIndexInDoc =
                        navigationResult.getIdIndexList().indexOf(
                                action.getTargetTransUnitId());
                targetPageIndex = targetIndexInDoc / action.getCount();
                targetOffset = action.getCount() * targetPageIndex;
            }
        }
View Full Code Here

        for (TransUnit tu : data) {
            idIndexList.add(tu.getId());
            transIdStateMap.put(tu.getId(), tu.getStatus());
        }

        result.setNavigationIndex(new GetTransUnitsNavigationResult(
                idIndexList, transIdStateMap));

        callback.onSuccess(result);
        Log.info("EXIT DummyGetTransUnitCommand.execute()");
    }
View Full Code Here

        assertThat(getTransUnitListResult.getDocumentId(),
                equalTo(DOCUMENT.getId()));
        assertThat(TestFixture.asIds(getTransUnitListResult.getUnits()),
                contains(0, 1, 2, 3, 4, 5));

        GetTransUnitsNavigationResult navigationResult =
                getTransUnitListResult.getNavigationIndex();
        assertThat(TestFixture.asLongs(navigationResult.getIdIndexList()),
                contains(0L, 1L, 2L, 3L, 4L, 5L));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(0L), ContentState.New));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(1L), ContentState.New));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(2L), ContentState.NeedReview));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(3L), ContentState.Approved));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(4L), ContentState.NeedReview));
        assertThat(navigationResult.getTransIdStateList(),
                hasEntry(new TransUnitId(5L), ContentState.New));
    }
View Full Code Here

         * = 74
         */
        int offset = 75;
        int countPerPage = 25;

        GetTransUnitsNavigationResult navigationResult =
                mock(GetTransUnitsNavigationResult.class);
        List<TransUnitId> idIndexList = new ArrayList<TransUnitId>();
        for (int i = 1; i < offset; i++) {
            idIndexList.add(new TransUnitId(i));
        }

        GetTransUnitList action =
                GetTransUnitList.newAction(new GetTransUnitActionContext(
                        document).withFindMessage("FiLe")
                        .withFilterUntranslated(true).withFilterFuzzy(true)
                        .withFilterHasError(true).withOffset(offset)
                        .withCount(countPerPage));
        action.setNeedReloadIndex(true);

        prepareActionAndMockLocaleService(action);

        // When:
        when(
                getTransUnitsNavigationService.getNavigationIndexes(
                        isA(GetTransUnitsNavigation.class), isA(HLocale.class)))
                .thenReturn(navigationResult);
        when(navigationResult.getIdIndexList()).thenReturn(idIndexList);

        GetTransUnitListResult result = handler.execute(action, null);

        assertThat(result.getTargetPageIndex(), Matchers.equalTo(2));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.rpc.GetTransUnitsNavigationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.