← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11927: event import, wip

 

------------------------------------------------------------
revno: 11927
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-05 11:25:02 +0200
message:
  event import, wip
modified:
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java
  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/eventImportForm.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/eventData.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-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java	2013-08-28 07:27:01 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java	2013-09-05 09:25:02 +0000
@@ -30,6 +30,14 @@
 
 import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.dxf2.event.EventService;
+import org.hisp.dhis.dxf2.event.tasks.ImportEventTask;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.system.util.StreamUtils;
+import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.io.File;
@@ -46,6 +54,15 @@
     // -------------------------------------------------------------------------
 
     @Autowired
+    private Scheduler scheduler;
+
+    @Autowired
+    private Notifier notifier;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
+    @Autowired
     private EventService eventService;
 
     // -------------------------------------------------------------------------
@@ -59,6 +76,13 @@
         this.upload = upload;
     }
 
+    private boolean dryRun;
+
+    public void setDryRun( boolean dryRun )
+    {
+        this.dryRun = dryRun;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -66,7 +90,17 @@
     @Override
     public String execute() throws Exception
     {
+        TaskId taskId = new TaskId( TaskCategory.EVENT_IMPORT, currentUserService.getCurrentUser() );
+
+        notifier.clear( taskId );
+
         InputStream in = new FileInputStream( upload );
+        in = StreamUtils.wrapAndCheckCompressionFormat( in );
+
+        ImportOptions importOptions = new ImportOptions();
+        importOptions.setDryRun( dryRun );
+
+        scheduler.executeTask( new ImportEventTask( in, eventService, importOptions, taskId, true ) );
 
         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	2013-08-29 11:59:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2013-09-05 09:25:02 +0000
@@ -219,4 +219,8 @@
     <property name="category" value="METADATA_IMPORT" />
   </bean>
 
+  <bean id="org.hisp.dhis.importexport.action.event.GetImportEventSummariesAction"
+    class="org.hisp.dhis.importexport.action.event.GetImportEventSummariesAction" scope="prototype">
+  </bean>
+
 </beans>

=== 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	2013-09-03 11:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2013-09-05 09:25:02 +0000
@@ -264,6 +264,7 @@
 intro_xml_data_import=Import data values on the DXF 2 XML format which is used for data exchange by DHIS 2 and other software.
 intro_csv_data_import=Import data values on the CSV format which is used for data exchange by DHIS 2 and other third-party software.
 intro_pdf_data_import=Import data from a PDF data entry form. PDF forms can be generated from the data set module.
+intro_event_data_import=Import event data.
 intro_dhis14_import=Import data from DHIS 1.4 installations. DHIS 1.4 is the predecessor of DHIS 2.
 intro_data_export=Export data values. This is the regular export function which exports data to the DHIS 2 exchange format called DXF 2.
 intro_metadata_export=Export meta data like data elements and organisation units to the standard DHIS 2 exchange format.

=== 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	2013-09-04 07:19:46 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2013-09-05 09:25:02 +0000
@@ -61,12 +61,17 @@
       <param name="requiredAuthorities">F_IMPORT_DATA</param>
     </action>
 
-    <action name="importEventDataValue" class="org.hisp.dhis.importexport.action.event.ImportEventAction">
+    <action name="importEvents" class="org.hisp.dhis.importexport.action.event.ImportEventAction">
       <result name="success" type="redirect">displayEventImportForm.action</result>
       <interceptor-ref name="fileUploadStack" />
       <param name="requiredAuthorities">F_IMPORT_DATA</param>
     </action>
 
+    <action name="getImportEventSummaries" class="org.hisp.dhis.importexport.action.event.GetImportEventSummariesAction">
+      <result name="success" type="velocity">/dhis-web-importexport/importEvents.vm</result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+
     <!-- Event Export -->
 
     <action name="displayEventExportForm" class="org.hisp.dhis.importexport.action.NoAction">
@@ -77,11 +82,6 @@
       <param name="requiredAuthorities">F_EXPORT_DATA</param>
     </action>
 
-    <action name="importDataValue" class="org.hisp.dhis.importexport.action.event.ExportEventAction">
-      <result name="success" type="redirect">displayEventExportForm.action</result>
-      <param name="requiredAuthorities">F_EXPORT_DATA</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/eventImportForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventImportForm.vm	2013-09-04 08:56:15 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventImportForm.vm	2013-09-05 09:25:02 +0000
@@ -12,7 +12,7 @@
 </tr>
 <tr>
 	<td>$i18n.getString( "dry_run" )</td>
-	<td><select disabled="disabled" id="dryRun" name="dryRun" style="width:190px">
+	<td><select id="dryRun" name="dryRun" style="width:190px">
 		<option value="false">$i18n.getString( "no" )</option>
 		<option value="true">$i18n.getString( "yes" )</option>
     </select></td>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/eventData.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/eventData.js	2013-08-29 11:59:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/eventData.js	2013-09-05 09:25:02 +0000
@@ -1,4 +1,10 @@
 
+$( document ).ready( function() {
+	pingNotificationsTimeout();
+} );
+
+var pingTimeout = null;
+
 function importEventData()
 {
 	if ( !$( "#upload" ).val() )
@@ -10,3 +16,21 @@
 	$( "#notificationTable" ).empty();
 	$( "#importForm" ).submit();
 }
+
+function pingNotificationsTimeout()
+{
+	pingNotifications( 'EVENT_IMPORT', 'notificationTable', displaySummaryLink );
+	pingTimeout = setTimeout( "pingNotificationsTimeout()", 2500 );
+}
+
+function displaySummaryLink()
+{
+	var html = '<tr><td></td><td><a href="javascript:displaySummary()">Display import summary</a></td></tr>';
+	$( '#notificationTable' ).prepend( html );
+}
+
+function displaySummary()
+{
+	$( '#notificationDiv' ).hide();
+	$( '#importSummaryDiv' ).show( 'fast' ).load( 'getImportEventSummaries.action' );
+}