dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31395
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15973: web api - multiple notes for events
------------------------------------------------------------
revno: 15973
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Sun 2014-07-06 14:44:31 +0200
message:
web api - multiple notes for events
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/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-07-02 16:24:42 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-07-06 12:44:31 +0000
@@ -411,8 +411,6 @@
programStageInstanceService.updateProgramStageInstance( programStageInstance );
- //ProgramInstance programInstance = programStageInstance.getProgramInstance();
-
saveTrackedEntityComment( programStageInstance, event, storedBy );
Set<TrackedEntityDataValue> dataValues = new HashSet<TrackedEntityDataValue>(
@@ -814,6 +812,7 @@
{
for ( Note note : event.getNotes() )
{
+ System.out.println("The note I am about to save is: " + note.getValue());
TrackedEntityComment comment = new TrackedEntityComment();
comment.setCreator( storedBy );
comment.setCreatedDate( new Date() );
=== 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-24 14:23:58 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-07-06 12:44:31 +0000
@@ -35,7 +35,9 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -100,6 +102,8 @@
Event event = new Event();
event.setEvent( "not_valid" );
+
+ Set<String> notes = new HashSet<String>();
while ( rowSet.next() )
{
@@ -169,6 +173,24 @@
dataValue.setStoredBy( rowSet.getString( "pdv_storedby" ) );
event.getDataValues().add( dataValue );
+
+ if ( rowSet.getString( "psinote_value" ) == null )
+ {
+ continue;
+ }
+
+ if( !notes.contains( rowSet.getString( "psinote_id" ) ) )
+ {
+ Note note = new Note();
+ note.setValue( rowSet.getString( "psinote_value" ) );
+ note.setStoredDate( StringUtils.defaultIfEmpty(
+ rowSet.getString( "psinote_soreddate" ), rowSet.getString( "psinote_soreddate" ) ) );
+ note.setStoredBy( rowSet.getString( "psinote_storedby" ) );
+
+ event.getNotes().add( note );
+ notes.add( rowSet.getString( "psinote_id" ) );
+ }
+
}
return events;
@@ -182,11 +204,14 @@
String sql =
"select p.uid as p_uid, 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.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, psinote.createddate as psinote_soreddate, psinote.creator as psinote_storedby, " +
"pdv.value as pdv_value, pdv.storedby as pdv_storedby, pdv.providedelsewhere as pdv_providedelsewhere, de.uid as de_uid " +
"from program p " +
"left join programstage ps on ps.programid=p.programid " +
"left join programstageinstance psi on ps.programstageid=psi.programstageid " +
- "left join programinstance pi on pi.programinstanceid=psi.programinstanceid ";
+ "left join programinstance pi on pi.programinstanceid=psi.programinstanceid " +
+ "left join programstageinstancecomments psic on psi.programstageinstanceid=psic.programstageinstanceid " +
+ "left join trackedentitycomment psinote on psic.trackedentitycommentid=psinote.trackedentitycommentid ";
if ( status == null || EventStatus.isExistingEvent( status ) )
{