← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12498: minor fixes to importer

 

------------------------------------------------------------
revno: 12498
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-08 12:20:06 +0200
message:
  minor fixes to importer
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-09-30 10:39:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-10-08 10:20:06 +0000
@@ -62,7 +62,7 @@
  *
  * @author Kristian Nordal
  */
-@JacksonXmlRootElement( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
+@JacksonXmlRootElement(localName = "dataSet", namespace = DxfNamespaces.DXF_2_0)
 public class DataSet
     extends BaseNameableObject
 {
@@ -193,7 +193,7 @@
      */
     private boolean skipOffline;
 
-   /**
+    /**
      * Property indicating whether it should enable data elements decoration in forms.
      */
     private boolean dataElementDecoration;
@@ -334,11 +334,6 @@
         dataElement.getDataSets().remove( dataElement );
     }
 
-    public void removeAllDataElements()
-    {
-        dataElements.clear();
-    }
-
     public void updateDataElements( Set<DataElement> updates )
     {
         for ( DataElement dataElement : new HashSet<DataElement>( dataElements ) )
@@ -367,11 +362,6 @@
         indicator.getDataSets().remove( this );
     }
 
-    public void removeAllIndicators()
-    {
-        indicators.clear();
-    }
-
     public void addCompulsoryDataElementOperand( DataElementOperand dataElementOperand )
     {
         compulsoryDataElementOperands.add( dataElementOperand );
@@ -382,11 +372,6 @@
         compulsoryDataElementOperands.remove( dataElementOperand );
     }
 
-    public void removeAllCompulsoryDataElementOperands()
-    {
-        compulsoryDataElementOperands.clear();
-    }
-
     public boolean hasDataEntryForm()
     {
         return dataEntryForm != null;
@@ -441,10 +426,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize( using = JacksonPeriodTypeSerializer.class )
-    @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonSerialize(using = JacksonPeriodTypeSerializer.class)
+    @JsonDeserialize(using = JacksonPeriodTypeDeserializer.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public PeriodType getPeriodType()
     {
         return periodType;
@@ -456,8 +441,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public DataEntryForm getDataEntryForm()
     {
         return dataEntryForm;
@@ -469,10 +454,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "dataElements", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "dataElement", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "dataElements", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "dataElement", namespace = DxfNamespaces.DXF_2_0)
     public Set<DataElement> getDataElements()
     {
         return dataElements;
@@ -484,10 +469,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "indicators", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "indicator", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "indicators", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "indicator", namespace = DxfNamespaces.DXF_2_0)
     public Set<Indicator> getIndicators()
     {
         return indicators;
@@ -499,9 +484,9 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "compulsoryDataElementOperands", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "compulsoryDataElementOperand", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "compulsoryDataElementOperands", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "compulsoryDataElementOperand", namespace = DxfNamespaces.DXF_2_0)
     public Set<DataElementOperand> getCompulsoryDataElementOperands()
     {
         return compulsoryDataElementOperands;
@@ -512,11 +497,11 @@
         this.compulsoryDataElementOperands = compulsoryDataElementOperands;
     }
 
-    @JsonProperty( value = "organisationUnits" )
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonProperty(value = "organisationUnits")
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0)
     public Set<OrganisationUnit> getSources()
     {
         return sources;
@@ -527,11 +512,11 @@
         this.sources = sources;
     }
 
-    @JsonProperty( value = "organisationUnitGroups" )
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonProperty(value = "organisationUnitGroups")
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlElementWrapper(localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0)
     public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
     {
         return organisationUnitGroups;
@@ -553,10 +538,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( { DetailedView.class } )
-    @JacksonXmlElementWrapper( localName = "sections", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "section", namespace = DxfNamespaces.DXF_2_0 )
+    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
+    @JsonView({ DetailedView.class })
+    @JacksonXmlElementWrapper(localName = "sections", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "section", namespace = DxfNamespaces.DXF_2_0)
     public Set<Section> getSections()
     {
         return sections;
@@ -568,8 +553,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isMobile()
     {
         return mobile;
@@ -581,8 +566,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public Integer getVersion()
     {
         return version;
@@ -594,8 +579,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public int getExpiryDays()
     {
         return expiryDays;
@@ -607,8 +592,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public int getTimelyDays()
     {
         return timelyDays;
@@ -620,8 +605,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isSkipAggregation()
     {
         return skipAggregation;
@@ -633,8 +618,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public UserGroup getNotificationRecipients()
     {
         return notificationRecipients;
@@ -646,8 +631,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isNotifyCompletingUser()
     {
         return notifyCompletingUser;
@@ -659,8 +644,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isAllowFuturePeriods()
     {
         return allowFuturePeriods;
@@ -672,8 +657,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isFieldCombinationRequired()
     {
         return fieldCombinationRequired;
@@ -685,8 +670,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isValidCompleteOnly()
     {
         return validCompleteOnly;
@@ -698,8 +683,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isSkipOffline()
     {
         return skipOffline;
@@ -711,8 +696,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isRenderAsTabs()
     {
         return renderAsTabs;
@@ -724,8 +709,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isRenderHorizontally()
     {
         return renderHorizontally;
@@ -737,8 +722,8 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isDataElementDecoration()
     {
         return dataElementDecoration;
@@ -773,22 +758,23 @@
             renderHorizontally = dataSet.isRenderHorizontally();
 
             dataElementDecoration = dataSet.isDataElementDecoration();
+            notificationRecipients = dataSet.getNotificationRecipients();
 
-            removeAllDataElements();
+            dataElements.clear();
 
             for ( DataElement dataElement : dataSet.getDataElements() )
             {
                 addDataElement( dataElement );
             }
 
-            removeAllIndicators();
+            indicators.clear();
 
             for ( Indicator indicator : dataSet.getIndicators() )
             {
                 addIndicator( indicator );
             }
 
-            removeAllCompulsoryDataElementOperands();
+            compulsoryDataElementOperands.clear();
 
             for ( DataElementOperand dataElementOperand : dataSet.getCompulsoryDataElementOperands() )
             {

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2013-10-01 13:32:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2013-10-08 10:20:06 +0000
@@ -200,16 +200,6 @@
         return userCredentials != null ? userCredentials.getUsername() : null;
     }
 
-    public void removeAllOrganisationUnits()
-    {
-        organisationUnits.clear();
-    }
-
-    public void removeAllAttributeValues()
-    {
-        attributeValues.clear();
-    }
-
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
@@ -474,10 +464,10 @@
             phoneNumber = user.getPhoneNumber() == null ? phoneNumber : user.getPhoneNumber();
             userCredentials = user.getUserCredentials() == null ? userCredentials : user.getUserCredentials();
 
-            removeAllAttributeValues();
+            attributeValues.clear();
             attributeValues.addAll( user.getAttributeValues() );
 
-            removeAllOrganisationUnits();
+            organisationUnits.clear();
             organisationUnits.addAll( user.getOrganisationUnits() );
         }
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java	2013-10-04 12:20:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java	2013-10-08 10:20:06 +0000
@@ -89,11 +89,6 @@
     // Logic
     // -------------------------------------------------------------------------
 
-    public void removeAllUsers()
-    {
-        members.clear();
-    }
-
     public void addUser( User user )
     {
         members.add( user );
@@ -182,7 +177,7 @@
         {
             UserGroup userGroup = (UserGroup) other;
 
-            removeAllUsers();
+            members.clear();
             members.addAll( userGroup.getMembers() );
 
             attributeValues.clear();

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-10-04 12:20:15 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-10-08 10:20:06 +0000
@@ -138,9 +138,14 @@
 
         allExportClasses.put( DataDictionary.class, "dataDictionaries" );
 
+        allExportClasses.put( User.class, "users" );
+        allExportClasses.put( UserGroup.class, "userGroups" );
+
         allExportClasses.put( DataSet.class, "dataSets" );
         allExportClasses.put( Section.class, "sections" );
 
+        allExportClasses.put( UserAuthorityGroup.class, "userRoles" );
+
         allExportClasses.put( ReportTable.class, "reportTables" );
         allExportClasses.put( Report.class, "reports" );
         allExportClasses.put( Chart.class, "charts" );
@@ -153,10 +158,6 @@
         allExportClasses.put( MapView.class, "mapViews" );
         allExportClasses.put( org.hisp.dhis.mapping.Map.class, "maps" );
 
-        allExportClasses.put( UserAuthorityGroup.class, "userRoles" );
-        allExportClasses.put( User.class, "users" );
-        allExportClasses.put( UserGroup.class, "userGroups" );
-
         allExportClasses.put( MessageConversation.class, "messageConversations" );
         allExportClasses.put( Interpretation.class, "interpretations" );
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2013-10-04 12:20:15 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2013-10-08 10:20:06 +0000
@@ -61,9 +61,7 @@
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.system.util.functional.Function1;
 import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserGroup;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.lang.reflect.Field;