dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19616
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8634: Add 'Outbox' function to supervise the message queue
------------------------------------------------------------
revno: 8634
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-22 15:51:28 +0700
message:
Add 'Outbox' function to supervise the message queue
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/DeleteSentSMSAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSentSMSAction.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/showSentSMSPage.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/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2012-10-22 08:51:28 +0000
@@ -57,5 +57,7 @@
void updateOutboundSms( OutboundSms sms);
+ void deleteById( Integer outboundSmsId );
+
List<OutboundSms> getOutboundSms( OutboundSmsStatus status );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java 2012-10-22 08:51:28 +0000
@@ -39,5 +39,7 @@
OutboundSms get( int id );
- List<OutboundSms> get( OutboundSmsStatus status );
+ List<OutboundSms> get( OutboundSmsStatus status );
+
+ void delete( OutboundSms sms );
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java 2012-10-01 04:52:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java 2012-10-22 08:51:28 +0000
@@ -36,7 +36,9 @@
import org.hibernate.SessionFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
+import org.springframework.transaction.annotation.Transactional;
+@Transactional
public class HibernateOutboundSmsStore
implements OutboundSmsStore
{
@@ -135,4 +137,10 @@
{
sessionFactory.getCurrentSession().update( sms );
}
+
+ @Override
+ public void delete( OutboundSms sms )
+ {
+ sessionFactory.getCurrentSession().delete( sms );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-09-14 09:11:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-10-22 08:51:28 +0000
@@ -131,7 +131,13 @@
public int saveOutboundSms(OutboundSms sms) {
return outboundSmsStore.save( sms );
}
-
+
+ @Override
+ public void deleteById( Integer outboundSmsId )
+ {
+ OutboundSms sms = outboundSmsStore.get( outboundSmsId );
+ outboundSmsStore.delete( sms );
+ }
// -------------------------------------------------------------------------
// Support methods
// -------------------------------------------------------------------------
@@ -151,4 +157,5 @@
}
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2012-10-22 08:51:28 +0000
@@ -125,4 +125,11 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public void deleteById( Integer outboundSmsId )
+ {
+ // TODO Auto-generated method stub
+
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-09-18 07:53:45 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-10-22 08:51:28 +0000
@@ -485,4 +485,12 @@
{
return outboundSmsStore.get( status );
}
+
+ @Override
+ public void deleteById( Integer outboundSmsId )
+ {
+ OutboundSms sms = outboundSmsStore.get( outboundSmsId );
+
+ outboundSmsStore.delete( sms );
+ }
}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/DeleteSentSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/DeleteSentSMSAction.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/DeleteSentSMSAction.java 2012-10-22 08:51:28 +0000
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.hisp.dhis.mobile.action;
+
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Nguyen Kim Lai
+ *
+ * @version $ DeleteSentSMSAction.java Oct 16, 2012 $
+ */
+public class DeleteSentSMSAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OutboundSmsService outboundSmsService;
+
+ public void setOutboundSmsService( OutboundSmsService outboundSmsService )
+ {
+ this.outboundSmsService = outboundSmsService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer[] ids;
+
+ public void setIds( Integer[] ids )
+ {
+ this.ids = ids;
+ }
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ if ( ids != null && ids.length > 0 )
+ {
+ for ( Integer each : ids )
+ {
+ outboundSmsService.deleteById( each );
+ }
+ }
+ if ( id != null )
+ {
+ outboundSmsService.deleteById( id );
+ }
+ return SUCCESS;
+
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSentSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSentSMSAction.java 2012-06-04 06:37:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSentSMSAction.java 2012-10-22 08:51:28 +0000
@@ -1,9 +1,14 @@
package org.hisp.dhis.mobile.action;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.SchedulingProgramObject;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
import com.opensymphony.xwork2.Action;
@@ -22,26 +27,83 @@
this.outboundSmsService = outboundSmsService;
}
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
- private List<OutboundSms> ListOutboundSMS;
+ private List<OutboundSms> listOutboundSMS;
public List<OutboundSms> getListOutboundSMS()
{
- return ListOutboundSMS;
- }
-
+ return listOutboundSMS;
+ }
+
+ private Integer filterStatusType;
+
+ public Integer getFilterStatusType()
+ {
+ return filterStatusType;
+ }
+
+ public void setFilterStatusType( Integer filterStatusType )
+ {
+ this.filterStatusType = filterStatusType;
+ }
+
+ private Collection<SchedulingProgramObject> schedulingProgramObjects;
+
+ public Collection<SchedulingProgramObject> getSchedulingProgramObjects()
+ {
+ return schedulingProgramObjects;
+ }
+
// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
-
+
@Override
public String execute()
throws Exception
{
- ListOutboundSMS = outboundSmsService.getAllOutboundSms();
+ List<OutboundSms> tempListOutboundSMS = outboundSmsService.getAllOutboundSms();
+
+ listOutboundSMS = new ArrayList<OutboundSms>();
+
+ if ( filterStatusType != null && filterStatusType == 0)
+ {
+ for ( OutboundSms each: tempListOutboundSMS )
+ {
+ if (each.getStatus().equals( OutboundSmsStatus.OUTBOUND ))
+ {
+ this.listOutboundSMS.add( each );
+ }
+ }
+ }
+ if ( filterStatusType != null && filterStatusType == 1 )
+ {
+ for ( OutboundSms each: tempListOutboundSMS )
+ {
+ if (each.getStatus().equals( OutboundSmsStatus.SENT ))
+ {
+ this.listOutboundSMS.add( each );
+ }
+ }
+ }
+ if ( filterStatusType != null && filterStatusType == 2 || filterStatusType == null)
+ {
+ for ( OutboundSms each: tempListOutboundSMS )
+ {
+ this.listOutboundSMS.add( each );
+ }
+ }
+ schedulingProgramObjects = programStageInstanceService.getSendMesssageEvents();
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-08-22 07:08:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-10-22 08:51:28 +0000
@@ -32,6 +32,13 @@
<property name="incomingSmsService"
ref="org.hisp.dhis.sms.incoming.IncomingSmsService" />
</bean>
+
+ <bean id="org.hisp.dhis.mobile.action.DeleteSentSMSAction"
+ class="org.hisp.dhis.mobile.action.DeleteSentSMSAction"
+ scope="prototype">
+ <property name="outboundSmsService"
+ ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+ </bean>
<bean id="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
class="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
@@ -54,6 +61,8 @@
scope="prototype">
<property name="outboundSmsService"
ref="org.hisp.dhis.sms.outbound.OutboundSmsService"></property>
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService"></property>
</bean>
<!-- Patient Mobile Settings -->
=== 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-08-30 12:47:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-10-22 08:51:28 +0000
@@ -34,6 +34,9 @@
send_sms=Send SMS
send_sms_beneficiary=Send SMS to Person
list_sent_SMS=List Of Sent SMS
+sent=Sent
+all=All
+filter_by_status=Filter by Status
add_gateway=Add Gateway
type=Type
gateway_configuration=Gateway Configuration
=== 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-08-30 12:47:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-10-22 08:51:28 +0000
@@ -76,6 +76,12 @@
<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
<param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="deleteSentSMS" class="org.hisp.dhis.mobile.action.DeleteSentSMSAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
</action>
<action name="searchRegistrationPatient"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showSentSMSPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showSentSMSPage.vm 2012-06-18 10:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showSentSMSPage.vm 2012-10-22 08:51:28 +0000
@@ -1,22 +1,105 @@
+
+<script type="text/javascript">
+ function deleteChecked()
+ {
+ var aa = document.getElementById( 'sentSMSPage' );
+ var result = "";
+ for (var i = 0; i < aa.elements.length; i++)
+ {
+ if ( aa.elements[i].checked )
+ {
+ result += "ids=" + aa.elements[i].value + "&";
+ }
+ }
+ result = result.substring(0 , result.length - 1);
+
+ if( result != "")
+ {
+ var confirmation = window.confirm( "$i18n.getString( 'confirm_delete_items' )" );
+ if ( confirmation )
+ {
+ jQuery.get( 'deleteSentSMS.action?' + result, {},
+ function ( json ) {
+ if ( json.response == "success" ) {
+ window.location = "showSentPage.action";
+ } else {
+ showMessage( json.message );
+ }
+ });
+ }
+ }
+ else
+ {
+ showErrorMessage( "$i18n.getString( 'error_delete' )", 7000 );
+ }
+ };
+ checked = false;
+ function checkAll()
+ {
+ var aa = document.getElementById( 'sentSMSPage' );
+ if (checked == false)
+ {
+ checked = true
+ }
+ else
+ {
+ checked = false
+ }
+ for (var i = 0; i < aa.elements.length; i++)
+ {
+ aa.elements[i].checked = checked;
+ }
+ };
+
+ function removeSingleItem( key, name )
+ {
+ removeItem( key, name, i18n_confirm_delete, "deleteSentSMS.action" );
+ };
+
+ function filterByStatus(value)
+ {
+ window.location.href='showSentPage.action?filterStatusType='+value;
+ };
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_sms" ) , "'")';
+</script>
<h3>$i18n.getString( 'list_sent_SMS' )</h3>
-<form id="sentSMSPage" name="sentSMSPage" action="showSentPage.action" method="post" >
-<table id="detailsSentSMSList" class="listTable" style="width:800px">
+<form id="sentSMSPage" name="sentSMSPage" action="showSentPage.action" method="post">
+<table border="0px" style="width:100%">
+ <tr>
+ <td style="width:90px">$i18n.getString('filter_by_status'):</td>
+ <td style="width:200px">
+ <select id="statusType" style="width:100%;" onchange="filterByStatus(this.value)">
+ <option value="0" #if ( $!filterStatusType == 0 ) selected='selected' #end>$i18n.getString('outbound')</option>
+ <option value="1" #if ( $!filterStatusType == 1 ) selected='selected' #end>$i18n.getString('sent')</option>
+ <option value="2" #if ( $!filterStatusType == 2 ) selected='selected' #end>$i18n.getString('all')</option>
+ </select>
+ </td>
+ <td style="text-align:right"><input type="button" name="btnDelete" value="$i18n.getString( 'delete_checked_option' )" onclick="deleteChecked()"/></td>
+ </tr>
+<table>
+<table id="detailsSentSMSList" class="listTable" style="width:100%">
<thead>
+ <th style="text-align:center"><a href="#" onclick="checkAll()" title="$i18n.getString( 'check_all' )"><img src="../images/check.png"/></a></th>
<th style="text-align:center">$i18n.getString( "no." )</th>
<th>$i18n.getString( "message" )</th>
- <th>$i18n.getString( "admin" )</th>
<th>$i18n.getString( "receiver" )</th>
- <th style="text-align:center"><a href="#" onclick="checkAll()" title="Click Here To Check All"><img src="../images/check.png"/></a></th>
+ <th>$i18n.getString( "date" )</th>
+ <th>$i18n.getString( "status" )</th>
+ <th style="text-align:center">$i18n.getString( "delete" )</th>
</thead>
- #foreach( $outboundSms in $ListOutboundSMS)
- <tr>
- <td>$velocityCount</td>
- <td>$outboundSms.message</td>
- <td>admin</td>
- <td>$outboundSms.recipients</td>
- <td></td>
- </tr>
-
- #end
+ <tbody id="sentSMS">
+ #foreach( $outboundSms in $listOutboundSMS)
+ <tr id="tr${outboundSms.id}">
+ <td style="text-align:center"><input type="checkbox" name="mycheck" value="$outboundSms.id"/></td>
+ <td style="text-align:center">$velocityCount</td>
+ <td>$outboundSms.message</td>
+ <td>$outboundSms.recipients</td>
+ <td>$outboundSms.date</td>
+ <td>$outboundSms.status</td>
+ <td style="text-align:center"><a href="javascript:removeSingleItem( '$outboundSms.id', '$outboundSms.message' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></td>
+ </tr>
+ #end
+ </tbody>
</table>
</form>
\ No newline at end of file