← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5094: Ensure timestamps are fully populated as part of identity checking startup task.

 

------------------------------------------------------------
revno: 5094
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2011-11-03 10:11:33 +0000
message:
  Ensure timestamps are fully populated as part of identity checking startup task.
  Given categoryoptioncombo the fields of an identifiable object (minus the name)
  Included categoryoptioncombo table in the startup task.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.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-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2011-11-03 09:13:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2011-11-03 10:11:33 +0000
@@ -6,6 +6,8 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
+import java.sql.Timestamp;
+import java.util.Date;
 import java.util.UUID;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -59,7 +61,8 @@
         "indicatorgroup", "datadictionary", "validationrulegroup", "validationrule",
         "dataset", "orgunitlevel", "organisationunit", "orgunitgroup",
         "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup",
-        "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo"
+        "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo",
+        "categoryoptioncombo"
     };
 
     // -------------------------------------------------------------------------
@@ -122,7 +125,21 @@
                     {
                         log.info( count + " uuids updated on " + table );
                     }
-
+                    
+                    Timestamp now = new Timestamp (new Date().getTime());
+                    
+                    resultSet = statement.executeQuery( "SELECT * from " + table + " WHERE lastUpdated IS NULL" );
+                    while ( resultSet.next() )
+                    {
+                        ++count;
+                        resultSet.updateTimestamp( "lastUpdated", now);
+                        resultSet.updateRow();
+                    }
+                    if ( count > 0 )
+                    {
+                        log.info( count + " timestamps updated on " + table );
+                    }
+                    
                 } catch ( SQLException ex )
                 {
                     Logger.getLogger( IdentityPopulator.class.getName() ).log( Level.SEVERE, null, ex );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml	2011-08-17 09:25:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml	2011-11-03 10:11:33 +0000
@@ -8,14 +8,16 @@
 
     <cache usage="read-write" />
 
-    <id name="id" column="categoryoptioncomboid">
+    <id name="id" column="categoryoptioncomboid">
       <generator class="native" />
     </id>
 
-    <property name="uuid">
-      <column name="uuid" length="40" />
-    </property>
-
+    <!-- <property name="name" column="name" not-null="true" unique="true" length="230" /> -->
+    <property name="uuid" column="uuid" length="40" />
+    <property name="uid" column="uid" length="11" />
+    <property name="code" column="code" not-null="false" unique="true" length="50" />
+    <property name="lastUpdated" type="timestamp"/>
+    
     <list name="categoryOptions" table="categoryoptioncombos_categoryoptions">
 	  <cache usage="read-write" />
       <key column="categoryoptioncomboid" foreign-key="fk_categoryoptioncombos_categoryoptions_categoryoptioncomboid" />
@@ -27,6 +29,6 @@
     <join table="categorycombos_optioncombos">
       <key column="categoryoptioncomboid" />
       <many-to-one name="categoryCombo" column="categorycomboid" />
-    </join>
+    </join>
   </class>
 </hibernate-mapping>