dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22672
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10970: renamed id => programId / programStageId. for single event only programId makes sense, but this c...
------------------------------------------------------------
revno: 10970
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-24 14:24:49 +0700
message:
renamed id => programId / programStageId. for single event only programId makes sense, but this class is also used for multiple.
modified:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.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-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 2013-05-21 09:23:50 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 2013-05-24 07:24:49 +0000
@@ -48,6 +48,7 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.user.CurrentUserService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +68,9 @@
private ProgramService programService;
@Autowired
+ private ProgramStageService programStageService;
+
+ @Autowired
private ProgramInstanceService programInstanceService;
@Autowired
@@ -98,11 +102,25 @@
protected ImportSummary saveEvent( Event event )
{
- Program program = programService.getProgram( event.getId() );
+ Program program;
+
+ if ( event.getProgramId() != null )
+ {
+ program = programService.getProgram( event.getProgramId() );
+ }
+ else if ( event.getProgramStageId() != null )
+ {
+ ProgramStage programStage = programStageService.getProgramStage( event.getProgramStageId() );
+ program = programStage.getProgram();
+ }
+ else
+ {
+ return new ImportSummary( ImportStatus.ERROR, "No Event programId or programStageId was provided." );
+ }
if ( program == null )
{
- return new ImportSummary( ImportStatus.ERROR, "Event ID does not point to a valid program." );
+ return new ImportSummary( ImportStatus.ERROR, "No valid Event programId or programStageId was provided." );
}
else
{
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java 2013-05-21 09:23:50 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java 2013-05-24 07:24:49 +0000
@@ -42,9 +42,11 @@
@JacksonXmlRootElement( localName = "event", namespace = DxfNamespaces.DXF_2_0 )
public class Event
{
- private String id;
-
- private String eventId;
+ private String programId;
+
+ private String programStageId;
+
+ private String programStageInstanceId;
private String organisationUnitId;
@@ -66,26 +68,38 @@
@JsonProperty( required = true )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getEventId()
- {
- return eventId;
- }
-
- public void setEventId( String eventId )
- {
- this.eventId = eventId;
+ public String getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( String programId )
+ {
+ this.programId = programId;
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getProgramStageId()
+ {
+ return programStageId;
+ }
+
+ public void setProgramStageId( String programStageId )
+ {
+ this.programStageId = programStageId;
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getProgramStageInstanceId()
+ {
+ return programStageInstanceId;
+ }
+
+ public void setProgramStageInstanceId( String programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
}
@JsonProperty
@@ -177,8 +191,9 @@
public String toString()
{
return "Event{" +
- "id='" + id + '\'' +
- ", eventId='" + eventId + '\'' +
+ "programId='" + programId + '\'' +
+ ", programStageId='" + programStageId + '\'' +
+ ", programStageInstanceId='" + programStageInstanceId + '\'' +
", organisationUnitId='" + organisationUnitId + '\'' +
", patientId='" + patientId + '\'' +
", eventDate='" + eventDate + '\'' +