From 67db4230b930c5c6e06c0f32cdfe871e6c49d9eb Mon Sep 17 00:00:00 2001 From: StevaneticS Date: Tue, 21 Nov 2023 23:00:05 +0100 Subject: [PATCH] removed deprecated code --- .../service/TranslationService.java | 27 ------------ .../google/DummyGTranslateService.java | 12 ------ .../google/GoogleTranslationService.java | 42 ------------------- .../DummyPangTranslationService.java | 12 ------ .../PangeanicTranslationService.java | 17 -------- .../web/service/CachedTranslationService.java | 10 ----- 6 files changed, 120 deletions(-) diff --git a/translation-service-common/src/main/java/eu/europeana/api/translation/service/TranslationService.java b/translation-service-common/src/main/java/eu/europeana/api/translation/service/TranslationService.java index 146cd916..f6bb95ba 100644 --- a/translation-service-common/src/main/java/eu/europeana/api/translation/service/TranslationService.java +++ b/translation-service-common/src/main/java/eu/europeana/api/translation/service/TranslationService.java @@ -27,18 +27,6 @@ public interface TranslationService { */ boolean isSupported(String srcLang, String trgLang); - @Deprecated - /** - * Use the method translate(List translationObjs). - * Translate multiple texts - * - * @param texts to translate - * @param targetLanguage language into which the texts are translated - * @return translations of the provided texts - * @throws TranslationException when there is a problem sending the translation request - */ - List translate(List texts, String targetLanguage) throws TranslationException; - /** * Translates a list of texts from a list of TranslationObj and saves the results back to the objects. * @param translationObjs @@ -48,21 +36,6 @@ public interface TranslationService { void detectLanguages(List translationObjs) throws TranslationException; - @Deprecated - /** - * Use the method translate(List translationObjs). - * Translate multiple texts. - * - * @param texts to translate - * @param targetLanguage language into which the texts are translated - * @param sourceLanguage source language of the texts to be translated - * @return translations of the provided texts - * @throws TranslationException when there is a problem sending the translation request - */ - List translate(List texts, String targetLanguage, String sourceLanguage) - throws TranslationException; - - /** * to close the engine */ diff --git a/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/DummyGTranslateService.java b/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/DummyGTranslateService.java index 2f39ef5c..4f7d0082 100644 --- a/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/DummyGTranslateService.java +++ b/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/DummyGTranslateService.java @@ -18,18 +18,6 @@ public class DummyGTranslateService extends GoogleTranslationService { public DummyGTranslateService(GoogleTranslationServiceClientWrapper clientWrapperBean) { super(GoogleTranslationServiceClientWrapper.MOCK_CLIENT_PROJ_ID, clientWrapperBean); } - - @Override - public List translate(List text, String targetLanguage, String sourceLanguage) - throws TranslationException { - return translate(text, null); - } - - @Override - public List translate(List text, String targetLanguage) - throws TranslationException { - return text; - } @Override public void translate(List translationObjs, boolean detectLanguages) throws TranslationException { diff --git a/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/GoogleTranslationService.java b/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/GoogleTranslationService.java index 11eafdd6..44165a49 100644 --- a/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/GoogleTranslationService.java +++ b/translation-service-google/src/main/java/eu/europeana/api/translation/service/google/GoogleTranslationService.java @@ -1,6 +1,5 @@ package eu.europeana.api.translation.service.google; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -45,16 +44,6 @@ public void init(GoogleTranslationServiceClientWrapper clientWrapper) { this.locationName = LocationName.of(getGoogleProjectId(), "global"); } - @Deprecated - /** - * Use the method translate(List translationObjs). - */ - @Override - public List translate(List text, String targetLanguage) - throws TranslationException { - return translate(text, targetLanguage, null); - } - @Override public void translate(List translationObjs, boolean detectLanguages) throws TranslationException { try { @@ -105,37 +94,6 @@ public void translate(List translationObjs, boolean detectLangua } - @Deprecated - /** - * Use the method translate(List translationObjs). - */ - @Override - public List translate(List text, String targetLanguage, String sourceLanguage) throws TranslationException { - try { - List result = new ArrayList<>(); - if(text.isEmpty()) { - return result; - } - - Builder requestBuilder = TranslateTextRequest.newBuilder().setParent(locationName.toString()) - .setMimeType(MIME_TYPE_TEXT).setTargetLanguageCode(targetLanguage).addAllContents(text); - if (sourceLanguage != null) { - requestBuilder.setSourceLanguageCode(sourceLanguage); - } - TranslateTextRequest request = requestBuilder.build(); - - TranslateTextResponse response = this.clientWrapper.getClient().translateText(request); - - for (Translation t : response.getTranslationsList()) { - result.add(t.getTranslatedText()); - } - return result; - } catch (ApiException ex) { - final int remoteStatusCode = ex.getStatusCode().getCode().getHttpStatusCode(); - throw new TranslationException("Exception occured during Google translation!", remoteStatusCode, ex); - } - } - @Override public boolean isSupported(String srcLang, String targetLanguage) { return true; diff --git a/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/DummyPangTranslationService.java b/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/DummyPangTranslationService.java index 3049404f..9bf4d52a 100644 --- a/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/DummyPangTranslationService.java +++ b/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/DummyPangTranslationService.java @@ -17,18 +17,6 @@ public class DummyPangTranslationService extends PangeanicTranslationService{ public DummyPangTranslationService() { super(null, null); } - - @Override - public List translate(List text, String targetLanguage, String sourceLanguage) - throws TranslationException { - return translate(text, null); - } - - @Override - public List translate(List text, String targetLanguage) - throws TranslationException { - return text; - } @Override public void translate(List translationObjs, boolean detectLanguages) throws TranslationException { diff --git a/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/PangeanicTranslationService.java b/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/PangeanicTranslationService.java index 057e1714..76387586 100644 --- a/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/PangeanicTranslationService.java +++ b/translation-service-pangeanic/src/main/java/eu/europeana/api/translation/service/pangeanic/PangeanicTranslationService.java @@ -117,16 +117,6 @@ public void translate(List translationObjs, boolean detectLangua } } - @Deprecated - /** - * Use the method translate(List translationObjs). - */ - @Override - public List translate(List texts, String targetLanguage) - throws TranslationException { - return translate(texts, targetLanguage, null); - } - private void computeTranslations(List translationObjs) throws JSONException, TranslationException { List analyzedLangs = new ArrayList(); for(int i=0;i translate(List texts, String targetLanguage, String sourceLanguage) - throws TranslationException { - return null; - } - } diff --git a/translation-web/src/main/java/eu/europeana/api/translation/web/service/CachedTranslationService.java b/translation-web/src/main/java/eu/europeana/api/translation/web/service/CachedTranslationService.java index 6092749e..f1ab781d 100644 --- a/translation-web/src/main/java/eu/europeana/api/translation/web/service/CachedTranslationService.java +++ b/translation-web/src/main/java/eu/europeana/api/translation/web/service/CachedTranslationService.java @@ -40,11 +40,6 @@ public boolean isSupported(String srcLang, String trgLang) { return true; } - @Override - public List translate(List texts, String targetLanguage) throws TranslationException { - return null; - } - @Override public void translate(List translationObjs, boolean detectLanguages) throws TranslationException { //first detect languages for the texts that do not have it using the pangeanic lang detect @@ -62,11 +57,6 @@ public void translate(List translationObjs, boolean detectLangua redisCacheService.saveRedisCache(translationObjs); } - @Override - public List translate(List texts, String targetLanguage, String sourceLanguage) throws TranslationException { - return null; - } - @Override public void close() { }