← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20243: add new property to Schema: translated. Updated at server startup and tells if type have any tran...

 

------------------------------------------------------------
revno: 20243
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 11:59:10 +0700
message:
  add new property to Schema: translated. Updated at server startup and tells if type have any translations or not (means displayName == name,etc)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.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/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-07-14 07:21:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-09-21 04:59:10 +0000
@@ -112,6 +112,12 @@
     private boolean shareable;
 
     /**
+     * Does this type have any translations.
+     * Please remember that this is only updated at server start, so if any translation was added later, this flag is not updated.
+     */
+    private boolean translated;
+
+    /**
      * Points to relative Web-API endpoint (if exposed).
      */
     private String relativeApiEndpoint;
@@ -291,6 +297,18 @@
 
     @JsonProperty
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public boolean isTranslated()
+    {
+        return translated;
+    }
+
+    public void setTranslated( boolean translated )
+    {
+        this.translated = translated;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getRelativeApiEndpoint()
     {
         return relativeApiEndpoint;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2015-08-12 05:41:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2015-09-21 04:59:10 +0000
@@ -34,6 +34,7 @@
 import com.google.common.collect.Maps;
 import org.hibernate.SessionFactory;
 import org.hisp.dhis.system.util.ReflectionUtils;
+import org.hisp.dhis.translation.TranslationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.OrderComparator;
 import org.springframework.util.StringUtils;
@@ -65,6 +66,9 @@
     @Autowired
     private SessionFactory sessionFactory;
 
+    @Autowired
+    private TranslationService translationService;
+
     @PostConstruct
     public void init()
     {
@@ -75,6 +79,7 @@
             if ( sessionFactory.getClassMetadata( schema.getKlass() ) != null )
             {
                 schema.setPersisted( true );
+                schema.setTranslated( translationService.haveTranslations( schema.getKlass().getSimpleName() ) );
             }
 
             schema.setDisplayName( beautify( schema.getName() ) );