[kune-commits] r1564 - in trunk/src/main/java/cc/kune: core/server/manager/impl domain/finders

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Thu Oct 20 19:31:53 CEST 2011


Author: vjrj_
Date: 2011-10-20 19:31:53 +0200 (Thu, 20 Oct 2011)
New Revision: 1564

Modified:
   trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
   trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
Log:
NEW - # 144: Resolve some i18n typos (sizes, no translated, etc) 
http://kune.ourproject.org/issues/ticket/144

Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java	2011-10-20 01:06:02 UTC (rev 1563)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java	2011-10-20 17:31:53 UTC (rev 1564)
@@ -43,6 +43,7 @@
 public class I18nTranslationManagerDefault extends DefaultManager<I18nTranslation, Long> implements
     I18nTranslationManager {
 
+  private I18nLanguage defLang;
   private final I18nTranslationFinder finder;
   private final ConcurrentHashMap<String, HashMap<String, String>> langCache;
   private final I18nLanguageManager languageManager;
@@ -56,6 +57,13 @@
     langCache = new ConcurrentHashMap<String, HashMap<String, String>>();
   }
 
+  private I18nLanguage defLang() {
+    if (defLang == null) {
+      defLang = languageManager.findByCode(I18nTranslation.DEFAULT_LANG);
+    }
+    return defLang;
+  }
+
   private I18nLanguage getLanguage(final String languageId) {
     return languageManager.findByCode(languageId);
   }
@@ -98,8 +106,7 @@
       final Integer firstResult, final Integer maxResults) {
     final I18nLanguage language = getLanguage(languageCode);
     final List<I18nTranslationDTO> list = finder.getTranslatedLexicon(language, firstResult, maxResults);
-    final Long count = finder.getTranslatedLexiconCount(language);
-    return new SearchResultDTO<I18nTranslationDTO>(count.intValue(), list);
+    return new SearchResultDTO<I18nTranslationDTO>(list.size(), list);
   }
 
   @Override
@@ -115,8 +122,7 @@
       if (!getLexicon(I18nTranslation.DEFAULT_LANG).containsKey(text)) {
         final I18nTranslation newTranslation = new I18nTranslation("", null,
             I18nTranslation.DEF_PLUR_INDEX, "", I18nTranslation.UNTRANSLATED_VALUE, escapedText,
-            I18nTranslation.DEF_NAMESPACE, languageManager.findByCode(I18nTranslation.DEFAULT_LANG),
-            null, noteForTranslators);
+            I18nTranslation.DEF_NAMESPACE, defLang(), null, noteForTranslators);
         persist(newTranslation);
         langCache.clear();
       }
@@ -133,14 +139,13 @@
   public SearchResultDTO<I18nTranslationDTO> getUntranslatedLexicon(final String languageCode,
       final Integer firstResult, final Integer maxResults) {
     final I18nLanguage language = initUnstranlated(languageCode);
-    final Long count = finder.getUnstranslatedLexiconCount(language);
     final List<I18nTranslationDTO> list = finder.getUnstranslatedLexicon(language, firstResult,
         maxResults);
-    return new SearchResultDTO<I18nTranslationDTO>(count.intValue(), list);
+    return new SearchResultDTO<I18nTranslationDTO>(list.size(), list);
   }
 
   private I18nLanguage initUnstranlated(final String languageCode) {
-    final I18nLanguage defLanguage = languageManager.findByCode(I18nTranslation.DEFAULT_LANG);
+    final I18nLanguage defLanguage = defLang();
     I18nLanguage language;
     if (languageCode.equals(I18nTranslation.DEFAULT_LANG)) {
       language = defLanguage;

Modified: trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java	2011-10-20 01:06:02 UTC (rev 1563)
+++ trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java	2011-10-20 17:31:53 UTC (rev 1564)
@@ -32,15 +32,17 @@
 import com.google.inject.persist.finder.MaxResults;
 
 public interface I18nTranslationFinder {
-  String TRANSLATED_COUNT_QUERY = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text!=null";
-  String TRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey, gt.parent.noteForTranslators) FROM I18nTranslation gt LEFT JOIN  gt.parent gp WHERE gt.language = :language AND gt.text!=null ORDER BY gt.parent.trKey";
-  String UNTRANSLATED_COUNT_QUERY = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text=null";
-  String UNTRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey, gt.parent.noteForTranslators) FROM I18nTranslation gt LEFT JOIN gt.parent gp WHERE gt.language = :language AND gt.text=null ORDER BY gt.parent.trKey";
+  String TRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO"
+      + "(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey, gt.parent.noteForTranslators) "
+      + "FROM I18nTranslation gt LEFT JOIN gt.parent gp WHERE gt.language = :language AND gt.text!=null ORDER BY gt.parent.trKey";
+  String UNTRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO"
+      + "(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey, gt.parent.noteForTranslators) "
+      + "FROM I18nTranslation gt LEFT JOIN gt.parent gp WHERE gt.language = :language AND gt.text=null  ORDER BY gt.parent.trKey";
 
   @Finder(query = "SELECT gt FROM I18nTranslation gt JOIN gt.language gl WHERE gl.code = :language", returnAs = ArrayList.class)
   public List<I18nTranslation> findByLanguage(@Named("language") final String language);
 
-  @Finder(query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :deflanguage AND gt.trKey NOT IN (SELECT gt.trKey FROM I18nTranslation gt WHERE gt.language = :language)", returnAs = ArrayList.class)
+  @Finder(query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :deflanguage AND gt.id NOT IN (SELECT gt.parent FROM I18nTranslation gt WHERE gt.language = :language)", returnAs = ArrayList.class)
   public List<I18nTranslation> getNonExistentFromDefault(
       @Named("deflanguage") final I18nLanguage deflanguage,
       @Named("language") final I18nLanguage language);
@@ -52,17 +54,11 @@
   public List<I18nTranslationDTO> getTranslatedLexicon(@Named("language") final I18nLanguage language,
       @FirstResult final int first, @MaxResults final int max);
 
-  @Finder(query = TRANSLATED_COUNT_QUERY)
-  public Long getTranslatedLexiconCount(@Named("language") final I18nLanguage language);
-
   @Finder(query = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
   public List<I18nTranslationDTO> getUnstranslatedLexicon(
       @Named("language") final I18nLanguage language, @FirstResult final int first,
       @MaxResults final int max);
 
-  @Finder(query = UNTRANSLATED_COUNT_QUERY)
-  public Long getUnstranslatedLexiconCount(@Named("language") final I18nLanguage language);
-
   @Finder(query = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
   public List<I18nTranslationDTO> getUntranslatedLexicon(@Named("language") final I18nLanguage language);
 




More information about the kune-commits mailing list