← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12549: TranslationService, added method getTranslaionsNoFallback(String, int, Locale)

 

------------------------------------------------------------
revno: 12549
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-10 10:26:52 +0200
message:
  TranslationService, added method getTranslaionsNoFallback(String,int,Locale)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java	2013-10-10 08:26:52 +0000
@@ -75,6 +75,17 @@
     Collection<Translation> getTranslations( String className, int id, Locale locale );
 
     /**
+     * Retrieves a Collection of Translations. Only exact matches on the given
+     * Locale will be returned.
+     * 
+     * @param className the class name.
+     * @param id the id.
+     * @param locale the locale.
+     * @return a Collection of Translations.
+     */
+    Collection<Translation> getTranslationsNoFallback( String className, int id, Locale locale );
+
+    /**
      * Retrieves a Collection of Translations.
      * 
      * @param className the class name.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java	2013-10-10 08:26:52 +0000
@@ -74,6 +74,17 @@
     Collection<Translation> getTranslations( String className, int id, Locale locale );
 
     /**
+     * Retrieves a Collection of Translations. Only exact matches on the given
+     * Locale will be returned.
+     * 
+     * @param className the class name.
+     * @param id the id.
+     * @param locale the locale.
+     * @return a Collection of Translations.
+     */
+    Collection<Translation> getTranslationsNoFallback( String className, int id, Locale locale );
+    
+    /**
      * Retrieves a Collection of Translations.
      * 
      * @param className the class name.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java	2013-10-10 08:26:52 +0000
@@ -76,6 +76,11 @@
         return translationStore.getTranslations( className, id, locale );
     }
 
+    public Collection<Translation> getTranslationsNoFallback( String className, int id, Locale locale )
+    {
+        return translationStore.getTranslationsNoFallback( className, id, locale );
+    }
+
     public Collection<Translation> getTranslations( String className, Locale locale )
     {
         return translationStore.getTranslations( className, locale );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java	2013-10-10 08:26:52 +0000
@@ -114,6 +114,22 @@
     }
 
     @SuppressWarnings( "unchecked" )
+    public Collection<Translation> getTranslationsNoFallback( String className, int id, Locale locale )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( Translation.class );
+
+        criteria.add( Restrictions.eq( "className", className ) );
+        criteria.add( Restrictions.eq( "id", id ) );
+        criteria.add( Restrictions.eq( "locale", locale.toString() ) );
+
+        criteria.setCacheable( true );
+
+        return criteria.list();
+    }
+
+    @SuppressWarnings( "unchecked" )
     public Collection<Translation> getTranslations( String className, Locale locale )
     {
         Session session = sessionFactory.getCurrentSession();