← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6549: Basic impl of html view of import summary. Minor change to ImportSummary class.

 

------------------------------------------------------------
revno: 6549
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-11 22:16:18 +0200
message:
  Basic impl of html view of import summary. Minor change to ImportSummary class.
added:
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/GetImportSummaryAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm
modified:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.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/AbstractImporter.java
  dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js


--
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-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2012-04-11 16:18:25 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2012-04-11 20:16:18 +0000
@@ -271,7 +271,7 @@
         
         int ignores = totalCount - importCount - updateCount;
         
-        summary.getCounts().add( new ImportCount( DataValue.class.getSimpleName(), importCount, updateCount, ignores ) );
+        summary.setDataValueCount( new ImportCount( importCount, updateCount, ignores ) );
         
         batchHandler.flush();
         

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java	2012-04-11 19:17:22 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java	2012-04-11 20:16:18 +0000
@@ -34,22 +34,14 @@
 @JacksonXmlRootElement( localName = "count" )
 public class ImportCount
 {
-    private String object;
-
     private int imported;
 
     private int updated;
 
     private int ignored;
 
-    public ImportCount( String object )
-    {
-        this.object = object;
-    }
-
-    public ImportCount( String object, int imported, int updated, int ignored )
-    {
-        this.object = object;
+    public ImportCount( int imported, int updated, int ignored )
+    {
         this.imported = imported;
         this.updated = updated;
         this.ignored = ignored;
@@ -57,18 +49,6 @@
 
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
-    public String getObject()
-    {
-        return object;
-    }
-
-    public void setObject( String object )
-    {
-        this.object = object;
-    }
-
-    @JsonProperty
-    @JacksonXmlProperty( isAttribute = true )
     public int getImported()
     {
         return imported;
@@ -106,9 +86,6 @@
     @Override
     public String toString()
     {
-        return "[object='" + object + "'" +
-            ", imports=" + imported +
-            ", updates=" + updated +
-            ", ignores=" + ignored + "]";
+        return "[imports=" + imported + ", updates=" + updated + ", ignores=" + ignored + "]";
     }
 }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2012-04-02 17:23:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2012-04-11 20:16:18 +0000
@@ -38,27 +38,22 @@
 @JacksonXmlRootElement( localName = "importSummary" )
 public class ImportSummary
 {
-    private List<ImportCount> counts = new ArrayList<ImportCount>();
+    private ImportCount dataValueCount;
 
     private List<ImportConflict> conflicts = new ArrayList<ImportConflict>();
 
     private String dataSetComplete;
 
-    public void increaseImportCount( Class<?> clazz )
-    {
-    }
-
     @JsonProperty
-    @JacksonXmlElementWrapper
     @JacksonXmlProperty
-    public List<ImportCount> getCounts()
+    public ImportCount getDataValueCount()
     {
-        return counts;
+        return dataValueCount;
     }
 
-    public void setCounts( List<ImportCount> counts )
+    public void setDataValueCount( ImportCount dataValueCount )
     {
-        this.counts = counts;
+        this.dataValueCount = dataValueCount;
     }
 
     @JsonProperty
@@ -85,14 +80,4 @@
     {
         this.dataSetComplete = dataSetComplete;
     }
-
-    @Override
-    public String toString()
-    {
-        return "ImportSummary{" +
-            "counts=" + counts +
-            ", noneExistingIdentifiers=" + conflicts +
-            ", dataSetComplete='" + dataSetComplete + '\'' +
-            '}';
-    }
 }

=== 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-11 15:11:09 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-11 20:16:18 +0000
@@ -88,7 +88,7 @@
                 ImportCount count = importer.getCurrentImportCount();
 
                 importSummary.getConflicts().addAll( conflicts );
-                importSummary.getCounts().add( count );
+                // importSummary.getCounts().add( count ); //FIXME
             }
         }
     }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java	2012-04-11 19:17:22 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java	2012-04-11 20:16:18 +0000
