← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19197: Import. Fixed bug that affected imports were id scheme was set and preheat cache was false.

 

------------------------------------------------------------
revno: 19197
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-05-28 13:30:20 -0400
message:
  Import. Fixed bug that affected imports were id scheme was set and preheat cache was false.
modified:
  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/dataentryform/DefaultDataEntryFormService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/callable/IdentifiableObjectCallable.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-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	2015-03-27 17:33:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2015-05-28 17:30:20 +0000
@@ -808,7 +808,7 @@
 
         if ( id != null )
         {
-            if ( IdentifiableProperty.ID.equals( property ) )
+            if ( property == null || IdentifiableProperty.ID.equals( property ) )
             {
                 if ( Integer.valueOf( id ) > 0 )
                 {
@@ -831,9 +831,11 @@
             {
                 return store.getByName( id );
             }
+            
+            throw new IllegalArgumentException( "Invalid identifiable property / class combination: " + property );
         }
 
-        throw new IllegalArgumentException( String.valueOf( property ) );
+        return null;
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2015-05-03 14:12:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2015-05-28 17:30:20 +0000
@@ -230,7 +230,7 @@
 
                 String optionComboId = identifierMatcher.group( 2 );
 
-                DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setUid( optionComboId ) );
+                DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setId( optionComboId ) );
 
                 String optionComboName = categoryOptionCombo != null ? escapeHtml3( categoryOptionCombo.getName() ) : "[ " + i18n.getString( "cat_option_combo_not_exist" ) + " ]";
 
@@ -333,7 +333,7 @@
                     return i18n.getString( "dataelement_with_id" ) + ": " + dataElementId + " " + i18n.getString( "does_not_exist_in_data_set" );
                 }
 
-                DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setUid( optionComboId ) );
+                DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setId( optionComboId ) );
 
                 if ( categoryOptionCombo == null )
                 {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-04-22 18:05:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-05-28 17:30:20 +0000
@@ -642,9 +642,9 @@
         }
         
         IdentifiableObjectCallable<DataElement> dataElementCallable = new IdentifiableObjectCallable<>( 
-            identifiableObjectManager, DataElement.class, null );
+            identifiableObjectManager, DataElement.class, dataElementIdScheme, null );
         IdentifiableObjectCallable<OrganisationUnit> orgUnitCallable = new IdentifiableObjectCallable<>( 
-            identifiableObjectManager, OrganisationUnit.class, trimToNull( dataValueSet.getOrgUnit() ) );
+            identifiableObjectManager, OrganisationUnit.class, orgUnitIdScheme, trimToNull( dataValueSet.getOrgUnit() ) );
         
         //----------------------------------------------------------------------
         // Get outer meta-data
@@ -728,10 +728,10 @@
 
             totalCount++;
 
-            DataElement dataElement = dataElementMap.get( trimToNull( dataValue.getDataElement() ), dataElementCallable.setUid( trimToNull( dataValue.getDataElement() ) ) );
+            DataElement dataElement = dataElementMap.get( trimToNull( dataValue.getDataElement() ), dataElementCallable.setId( trimToNull( dataValue.getDataElement() ) ) );
             Period period = outerPeriod != null ? outerPeriod : PeriodType.getPeriodFromIsoString( trimToNull( dataValue.getPeriod() ) );
             OrganisationUnit orgUnit = outerOrgUnit != null ? outerOrgUnit : 
-                orgUnitMap.get( trimToNull( dataValue.getOrgUnit() ), orgUnitCallable.setUid( trimToNull( dataValue.getOrgUnit() ) ) );
+                orgUnitMap.get( trimToNull( dataValue.getOrgUnit() ), orgUnitCallable.setId( trimToNull( dataValue.getOrgUnit() ) ) );
             DataElementCategoryOptionCombo categoryOptionCombo = categoryOptionComboMap.get( trimToNull( dataValue.getCategoryOptionCombo() ) );
             DataElementCategoryOptionCombo attrOptionCombo = outerAttrOptionCombo != null ? outerAttrOptionCombo :
                 categoryOptionComboMap.get( trimToNull( dataValue.getAttributeOptionCombo() ) );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2015-04-05 20:00:35 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2015-05-28 17:30:20 +0000
@@ -281,6 +281,25 @@
         
         assertImportDataValues( summary );
     }
+
+    @Test
+    public void testImportDataValuesXmlWithCodePreheatCacheFalseB()
+        throws Exception
+    {
+        in = new ClassPathResource( "datavalueset/dataValueSetBcode.xml" ).getInputStream();
+        
+        ImportOptions options = new ImportOptions( CODE, CODE, CODE, false, false, NEW_AND_UPDATES, false );
+        ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
+
+        assertEquals( 0, summary.getConflicts().size() );
+        assertEquals( 12, summary.getImportCount().getImported() );
+        assertEquals( 0, summary.getImportCount().getUpdated() );
+        assertEquals( 0, summary.getImportCount().getDeleted() );
+        assertEquals( 0, summary.getImportCount().getIgnored() );
+        assertEquals( ImportStatus.SUCCESS, summary.getStatus() );
+        
+        assertImportDataValues( summary );
+    }
     
     @Test
     public void testImportDataValuesCsv()

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/callable/IdentifiableObjectCallable.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/callable/IdentifiableObjectCallable.java	2015-03-03 09:13:20 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/callable/IdentifiableObjectCallable.java	2015-05-28 17:30:20 +0000
@@ -44,21 +44,21 @@
     private IdentifiableObjectManager manager;
     private Class<T> clazz;
     private IdentifiableProperty property;
-    private String uid;
+    private String id;
     
-    public IdentifiableObjectCallable( IdentifiableObjectManager manager, Class<T> clazz, String uid )
+    public IdentifiableObjectCallable( IdentifiableObjectManager manager, Class<T> clazz, String id )
     {
         this.manager = manager;
         this.clazz = clazz;
-        this.uid = uid;
+        this.id = id;
     }
 
-    public IdentifiableObjectCallable( IdentifiableObjectManager manager, Class<T> clazz, IdentifiableProperty property, String uid )
+    public IdentifiableObjectCallable( IdentifiableObjectManager manager, Class<T> clazz, IdentifiableProperty property, String id )
     {
         this.manager = manager;
         this.clazz = clazz;
         this.property = property;
-        this.uid = uid;
+        this.id = id;
     }
     
     @Override
@@ -67,17 +67,17 @@
     {
         if ( property == null )
         {
-            return manager.get( clazz, uid );
+            return manager.get( clazz, id );
         }
         else
         {
-            return manager.getObject( clazz, property, uid );
+            return manager.getObject( clazz, property, id );
         }
     }
     
-    public IdentifiableObjectCallable<T> setUid( String uid )
+    public IdentifiableObjectCallable<T> setId( String id )
     {
-        this.uid = uid;
+        this.id = id;
         return this;
     }
 }