dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17770
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7203: Add update incoming SMS function
------------------------------------------------------------
revno: 7203
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-06 14:48:54 +0700
message:
Add update incoming SMS function
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/UpdateReceiveSMSAction.java
modified:
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/IncomingSmsStore.java
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/HibernateIncomingSmsStore.java
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/org/hisp/dhis/mobile/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm
--
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-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<IncomingSms> listAllMessage();
List<IncomingSms> 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<IncomingSms> 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<IncomingSms> 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 @@
<property name="incomingSmsService"
ref="org.hisp.dhis.sms.incoming.IncomingSmsService" />
</bean>
+
+ <bean id="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
+ class="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
+ scope="prototype">
+ <property name="incomingSmsService"
+ ref="org.hisp.dhis.sms.incoming.IncomingSmsService" />
+ </bean>
<bean id="org.hisp.dhis.mobile.action.incoming.ImportReceiveSMSAction"
class="org.hisp.dhis.mobile.action.incoming.ImportReceiveSMSAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-06-04 08:37:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-06-06 07:48:54 +0000
@@ -75,10 +75,11 @@
send_sms_to_target=Send SMS to
list_sent_SMS =List Of Sent SMS
show_receive_sms_form =Receive SMS
+update_success=Update Successfully
config_my_gateway =Configure My Gateway
delete_checked_option =Delete Checked Options
import =Import
-error_import=Please check before import
+error_import=Please Check Before Import
phone_number=Phone number
raw_phone_number=Raw phone numbers
assigned_user_number=User assigned to organisation unit
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-06-04 08:37:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-06-06 07:48:54 +0000
@@ -57,6 +57,11 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="updateReceiveSMS" class="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<action name="importReceiveSMS" class="org.hisp.dhis.mobile.action.incoming.ImportReceiveSMSAction">
<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="onExceptionReturn">plainTextError</param>
=== 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" ) , "'")';
</script>
<h3>$i18n.getString( "show_receive_sms_form" )</h3>
-
<form id="receiveSmsPage" name="receiveSmsPage" action="showReceivingPage.action" method="post" >
<br/>
<table id="detailsSmsList" class="listTable" style="width:800px">
@@ -128,11 +159,14 @@
<th style="text-align:center">$i18n.getString( "delete" )</th>
<th style="text-align:center"><a href="#" onclick="checkAll()" title="$i18n.getString( 'check_all' )"><img src="../images/check.png"/></a></th>
</thead>
+
#foreach( $incomingSms in $listIncomingSms )
<tr id="tr${incomingSms.id}">
<td style="text-align:center">$velocityCount</td>
- <td>$incomingSms.getText()</td>
- <td>$incomingSms.getOriginator()</td>
+ <td>
+ <a id="$velocityCount" style="display: block" href="#" onclick="makeVisible( $incomingSms.id, $velocityCount )">$incomingSms.text</a>
+ <input type="hidden" id="$incomingSms.id" value="$incomingSms.text" onblur="makeVisible( $incomingSms.id, $velocityCount )"/></td>
+ <td>$incomingSms.originator</td>
<td>update</td>
<td style="text-align:center"><a href="javascript:removeSingleItem( '$incomingSms.id', '$incomingSms.getText()' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></td>
<td style="text-align:center"><input type="checkbox" name="mycheck" value="$incomingSms.id"/></td>