@@ -27,9 +27,21 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.*;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.dxf2.importsummary.ImportConflict;
 import org.hisp.dhis.dxf2.importsummary.ImportCount;
 import org.hisp.dhis.dxf2.metadata.ImportOptions;
@@ -38,9 +50,6 @@
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.lang.reflect.Field;
-import java.util.*;
-
 /**
  * Abstract importer that can handle IdentifiableObject and NameableObject.
  *
@@ -213,14 +222,8 @@
 
     @Override
     public ImportCount getCurrentImportCount()
-    {
-        ImportCount importCount = new ImportCount( getObjectName() );
-
-        importCount.setImported( imported );
-        importCount.setUpdated( updated );
-        importCount.setIgnored( ignored );
-
-        return importCount;
+    {        
+        return new ImportCount( imported, updated, ignored );
     }
 
     //-------------------------------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java'
--- dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2012-04-11 11:40:51 +0000
+++ dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2012-04-11 20:16:18 +0000
@@ -121,7 +121,7 @@
         ImportSummary summary = dataValueSetService.saveDataValueSet( new ClassPathResource( "dataValueSetA.xml" ).getInputStream() );
         
         assertNotNull( summary );
-        assertEquals( 1, summary.getCounts().size() );
+        assertNotNull( summary.getDataValueCount() );
         
         Collection<DataValue> dataValues = dataValueService.getAllDataValues();
         

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-04-11 14:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-04-11 20:16:18 +0000
@@ -1591,7 +1591,7 @@
 // Notifications
 // -----------------------------------------------------------------------------
 
-function pingNotifications( category, tableId )
+function pingNotifications( category, tableId, completedCallback )
 {	
 	var lastUid = $( '#' + tableId ).prop( 'lastUid' );
 	
@@ -1617,6 +1617,11 @@
 			html += '<tr><td>' + notification.time + '</td><td>' + notification.message + ' &nbsp;';
 			html += notification.completed == "true" ?  completedHtml : loaderHtml;
 			html += '</td></tr>';
+			
+			if ( notification.completed && completedCallback && completedCallback.call )
+			{
+				completedCallback();				
+			}
 		} );
 		
 		$( '#' + tableId ).prepend( html );

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/GetImportSummaryAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/GetImportSummaryAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/GetImportSummaryAction.java	2012-04-11 20:16:18 +0000
@@ -0,0 +1,63 @@
+package org.hisp.dhis.importexport.action;
+
+/*
+ * Copyright (c) 2011, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.system.notification.NotificationCategory;
+import org.hisp.dhis.system.notification.Notifier;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetImportSummaryAction
+    implements Action
+{
+    @Autowired
+    private Notifier notifier;
+    
+    private NotificationCategory category;
+    
+    public void setCategory( NotificationCategory category )
+    {
+        this.category = category;
+    }
+
+    private ImportSummary summary;
+    
+    public ImportSummary getSummary()
+    {
+        return summary;
+    }
+
+    public String execute()
+    {
+        summary = (ImportSummary) notifier.getTaskSummary( category );
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2012-04-11 13:49:03 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2012-04-11 20:16:18 +0000
@@ -7,6 +7,10 @@
 
   <bean id="org.hisp.dhis.importexport.action.datavalue.ImportDataValueAction" class="org.hisp.dhis.importexport.action.datavalue.ImportDataValueAction"/>
 
+  <bean id="org.hisp.dhis.importexport.action.GetImportSummaryAction" class="org.hisp.dhis.importexport.action.GetImportSummaryAction">
+	<property name="category" value="DATAVALUE_IMPORT" />
+  </bean>
+
   <!-- Import -->
 
   <bean id="org.hisp.dhis.importexport.action.imp.ImportAction" class="org.hisp.dhis.importexport.action.imp.ImportAction"

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2012-04-11 14:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2012-04-11 20:16:18 +0000
@@ -274,4 +274,14 @@
 strategy=Strategy
 new_only=New only
 updates_only=Updates only
-data_value_import=Data value import
\ No newline at end of file
+data_value_import=Data value import
+import_summary=Import summary
+data_set_completed_on=Data set completed on
+import_count=Import count
+imported=Imported
+updated=Updated
+ignored=Ignored
+conflicts=Conflicts
+no_conflicts_found=No conflicts found
+type=Type
+count=Count
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2012-04-11 13:49:03 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2012-04-11 20:16:18 +0000
@@ -28,6 +28,11 @@
       <interceptor-ref name="fileUploadStack" />
 	</action>
 
+    <action name="getDataValueImportSummary" class="org.hisp.dhis.importexport.action.GetImportSummaryAction">			
+      <result name="success" type="velocity">/dhis-web-importexport/importSummary.vm</result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+
     <!-- Menu -->
 
     <action name="displayExternalImportMenu" class="org.hisp.dhis.importexport.action.NoAction">

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2012-04-11 14:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2012-04-11 20:16:18 +0000
@@ -35,7 +35,7 @@
 
 #if( $running )
 
-<div>
+<div id="notificationDiv">
 <table id="notificationTable" class="notificationTable">
 <col width="120">
 <col width="380">
@@ -49,4 +49,6 @@
 } );
 </script>
 
-#end
\ No newline at end of file
+#end
+
+<div id="importSummaryDiv" class="page"></div>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm	2012-04-11 20:16:18 +0000
@@ -0,0 +1,50 @@
+
+<h3>$i18n.getString( "import_summary" )</h3>
+
+#if( $summary.dataSetComplete )
+<p>$i18n.getString( "data_set_completed_on" ) ${summary.dataSetComplete}</p>
+#end
+
+<h4>$i18n.getString( "import_count" )</h4>
+#if( $summary.dataValueCount )
+<table>
+<col width="80">
+<col width="80">
+<tr>
+	<th>$i18n.getString( "type" )</th>
+	<th style="text-align:center">$i18n.getString( "count" )</th>
+</tr>
+<tr>
+	<td>$i18n.getString( "imported" )</td>
+	<td style="text-align:center">${summary.dataValueCount.imported}</td>
+</tr>
+<tr>
+	<td>$i18n.getString( "updated" )</td>
+	<td style="text-align:center">${summary.dataValueCount.updated}</td>
+</tr>
+<tr>
+	<td>$i18n.getString( "ignored" )</td>
+	<td style="text-align:center">${summary.dataValueCount.ignored}</td>
+</tr>
+</table>
+#else
+<p>$i18n.getString( "no_data_values_found" )</p>
+#end
+
+<h4>$i18n.getString( "conflicts" )</h4>
+#if( $summary.conflicts.size() > 0 )
+<table>
+<tr>
+	<th>$i18n.getString( "element" )</th>
+	<th>$i18n.getString( "description" )</th>
+</tr>
+#foreach( $conflict in $summary.conflicts )
+<tr>
+	<td>${conflict.object}</td>
+	<td>$encoder.htmlEncode( $conflict.value )</td>
+</tr>
+#end
+</table>
+#else
+<p>$i18n.getString( "no_conflicts_found" )</p>
+#end

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-04-11 14:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-04-11 20:16:18 +0000
@@ -1,4 +1,6 @@
 
+var pingTimeout = null;
+
 function importDataValue()
 {
 	if ( !$( "#upload" ).val() )
@@ -12,6 +14,18 @@
 
 function pingNotificationsTimeout()
 {
-	pingNotifications( 'DATAVALUE_IMPORT', 'notificationTable' );
-	setTimeout( "pingNotificationsTimeout()", 2500 );
-}
+	pingNotifications( 'DATAVALUE_IMPORT', 'notificationTable', displayImportSummaryTimeout );	
+	pingTimeout = setTimeout( "pingNotificationsTimeout()", 1500 );
+}
+
+function displayImportSummaryTimeout()
+{
+	setTimeout( "displayImportSummary()", 2000 );	
+}
+
+function displayImportSummary()
+{	
+	window.clearTimeout( pingTimeout );
+	$( '#notificationDiv' ).hide();
+	$( '#importSummaryDiv' ).show().load( 'getDataValueImportSummary.action' );
+}
\ No newline at end of file