From 1d25edc216b9f9ab85a4af25caa1c30137533072 Mon Sep 17 00:00:00 2001 From: Alex Eng Date: Thu, 12 Jul 2018 20:32:41 +1000 Subject: [PATCH] feat: GWT MT filter --- .../client/events/FilterViewEvent.java | 13 ++++-- .../webtrans/client/history/EditorTokens.java | 12 ++++- .../webtrans/client/history/HistoryToken.java | 10 ++++ .../presenter/TransFilterPresenter.java | 32 +++++++------ .../presenter/TransUnitsTablePresenter.java | 12 ++--- .../service/HistoryEventHandlerService.java | 10 ++-- .../client/service/UserOptionsService.java | 1 + .../client/view/TransFilterDisplay.java | 4 +- .../webtrans/client/view/TransFilterView.java | 12 +++-- .../client/view/TransFilterView.ui.xml | 27 +++++++---- .../client/history/HistoryTokenTest.java | 4 ++ .../presenter/TransFilterPresenterTest.java | 18 ++++++-- .../TransUnitsTablePresenterTest.java | 11 +++-- .../GetTransUnitActionContextTest.java | 10 ++++ .../service/UserOptionsServiceTest.java | 2 + .../model/GetTransUnitActionContext.java | 14 ++++++ .../webtrans/shared/rpc/GetTransUnitList.java | 9 +++- .../shared/search/FilterConstraints.java | 28 +++++++++-- .../webtrans/shared/ui/UserConfigHolder.java | 21 +++++++-- .../search/FilterConstraintToQuery.java | 12 +++++ .../org/zanata/model/HTextFlowBuilder.java | 46 ++++++++++++------- .../FilterConstraintToQueryJpaTest.java | 6 +++ 22 files changed, 241 insertions(+), 73 deletions(-) diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java index f32accb240b..304e2a695e7 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java @@ -15,7 +15,7 @@ public class FilterViewEvent extends GwtEvent implements */ private static final Type TYPE = new Type<>(); public static final FilterViewEvent DEFAULT = new FilterViewEvent(false, - false, false, false, false, false, EditorFilter.ALL, false); + false, false, false, false, false, false, EditorFilter.ALL, false); /** * Gets the type associated with this event. @@ -27,20 +27,21 @@ public static Type getType() { } private boolean filterTranslated, filterFuzzy, filterUntranslated, - filterApproved, filterRejected, filterHasError; + filterApproved, filterRejected, filterHasError, filterMT; private boolean cancelFilter; private EditorFilter editorFilter; public FilterViewEvent(boolean filterTranslated, boolean filterFuzzy, boolean filterUntranslated, boolean filterApproved, boolean filterRejected, boolean filterHasError, - EditorFilter editorFilter, boolean cancelFilter) { + boolean filterMT, EditorFilter editorFilter, boolean cancelFilter) { this.filterTranslated = filterTranslated; this.filterFuzzy = filterFuzzy; this.filterUntranslated = filterUntranslated; this.filterApproved = filterApproved; this.filterRejected = filterRejected; this.filterHasError = filterHasError; + this.filterMT = filterMT; this.editorFilter = editorFilter; this.cancelFilter = cancelFilter; } @@ -83,6 +84,10 @@ public boolean isFilterHasError() { return filterHasError; } + public boolean isFilterMT() { + return filterMT; + } + public EditorFilter getEditorFilter() { return editorFilter; } @@ -98,6 +103,7 @@ public GetTransUnitActionContext updateContext( .withFilterApproved(filterApproved) .withFilterRejected(filterRejected) .withFilterHasError(filterHasError) + .withFilterMT(filterMT) .withEditorFilter(editorFilter); } @@ -110,6 +116,7 @@ public String toString() { .add("filterApproved", filterApproved) .add("filterRejected", filterRejected) .add("filterHasError", filterHasError) + .add("filterMT", filterMT) .add("editorFilter", editorFilter) .add("cancelFilter", cancelFilter).toString(); } diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/EditorTokens.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/EditorTokens.java index 9ebe6ed6373..3ba30aedbb7 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/EditorTokens.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/EditorTokens.java @@ -16,6 +16,7 @@ enum EditorTokens implements TokensConverter { static final String KEY_MESSAGE_FILTER_APPROVED = "approved"; static final String KEY_MESSAGE_FILTER_REJECTED = "rejected"; static final String KEY_MESSAGE_FILTER_ERROR = "error"; + static final String KEY_MESSAGE_FILTER_MT = "mt"; static final String VALUE_MESSAGE_FILTER = "show"; static final String KEY_RES_ID = "resid"; static final String KEY_MSG_CONTEXT = "msgcontext"; @@ -54,6 +55,9 @@ public void populateHistoryToken(HistoryToken historyToken, Token token) { if (key.equals(KEY_MESSAGE_FILTER_ERROR)) { historyToken.setFilterHasError(true); } + if (key.equals(KEY_MESSAGE_FILTER_MT)) { + historyToken.setFilterMT(true); + } if (key.equals(KEY_RES_ID)) { historyToken.setResId(value); } @@ -99,7 +103,9 @@ public void toTokenString(HistoryToken historyToken, List tokens) { || historyToken.isFilterUntranslated() != historyToken .isFilterApproved() || historyToken.isFilterUntranslated() != historyToken - .isFilterRejected()) { + .isFilterRejected() + || historyToken.isFilterUntranslated() != historyToken + .isFilterMT()) { // if filter options is set (not showing everything) if (historyToken.isFilterUntranslated()) { tokens.add(new Token(KEY_MESSAGE_FILTER_UNTRANSLATED, @@ -125,6 +131,10 @@ public void toTokenString(HistoryToken historyToken, List tokens) { tokens.add(new Token(KEY_MESSAGE_FILTER_ERROR, VALUE_MESSAGE_FILTER)); } + if (historyToken.isFilterMT()) { + tokens.add(new Token(KEY_MESSAGE_FILTER_MT, + VALUE_MESSAGE_FILTER)); + } } setIfExists(tokens, KEY_RES_ID, historyToken.getResId()); setIfExists(tokens, KEY_MSG_CONTEXT, historyToken.getMsgContext()); diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/HistoryToken.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/HistoryToken.java index 554a58ea431..4230efcd295 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/HistoryToken.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/history/HistoryToken.java @@ -62,6 +62,7 @@ public class HistoryToken { private boolean filterApproved; private boolean filterRejected; private boolean filterHasError; + private boolean filterMT; public HistoryToken() { view = DEFAULT_VIEW; @@ -282,10 +283,18 @@ public void setFilterHasError(boolean filterHasError) { this.filterHasError = filterHasError; } + public void setFilterMT(boolean filterMT) { + this.filterMT = filterMT; + } + public boolean isFilterHasError() { return filterHasError; } + public boolean isFilterMT() { + return filterMT; + } + public void setResId(String resId) { this.resId = resId; } @@ -345,6 +354,7 @@ public String getTargetComment() { public void clearEditorFilterAndSearch() { filterFuzzy = false; filterHasError = false; + filterMT = false; filterTranslated = false; filterUntranslated = false; filterApproved = false; diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransFilterPresenter.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransFilterPresenter.java index 78e8e0922ff..ba44394205a 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransFilterPresenter.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransFilterPresenter.java @@ -126,7 +126,7 @@ private static void populateHistoryTokenForEditorFilter( public void messageFilterOptionChanged(Boolean translatedChkValue, Boolean fuzzyChkValue, Boolean untranslatedChkValue, Boolean approvedChkValue, Boolean rejectedChkValue, - Boolean hasErrorChkValue) { + Boolean hasErrorChkValue, Boolean mtChkValue) { UserConfigHolder configHolder = userOptionsService.getConfigHolder(); configHolder.setFilterByTranslated(translatedChkValue); configHolder.setFilterByFuzzy(fuzzyChkValue); @@ -134,10 +134,11 @@ public void messageFilterOptionChanged(Boolean translatedChkValue, configHolder.setFilterByApproved(approvedChkValue); configHolder.setFilterByRejected(rejectedChkValue); configHolder.setFilterByHasError(hasErrorChkValue); + configHolder.setFilterByMT(mtChkValue); pushFilterHistory(translatedChkValue, fuzzyChkValue, - untranslatedChkValue, approvedChkValue, rejectedChkValue, - hasErrorChkValue, null); + untranslatedChkValue, approvedChkValue, rejectedChkValue, + hasErrorChkValue, mtChkValue, null); } @Override @@ -166,13 +167,15 @@ public void onUserConfigChanged(UserConfigChangeEvent event) { configurationState.isFilterByUntranslated(), configurationState.isFilterByApproved(), configurationState.isFilterByRejected(), - configurationState.isFilterByHasError()); + configurationState.isFilterByHasError(), + configurationState.isFilterByMT()); pushFilterHistory(configurationState.isFilterByTranslated(), configurationState.isFilterByFuzzy(), configurationState.isFilterByUntranslated(), configurationState.isFilterByApproved(), configurationState.isFilterByRejected(), - configurationState.isFilterByHasError(), null); + configurationState.isFilterByHasError(), + configurationState.isFilterByMT(), null); } } @@ -181,13 +184,14 @@ public void onUserConfigChanged(UserConfigChangeEvent event) { public void onFilterView(FilterViewEvent event) { if (event.isCancelFilter()) { updateFilterStates(event.isFilterTranslated(), - event.isFilterFuzzy(), event.isFilterUntranslated(), - event.isFilterApproved(), event.isFilterRejected(), - event.isFilterHasError()); + event.isFilterFuzzy(), event.isFilterUntranslated(), + event.isFilterApproved(), event.isFilterRejected(), + event.isFilterHasError(), event.isFilterMT()); pushFilterHistory(event.isFilterTranslated(), - event.isFilterFuzzy(), event.isFilterUntranslated(), - event.isFilterApproved(), event.isFilterRejected(), - event.isFilterHasError(), event.getEditorFilter()); + event.isFilterFuzzy(), event.isFilterUntranslated(), + event.isFilterApproved(), event.isFilterRejected(), + event.isFilterHasError(), event.isFilterMT(), + event.getEditorFilter()); } else { // this is fired from HistoryEventHandlerService @@ -200,19 +204,20 @@ public void onFilterView(FilterViewEvent event) { public void updateFilterStates(boolean filterByTranslated, boolean filterByFuzzy, boolean filterByUntranslated, boolean filterByApproved, boolean filterByRejected, - boolean filterByHasError) { + boolean filterByHasError, boolean filterByMT) { display.setTranslatedFilter(filterByTranslated); display.setNeedReviewFilter(filterByFuzzy); display.setUntranslatedFilter(filterByUntranslated); display.setApprovedFilter(filterByApproved); display.setRejectedFilter(filterByRejected); display.setHasErrorFilter(filterByHasError); + display.setMTFilter(filterByMT); } private void pushFilterHistory(boolean filterByTranslated, boolean filterByFuzzy, boolean filterByUntranslated, boolean filterByApproved, boolean filterByRejected, - boolean filterByHasError, EditorFilter editorFilter) { + boolean filterByHasError, boolean filterByMT, EditorFilter editorFilter) { HistoryToken token = history.getHistoryToken(); token.setFilterTranslated(filterByTranslated); token.setFilterFuzzy(filterByFuzzy); @@ -220,6 +225,7 @@ private void pushFilterHistory(boolean filterByTranslated, token.setFilterApproved(filterByApproved); token.setFilterRejected(filterByRejected); token.setFilterHasError(filterByHasError); + token.setFilterMT(filterByMT); if (editorFilter != null) { populateHistoryTokenForEditorFilter(token, editorFilter); diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenter.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenter.java index e0ab641ff68..3be6366ed1e 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenter.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenter.java @@ -208,12 +208,12 @@ public void discardChangesAndFilter() { @Override public void cancelFilter() { eventBus.fireEvent(new FilterViewEvent(previousFilterOptions - .isFilterTranslated(), previousFilterOptions.isFilterFuzzy(), - previousFilterOptions.isFilterUntranslated(), - previousFilterOptions.isFilterApproved(), previousFilterOptions - .isFilterRejected(), previousFilterOptions - .isFilterHasError(), previousFilterOptions - .getEditorFilter(), true)); + .isFilterTranslated(), previousFilterOptions.isFilterFuzzy(), + previousFilterOptions.isFilterUntranslated(), + previousFilterOptions.isFilterApproved(), previousFilterOptions + .isFilterRejected(), previousFilterOptions + .isFilterHasError(), previousFilterOptions.isFilterMT(), + previousFilterOptions.getEditorFilter(), true)); display.hideFilterConfirmation(); } diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/HistoryEventHandlerService.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/HistoryEventHandlerService.java index 1093ba0adef..f70dda6a1f6 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/HistoryEventHandlerService.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/HistoryEventHandlerService.java @@ -77,6 +77,7 @@ public void onValueChange(ValueChangeEvent event) { configHolder.setFilterByApproved(newHistoryToken.isFilterApproved()); configHolder.setFilterByRejected(newHistoryToken.isFilterRejected()); configHolder.setFilterByHasError(newHistoryToken.isFilterHasError()); + configHolder.setFilterByMT(newHistoryToken.isFilterMT()); DocumentId documentId = documentListPresenter.getDocumentId(newHistoryToken @@ -190,14 +191,17 @@ protected void processMessageFilterOptions(HistoryToken token) { currentHistoryState.isFilterRejected()) || !equal(token.isFilterHasError(), currentHistoryState.isFilterHasError()) + || !equal(token.isFilterHasError(), + currentHistoryState.isFilterMT()) || editorFilterChanged) { Log.info("[gwt-history] message filter has changed"); eventBus.fireEvent(UserConfigChangeEvent.EDITOR_CONFIG_CHANGE_EVENT); eventBus.fireEvent(new FilterViewEvent(token.isFilterTranslated(), - token.isFilterFuzzy(), token.isFilterUntranslated(), token - .isFilterApproved(), token.isFilterRejected(), - token.isFilterHasError(), newEditorToken, false)); + token.isFilterFuzzy(), token.isFilterUntranslated(), token + .isFilterApproved(), token.isFilterRejected(), + token.isFilterHasError(), token.isFilterMT(), newEditorToken, + false)); } } diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/UserOptionsService.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/UserOptionsService.java index 89d420d4914..b87b406555e 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/UserOptionsService.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/service/UserOptionsService.java @@ -169,6 +169,7 @@ public void loadEditorDefaultOptions() { configHolder.setFilterByApproved(UserConfigHolder.DEFAULT_FILTER); configHolder.setFilterByRejected(UserConfigHolder.DEFAULT_FILTER); configHolder.setFilterByHasError(UserConfigHolder.DEFAULT_FILTER); + configHolder.setFilterByMT(UserConfigHolder.DEFAULT_FILTER); configHolder.setEnabledValidationIds(new ArrayList()); configHolder.setNavOption(NavOption.FUZZY_UNTRANSLATED); configHolder diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterDisplay.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterDisplay.java index f931fb90b6f..982841fd9ff 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterDisplay.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterDisplay.java @@ -48,6 +48,8 @@ public interface TransFilterDisplay extends WidgetDisplay, EditorSearchFieldList void setHasErrorFilter(boolean filterByHasError); + void setMTFilter(boolean filterByMT); + void selectPartialText(String text); interface Listener { @@ -56,7 +58,7 @@ interface Listener { void messageFilterOptionChanged(Boolean translatedChkValue, Boolean fuzzyChkValue, Boolean untranslatedChkValue, Boolean approvedChkValue, Boolean rejectedChkValue, - Boolean hasErrorChkValue); + Boolean hasErrorChkValue, Boolean hasMTChkValue); void onSearchFieldFocused(boolean focused); } diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.java b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.java index b6c76c140eb..1b2cde1397c 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.java +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.java @@ -49,7 +49,7 @@ public class TransFilterView extends Composite implements TransFilterDisplay { @UiField CheckBox parentIncompleteChk, untranslatedChk, fuzzyChk, rejectedChk, - parentCompleteChk, translatedChk, approvedChk, hasErrorChk; + parentCompleteChk, translatedChk, approvedChk, hasErrorChk, mtChk; private Listener listener; @@ -119,6 +119,11 @@ public void setHasErrorFilter(boolean filterByHasError) { updateChildCheckbox(hasErrorChk, filterByHasError); } + @Override + public void setMTFilter(boolean filterByMT) { + updateChildCheckbox(mtChk, filterByMT); + } + private void updateChildCheckbox(CheckBox checkbox, boolean value) { checkbox.setValue(value); updateParentCheckboxes(); @@ -146,13 +151,13 @@ public void onSearchFieldCancel() { } @UiHandler({ "translatedChk", "fuzzyChk", "untranslatedChk", "approvedChk", - "rejectedChk", "hasErrorChk" }) + "rejectedChk", "hasErrorChk", "mtChk" }) public void onFilterOptionsChanged(ValueChangeEvent event) { updateParentCheckboxes(); listener.messageFilterOptionChanged(translatedChk.getValue(), fuzzyChk.getValue(), untranslatedChk.getValue(), approvedChk.getValue(), rejectedChk.getValue(), - hasErrorChk.getValue()); + hasErrorChk.getValue(), mtChk.getValue()); } private void updateParentCheckboxes() { @@ -222,5 +227,6 @@ public void setOptionsState(ConfigurationState state) { approvedChk.setValue(state.isFilterByApproved()); rejectedChk.setValue(state.isFilterByRejected()); hasErrorChk.setValue(state.isFilterByHasError()); + mtChk.setValue(state.isFilterByMT()); } } diff --git a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.ui.xml b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.ui.xml index dfbb6f0ec10..3b9f678e2cf 100644 --- a/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.ui.xml +++ b/server/gwt-editor/src/main/java/org/zanata/webtrans/client/view/TransFilterView.ui.xml @@ -56,10 +56,10 @@ .hasError { border-left: 3px solid #e0575b; - padding-right: 5px; - opacity: 0.6; - transition: .3s; - display: inline !important; + } + + .mt { + border-left: 3px solid #a456e0; } .filterListToggle { @@ -206,10 +206,21 @@
  • - - Invalid - + +
      +
    • + + Invalid + +
    • +
    • + + Machine Translation + +
    • +
  • diff --git a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/history/HistoryTokenTest.java b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/history/HistoryTokenTest.java index 6fbedf01764..c4ef225f481 100644 --- a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/history/HistoryTokenTest.java +++ b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/history/HistoryTokenTest.java @@ -54,6 +54,7 @@ public void constructionSetsDefaults() { assertThat(token.isFilterApproved()).isFalse(); assertThat(token.isFilterRejected()).isFalse(); assertThat(token.isFilterHasError()).isFalse(); + assertThat(token.isFilterMT()).isFalse(); } @Test @@ -90,6 +91,7 @@ public void fromEmptyStringSetsDefaults() { assertThat(token.isFilterApproved()).isFalse(); assertThat(token.isFilterRejected()).isFalse(); assertThat(token.isFilterHasError()).isFalse(); + assertThat(token.isFilterMT()).isFalse(); } @Test @@ -126,6 +128,7 @@ public void fromNullStringSetsDefaults() { assertThat(token.isFilterApproved()).isFalse(); assertThat(token.isFilterRejected()).isFalse(); assertThat(token.isFilterHasError()).isFalse(); + assertThat(token.isFilterMT()).isFalse(); } @Test @@ -538,6 +541,7 @@ public void tokenStringHasAllFilterOption() { token.setFilterApproved(true); token.setFilterRejected(true); token.setFilterHasError(true); + token.setFilterMT(true); String tokenString = token.toTokenString(); diff --git a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransFilterPresenterTest.java b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransFilterPresenterTest.java index 5dd6ff1833a..717dffe88fb 100644 --- a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransFilterPresenterTest.java +++ b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransFilterPresenterTest.java @@ -89,8 +89,8 @@ public void onRevealDisplay() { @Test public void willSetOptionsBackOnFilterViewCancelEvent() { FilterViewEvent event = - new FilterViewEvent(true, true, true, true, true, false, - EditorFilter.ALL, true); + new FilterViewEvent(true, true, true, true, true, false, false, + EditorFilter.ALL, true); HistoryToken historyToken = new HistoryToken(); when(history.getHistoryToken()).thenReturn(historyToken); @@ -114,13 +114,15 @@ public void willSetOptionsBackOnFilterViewCancelEvent() { .isEqualTo(event.isFilterRejected()); assertThat(historyToken.isFilterHasError()) .isEqualTo(event.isFilterHasError()); + assertThat(historyToken.isFilterMT()) + .isEqualTo(event.isFilterMT()); } @Test public void willUpdateSearchTermIfItsNotCancelEvent() { FilterViewEvent cancelEvent = - new FilterViewEvent(true, true, true, true, true, false, - EditorFilter.ALL, false); + new FilterViewEvent(true, true, true, true, true, false, false, + EditorFilter.ALL, false); presenter.onFilterView(cancelEvent); @@ -135,6 +137,7 @@ public void onUserConfigChange() { configHolder.setFilterByApproved(true); configHolder.setFilterByRejected(true); configHolder.setFilterByHasError(true); + configHolder.setFilterByMT(true); HistoryToken historyToken = new HistoryToken(); when(history.getHistoryToken()).thenReturn(historyToken); @@ -154,6 +157,8 @@ public void onUserConfigChange() { configHolder.getState().isFilterByRejected()); verify(display).setHasErrorFilter( configHolder.getState().isFilterByHasError()); + verify(display).setMTFilter( + configHolder.getState().isFilterByMT()); assertThat( historyToken.isFilterTranslated()) @@ -169,6 +174,8 @@ public void onUserConfigChange() { .isEqualTo(configHolder.getState().isFilterByRejected()); assertThat(historyToken.isFilterHasError()) .isEqualTo(configHolder.getState().isFilterByHasError()); + assertThat(historyToken.isFilterMT()) + .isEqualTo(configHolder.getState().isFilterByMT()); } @Test @@ -177,7 +184,7 @@ public void onMessageFilterOptionChanged() { when(history.getHistoryToken()).thenReturn(historyToken); presenter.messageFilterOptionChanged(true, false, true, true, false, - false); + false, false); UserConfigHolder configHolder = userOptionsService.getConfigHolder(); assertThat(configHolder.getState().isFilterByTranslated()).isTrue(); @@ -192,6 +199,7 @@ public void onMessageFilterOptionChanged() { assertThat(historyToken.isFilterApproved()).isTrue(); assertThat(historyToken.isFilterRejected()).isFalse(); assertThat(historyToken.isFilterHasError()).isFalse(); + assertThat(historyToken.isFilterMT()).isFalse(); verify(history).newItem(historyToken); } } diff --git a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenterTest.java b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenterTest.java index 4e64783a6be..08b522880f2 100644 --- a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenterTest.java +++ b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/presenter/TransUnitsTablePresenterTest.java @@ -138,11 +138,12 @@ public void onFilterViewEventDoNothingIfItsCancel() { boolean viewApproved = true; boolean viewRejected = true; boolean viewHasError = false; + boolean viewMT = false; boolean cancelFilter = true; presenter.onFilterView(new FilterViewEvent(viewTranslated, viewFuzzy, - viewUntranslated, viewApproved, viewRejected, viewHasError, - EditorFilter.ALL, cancelFilter)); + viewUntranslated, viewApproved, viewRejected, viewHasError, viewMT, + EditorFilter.ALL, cancelFilter)); verifyNoMoreInteractions(eventBus, display, targetContentsPresenter); } @@ -155,7 +156,7 @@ public void onFilterViewEventWillShowConfirmationIfHasUnsavedContent() { // When: not a cancel event presenter.onFilterView(new FilterViewEvent(true, false, true, false, - false, false, EditorFilter.ALL, false)); + false, false, false, EditorFilter.ALL, false)); // Then: verify(display).showFilterConfirmation(); @@ -167,8 +168,8 @@ public void onFilterViewEventWillHideConfirmationAndDoFilter() { when(targetContentsPresenter.currentEditorContentHasChanged()) .thenReturn(false); FilterViewEvent event = - new FilterViewEvent(true, false, true, false, false, false, - EditorFilter.ALL, false); + new FilterViewEvent(true, false, true, false, false, false, false, + EditorFilter.ALL, false); // When: presenter.onFilterView(event); diff --git a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/GetTransUnitActionContextTest.java b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/GetTransUnitActionContextTest.java index a76d176730a..390f3e1289b 100644 --- a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/GetTransUnitActionContextTest.java +++ b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/GetTransUnitActionContextTest.java @@ -84,6 +84,14 @@ public void testChangeFilterRejected() throws Exception { assertThat(result.isFilterRejected()).isTrue(); } + @Test + public void testChangeFilterMT() { + GetTransUnitActionContext result = context.withFilterMT(true); + + assertThat(context.isFilterMT()).isFalse(); + assertThat(result.isFilterMT()).isTrue(); + } + @Test public void testNeedReloadList() throws Exception { verifyNeedReloadTransUnits(context, context.withFilterFuzzy(true), @@ -125,6 +133,8 @@ public void testNeedReloadNavigationIndex() throws Exception { context.withFilterApproved(true), NEEDED); verifyNeedReloadNavigationIndex(context, context.withFilterRejected(true), NEEDED); + verifyNeedReloadNavigationIndex(context, + context.withFilterMT(true), NEEDED); verifyNeedReloadNavigationIndex(context, context.changeDocument(documentInfo(99, "")), NEEDED); verifyNeedReloadNavigationIndex(context, diff --git a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/UserOptionsServiceTest.java b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/UserOptionsServiceTest.java index 58d02d9160b..a830e1ec644 100644 --- a/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/UserOptionsServiceTest.java +++ b/server/gwt-editor/src/test/java/org/zanata/webtrans/client/service/UserOptionsServiceTest.java @@ -191,6 +191,8 @@ public void loadEditorDefaultOptions() { .isEqualTo(UserConfigHolder.DEFAULT_FILTER); assertThat(configHolder.getState().isFilterByRejected()) .isEqualTo(UserConfigHolder.DEFAULT_FILTER); + assertThat(configHolder.getState().isFilterByMT()) + .isEqualTo(UserConfigHolder.DEFAULT_FILTER); assertThat(configHolder.getState().getNavOption()) .isEqualTo(NavOption.FUZZY_UNTRANSLATED); assertThat(configHolder.getState().getEditorPageSize()) diff --git a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/model/GetTransUnitActionContext.java b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/model/GetTransUnitActionContext.java index 9439b08ee23..b4399202b50 100644 --- a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/model/GetTransUnitActionContext.java +++ b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/model/GetTransUnitActionContext.java @@ -51,6 +51,7 @@ public class GetTransUnitActionContext { private boolean filterApproved; private boolean filterRejected; private boolean filterHasError; + private boolean filterMT; private TransUnitId targetTransUnitId; private List validationIds; private EditorFilter editorFilter = EditorFilter.ALL; @@ -69,6 +70,7 @@ private GetTransUnitActionContext(GetTransUnitActionContext other) { filterApproved = other.isFilterApproved(); filterRejected = other.isFilterRejected(); filterHasError = other.isFilterHasError(); + filterMT = other.isFilterMT(); targetTransUnitId = other.getTargetTransUnitId(); validationIds = other.getValidationIds(); editorFilter = other.getEditorFilter(); @@ -156,6 +158,16 @@ public GetTransUnitActionContext withFilterHasError(boolean filterHasError) { return result; } + public boolean isFilterMT() { + return filterMT; + } + + public GetTransUnitActionContext withFilterMT(boolean filterMT) { + GetTransUnitActionContext result = new GetTransUnitActionContext(this); + result.filterMT = filterMT; + return result; + } + public TransUnitId getTargetTransUnitId() { return targetTransUnitId; } @@ -222,6 +234,7 @@ public String toString() { add("filterApproved", filterApproved). add("filterRejected", filterRejected). add("filterHasError", filterHasError). + add("filterMT", filterMT). add("targetTransUnitId", targetTransUnitId). add("editorFilter", editorFilter). toString(); @@ -262,6 +275,7 @@ public boolean needReloadNavigationIndex( || filterApproved != newContext.filterApproved || filterRejected != newContext.filterRejected || filterHasError != newContext.filterHasError + || filterMT != newContext.filterMT || offset != newContext.offset || !document.equals(newContext.document) || !Objects.equal(editorFilter, newContext.editorFilter); diff --git a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java index 0697ef7f767..1dcfeb98a5d 100644 --- a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java +++ b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java @@ -17,6 +17,7 @@ public class GetTransUnitList extends private DocumentId documentId; private ContentStateGroup filterStates; private boolean filterHasError; + private boolean filterMT; private List validationIds; private TransUnitId targetTransUnitId; private boolean needReloadIndex = false; @@ -31,6 +32,7 @@ private GetTransUnitList(GetTransUnitActionContext context) { count = context.getCount(); setIncludeStates(context.getCurrentFilterStates()); filterHasError = context.isFilterHasError(); + filterMT = context.isFilterMT(); targetTransUnitId = context.getTargetTransUnitId(); validationIds = context.getValidationIds(); editorFilter = context.getEditorFilter(); @@ -103,6 +105,10 @@ public boolean isFilterHasError() { return filterHasError; } + public boolean isFilterMT() { + return filterMT; + } + public TransUnitId getTargetTransUnitId() { return targetTransUnitId; } @@ -112,7 +118,7 @@ public List getValidationIds() { } public boolean isAcceptAllStatus() { - return filterStates.hasAllStates() && !filterHasError; + return filterStates.hasAllStates() && !filterHasError && !filterMT; } @Override @@ -124,6 +130,7 @@ public String toString() { add("documentId", documentId). add("filterStates", filterStates). add("filterHasError", filterHasError). + add("filterMT", filterMT). add("targetTransUnitId", targetTransUnitId). add("needReloadIndex", needReloadIndex). add("editorFilter", editorFilter). diff --git a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/search/FilterConstraints.java b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/search/FilterConstraints.java index 8eba174486c..b8009d18074 100644 --- a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/search/FilterConstraints.java +++ b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/search/FilterConstraints.java @@ -41,6 +41,7 @@ public class FilterConstraints { private boolean searchInSource; private boolean searchInTarget; private ContentStateGroup includedStates; + private boolean includedMT; private String resId; private DateTime changedBefore; private DateTime changedAfter; @@ -55,6 +56,7 @@ private FilterConstraints(Builder builder) { searchString = builder.searchString; isCaseSensitive = builder.caseSensitive; includedStates = builder.states.build(); + includedMT = builder.includedMT; resId = builder.resId; changedBefore = builder.changedBefore; changedAfter = builder.changedAfter; @@ -77,6 +79,7 @@ public boolean equals(Object o) { return isCaseSensitive == that.isCaseSensitive && searchInSource == that.searchInSource && searchInTarget == that.searchInTarget && + Objects.equals(includedMT, that.includedMT) && Objects.equals(searchString, that.searchString) && Objects.equals(includedStates, that.includedStates) && Objects.equals(resId, that.resId) && @@ -92,10 +95,9 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash(searchString, isCaseSensitive, searchInSource, - searchInTarget, - includedStates, resId, changedBefore, changedAfter, - lastModifiedByUser, sourceComment, transComment, - msgContext); + searchInTarget, includedStates, includedMT, resId, changedBefore, + changedAfter, lastModifiedByUser, sourceComment, transComment, + msgContext); } public static Builder builder() { @@ -106,6 +108,7 @@ public static Builder builder() { public String toString() { return MoreObjects.toStringHelper(this) .add("searchString", searchString) + .add("includedMT", includedMT) .add("isCaseSensitive", isCaseSensitive) .add("searchInSource", searchInSource) .add("searchInTarget", searchInTarget) @@ -126,6 +129,7 @@ public static class Builder { private boolean searchInSource; private boolean searchInTarget; private ContentStateGroup.Builder states; + private boolean includedMT; private String resId; private DateTime changedBefore; private DateTime changedAfter; @@ -153,6 +157,7 @@ private void setKeepAll() { caseSensitive = false; searchInSource = true; searchInTarget = true; + includedMT = true; states.addAll(); resId = ""; changedAfter = null; @@ -164,6 +169,7 @@ private void setKeepAll() { } public Builder keepNone() { + includedMT = false; searchString = ""; caseSensitive = false; searchInSource = false; @@ -254,6 +260,16 @@ public Builder excludeRejected() { return this; } + public Builder includeMT() { + this.includedMT = true; + return this; + } + + public Builder excludeMT() { + this.includedMT = false; + return this; + } + public Builder resourceIdIs(String resId) { this.resId = resId; return this; @@ -343,4 +359,8 @@ public String getTransComment() { public String getMsgContext() { return this.msgContext; } + + public boolean isIncludedMT() { + return includedMT; + } } diff --git a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/ui/UserConfigHolder.java b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/ui/UserConfigHolder.java index f3a917159a2..826e7986174 100644 --- a/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/ui/UserConfigHolder.java +++ b/server/gwt-shared/src/main/java/org/zanata/webtrans/shared/ui/UserConfigHolder.java @@ -76,6 +76,7 @@ public UserConfigHolder() { state.filterByApproved = DEFAULT_FILTER; state.filterByRejected = DEFAULT_FILTER; state.filterByHasError = DEFAULT_FILTER; + state.filterByMT = !DEFAULT_FILTER; state.showTMPanel = DEFAULT_SHOW_PANEL; state.showGlossaryPanel = DEFAULT_SHOW_PANEL; @@ -174,6 +175,11 @@ public void setFilterByHasError(boolean filterByHasError) { state.filterByHasError = filterByHasError; } + public void setFilterByMT(boolean filterByMT) { + state = new ConfigurationState(state); + state.filterByMT = filterByMT; + } + public void setShowSaveApprovedWarning(boolean showSaveApprovedWarning) { state = new ConfigurationState(state); state.showSaveApprovedWarning = showSaveApprovedWarning; @@ -217,10 +223,11 @@ public void setShowOptionalTransUnitDetails(boolean show) { public boolean isAcceptAllStatus() { return state.isFilterByTranslated() == state.isFilterByFuzzy() - && state.isFilterByUntranslated() == state.isFilterByFuzzy() - && state.isFilterByHasError() == state.isFilterByFuzzy() - && state.isFilterByApproved() == state.isFilterByFuzzy() - && state.isFilterByRejected() == state.isFilterByFuzzy(); + && state.isFilterByUntranslated() == state.isFilterByFuzzy() + && state.isFilterByHasError() == state.isFilterByFuzzy() + && state.isFilterByApproved() == state.isFilterByFuzzy() + && state.isFilterByRejected() == state.isFilterByFuzzy() + && state.isFilterByMT() == state.isFilterByFuzzy(); } /** @@ -241,6 +248,7 @@ public static class ConfigurationState implements IsSerializable { private boolean filterByApproved; private boolean filterByRejected; private boolean filterByHasError; + private boolean filterByMT; private String selectedReferenceForSourceLang; private boolean showSaveApprovedWarning; @@ -271,6 +279,7 @@ private ConfigurationState(ConfigurationState old) { this.filterByApproved = old.isFilterByApproved(); this.filterByRejected = old.isFilterByRejected(); this.filterByHasError = old.isFilterByHasError(); + this.filterByMT = old.isFilterByMT(); this.showSaveApprovedWarning = old.isShowSaveApprovedWarning(); this.transMemoryDisplayMode = old.getTransMemoryDisplayMode(); this.displayTheme = old.getDisplayTheme(); @@ -335,6 +344,10 @@ public boolean isFilterByHasError() { return filterByHasError; } + public boolean isFilterByMT() { + return filterByMT; + } + public boolean isShowSaveApprovedWarning() { return showSaveApprovedWarning; } diff --git a/server/services/src/main/java/org/zanata/search/FilterConstraintToQuery.java b/server/services/src/main/java/org/zanata/search/FilterConstraintToQuery.java index 37efa5b6142..dc43da63414 100644 --- a/server/services/src/main/java/org/zanata/search/FilterConstraintToQuery.java +++ b/server/services/src/main/java/org/zanata/search/FilterConstraintToQuery.java @@ -8,6 +8,7 @@ import org.hibernate.criterion.MatchMode; import org.joda.time.DateTime; import org.zanata.model.HLocale; +import org.zanata.model.type.TranslationSourceType; import org.zanata.util.HqlCriterion; import org.zanata.util.QueryBuilder; import org.zanata.webtrans.shared.model.DocumentId; @@ -165,6 +166,7 @@ protected String buildSourceConditionsOtherThanSearch() { protected String buildTargetConditionsOtherThanSearch() { List targetConjunction = Lists.newArrayList(); + addToJunctionIfNotNull(targetConjunction, buildIncludeMTCondition()); addToJunctionIfNotNull(targetConjunction, buildLastModifiedByCondition()); addToJunctionIfNotNull(targetConjunction, @@ -273,6 +275,13 @@ protected String buildStateCondition() { return stateInListCondition; } + protected String buildIncludeMTCondition() { + if (constraints.isIncludedMT()) { + return eq("tft.sourceType", IncludeMT.placeHolder()); + } + return null; + } + protected String buildLastModifiedByCondition() { if (Strings.isNullOrEmpty(constraints.getLastModifiedByUser())) { return null; @@ -318,6 +327,8 @@ public Query setQueryParameters(Query textFlowQuery, HLocale hLocale) { textFlowQuery.setParameterList(ContentStateList.namedParam(), constraints.getIncludedStates().asList()); } + textFlowQuery.setParameter(IncludeMT.namedParam(), + TranslationSourceType.MACHINE_TRANS); addExactMatchParamIfPresent(textFlowQuery, constraints.getResId(), ResId); addWildcardSearchParamIfPresent(textFlowQuery, @@ -363,6 +374,7 @@ private static Query addWildcardSearchParamIfPresent(Query textFlowQuery, enum Parameters { SearchString, ContentStateList, + IncludeMT, Locale, DocumentId, DocumentIdList, diff --git a/server/services/src/test/java/org/zanata/model/HTextFlowBuilder.java b/server/services/src/test/java/org/zanata/model/HTextFlowBuilder.java index 6a78928e60e..255e36b3b20 100644 --- a/server/services/src/test/java/org/zanata/model/HTextFlowBuilder.java +++ b/server/services/src/test/java/org/zanata/model/HTextFlowBuilder.java @@ -6,6 +6,7 @@ import org.zanata.model.po.HPotEntryData; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; +import org.zanata.model.type.TranslationSourceType; /** * A builder to build HTextFlow entity and possibly [HTextFlowTarget] [and @@ -30,6 +31,7 @@ public class HTextFlowBuilder { private HPerson lastModifiedBy; private DateTime lastModifiedDate; private String targetComment; + private TranslationSourceType translationSourceType; public HTextFlow build() { Preconditions.checkNotNull(resId, "resId can not be null"); @@ -66,6 +68,7 @@ public HTextFlow build() { if (targetComment != null) { target.setComment(new HSimpleComment(targetComment)); } + target.setSourceType(translationSourceType); } log.debug(this.toString()); return hTextFlow; @@ -82,11 +85,12 @@ public HTextFlowBuilder() { } private HTextFlowBuilder(final HDocument document, - final HLocale targetLocale, final String resId, - final String sourceContent, final String sourceComment, - final String msgContext, final String targetContent, - final ContentState targetState, final HPerson lastModifiedBy, - final DateTime lastModifiedDate, final String targetComment) { + final HLocale targetLocale, final String resId, + final String sourceContent, final String sourceComment, + final String msgContext, final String targetContent, + final ContentState targetState, final HPerson lastModifiedBy, + final DateTime lastModifiedDate, final String targetComment, + final TranslationSourceType translationSourceType) { this.document = document; this.targetLocale = targetLocale; this.resId = resId; @@ -98,6 +102,7 @@ private HTextFlowBuilder(final HDocument document, this.lastModifiedBy = lastModifiedBy; this.lastModifiedDate = lastModifiedDate; this.targetComment = targetComment; + this.translationSourceType = translationSourceType; } public HTextFlowBuilder withDocument(final HDocument document) { @@ -106,7 +111,7 @@ public HTextFlowBuilder withDocument(final HDocument document) { this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withTargetLocale(final HLocale targetLocale) { @@ -115,7 +120,7 @@ public HTextFlowBuilder withTargetLocale(final HLocale targetLocale) { this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withResId(final String resId) { @@ -124,7 +129,7 @@ public HTextFlowBuilder withResId(final String resId) { this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withSourceContent(final String sourceContent) { @@ -133,7 +138,16 @@ public HTextFlowBuilder withSourceContent(final String sourceContent) { this.resId, sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); + } + + public HTextFlowBuilder withSourceType(final TranslationSourceType translationSourceType) { + return this.translationSourceType == translationSourceType ? this + : new HTextFlowBuilder(this.document, this.targetLocale, + this.resId, this.sourceContent, this.sourceComment, + this.msgContext, this.targetContent, this.targetState, + this.lastModifiedBy, this.lastModifiedDate, + this.targetComment, translationSourceType); } public HTextFlowBuilder withSourceComment(final String sourceComment) { @@ -142,7 +156,7 @@ public HTextFlowBuilder withSourceComment(final String sourceComment) { this.resId, this.sourceContent, sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withMsgContext(final String msgContext) { @@ -151,7 +165,7 @@ public HTextFlowBuilder withMsgContext(final String msgContext) { this.resId, this.sourceContent, this.sourceComment, msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withTargetContent(final String targetContent) { @@ -160,7 +174,7 @@ public HTextFlowBuilder withTargetContent(final String targetContent) { this.resId, this.sourceContent, this.sourceComment, this.msgContext, targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withTargetState(final ContentState targetState) { @@ -169,7 +183,7 @@ public HTextFlowBuilder withTargetState(final ContentState targetState) { this.resId, this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, targetState, this.lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withLastModifiedBy(final HPerson lastModifiedBy) { @@ -178,7 +192,7 @@ public HTextFlowBuilder withLastModifiedBy(final HPerson lastModifiedBy) { this.resId, this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, lastModifiedBy, this.lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder @@ -188,7 +202,7 @@ public HTextFlowBuilder withLastModifiedBy(final HPerson lastModifiedBy) { this.resId, this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, lastModifiedDate, - this.targetComment); + this.targetComment, this.translationSourceType); } public HTextFlowBuilder withTargetComment(final String targetComment) { @@ -197,6 +211,6 @@ public HTextFlowBuilder withTargetComment(final String targetComment) { this.resId, this.sourceContent, this.sourceComment, this.msgContext, this.targetContent, this.targetState, this.lastModifiedBy, this.lastModifiedDate, - targetComment); + targetComment, this.translationSourceType); } } diff --git a/server/services/src/test/java/org/zanata/search/FilterConstraintToQueryJpaTest.java b/server/services/src/test/java/org/zanata/search/FilterConstraintToQueryJpaTest.java index 057e6ec6875..1201e183a3e 100644 --- a/server/services/src/test/java/org/zanata/search/FilterConstraintToQueryJpaTest.java +++ b/server/services/src/test/java/org/zanata/search/FilterConstraintToQueryJpaTest.java @@ -18,6 +18,7 @@ import org.zanata.model.HTextFlowBuilder; import org.zanata.model.HTextFlowTarget; import org.zanata.model.WebHook; +import org.zanata.model.type.TranslationSourceType; import org.zanata.model.type.WebhookType; import org.zanata.webtrans.server.rpc.GetTransUnitsNavigationService; import org.zanata.webtrans.shared.model.ContentStateGroup; @@ -114,6 +115,11 @@ public void setUpData() { .withLastModifiedDate(yesterday).withResId("res10") .withSourceContent("source 10").withTargetContent("target_10") .withTargetState(ContentState.Translated).build(); + // 11. target translated by machine translation + baseBuilder.withSourceType(TranslationSourceType.MACHINE_TRANS) + .withLastModifiedDate(yesterday).withResId("res11") + .withSourceContent("source 11").withTargetContent("target_11") + .withTargetState(ContentState.Translated).build(); getEm().flush(); }