← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6562: Lots of minor fixes to importer. References are now verified.

 

------------------------------------------------------------
revno: 6562
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-13 13:38:21 +0300
message:
  Lots of minor fixes to importer. References are now verified.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultImporter.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
  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/dataset/DefaultSectionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.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/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-04-11 15:11:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-04-13 10:38:21 +0000
@@ -42,7 +42,7 @@
 
     void update( IdentifiableObject object );
 
-    <T extends IdentifiableObject> void get( Class<T> clazz, String uid );
+    <T extends IdentifiableObject> T get( Class<T> clazz, String uid );
 
     <T extends IdentifiableObject> Collection<T> getAll( Class<T> clazz );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2012-04-10 21:41:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2012-04-13 10:38:21 +0000
@@ -419,6 +419,7 @@
     }
 
     @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlElementWrapper( localName = "sections", namespace = Dxf2Namespace.NAMESPACE )
     @JacksonXmlProperty( localName = "section", namespace = Dxf2Namespace.NAMESPACE )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2012-04-13 10:38:21 +0000
@@ -160,6 +160,10 @@
     // Getters and setters
     // -------------------------------------------------------------------------
 
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public DataSet getDataSet()
     {
         return dataSet;
@@ -190,9 +194,6 @@
         this.dataElements.add( dataElement );
     }
 
-    @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public int getSortOrder()
     {
         return sortOrder;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionService.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionService.java	2012-04-13 10:38:21 +0000
@@ -64,6 +64,14 @@
     Section getSection( int id );
 
     /**
+     * Retrieves the Section with the given identifier (uid).
+     *
+     * @param uid the identifier of the Section to retrieve.
+     * @return the Section.
+     */
+    Section getSection( String uid );
+
+    /**
      * Retrieves the Section with the given name.
      * 
      * @param name the name of the Section to retrieve.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java	2012-04-13 10:38:21 +0000
@@ -27,16 +27,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 
 public interface SectionStore
-    extends GenericStore<Section>
+    extends GenericIdentifiableObjectStore<Section>
 {
     String ID = SectionStore.class.getName();
 
     /**
      * Retrieves the Section with the given name and the given DataSet.
-     * 
+     *
      * @param name the name of the Section to retrieve.
      * @return the Section.
      */

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2012-04-13 10:38:21 +0000
@@ -27,18 +27,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.Weighted;
 import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
  * @author Kristian Nordal
@@ -54,7 +54,7 @@
     private static final long serialVersionUID = -4445992494203466044L;
 
     public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
-    
+
     private static final String SEPARATOR = "_";
 
     /**
@@ -120,7 +120,7 @@
     {
         return getIsoDate();
     }
-    
+
     /**
      * Returns an ISO8601 formatted string version of the period
      *
@@ -215,28 +215,27 @@
             format.applyPattern( DEFAULT_DATE_FORMAT );
 
             return dateString != null ? format.parse( dateString ) : null;
-        } 
-        catch ( ParseException ex )
+        } catch ( ParseException ex )
         {
             throw new RuntimeException( "Failed to parse medium date", ex );
         }
     }
-    
+
     /**
      * Return the potential number of periods of the given period type which is
      * spanned by this period.
-     * 
+     *
      * @param type the period type.
-     * @return the potential number of periods of the given period type spanned 
+     * @return the potential number of periods of the given period type spanned
      *         by this period.
      */
     public int getPeriodSpan( PeriodType type )
     {
         double no = (double) this.periodType.getFrequencyOrder() / type.getFrequencyOrder();
-        
+
         return (int) Math.floor( no );
     }
-    
+
     // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------
@@ -282,7 +281,7 @@
     @Override
     public String toString()
     {
-        return "[" + periodType.getName() + ": " + startDate + " - " + endDate + "]";
+        return "[" + (periodType == null ? "" : periodType.getName() + ": ") + startDate + " - " + endDate + "]";
     }
 
     // -------------------------------------------------------------------------
@@ -290,7 +289,7 @@
     // -------------------------------------------------------------------------
 
     @JsonProperty
-    @JsonView( {DetailedView.class} )
+    @JsonView( {DetailedView.class, ExportView.class} )
     public Date getEndDate()
     {
         return endDate;
@@ -313,7 +312,7 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class} )
+    @JsonView( {DetailedView.class, ExportView.class} )
     public Date getStartDate()
     {
         return startDate;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2012-04-11 04:56:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2012-04-13 10:38:21 +0000
@@ -283,7 +283,7 @@
     private List<NameableObject> allUnits = new ArrayList<NameableObject>();
 
     /**
-     * All Indicatrs, including DateElements, Indicators and DataSets.
+     * All Indicators, including DateElements, Indicators and DataSets.
      */
     private List<NameableObject> allIndicators = new ArrayList<NameableObject>();
 

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-13 08:17:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-13 10:38:21 +0000
@@ -29,6 +29,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dxf2.importsummary.ImportConflict;
 import org.hisp.dhis.dxf2.importsummary.ImportCount;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -38,6 +39,7 @@
 
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultImporter.java	2012-04-13 08:17:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultImporter.java	2012-04-13 10:38:21 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.dxf2.metadata.ImportOptions;
 import org.hisp.dhis.dxf2.metadata.Importer;
 import org.hisp.dhis.importexport.ImportStrategy;
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -117,13 +118,13 @@
             return null;
         }
 
