← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17247: minor changes to the web-api in displaying eventrows, allowed to return event orgunit name as thi...

 

------------------------------------------------------------
revno: 17247
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 18:53:04 +0200
message:
  minor changes to the web-api in displaying eventrows, allowed to return event orgunit name as this makes it easier to display events in tabular reports
modified:
  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
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.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/Event.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java	2014-09-09 12:54:28 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java	2014-10-23 16:53:04 +0000
@@ -59,6 +59,8 @@
     private EventStatus enrollmentStatus;
 
     private String orgUnit;
+    
+    private String orgUnitName;
 
     private String trackedEntityInstance;
 
@@ -166,6 +168,18 @@
 
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
+    public String getOrgUnitName()
+    {
+        return orgUnitName;
+    }
+
+    public void setOrgUnitName( String orgUnitName )
+    {
+        this.orgUnitName = orgUnitName;
+    }
+    
+    @JsonProperty
+    @JacksonXmlProperty( isAttribute = true )
     public String getTrackedEntityInstance()
     {
         return trackedEntityInstance;

=== 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-10-21 11:58:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java	2014-10-23 16:53:04 +0000
@@ -133,6 +133,7 @@
 
                 event.setStoredBy( rowSet.getString( "psi_completeduser" ) );
                 event.setOrgUnit( rowSet.getString( "ou_uid" ) );
+                event.setOrgUnitName( rowSet.getString( "ou_name" ) );
 
                 event.setDueDate( StringUtils.defaultIfEmpty(
                     DateUtils.getLongDateString( rowSet.getDate( "psi_duedate" ) ), DateUtils.getLongDateString( rowSet.getDate(
@@ -211,7 +212,7 @@
         String sql =
             "select pa.uid as tei_uid, pi.uid as pi_uid, pi.status as pi_status, pi.followup as pi_followup, p.uid as p_uid, " +
                 "p.type as p_type, ps.uid as ps_uid, ps.capturecoordinates as ps_capturecoordinates, pa.uid as pa_uid, " +
-                "psi.uid as psi_uid, psi.status as psi_status, ou.uid as ou_uid, " +
+                "psi.uid as psi_uid, psi.status as psi_status, ou.uid as ou_uid, ou.name as ou_name, " +
                 "psi.executiondate as psi_executiondate, psi.duedate as psi_duedate, psi.completeduser as psi_completeduser, " +
                 "psi.longitude as psi_longitude, psi.latitude as psi_latitude, " +
                 "psinote.trackedentitycommentid as psinote_id, psinote.commenttext as psinote_value, " +

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java	2014-09-18 13:36:12 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java	2014-10-23 16:53:04 +0000
@@ -41,7 +41,6 @@
 import org.hisp.dhis.event.EventStatus;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -87,11 +86,10 @@
                 eventRow.setAttributes( tei.getAttributes() );
                 eventRow.setEvent( event.getEvent() );
                 eventRow.setProgram( program.getUid() );
-                eventRow.setProgramStage( event.getProgramStage() );
-                eventRow.setEventName( manager.get( ProgramStage.class, event.getProgramStage() ).getName() );
-                eventRow.setRegistrationOrgUnit( manager.get( OrganisationUnit.class, tei.getOrgUnit() ).getName() );
+                eventRow.setProgramStage( event.getProgramStage() );                
+                eventRow.setRegistrationOrgUnit( tei.getOrgUnit() );
                 eventRow.setRegistrationDate( tei.getCreated() );
-                // eventRow.setOrgUnit( event.getOrgUnit() );
+                eventRow.setEventOrgUnitName( event.getOrgUnitName() );
                 eventRow.setDueDate( event.getDueDate() );
                 eventRow.setFollowup( event.getFollowup() );
                 eventRowList.add( eventRow );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java	2014-09-18 13:36:12 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java	2014-10-23 16:53:04 +0000
@@ -56,15 +56,13 @@
     
     private String event;
     
-    private String eventName;
-    
     private String program;
     
     private String programStage;
 
     private String enrollment;
     
-    private String eventOrgUnit; 
+    private String eventOrgUnitName;
     
     private String registrationOrgUnit;
     
@@ -120,18 +118,6 @@
     
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
-    public String getEventName()
-    {
-        return eventName;
-    }
-
-    public void setEventName( String eventName )
-    {
-        this.eventName = eventName;
-    }
-
-    @JsonProperty
-    @JacksonXmlProperty( isAttribute = true )
     public String getProgram()
     {
         return program;
@@ -192,14 +178,14 @@
 
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
-    public String getEventOrgUnit()
+    public String getEventOrgUnitName()
     {
-        return eventOrgUnit;
+        return eventOrgUnitName;
     }
 
-    public void seteventOrgUnit( String eventOrgUnit )
+    public void setEventOrgUnitName( String eventOrgUnitName )
     {
-        this.eventOrgUnit = eventOrgUnit;
+        this.eventOrgUnitName = eventOrgUnitName;
     }    
 
     @JsonProperty( required = true )
@@ -271,7 +257,7 @@
             return false;
         if ( dueDate != null ? !dueDate.equals( eventRow1.dueDate ) : eventRow1.dueDate != null )
             return false;
-        if ( eventOrgUnit != null ? !eventOrgUnit.equals( eventRow1.eventOrgUnit ) : eventRow1.eventOrgUnit != null )
+        if ( eventOrgUnitName != null ? !eventOrgUnitName.equals( eventRow1.eventOrgUnitName ) : eventRow1.eventOrgUnitName != null )
             return false;        
         if ( registrationOrgUnit != null ? !registrationOrgUnit.equals( eventRow1.registrationOrgUnit ) : eventRow1.registrationOrgUnit != null )
             return false;
@@ -295,7 +281,7 @@
         result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
         result = 31 * result + (program != null ? program.hashCode() : 0);
         result = 31 * result + (programStage != null ? programStage.hashCode() : 0);
-        result = 31 * result + (eventOrgUnit != null ? eventOrgUnit.hashCode() : 0);
+        result = 31 * result + (eventOrgUnitName != null ? eventOrgUnitName.hashCode() : 0);
         result = 31 * result + (registrationOrgUnit != null ? registrationOrgUnit.hashCode() : 0);
         result = 31 * result + (registrationDate != null ? registrationDate.hashCode() : 0);
         result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
@@ -309,11 +295,10 @@
     {
         return "Event{" + 
             "event='" + event + '\'' +
-            ", eventName=" + eventName +
             ", attributes=" + attributes +
             ", program='" + program + '\'' + 
             ", programStage='" + programStage + '\'' + 
-            ", eventOrgUnit='" + eventOrgUnit + '\'' + 
+            ", eventOrgUnitName='" + eventOrgUnitName + '\'' + 
             ", registrationOrgUnit='" + registrationOrgUnit + '\'' +
             ", registrationDate='" + registrationDate + '\'' +
             ", trackedEntityInstance='" + trackedEntityInstance + '\'' + 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2014-10-23 08:20:15 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2014-10-23 16:53:04 +0000
@@ -296,9 +296,9 @@
         return "events";
     }
 
-    @RequestMapping( value = "/overdue", method = RequestMethod.GET )
+    @RequestMapping( value = "/eventRows", method = RequestMethod.GET )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
-    public String getOverdueEvents(
+    public String getEventRows(
         @RequestParam( required = false ) String program,
         @RequestParam( required = false ) String orgUnit,
         @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,