=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java 2012-06-04 06:37:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java 2012-06-06 07:48:54 +0000 @@ -49,6 +49,8 @@ void update( IncomingSms sms ); + IncomingSms findBy ( Integer id ); + List listAllMessage(); List listAllMessageFromModem(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java 2012-06-04 06:37:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java 2012-06-06 07:48:54 +0000 @@ -37,6 +37,8 @@ static final String ID = IncomingSmsStore.class.getName(); int save( IncomingSms incomingSms ); + + void update ( IncomingSms incomingSms ); IncomingSms get( int id ); === modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java' --- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java 2012-06-04 06:37:01 +0000 +++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java 2012-06-06 07:48:54 +0000 @@ -150,6 +150,12 @@ } @Override + public IncomingSms findBy( Integer id ) + { + return incomingSmsStore.get( id ); + } + + @Override public IncomingSms getNextUnprocessed() { // TODO Auto-generated method stub @@ -157,9 +163,9 @@ } @Override - public void update( IncomingSms sms ) + public void update( IncomingSms incomingSms ) { - // TODO Auto-generated method stub + incomingSmsStore.update( incomingSms ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java' --- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java 2012-06-04 06:37:01 +0000 +++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java 2012-06-06 07:48:54 +0000 @@ -32,6 +32,7 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.sms.incoming.IncomingSms; @@ -90,7 +91,7 @@ @Override public Collection getAllSmses() { - return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).list(); + return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).addOrder( Order.asc( "id" ) ).list(); } @Override @@ -109,6 +110,12 @@ sessionFactory.getCurrentSession().delete( incomingSms ); } + @Override + public void update( IncomingSms incomingSms ) + { + sessionFactory.getCurrentSession().update( incomingSms ); + } + // @Override // public Collection getSms( String originator, Date startDate, // Date endDate ) === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/UpdateReceiveSMSAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/UpdateReceiveSMSAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/UpdateReceiveSMSAction.java 2012-06-06 07:48:54 +0000 @@ -0,0 +1,89 @@ +package org.hisp.dhis.mobile.action.incoming; + +/* + * Copyright (c) 2004-2012, 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 org.hisp.dhis.sms.incoming.IncomingSms; +import org.hisp.dhis.sms.incoming.IncomingSmsService; + +import com.opensymphony.xwork2.Action; + +/** +* @author Nguyen Kim Lai +* @version $Id$ +*/ + +public class UpdateReceiveSMSAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IncomingSmsService incomingSmsService; + + public void setIncomingSmsService( IncomingSmsService incomingSmsService ) + { + this.incomingSmsService = incomingSmsService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String text; + + public void setText( String text ) + { + this.text = text; + } + + @Override + public String execute() + throws Exception + { + System.out.println("welcome to update sMS function!!!!"); + System.out.println("id: " + id); + System.out.println("text: " + text); + + IncomingSms incomingSms = incomingSmsService.findBy( id ); + + incomingSms.setText( text ); + + incomingSmsService.update( incomingSms ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-06-04 06:37:01 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-06-06 07:48:54 +0000 @@ -32,6 +32,13 @@ + + + + plainTextError + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm plainTextError === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm 2012-06-04 09:56:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm 2012-06-06 07:48:54 +0000 @@ -63,8 +63,7 @@ } else { showMessage( json.message ); } - } - ); + }); } } else @@ -94,9 +93,9 @@ if ( json.response == "success") { showSuccessMessage( "Import Successfully!" ); } else { - showErrorMessage( "eggor!" ); + showErrorMessage( "error!" ); } - }) + }); } else { @@ -107,12 +106,44 @@ { removeItem( key, name, i18n_confirm_delete, "deleteReceiveSMS.action" ); }; + + function makeVisible( idInput, idText ) + { + if ( document.getElementById( idInput ).type == 'hidden') + { + document.getElementById( idInput ).type = 'text'; + + jQuery( '#' + idInput).focus(); + tmpStr = jQuery( '#' + idInput).val(); + jQuery( '#' + idInput).val(''); + jQuery( '#' + idInput).val(tmpStr); + + document.getElementById( idText ).style.display = 'none'; + } + else + { + document.getElementById( idInput ).type = 'hidden'; + document.getElementById( idText ).style.display = 'block'; + + jQuery.get( 'updateReceiveSMS.action', {id: idInput, text: getFieldValue( ''+idInput )}, + function ( json ) + { + if ( json.response == "success" ) { + //jQuery( 'label[id=' + idText + '] > a' ).html( getFieldValue( idInput ) ); + jQuery( 'a[id=' + idText + ']' ).html( getFieldValue( idInput ) ); + showSuccessMessage( "$i18n.getString( 'update_success' )" ); + } else { + showErrorMessage( "error!" ); + } + } + ); + } + }; var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_sms" ) , "'")';

$i18n.getString( "show_receive_sms_form" )

-

@@ -128,11 +159,14 @@ + #foreach( $incomingSms in $listIncomingSms ) - - + +
$i18n.getString( "delete" )
$velocityCount$incomingSms.getText()$incomingSms.getOriginator() + $incomingSms.text + $incomingSms.originator update $i18n.getString( 'remove' )