-        log.info( "Trying to save new object with UID: " + object.getUid() );
+        // log.info( "Trying to save new object with UID: " + object.getUid() );
 
         findAndUpdateReferences( object );
         //manager.save( object );
         //updateIdMaps( object );
 
-        log.info( "Save successful." );
+        // log.info( "Save successful." );
 
         return null;
     }
@@ -143,13 +144,13 @@
             return null;
         }
 
-        log.info( "Trying to update object with UID: " + oldObject.getUid() );
+        // log.info( "Trying to update object with UID: " + oldObject.getUid() );
 
         findAndUpdateReferences( object );
         // oldObject.mergeWith( object );
         // manager.update( oldObject );
 
-        log.info( "Update successful." );
+        // log.info( "Update successful." );
 
         return null;
     }
@@ -559,6 +560,8 @@
     {
         Field[] fields = object.getClass().getDeclaredFields();
 
+        log.info( "Finding and updating references for " + object.getClass().getSimpleName() );
+
         for ( Field field : fields )
         {
             if ( ReflectionUtils.isType( field, IdentifiableObject.class ) )
@@ -567,7 +570,24 @@
 
                 if ( identifiableObject != null )
                 {
-                    log.info( "VERIFYING: " + identifiableObject );
+                    log.info( "Verifying field " + field.getName() );
+
+                    if ( Period.class.isAssignableFrom( identifiableObject.getClass() ) )
+                    {
+                        log.info( "Skipping Period.class" );
+                    }
+                    else
+                    {
+                        IdentifiableObject ref = manager.get( identifiableObject.getClass(), identifiableObject.getUid() );
+
+                        if ( ref != null )
+                        {
+                        }
+                        else
+                        {
+                            log.info( "Reference " + identifiableObject + " not found." );
+                        }
+                    }
                 }
             }
             else
@@ -578,9 +598,32 @@
                 {
                     Collection<IdentifiableObject> identifiableObjects = ReflectionUtils.invokeGetterMethod( field.getName(), object );
 
-                    if ( !identifiableObjects.isEmpty() )
-                    {
-                        log.info( "VERIFYING: " + identifiableObjects );
+                    if ( identifiableObjects == null )
+                    {
+                        log.info( "identifiableObjects is null for field " + field.getName() );
+                    }
+                    else if ( !identifiableObjects.isEmpty() )
+                    {
+                        log.info( "Verifying field " + field.getName() );
+
+                        for ( IdentifiableObject identifiableObject : identifiableObjects )
+                        {
+                            if ( Period.class.isAssignableFrom( identifiableObject.getClass() ) )
+                            {
+                                log.info( "Skipping Period.class" );
+                                continue;
+                            }
+
+                            IdentifiableObject ref = manager.get( identifiableObject.getClass(), identifiableObject.getUid() );
+
+                            if ( ref != null )
+                            {
+                            }
+                            else
+                            {
+                                log.info( "Reference " + identifiableObject + " not found." );
+                            }
+                        }
                     }
                 }
             }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-04-11 15:11:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-04-13 10:38:21 +0000
@@ -75,17 +75,28 @@
 
     public void save( IdentifiableObject object )
     {
-        objectStoreMap.get( object.getClass() ).save( object );
+        if ( objectStoreMap.get( object.getClass() ) != null )
+        {
+            objectStoreMap.get( object.getClass() ).save( object );
+        }
     }
 
     public void update( IdentifiableObject object )
     {
-        objectStoreMap.get( object.getClass() ).update( object );
+        if ( objectStoreMap.get( object.getClass() ) != null )
+        {
+            objectStoreMap.get( object.getClass() ).update( object );
+        }
     }
 
-    public <T extends IdentifiableObject> void get( Class<T> clazz, String uid )
+    public <T extends IdentifiableObject> T get( Class<T> clazz, String uid )
     {
-        objectStoreMap.get( clazz ).getByUid( uid );
+        if ( objectStoreMap.get( clazz ) != null )
+        {
+            return (T) objectStoreMap.get( clazz ).getByUid( uid );
+        }
+
+        return null;
     }
 
     @SuppressWarnings( "unchecked" )

=== 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	2012-03-22 10:00:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2012-04-13 10:38:21 +0000
@@ -50,7 +50,7 @@
         "organisationunit", "orgunitgroup", "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup", "sqlview",
         "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "mapview",
         "reporttable", "report", "messageconversation", "message", "userinfo", "usergroup", "userrole", "maplegend",
-        "maplegendset", "maplayer"
+        "maplegendset", "maplayer", "section"
     };
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java	2012-01-27 11:40:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java	2012-04-13 10:38:21 +0000
@@ -23,13 +23,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
-import java.util.Collection;
-import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.i18n.I18nService;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collection;
+
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
 /**
  * @author Tri
  * @version $Id$
@@ -89,6 +89,12 @@
         return i18n( i18nService, sectionStore.get( id ) );
     }
 
+    @Override
+    public Section getSection( String uid )
+    {
+        return i18n( i18nService, sectionStore.getByUid( uid ) );
+    }
+
     public Section getSectionByName( String name, Integer dataSetId )
     {
         return i18n( i18nService, sectionStore.getSectionByName( name, dataSetService.getDataSet( dataSetId ) ) );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2012-02-03 08:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2012-04-13 10:38:21 +0000
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
+    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+    [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+    >
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.dataelement.DataElement" table="dataelement">
@@ -21,7 +21,7 @@
 
     <property name="description" type="text" />
 
-	<property name="formName" length="230" />
+    <property name="formName" length="230" />
 
     <property name="active" not-null="true" />
 
@@ -33,8 +33,9 @@
 
     <property name="aggregationOperator" not-null="true" column="aggregationtype" length="16" />
 
-    <many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo" column="categorycomboid"
-      foreign-key="fk_dataelement_categorycomboid" />
+    <many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo"
+        column="categorycomboid"
+        foreign-key="fk_dataelement_categorycomboid" />
 
     <property name="sortOrder" />
 
@@ -68,8 +69,8 @@
       <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
     </set>
 
-	<many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet" column="optionsetid"
-		foreign-key="fk_dataelement_optionsetid"/>
+    <many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet" column="optionsetid"
+        foreign-key="fk_dataelement_optionsetid" />
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml	2011-08-27 10:06:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml	2012-04-13 10:38:21 +0000
@@ -1,7 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
+    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+    [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+    >
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.dataset.Section" table="section">
@@ -12,23 +14,32 @@
       <generator class="native" />
     </id>
 
-    <property name="name" not-null="true" unique-key="key_sectionnamedataset" />
-
-    <many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid" 
-		unique-key="key_sectionnamedataset" foreign-key="fk_section_datasetid" not-null="true" />
+    <!-- <property name="name" not-null="true" unique-key="key_sectionnamedataset" /> -->
+    <property name="name" column="name" not-null="true" unique="true" length="230"
+        unique-key="key_sectionnamedataset" />
+
+    <property name="uid" column="uid" length="11" />
+
+    <property name="code" column="code" not-null="false" unique="true" length="50" />
+
+    <property name="lastUpdated" type="timestamp" />
+
+    <many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid"
+        unique-key="key_sectionnamedataset" foreign-key="fk_section_datasetid" not-null="true" />
 
     <list name="dataElements" table="sectiondataelements">
       <cache usage="read-write" />
       <key column="sectionid" foreign-key="fk_sectiondataelements_sectionid" />
       <list-index column="sort_order" base="1" />
-      <many-to-many class="org.hisp.dhis.dataelement.DataElement" column="dataelementid" foreign-key="fk_section_dataelementid" />
+      <many-to-many class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
+          foreign-key="fk_section_dataelementid" />
     </list>
 
     <set name="greyedFields" table="sectiongreyedfields">
       <cache usage="read-write" />
       <key column="sectionid" foreign-key="fk_sectiongreyedfields_sectionid" />
       <many-to-many class="org.hisp.dhis.dataelement.DataElementOperand" column="dataelementoperandid"
-        foreign-key="fk_section_dataelementoperandid" />
+          foreign-key="fk_section_dataelementoperandid" />
     </set>
 
     <property name="sortOrder" column="sortorder" not-null="true" />