← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11920: Added system id to configuration

 

------------------------------------------------------------
revno: 11920
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-09-04 15:52:48 +0200
message:
  Added system id to configuration
added:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/ConfigurationPopulator.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/configuration/ConfigurationDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml


--
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/configuration/Configuration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java	2013-09-04 13:52:48 +0000
@@ -53,6 +53,8 @@
     
     private int id;
     
+    private String systemId;
+    
     private UserGroup feedbackRecipients;
     
     private OrganisationUnitLevel offlineOrganisationUnitLevel;
@@ -97,6 +99,16 @@
         this.id = id;
     }
 
+    public String getSystemId()
+    {
+        return systemId;
+    }
+
+    public void setSystemId( String systemId )
+    {
+        this.systemId = systemId;
+    }
+
     public UserGroup getFeedbackRecipients()
     {
         return feedbackRecipients;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/configuration/ConfigurationDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/configuration/ConfigurationDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/configuration/ConfigurationDeletionHandler.java	2013-09-04 13:52:48 +0000
@@ -34,8 +34,6 @@
 
 /**
  * @author Chau Thu Tran
- * 
- * @version $Id: ConfigurationDeletionHandler.java Jan 3, 2012 11:52:32 AM $
  */
 public class ConfigurationDeletionHandler
     extends DeletionHandler

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/ConfigurationPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/ConfigurationPopulator.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/ConfigurationPopulator.java	2013-09-04 13:52:48 +0000
@@ -0,0 +1,28 @@
+package org.hisp.dhis.startup;
+
+import java.util.UUID;
+
+import org.hisp.dhis.configuration.Configuration;
+import org.hisp.dhis.configuration.ConfigurationService;
+import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ConfigurationPopulator
+    extends AbstractStartupRoutine
+{
+    @Autowired
+    private ConfigurationService configurationService;
+
+    @Override
+    public void execute()
+        throws Exception
+    {
+        Configuration config = configurationService.getConfiguration();
+        
+        if ( config != null && config.getSystemId() == null )
+        {
+            config.setSystemId( UUID.randomUUID().toString() );
+            configurationService.setConfiguration( config );
+        }
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java	2013-09-01 21:38:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java	2013-09-04 13:52:48 +0000
@@ -38,6 +38,8 @@
 import java.util.Properties;
 
 import org.apache.commons.io.IOUtils;
+import org.hisp.dhis.configuration.Configuration;
+import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.external.location.LocationManagerException;
 import org.hisp.dhis.system.database.DatabaseInfoProvider;
@@ -56,6 +58,9 @@
     
     @Autowired
     private DatabaseInfoProvider databaseInfoProvider;
+    
+    @Autowired
+    private ConfigurationService configurationService;
 
     // -------------------------------------------------------------------------
     // SystemService implementation
@@ -156,6 +161,10 @@
         info.setCpuCores( SystemUtils.getCpuCores() );
         info.setServerDate( new Date() );
         
+        Configuration config = configurationService.getConfiguration();
+        
+        info.setSystemId( config.getSystemId() );
+        
         return info;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java	2013-09-02 12:36:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java	2013-09-04 13:52:48 +0000
@@ -78,6 +78,8 @@
     private String memoryInfo;
 
     private Integer cpuCores;
+    
+    private String systemId;
 
     // -------------------------------------------------------------------------
     // Logic
@@ -97,6 +99,7 @@
         this.databaseInfo = null;
         this.memoryInfo = null;
         this.cpuCores = null;
+        this.systemId = systemId;
     }
     
     // -------------------------------------------------------------------------
@@ -318,4 +321,16 @@
     {
         this.cpuCores = cpuCores;
     }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public String getSystemId()
+    {
+        return systemId;
+    }
+
+    public void setSystemId( String systemId )
+    {
+        this.systemId = systemId;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-09-04 09:44:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-09-04 13:52:48 +0000
@@ -876,6 +876,11 @@
     <property name="skipInTests" value="true" />
   </bean>
   
+  <bean id="org.hisp.dhis.startup.ConfigurationPopulator" class="org.hisp.dhis.startup.ConfigurationPopulator">
+    <property name="runlevel" value="7" />
+    <property name="skipInTests" value="true" />
+  </bean>
+  
   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
     <property name="targetObject" ref="org.hisp.dhis.system.startup.StartupRoutineExecutor" />
     <property name="targetMethod" value="addStartupRoutines" />
@@ -891,7 +896,7 @@
           <ref local="org.hisp.dhis.organisationunit.OrganisationUnitGroupSetPopulator" />
           <ref local="org.hisp.dhis.dataentryform.DataEntryFormUpgrader" />
           <ref local="org.hisp.dhis.startup.ExpressionUpgrader" />
-          <!--<ref local="org.hisp.dhis.user.UserDefaultPopulator" />-->
+          <ref local="org.hisp.dhis.startup.ConfigurationPopulator" />
         </list>
       </list>
     </property>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml	2012-11-04 08:37:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml	2013-09-04 13:52:48 +0000
@@ -12,6 +12,8 @@
       <generator class="native" />
     </id>
 
+    <property name="systemId" column="systemid" />
+
     <many-to-one name="feedbackRecipients" class="org.hisp.dhis.user.UserGroup"
         column="feedbackrecipientsid" foreign-key="fk_configuration_feedback_recipients" />