dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33977
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17413: fixes for event export, support csv, update to use new parameter for ou inclusion (ouMode = CHILD...
------------------------------------------------------------
revno: 17413
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-11 11:56:25 +0545
message:
fixes for event export, support csv, update to use new parameter for ou inclusion (ouMode = CHILDREN / DESCENDANTS), csv 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/webapp/dhis-web-importexport/eventExportForm.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventImportForm.vm
--
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 2014-03-31 06:54:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java 2014-11-11 06:11:25 +0000
@@ -30,7 +30,10 @@
import com.opensymphony.xwork2.Action;
import org.hisp.dhis.dxf2.events.event.EventService;
+import org.hisp.dhis.dxf2.events.event.Events;
import org.hisp.dhis.dxf2.events.event.ImportEventTask;
+import org.hisp.dhis.dxf2.events.event.ImportEventsTask;
+import org.hisp.dhis.dxf2.events.event.csv.CsvEventService;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
import org.hisp.dhis.scheduling.TaskCategory;
import org.hisp.dhis.scheduling.TaskId;
@@ -65,6 +68,9 @@
@Autowired
private EventService eventService;
+ @Autowired
+ private CsvEventService csvEventService;
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -83,11 +89,11 @@
this.dryRun = dryRun;
}
- public boolean jsonInput;
+ public String format;
- public void setJsonInput( boolean jsonInput )
+ public void setFormat( String format )
{
- this.jsonInput = jsonInput;
+ this.format = format;
}
private String orgUnitIdScheme = "UID";
@@ -97,6 +103,13 @@
this.orgUnitIdScheme = orgUnitIdScheme;
}
+ private boolean skipFirst;
+
+ public void setSkipFirst( boolean skipFirst )
+ {
+ this.skipFirst = skipFirst;
+ }
+
// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@@ -115,7 +128,16 @@
importOptions.setDryRun( dryRun );
importOptions.setOrgUnitIdScheme( orgUnitIdScheme );
- scheduler.executeTask( new ImportEventTask( in, eventService, importOptions, taskId, jsonInput ) );
+ if ( "csv".equals( format ) )
+ {
+ Events events = csvEventService.readEvents( in, skipFirst );
+ scheduler.executeTask( new ImportEventsTask( events.getEvents(), eventService, importOptions, taskId ) );
+ }
+ else
+ {
+ boolean jsonInput = "json".equals( format );
+ scheduler.executeTask( new ImportEventTask( in, eventService, importOptions, taskId, jsonInput ) );
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm 2013-11-27 10:00:19 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm 2014-11-11 06:11:25 +0000
@@ -34,9 +34,9 @@
if( inclusion ) {
if( "children" == inclusion ) {
- url += "&includeChildren=true";
+ url += "&ouMode=CHILDREN";
} else if( "descendants" == inclusion ) {
- url += "&includeDescendants=true";
+ url += "&ouMode=DESCENDANTS";
}
}
@@ -156,7 +156,8 @@
<td>
<select id="format" style="width: 300px;">
<option value=".xml">XML</option>
- <option value=".json">Json</option>
+ <option value=".json">JSON</option>
+ <option value=".csv">CSV</option>
</select>
</td>
</tr>
=== 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 2014-03-31 06:54:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventImportForm.vm 2014-11-11 06:11:25 +0000
@@ -18,11 +18,14 @@
</select></td>
</tr>
<tr>
- <td>$i18n.getString( "format" )</td>
- <td><select id="jsonInput" name="jsonInput" style="width:190px">
- <option value="false">$i18n.getString( "xml" )</option>
- <option value="true">$i18n.getString( "json" )</option>
- </select></td>
+ <td>$i18n.getString( "format" )</td>
+ <td>
+ <select id="format" style="width: 190px;">
+ <option value="xml">XML</option>
+ <option value="json">JSON</option>
+ <option value="csv">CSV</option>
+ </select>
+ </td>
</tr>
<tr>
<td>$i18n.getString( "orgunit_scheme" )</td>