=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2014-05-21 13:44:34 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.api.mobile.model.ActivityPlan; import org.hisp.dhis.api.mobile.model.ActivityValue; import org.hisp.dhis.api.mobile.model.Message; +import org.hisp.dhis.api.mobile.model.MessageConversation; import org.hisp.dhis.api.mobile.model.PatientAttribute; import org.hisp.dhis.api.mobile.model.User; import org.hisp.dhis.api.mobile.model.LWUITmodel.LostEvent; @@ -111,4 +112,9 @@ String sendMessage( Message message ) throws NotAllowedException; + public Collection downloadMessageConversation() + throws NotAllowedException; + + public Collection getMessage( String conversationId ) + throws NotAllowedException; } === added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Conversation.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Conversation.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Conversation.java 2014-05-21 13:44:34 +0000 @@ -0,0 +1,196 @@ +package org.hisp.dhis.api.mobile.model; + +/* + * Copyright (c) 2004-2014, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class Conversation + implements DataStreamSerializable +{ + private String clientVersion; + + private Collection conversations; + + private List conversationList = new ArrayList(); + + private Collection messages; + + private List messageList = new ArrayList(); + + public Conversation( Collection messages ) + { + this.messages = messages; + } + + public Conversation( String clientVersion, Collection conversations ) + { + this.clientVersion = clientVersion; + this.conversations = conversations; + } + + public Conversation() + { + + } + + public String getClientVersion() + { + return clientVersion; + } + + public void setClientVersion( String clientVersion ) + { + this.clientVersion = clientVersion; + } + + public Collection getConversations() + { + return conversations; + } + + public void setConversations( Collection conversations ) + { + this.conversations = conversations; + } + + public List getConversationList() + { + return conversationList; + } + + public void setConversationList( List conversationList ) + { + this.conversationList = conversationList; + } + + public Collection getMessages() + { + return messages; + } + + public void setMessages( Collection messages ) + { + this.messages = messages; + } + + public List getMessageList() + { + return messageList; + } + + public void setMessageList( List messageList ) + { + this.messageList = messageList; + } + + @Override + public void serialize( DataOutputStream dout ) + throws IOException + { + if ( conversations == null ) + { + dout.writeInt( 0 ); + } + else + { + dout.writeInt( conversations.size() ); + for ( MessageConversation conversation : conversations ) + { + conversation.setClientVersion( DataStreamSerializable.TWO_POINT_TEN ); + conversation.serialize( dout ); + } + } + + if ( messages == null ) + { + dout.writeInt( 0 ); + } + else + { + dout.writeInt( messages.size() ); + for ( Message message : messages ) + { + message.setClientVersion( DataStreamSerializable.TWO_POINT_TEN ); + message.serialize( dout ); + } + } + + } + + @Override + public void deSerialize( DataInputStream din ) + throws IOException + { + int conversationSize = din.readInt(); + + for ( int i = 0; i < conversationSize; i++ ) + { + MessageConversation conversation = new MessageConversation(); + conversation.deSerialize( din ); + conversationList.add( conversation ); + } + + int messageSize = din.readInt(); + + for ( int i = 0; i < messageSize; i++ ) + { + Message message = new Message(); + message.deSerialize( din ); + messageList.add( message ); + } + + } + + @Override + public void serializeVersion2_8( DataOutputStream dataOutputStream ) + throws IOException + { + + } + + @Override + public void serializeVersion2_9( DataOutputStream dataOutputStream ) + throws IOException + { + + } + + @Override + public void serializeVersion2_10( DataOutputStream dout ) + throws IOException + { + + } + +} === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Message.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Message.java 2014-05-16 06:06:48 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Message.java 2014-05-21 13:44:34 +0000 @@ -32,8 +32,6 @@ import java.io.DataOutputStream; import java.io.IOException; -import javax.xml.bind.annotation.XmlAttribute; - public class Message implements DataStreamSerializable { @@ -44,20 +42,10 @@ private String text; + private String lastSenderName; + private Recipient recipient; - public Message( String subject, String text, Recipient recipient ) - { - super(); - this.subject = subject; - this.text = text; - this.recipient = recipient; - } - - public Message() - { - } - public String getClientVersion() { return clientVersion; @@ -68,7 +56,6 @@ this.clientVersion = clientVersion; } - @XmlAttribute public String getSubject() { return subject; @@ -79,7 +66,6 @@ this.subject = subject; } - @XmlAttribute public String getText() { return text; @@ -90,6 +76,16 @@ this.text = text; } + public String getLastSenderName() + { + return lastSenderName; + } + + public void setLastSenderName( String lastSenderName ) + { + this.lastSenderName = lastSenderName; + } + public Recipient getRecipient() { return recipient; @@ -104,10 +100,21 @@ public void serialize( DataOutputStream dout ) throws IOException { - dout.writeUTF( this.subject ); - dout.writeUTF( this.text ); - - this.getRecipient().serialize( dout ); + + dout.writeUTF( this.getSubject() ); + dout.writeUTF( this.getText() ); + if ( this.getLastSenderName() != null ) + { + dout.writeUTF( this.getLastSenderName() ); + } + + int recipientSize = (this.recipient == null || this.recipient.getUserList() == null) ? 0 : this.recipient + .getUserList().size(); + dout.writeInt( recipientSize ); + if ( recipientSize > 0 ) + { + this.getRecipient().serialize( dout ); + } } @@ -117,6 +124,10 @@ { subject = din.readUTF(); text = din.readUTF(); + if ( lastSenderName != null ) + { + lastSenderName = din.readUTF(); + } int recipientSize = din.readInt(); @@ -150,10 +161,6 @@ public void serializeVersion2_10( DataOutputStream dataOutputStream ) throws IOException { - dataOutputStream.writeUTF( this.subject ); - dataOutputStream.writeUTF( this.text ); - - this.getRecipient().serialize( dataOutputStream ); } === added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MessageConversation.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MessageConversation.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MessageConversation.java 2014-05-21 13:44:34 +0000 @@ -0,0 +1,114 @@ +package org.hisp.dhis.api.mobile.model; + +/* + * Copyright (c) 2004-2014, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class MessageConversation + implements DataStreamSerializable +{ + private String clientVersion; + + private int id; + + private String subject; + + public String getClientVersion() + { + return clientVersion; + } + + public void setClientVersion( String clientVersion ) + { + this.clientVersion = clientVersion; + } + + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + + public String getSubject() + { + return subject; + } + + public void setSubject( String subject ) + { + this.subject = subject; + } + + @Override + public void serialize( DataOutputStream dout ) + throws IOException + { + dout.writeInt( id ); + dout.writeUTF( subject ); + + } + + @Override + public void deSerialize( DataInputStream din ) + throws IOException + { + + this.id = din.readInt(); + this.subject = din.readUTF(); + + } + + @Override + public void serializeVersion2_8( DataOutputStream dataOutputStream ) + throws IOException + { + + } + + @Override + public void serializeVersion2_9( DataOutputStream dataOutputStream ) + throws IOException + { + + } + + @Override + public void serializeVersion2_10( DataOutputStream dataOutputStream ) + throws IOException + { + + } + +} === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2014-05-21 13:44:34 +0000 @@ -68,9 +68,13 @@ private String sendFeedbackUrl; private String findUserUrl; - + private String sendMessageUrl; + private String downloadMessageConversationUrl; + + private String getMessageUrl; + private String updateContactUrl; private String findPatientUrl; @@ -242,8 +246,6 @@ { this.findUserUrl = findUserUrl; } - - public String getSendMessageUrl() { @@ -255,6 +257,26 @@ this.sendMessageUrl = sendMessageUrl; } + public String getDownloadMessageConversationUrl() + { + return downloadMessageConversationUrl; + } + + public void setDownloadMessageConversationUrl( String downloadMessageConversationUrl ) + { + this.downloadMessageConversationUrl = downloadMessageConversationUrl; + } + + public String getGetMessageUrl() + { + return getMessageUrl; + } + + public void setGetMessageUrl( String getMessageUrl ) + { + this.getMessageUrl = getMessageUrl; + } + public String getUpdateContactUrl() { return updateContactUrl; @@ -422,6 +444,8 @@ dataOutputStream.writeUTF( sendFeedbackUrl ); dataOutputStream.writeUTF( findUserUrl ); dataOutputStream.writeUTF( sendMessageUrl ); + dataOutputStream.writeUTF( downloadMessageConversationUrl ); + dataOutputStream.writeUTF( getMessageUrl ); dataOutputStream.writeUTF( updateContactUrl ); dataOutputStream.writeUTF( findPatientUrl ); dataOutputStream.writeUTF( registerPersonUrl ); @@ -457,6 +481,8 @@ sendFeedbackUrl = dataInputStream.readUTF(); findUserUrl = dataInputStream.readUTF(); sendMessageUrl = dataInputStream.readUTF(); + downloadMessageConversationUrl = dataInputStream.readUTF(); + getMessageUrl = dataInputStream.readUTF(); updateContactUrl = dataInputStream.readUTF(); findPatientUrl = dataInputStream.readUTF(); registerPersonUrl = dataInputStream.readUTF(); @@ -509,6 +535,8 @@ dataOutputStream.writeUTF( this.sendFeedbackUrl ); dataOutputStream.writeUTF( this.findUserUrl ); dataOutputStream.writeUTF( this.sendMessageUrl ); + dataOutputStream.writeUTF( this.downloadMessageConversationUrl ); + dataOutputStream.writeUTF( this.getMessageUrl ); // dataOutputStream.writeUTF( this.updateContactUrl ); } @@ -530,6 +558,8 @@ dataOutputStream.writeUTF( sendFeedbackUrl ); dataOutputStream.writeUTF( findUserUrl ); dataOutputStream.writeUTF( sendMessageUrl ); + dataOutputStream.writeUTF( downloadMessageConversationUrl ); + dataOutputStream.writeUTF( getMessageUrl ); dataOutputStream.writeUTF( updateContactUrl ); dataOutputStream.writeUTF( findPatientUrl ); dataOutputStream.writeUTF( registerPersonUrl ); === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/User.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/User.java 2014-05-16 06:06:48 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/User.java 2014-05-21 13:44:34 +0000 @@ -147,4 +147,4 @@ } -} +} \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-21 09:48:18 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-21 13:44:34 +0000 @@ -1972,4 +1972,56 @@ return MESSAGE_SENT; } + + @Override + public Collection downloadMessageConversation() + throws NotAllowedException + { + Collection conversations = new HashSet(); + + Collection mobileConversationList = new HashSet(); + + conversations = new ArrayList( messageService.getMessageConversations( 0, 10 ) ); + + for ( MessageConversation conversation : conversations ) + { + if ( conversation.getLastSenderFirstname() != null ) + { + org.hisp.dhis.api.mobile.model.MessageConversation messConversation = new org.hisp.dhis.api.mobile.model.MessageConversation(); + messConversation.setId( conversation.getId() ); + messConversation.setSubject( conversation.getSubject() ); + mobileConversationList.add( messConversation ); + } + + } + + return mobileConversationList; + } + + @Override + public Collection getMessage( String conversationId ) + throws NotAllowedException + { + + MessageConversation conversation = messageService.getMessageConversation( Integer.parseInt( conversationId ) ); + List messageList = new ArrayList( conversation.getMessages() ); + + Collection messages = new HashSet(); + + for ( Message message : messageList ) + { + + if ( message.getSender().getFirstName() != null ) + { + + org.hisp.dhis.api.mobile.model.Message messageMobile = new org.hisp.dhis.api.mobile.model.Message(); + messageMobile.setSubject( conversation.getSubject() ); + messageMobile.setText( message.getText() ); + messageMobile.setLastSenderName( message.getSender().getName() ); + messages.add( messageMobile ); + } + } + + return messages; + } } \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java' --- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2014-05-21 13:44:34 +0000 @@ -62,6 +62,8 @@ unit.setSendFeedbackUrl( "sendFeedbackUrl" ); unit.setFindUserUrl( "findUserUrl" ); unit.setSendMessageUrl( "sendMessageUrl" ); + unit.setDownloadMessageConversationUrl( "downloadMessageConversationUrl" ); + unit.setGetMessageUrl( "getMessageUrl" ); unit.setUpdateContactUrl( "updateContactUrl" ); unit.setFindPatientUrl( "findPatientUrl" ); unit.setUploadProgramStageUrl( "uploadProgramStageUrl" ); === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java' --- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2014-05-21 13:44:34 +0000 @@ -88,6 +88,8 @@ orgUnit.setSendFeedbackUrl( "sendFeedback" ); orgUnit.setFindUserUrl( "findUser" ); orgUnit.setSendMessageUrl( "sendMessage" ); + orgUnit.setDownloadMessageConversationUrl( "downloadMessageConversation" ); + orgUnit.setGetMessageUrl( "getMessage" ); orgUnit.setUpdateContactUrl( "updateContactForMobile" ); orgUnit.setFindPatientUrl( "findPatient" ); orgUnit.setRegisterPersonUrl( "registerPerson" ); === modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java' --- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2014-05-21 13:44:34 +0000 @@ -149,7 +149,9 @@ orgUnit.setUpdateNewVersionUrl( getUrl( request, unit.getId(), "updateNewVersionUrl" ) ); orgUnit.setSendFeedbackUrl( getUrl( request, unit.getId(), "sendFeedback" ) ); orgUnit.setFindUserUrl( getUrl( request, unit.getId(), "findUser" ) ); - orgUnit.setSendMessageUrl(getUrl( request, unit.getId(), "sendMessage" )); + orgUnit.setSendMessageUrl( getUrl( request, unit.getId(), "sendMessage" ) ); + orgUnit.setDownloadMessageConversationUrl( getUrl( request, unit.getId(), "downloadMessageConversation" ) ); + orgUnit.setGetMessageUrl( getUrl( request, unit.getId(), "getMessage" ) ); orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) ); orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) ); orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) ); === modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java' --- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2014-05-21 09:03:33 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2014-05-21 13:44:34 +0000 @@ -40,6 +40,7 @@ import org.hisp.dhis.api.mobile.NotAllowedException; import org.hisp.dhis.api.mobile.model.ActivityValue; import org.hisp.dhis.api.mobile.model.Contact; +import org.hisp.dhis.api.mobile.model.Conversation; import org.hisp.dhis.api.mobile.model.DataSetList; import org.hisp.dhis.api.mobile.model.DataSetValue; import org.hisp.dhis.api.mobile.model.DataSetValueList; @@ -112,7 +113,9 @@ // For client version 2.8 and lower @RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/all" ) @ResponseBody - public MobileModel getAllDataForOrgUnit2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale ) + public MobileModel getAllDataForOrgUnit2_8( @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale ) { MobileModel mobileModel = new MobileModel(); mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT ); @@ -127,8 +130,10 @@ @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/updateDataSets" ) @ResponseBody - public DataSetList checkUpdatedDataSet2_8( @PathVariable int id, @RequestBody DataSetList dataSetList, - @RequestHeader( "accept-language" ) String locale ) + public DataSetList checkUpdatedDataSet2_8( @PathVariable + int id, @RequestBody + DataSetList dataSetList, @RequestHeader( "accept-language" ) + String locale ) { DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale ); returnList.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT ); @@ -143,7 +148,9 @@ */ @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/dataSets" ) @ResponseBody - public String saveDataSetValues2_8( @PathVariable int id, @RequestBody DataSetValue dataSetValue ) + public String saveDataSetValues2_8( @PathVariable + int id, @RequestBody + DataSetValue dataSetValue ) throws NotAllowedException { facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue ); @@ -159,7 +166,9 @@ */ @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activities" ) @ResponseBody - public String saveActivityReport2_8( @PathVariable int id, @RequestBody ActivityValue activityValue ) + public String saveActivityReport2_8( @PathVariable + int id, @RequestBody + ActivityValue activityValue ) throws NotAllowedException { // FIXME set the last argument to 0 to fix compilation error @@ -169,8 +178,10 @@ @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activitiyplan" ) @ResponseBody - public MobileModel updatePrograms2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale, - @RequestBody ModelList programsFromClient ) + public MobileModel updatePrograms2_8( @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale, @RequestBody + ModelList programsFromClient ) { MobileModel model = new MobileModel(); model.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT ); @@ -182,7 +193,9 @@ @RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/changeLanguageDataSet" ) @ResponseBody - public DataSetList changeLanguageDataSet2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale ) + public DataSetList changeLanguageDataSet2_8( @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale ) { return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale ); } @@ -191,8 +204,10 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/all" ) @ResponseBody - public MobileModel getAllDataForOrgUnit( @PathVariable String clientVersion, @PathVariable int id, - @RequestHeader( "accept-language" ) String locale ) + public MobileModel getAllDataForOrgUnit( @PathVariable + String clientVersion, @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale ) { MobileModel mobileModel = new MobileModel(); mobileModel.setClientVersion( clientVersion ); @@ -210,8 +225,11 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/updateDataSets" ) @ResponseBody - public DataSetList checkUpdatedDataSet( @PathVariable String clientVersion, @PathVariable int id, - @RequestBody DataSetList dataSetList, @RequestHeader( "accept-language" ) String locale ) + public DataSetList checkUpdatedDataSet( @PathVariable + String clientVersion, @PathVariable + int id, @RequestBody + DataSetList dataSetList, @RequestHeader( "accept-language" ) + String locale ) { DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale ); returnList.setClientVersion( clientVersion ); @@ -227,7 +245,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/dataSets" ) @ResponseBody - public String saveDataSetValues( @PathVariable int id, @RequestBody DataSetValue dataSetValue ) + public String saveDataSetValues( @PathVariable + int id, @RequestBody + DataSetValue dataSetValue ) throws NotAllowedException { facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue ); @@ -236,7 +256,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/dataSetValue" ) @ResponseBody - public DataSetValueList getDataSetValues( @PathVariable int id, @RequestBody DataSetList dataSetList ) + public DataSetValueList getDataSetValues( @PathVariable + int id, @RequestBody + DataSetList dataSetList ) throws NotAllowedException { return facilityReportingService.getDataSetValues( getUnit( id ), dataSetList ); @@ -244,8 +266,11 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activitiyplan" ) @ResponseBody - public MobileModel updatePrograms( @PathVariable String clientVersion, @PathVariable int id, - @RequestHeader( "accept-language" ) String locale, @RequestBody ModelList programsFromClient ) + public MobileModel updatePrograms( @PathVariable + String clientVersion, @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale, @RequestBody + ModelList programsFromClient ) { MobileModel model = new MobileModel(); model.setClientVersion( clientVersion ); @@ -283,7 +308,9 @@ */ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activities" ) @ResponseBody - public String saveActivityReport( @PathVariable int id, @RequestBody ActivityValue activityValue ) + public String saveActivityReport( @PathVariable + int id, @RequestBody + ActivityValue activityValue ) throws NotAllowedException { // FIXME set the last argument to 0 to fix compilation error @@ -293,7 +320,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/changeLanguageDataSet" ) @ResponseBody - public DataSetList changeLanguageDataSet( @PathVariable int id, @RequestHeader( "accept-language" ) String locale ) + public DataSetList changeLanguageDataSet( @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale ) { return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale ); } @@ -307,8 +336,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/all" ) @ResponseBody - public org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel getAllDataForOrgUnitLWUIT( - @PathVariable String clientVersion, @PathVariable int id ) + public org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel getAllDataForOrgUnitLWUIT( @PathVariable + String clientVersion, @PathVariable + int id ) { org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel mobileModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel(); mobileModel.setClientVersion( clientVersion ); @@ -327,7 +357,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatient" ) @ResponseBody - public Patient findPatientByName( @PathVariable int id, @RequestHeader( "patientId" ) String patientId ) + public Patient findPatientByName( @PathVariable + int id, @RequestHeader( "patientId" ) + String patientId ) throws NotAllowedException { return activityReportingService.findPatient( Integer.parseInt( patientId ) ); @@ -335,8 +367,10 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatientInAdvanced/{programId}" ) @ResponseBody - public String findPatientInAdvanced( @PathVariable int programId, @PathVariable int id, - @RequestHeader( "name" ) String keyword ) + public String findPatientInAdvanced( @PathVariable + int programId, @PathVariable + int id, @RequestHeader( "name" ) + String keyword ) throws NotAllowedException { return activityReportingService.findPatientInAdvanced( keyword, id, programId ); @@ -344,8 +378,10 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/uploadProgramStage/{patientId}" ) @ResponseBody - public String saveProgramStage( @PathVariable int patientId, @PathVariable int id, - @RequestBody ProgramStage programStage ) + public String saveProgramStage( @PathVariable + int patientId, @PathVariable + int id, @RequestBody + ProgramStage programStage ) throws NotAllowedException { return activityReportingService.saveProgramStage( programStage, patientId, id ); @@ -353,7 +389,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/uploadSingleEventWithoutRegistration" ) @ResponseBody - public String saveSingleEventWithoutRegistration( @PathVariable int id, @RequestBody ProgramStage programStage ) + public String saveSingleEventWithoutRegistration( @PathVariable + int id, @RequestBody + ProgramStage programStage ) throws NotAllowedException { return activityReportingService.saveSingleEventWithoutRegistration( programStage, id ); @@ -361,7 +399,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/enrollProgram" ) @ResponseBody - public Patient enrollProgram( @PathVariable int id, @RequestHeader( "enrollInfo" ) String enrollInfo ) + public Patient enrollProgram( @PathVariable + int id, @RequestHeader( "enrollInfo" ) + String enrollInfo ) throws NotAllowedException { return activityReportingService.enrollProgram( enrollInfo, null, new Date() ); @@ -369,7 +409,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/addRelationship" ) @ResponseBody - public Patient addRelationship( @PathVariable int id, @RequestBody Relationship enrollmentRelationship ) + public Patient addRelationship( @PathVariable + int id, @RequestBody + Relationship enrollmentRelationship ) throws NotAllowedException { return activityReportingService.addRelationship( enrollmentRelationship, id ); @@ -377,7 +419,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/downloadAnonymousProgram" ) @ResponseBody - public Program getAnonymousProgram( @PathVariable int id, @RequestHeader( "programType" ) String programType ) + public Program getAnonymousProgram( @PathVariable + int id, @RequestHeader( "programType" ) + String programType ) throws NotAllowedException { return activityReportingService.getAllProgramByOrgUnit( id, programType ); @@ -385,7 +429,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findProgram" ) @ResponseBody - public Program findProgram( @PathVariable int id, @RequestHeader( "info" ) String programInfo ) + public Program findProgram( @PathVariable + int id, @RequestHeader( "info" ) + String programInfo ) throws NotAllowedException { return activityReportingService.findProgram( programInfo ); @@ -393,7 +439,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findLostToFollowUp" ) @ResponseBody - public String findLostToFollowUp( @PathVariable int id, @RequestHeader( "searchEventInfos" ) String searchEventInfos ) + public String findLostToFollowUp( @PathVariable + int id, @RequestHeader( "searchEventInfos" ) + String searchEventInfos ) throws NotAllowedException { return activityReportingService.findLostToFollowUp( id, searchEventInfos ); @@ -401,7 +449,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/handleLostToFollowUp" ) @ResponseBody - public Notification handleLostToFollowUp( @PathVariable int id, @RequestBody LostEvent lostEvent ) + public Notification handleLostToFollowUp( @PathVariable + int id, @RequestBody + LostEvent lostEvent ) throws NotAllowedException { return activityReportingService.handleLostToFollowUp( lostEvent ); @@ -409,7 +459,9 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/generateRepeatableEvent" ) @ResponseBody - public Patient generateRepeatableEvent( @PathVariable int id, @RequestHeader( "eventInfo" ) String eventInfo ) + public Patient generateRepeatableEvent( @PathVariable + int id, @RequestHeader( "eventInfo" ) + String eventInfo ) throws NotAllowedException { return activityReportingService.generateRepeatableEvent( id, eventInfo ); @@ -467,8 +519,10 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/registerPerson" ) @ResponseBody - public Patient savePatient( @PathVariable int id, @RequestBody Patient patient, - @RequestHeader( "programid" ) String programId ) + public Patient savePatient( @PathVariable + int id, @RequestBody + Patient patient, @RequestHeader( "programid" ) + String programId ) throws NotAllowedException { return activityReportingService.savePatient( patient, id, programId ); @@ -476,8 +530,11 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/getVariesInfo" ) @ResponseBody - public PatientIdentifierAndAttribute getVariesInfo( @PathVariable String clientVersion, @PathVariable int id, - @RequestHeader( "accept-language" ) String locale, @RequestHeader( "programid" ) String programId ) + public PatientIdentifierAndAttribute getVariesInfo( @PathVariable + String clientVersion, @PathVariable + int id, @RequestHeader( "accept-language" ) + String locale, @RequestHeader( "programid" ) + String programId ) { PatientIdentifierAndAttribute patientIdentifierAndAttribute = new PatientIdentifierAndAttribute(); patientIdentifierAndAttribute.setClientVersion( clientVersion ); @@ -489,7 +546,9 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/sendFeedback" ) @ResponseBody - public String sendFeedback( @PathVariable int id, @RequestBody Message message ) + public String sendFeedback( @PathVariable + int id, @RequestBody + Message message ) throws NotAllowedException { return activityReportingService.sendFeedback( message ); @@ -498,19 +557,22 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/findUser" ) @ResponseBody - public Recipient findUser( String clientVersion, @PathVariable int id, @RequestHeader( "name" ) String keyword ) + public Recipient findUser( String clientVersion, @PathVariable + int id, @RequestHeader( "name" ) + String keyword ) throws NotAllowedException { Recipient recipient = new Recipient(); - recipient.setClientVersion( clientVersion ); recipient.setUsers( activityReportingService.findUser( keyword ) ); return recipient; } @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findVisitSchedule/{programId}" ) @ResponseBody - public String findVisitSchedule( @PathVariable int programId, @PathVariable int id, - @RequestHeader( "details" ) String info ) + public String findVisitSchedule( @PathVariable + int programId, @PathVariable + int id, @RequestHeader( "details" ) + String info ) throws NotAllowedException { return activityReportingService.findVisitSchedule( id, programId, info ); @@ -518,10 +580,41 @@ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/sendMessage" ) @ResponseBody - public String sendMessage( @PathVariable int id, @RequestBody Message message ) + public String sendMessage( @PathVariable + int id, @RequestBody + Message message ) throws NotAllowedException { return activityReportingService.sendMessage( message ); } + @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/downloadMessageConversation" ) + @ResponseBody + public Conversation downloadConversation( String clientVersion ) + throws NotAllowedException + { + + Conversation conversation = new Conversation(); + conversation.setClientVersion( clientVersion ); + conversation.setConversations( activityReportingService.downloadMessageConversation() ); + + return conversation; + + } + + @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/getMessage" ) + @ResponseBody + public Conversation getMessage( String clientVersion, @PathVariable + int id, @RequestHeader( "id" ) + String conversationId ) + throws NotAllowedException + { + + Conversation conversation = new Conversation(); + conversation.setMessages( activityReportingService.getMessage( conversationId ) ); + + return conversation; + + } + }