dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31047
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15789: events have now due date as it is required for scheduling
------------------------------------------------------------
revno: 15789
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2014-06-20 16:17:48 +0200
message:
events have now due date as it is required for scheduling
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/Event.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.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-06-20 12:32:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-06-20 14:17:48 +0000
@@ -177,11 +177,13 @@
"No Event.trackedEntityInstance was provided for registration based program." );
}
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( event.getTrackedEntityInstance() );
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService
+ .getTrackedEntityInstance( event.getTrackedEntityInstance() );
if ( entityInstance == null )
{
- return new ImportSummary( ImportStatus.ERROR, "Event.trackedEntityInstance does not point to a valid trackedEntityInstance." );
+ return new ImportSummary( ImportStatus.ERROR,
+ "Event.trackedEntityInstance does not point to a valid trackedEntityInstance." );
}
List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>(
@@ -250,15 +252,13 @@
{
return new ImportSummary( ImportStatus.ERROR,
"No active event exists for single event no registration program " + program.getUid()
- + ", please check and correct your database."
- );
+ + ", please check and correct your database." );
}
else if ( programInstances.size() > 1 )
{
return new ImportSummary( ImportStatus.ERROR,
"Multiple active events exists for single event no registration program " + program.getUid()
- + ", please check and correct your database."
- );
+ + ", please check and correct your database." );
}
programInstance = programInstances.get( 0 );
@@ -300,8 +300,9 @@
}
@Override
- public Events getEvents( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp, List<OrganisationUnit> organisationUnits,
- TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
+ public Events getEvents( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp,
+ List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate,
+ Date endDate, EventStatus status )
{
List<Event> eventList = eventStore.getAll( program, programStage, programStatus, followUp, organisationUnits,
trackedEntityInstance, startDate, endDate, status );
@@ -338,7 +339,8 @@
@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 )
{
@@ -357,11 +359,18 @@
organisationUnit = programStageInstance.getOrganisationUnit();
}
- Date date = new Date();
+ Date executionDate = new Date();
if ( event.getEventDate() != null )
{
- date = DateUtils.getMediumDate( event.getEventDate() );
+ executionDate = DateUtils.getMediumDate( event.getEventDate() );
+ }
+
+ Date dueDate = new Date();
+
+ if ( event.getDueDate() != null )
+ {
+ dueDate = DateUtils.getMediumDate( event.getDueDate() );
}
String storedBy = getStoredBy( event, null );
@@ -374,8 +383,8 @@
}
else if ( event.getStatus() == EventStatus.COMPLETED )
{
+ programStageInstance.setCompletedDate( executionDate );
programStageInstance.setStatus( EventStatus.COMPLETED );
- programStageInstance.setCompletedDate( date );
programStageInstance.setCompletedUser( storedBy );
if ( !programStageInstance.isCompleted() )
@@ -385,8 +394,8 @@
}
}
- programStageInstance.setDueDate( date );
- programStageInstance.setExecutionDate( date );
+ programStageInstance.setDueDate( dueDate );
+ programStageInstance.setExecutionDate( executionDate );
programStageInstance.setOrganisationUnit( organisationUnit );
if ( programStageInstance.getProgramStage().getCaptureCoordinates() && event.getCoordinate().isValid() )
@@ -479,6 +488,7 @@
event.setStatus( programStageInstance.getStatus() );
event.setEventDate( DateUtils.getLongDateString( programStageInstance.getExecutionDate() ) );
+ event.setDueDate( DateUtils.getLongDateString( programStageInstance.getDueDate() ) );
event.setStoredBy( programStageInstance.getCompletedUser() );
event.setOrgUnit( programStageInstance.getOrganisationUnit().getUid() );
event.setProgram( programStageInstance.getProgramInstance().getProgram().getUid() );
@@ -502,8 +512,7 @@
List<Double> list = objectMapper.readValue( coordinate.getCoordinateString(),
new TypeReference<List<Double>>()
{
- }
- );
+ } );
coordinate.setLongitude( list.get( 0 ) );
coordinate.setLatitude( list.get( 1 ) );
@@ -601,8 +610,7 @@
{
importSummary.getConflicts().add(
new ImportConflict( "storedBy", storedBy
- + " is more than 31 characters, using current username instead." )
- );
+ + " is more than 31 characters, using current username instead." ) );
}
storedBy = currentUserService.getCurrentUsername();
}
@@ -647,24 +655,27 @@
}
private ProgramStageInstance createProgramStageInstance( ProgramStage programStage,
- ProgramInstance programInstance, OrganisationUnit organisationUnit, Date date, int status,
+
+ ProgramInstance programInstance, OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status,
Coordinate coordinate, String storedBy )
{
ProgramStageInstance programStageInstance = new ProgramStageInstance();
- updateProgramStageInstance( programStage, programInstance, organisationUnit, date, status, coordinate,
- storedBy, programStageInstance );
+
+ updateProgramStageInstance( programStage, programInstance, organisationUnit, dueDate, executionDate, status,
+ coordinate, storedBy, programStageInstance );
return programStageInstance;
}
private void updateProgramStageInstance( ProgramStage programStage, ProgramInstance programInstance,
- OrganisationUnit organisationUnit, Date date, int status, Coordinate coordinate, String storedBy,
- ProgramStageInstance programStageInstance )
+
+ OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status, Coordinate coordinate,
+ String storedBy, ProgramStageInstance programStageInstance )
{
programStageInstance.setProgramInstance( programInstance );
programStageInstance.setProgramStage( programStage );
- programStageInstance.setDueDate( date );
- programStageInstance.setExecutionDate( date );
+ programStageInstance.setDueDate( dueDate );
+ programStageInstance.setExecutionDate( executionDate );
programStageInstance.setOrganisationUnit( organisationUnit );
if ( programStage.getCaptureCoordinates() )
@@ -712,6 +723,8 @@
return new ImportSummary( ImportStatus.ERROR, "Event.eventDate is not in a valid format." );
}
+ Date dueDate = DateUtils.getMediumDate( event.getDueDate() );
+
String storedBy = getStoredBy( event, importSummary );
if ( !dryRun )
@@ -719,12 +732,13 @@
if ( programStageInstance == null )
{
programStageInstance = createProgramStageInstance( programStage, programInstance, organisationUnit,
- eventDate, event.getStatus().getValue(), event.getCoordinate(), storedBy );
+ dueDate, eventDate, event.getStatus().getValue(), event.getCoordinate(), storedBy );
}
else
{
- updateProgramStageInstance( programStage, programInstance, organisationUnit, eventDate,
- event.getStatus().getValue(), event.getCoordinate(), storedBy, programStageInstance );
+ updateProgramStageInstance( programStage, programInstance, organisationUnit, dueDate, eventDate, event
+ .getStatus().getValue(), event.getCoordinate(), storedBy, programStageInstance );
+
}
saveTrackedEntityCommentFromEvent( programInstance, event, storedBy );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2014-04-18 10:14:28 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2014-06-20 14:17:48 +0000
@@ -58,6 +58,8 @@
private String trackedEntityInstance;
private String eventDate;
+
+ private String dueDate;
private String storedBy;
@@ -154,6 +156,18 @@
{
this.eventDate = eventDate;
}
+
+ @JsonProperty( required = false )
+ @JacksonXmlProperty( isAttribute = true )
+ public String getDueDate()
+ {
+ return dueDate;
+ }
+
+ public void setDueDate( String dueDate )
+ {
+ this.dueDate = dueDate;
+ }
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
@@ -217,6 +231,7 @@
if ( dataValues != null ? !dataValues.equals( event1.dataValues ) : event1.dataValues != null ) return false;
if ( event != null ? !event.equals( event1.event ) : event1.event != null ) return false;
if ( eventDate != null ? !eventDate.equals( event1.eventDate ) : event1.eventDate != null ) return false;
+ if ( dueDate != null ? !dueDate.equals( event1.dueDate ) : event1.dueDate != null ) return false;
if ( orgUnit != null ? !orgUnit.equals( event1.orgUnit ) : event1.orgUnit != null ) return false;
if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( event1.trackedEntityInstance ) : event1.trackedEntityInstance != null )
return false;
@@ -238,6 +253,7 @@
result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0);
result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
result = 31 * result + (eventDate != null ? eventDate.hashCode() : 0);
+ result = 31 * result + (dueDate != null ? dueDate.hashCode() : 0);
result = 31 * result + (storedBy != null ? storedBy.hashCode() : 0);
result = 31 * result + (coordinate != null ? coordinate.hashCode() : 0);
result = 31 * result + (dataValues != null ? dataValues.hashCode() : 0);
@@ -255,6 +271,7 @@
", orgUnit='" + orgUnit + '\'' +
", trackedEntityInstance='" + trackedEntityInstance + '\'' +
", eventDate='" + eventDate + '\'' +
+ ", dueDate='" + dueDate + '\'' +
", storedBy='" + storedBy + '\'' +
", coordinate=" + coordinate +
", dataValues=" + dataValues +
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-06-20 12:32:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-06-20 14:17:48 +0000
@@ -119,8 +119,10 @@
event.setProgramStage( rowSet.getString( "ps_uid" ) );
event.setStoredBy( rowSet.getString( "psi_completeduser" ) );
event.setOrgUnit( rowSet.getString( "ou_uid" ) );
+ event.setDueDate( StringUtils.defaultIfEmpty(
+ rowSet.getString( "psi_duedate" ), rowSet.getString( "psi_duedate" ) ) );
event.setEventDate( StringUtils.defaultIfEmpty(
- rowSet.getString( "psi_executiondate" ), rowSet.getString( "psi_duedate" ) ) );
+ rowSet.getString( "psi_executiondate" ), rowSet.getString( "psi_executiondate" ) ) );
if ( rowSet.getBoolean( "ps_capturecoordinates" ) )
{