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;
}
}