From bda2738ea8b7e9c33d9823a368df812c09d073a0 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Mon, 27 Jul 2015 13:01:07 +1000 Subject: [PATCH] feat(TM): pre-sort TM results by TextFlowTarget timestamp --- .../impl/TranslationMemoryServiceImpl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/service/impl/TranslationMemoryServiceImpl.java b/zanata-war/src/main/java/org/zanata/service/impl/TranslationMemoryServiceImpl.java index 95da0bf311..a84551c03b 100644 --- a/zanata-war/src/main/java/org/zanata/service/impl/TranslationMemoryServiceImpl.java +++ b/zanata-war/src/main/java/org/zanata/service/impl/TranslationMemoryServiceImpl.java @@ -152,7 +152,7 @@ public Optional searchBestMatchTransMemory( Collection matches = findMatchingTranslation(targetLocaleId, sourceLocaleId, query, - 0, true, HTextFlowTarget.class); + 0, HTextFlowTarget.class); if (matches.isEmpty()) { return Optional. absent(); @@ -205,7 +205,7 @@ public List searchTransMemory( Collection matches = findMatchingTranslation(targetLocaleId, sourceLocaleId, - transMemoryQuery, SEARCH_MAX_RESULTS, false, + transMemoryQuery, SEARCH_MAX_RESULTS, HTextFlowTarget.class, TransMemoryUnit.class); Map matchesMap = @@ -272,7 +272,7 @@ private TransMemoryQuery buildTMQuery(HTextFlow textFlow, private Collection findMatchingTranslation( LocaleId targetLocaleId, LocaleId sourceLocaleId, TransMemoryQuery transMemoryQuery, int maxResults, - boolean sortByDate, Class... entities) { + Class... entities) { try { if (entities == null || entities.length < 1) { throw new RuntimeException( @@ -280,7 +280,7 @@ private Collection findMatchingTranslation( } List matches = getSearchResult(transMemoryQuery, sourceLocaleId, - targetLocaleId, maxResults, sortByDate, entities); + targetLocaleId, maxResults, entities); // filter out invalid target return Collections2.filter(matches, @@ -491,7 +491,7 @@ public int hashCode() { private List getSearchResult(TransMemoryQuery query, LocaleId sourceLocale, LocaleId targetLocale, int maxResult, - boolean sortByDate, Class... entities) throws ParseException { + Class... entities) throws ParseException { String queryText = null; String[] multiQueryText = null; @@ -560,9 +560,7 @@ private List getSearchResult(TransMemoryQuery query, ftQuery.setMaxResults(maxResult); } - if (sortByDate) { - ftQuery.setSort(lastChangedSort); - } + ftQuery.setSort(lastChangedSort); List resultList = (List) ftQuery.getResultList(); if (!resultList.isEmpty() && resultList.size() == maxResult) { @@ -908,7 +906,7 @@ private void processResultRow(Object[] resultRow) { */ private Collection runQuery() { return findMatchingTranslation(transLocale, srcLocale, query, - SEARCH_MAX_RESULTS, SORT_BY_DATE, + SEARCH_MAX_RESULTS, HTextFlowTarget.class, TransMemoryUnit.class); }