← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15702: CSV meta-data import, supporting parent of organisation units

 

------------------------------------------------------------
revno: 15702
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-16 15:31:32 +0200
message:
  CSV meta-data import, supporting parent of organisation units
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/CsvObjectUtils.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/CsvObjectUtils.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/CsvObjectUtils.java	2014-06-16 05:13:31 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/CsvObjectUtils.java	2014-06-16 13:31:32 +0000
@@ -205,20 +205,29 @@
             {
                 OrganisationUnit object = new OrganisationUnit();
                 setIdentifiableObject( object, values );
-                object.setShortName( getSafe( values, 3, object.getName(), 50 ) );
-                object.setDescription( getSafe( values, 4, null, null ) );
-                object.setUuid( getSafe( values, 5, null, 36 ) );
-                object.setOpeningDate( getMediumDate( getSafe( values, 6, "1970-01-01", null ) ) );
-                object.setClosedDate( getMediumDate( getSafe( values, 7, "1970-01-01", null ) ) );
+                object.setShortName( getSafe( values, 4, object.getName(), 50 ) );
+                object.setDescription( getSafe( values, 5, null, null ) );
+                object.setUuid( getSafe( values, 6, null, 36 ) );
+                object.setOpeningDate( getMediumDate( getSafe( values, 7, "1970-01-01", null ) ) );
+                object.setClosedDate( getMediumDate( getSafe( values, 8, "1970-01-01", null ) ) );
                 object.setActive( true );
-                object.setComment( getSafe( values, 8, null, null ) );
-                object.setFeatureType( getSafe( values, 9, null, 50 ) );
-                object.setCoordinates( getSafe( values, 10, null, null ) );
-                object.setUrl( getSafe( values, 11, null, 255 ) );
-                object.setContactPerson( getSafe( values, 12, null, 255 ) );
-                object.setAddress( getSafe( values, 13, null, 255 ) );
-                object.setEmail( getSafe( values, 14, null, 150 ) );
-                object.setPhoneNumber( getSafe( values, 15, null, 150 ) );
+                object.setComment( getSafe( values, 9, null, null ) );
+                object.setFeatureType( getSafe( values, 10, null, 50 ) );
+                object.setCoordinates( getSafe( values, 11, null, null ) );
+                object.setUrl( getSafe( values, 12, null, 255 ) );
+                object.setContactPerson( getSafe( values, 13, null, 255 ) );
+                object.setAddress( getSafe( values, 14, null, 255 ) );
+                object.setEmail( getSafe( values, 15, null, 150 ) );
+                object.setPhoneNumber( getSafe( values, 16, null, 150 ) );
+                
+                String parentUid = getSafe( values, 3, null, 11 );
+                
+                if ( parentUid != null )
+                {
+                    OrganisationUnit parent = new OrganisationUnit();
+                    parent.setUid( parentUid );
+                    object.setParent( parent );
+                }
 
                 list.add( object );
             }