dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33311
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16996: fixes to csv import/export, switched to using DateUtils.parseDate in AbstractCrudController to su...
------------------------------------------------------------
revno: 16996
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-08 14:48:52 +0700
message:
fixes to csv import/export, switched to using DateUtils.parseDate in AbstractCrudController to support more date formats.
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/csv/DefaultCsvEventService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-10-08 06:12:13 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-10-08 07:48:52 +0000
@@ -415,8 +415,7 @@
@Override
public void updateEvent( Event event, boolean singleValue, ImportOptions importOptions )
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event
- .getEvent() );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event.getEvent() );
if ( programStageInstance == null )
{
@@ -439,7 +438,7 @@
if ( event.getEventDate() != null )
{
- executionDate = DateUtils.getMediumDate( event.getEventDate() );
+ executionDate = DateUtils.parseDate( event.getEventDate() );
programStageInstance.setExecutionDate( executionDate );
}
@@ -447,9 +446,12 @@
if ( event.getDueDate() != null )
{
- dueDate = DateUtils.getMediumDate( event.getDueDate() );
+ dueDate = DateUtils.parseDate( event.getDueDate() );
}
+ System.err.println( "ed: " + executionDate );
+ System.err.println( "dd: " + dueDate );
+
String storedBy = getStoredBy( event, null );
if ( event.getStatus() == EventStatus.ACTIVE )
@@ -545,14 +547,14 @@
{
return;
}
+
saveTrackedEntityComment( programStageInstance, event, getStoredBy( event, null ) );
}
public void updateEventForEventDate( Event event )
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event
- .getEvent() );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event.getEvent() );
if ( programStageInstance == null )
{
@@ -563,7 +565,7 @@
if ( event.getEventDate() != null )
{
- executionDate = DateUtils.getMediumDate( event.getEventDate() );
+ executionDate = DateUtils.parseDate( event.getEventDate() );
}
if ( event.getStatus() == EventStatus.COMPLETED )
@@ -575,6 +577,8 @@
programStageInstance.setStatus( EventStatus.VISITED );
}
+ System.err.println( "updateEventForEventDate.ed: " + executionDate );
+
programStageInstance.setExecutionDate( executionDate );
programStageInstanceService.updateProgramStageInstance( programStageInstance );
@@ -587,8 +591,7 @@
@Override
public void deleteEvent( Event event )
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event
- .getEvent() );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event.getEvent() );
if ( programStageInstance != null )
{
@@ -804,7 +807,6 @@
}
private void updateProgramStageInstance( ProgramStage programStage, ProgramInstance programInstance,
-
OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status, Coordinate coordinate,
String storedBy, ProgramStageInstance programStageInstance )
{
@@ -835,8 +837,7 @@
programStageInstance.setStatus( EventStatus.COMPLETED );
programStageInstance.setCompletedDate( new Date() );
programStageInstance.setCompletedUser( storedBy );
- programStageInstanceService
- .completeProgramStageInstance( programStageInstance, i18nManager.getI18nFormat() );
+ programStageInstanceService.completeProgramStageInstance( programStageInstance, i18nManager.getI18nFormat() );
}
}
@@ -852,9 +853,9 @@
importSummary.setStatus( ImportStatus.SUCCESS );
boolean dryRun = importOptions != null && importOptions.isDryRun();
- Date eventDate = DateUtils.getMediumDate( event.getEventDate() );
+ Date eventDate = DateUtils.parseDate( event.getEventDate() );
- Date dueDate = DateUtils.getMediumDate( event.getDueDate() );
+ Date dueDate = DateUtils.parseDate( event.getDueDate() );
String storedBy = getStoredBy( event, importSummary );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/csv/DefaultCsvEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/csv/DefaultCsvEventService.java 2014-10-08 06:21:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/csv/DefaultCsvEventService.java 2014-10-08 07:48:52 +0000
@@ -120,8 +120,8 @@
{
Events events = new Events();
- ObjectReader reader = csvMapper
- .reader( CsvEventDataValue.class ).with( csvSchema.withSkipFirstDataRow( skipFirst ) );
+ ObjectReader reader = csvMapper.reader( CsvEventDataValue.class )
+ .with( csvSchema.withSkipFirstDataRow( skipFirst ) );
MappingIterator<CsvEventDataValue> iterator = reader.readValues( inputStream );
Event event = new Event();
@@ -135,14 +135,14 @@
{
event = new Event();
event.setEvent( dataValue.getEvent() );
- event.setStatus( StringUtils.isEmpty( dataValue.getStatus() ) ? EventStatus.ACTIVE : Enum.valueOf( EventStatus.class,
- dataValue.getStatus() ) );
+ event.setStatus( StringUtils.isEmpty( dataValue.getStatus() )
+ ? EventStatus.ACTIVE : Enum.valueOf( EventStatus.class, dataValue.getStatus() ) );
event.setProgram( dataValue.getProgram() );
event.setProgramStage( dataValue.getProgramStage() );
event.setEnrollment( dataValue.getEnrollment() );
event.setOrgUnit( dataValue.getOrgUnit() );
- event.setEventDate( event.getEventDate() );
- event.setDueDate( event.getDueDate() );
+ event.setEventDate( dataValue.getEventDate() );
+ event.setDueDate( dataValue.getDueDate() );
if ( dataValue.getLongitude() != null && dataValue.getLatitude() != null )
{
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2014-08-05 11:19:29 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2014-10-08 07:48:52 +0000
@@ -51,7 +51,7 @@
*/
public class DateUtils
{
- public static final SimpleDateFormat[] SUPPORTED_DATE_FORMATS = new SimpleDateFormat[] {
+ public static final SimpleDateFormat[] SUPPORTED_DATE_FORMATS = new SimpleDateFormat[]{
new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" ),
new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" ),
new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm" ),
@@ -61,11 +61,11 @@
new SimpleDateFormat( "yyyy-MM" ),
new SimpleDateFormat( "yyyy" )
};
-
+
public static final SimpleDateFormat LONG_DATE_FORMAT = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" );
public static final SimpleDateFormat ACCESS_DATE_FORMAT = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" );
public static final SimpleDateFormat HTTP_DATE_FORMAT = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss" );
-
+
public static final double DAYS_IN_YEAR = 365.0;
private static final long MS_PER_DAY = 86400000;
@@ -225,8 +225,8 @@
return false;
}
- if ( ( startDate.before( baseDate ) || startDate.equals( baseDate ) )
- && ( endDate.after( baseDate ) || endDate.equals( baseDate ) ) )
+ if ( (startDate.before( baseDate ) || startDate.equals( baseDate ))
+ && (endDate.after( baseDate ) || endDate.equals( baseDate )) )
{
return true;
}