=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateOutboundSmsStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateOutboundSmsStore.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateOutboundSmsStore.java 2013-09-04 09:44:07 +0000 @@ -28,17 +28,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.Date; import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Session; import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.sms.outbound.OutboundSms; import org.hisp.dhis.sms.outbound.OutboundSmsStatus; import org.hisp.dhis.sms.outbound.OutboundSmsStore; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; public class HibernateOutboundSmsStore extends HibernateGenericStore @@ -48,13 +48,6 @@ // Dependencies // ------------------------------------------------------------------------- - private JdbcTemplate jdbcTemplate; - - public void setJdbcTemplate( JdbcTemplate jdbcTemplate ) - { - this.jdbcTemplate = jdbcTemplate; - } - // ------------------------------------------------------------------------- // Implementation // ------------------------------------------------------------------------- @@ -87,49 +80,19 @@ return getCriteria().addOrder( Order.desc( "date" ) ).list(); } + @SuppressWarnings( "unchecked" ) @Override public List get( OutboundSmsStatus status ) { - int realStatus = 0; - - if ( status.equals( OutboundSmsStatus.OUTBOUND ) ) - { - realStatus = OutboundSmsStatus.OUTBOUND.ordinal(); - } - else if ( status.equals( OutboundSmsStatus.SENT ) ) - { - realStatus = OutboundSmsStatus.SENT.ordinal(); - } - else - { - realStatus = OutboundSmsStatus.ERROR.ordinal(); - } - - String sql = "select osm.id as outboundsmsid, message, ore.elt as phonenumber, date " - + "from outbound_sms osm inner join outbound_sms_recipients ore " - + "on osm.id=ore.outbound_sms_id where status = " + realStatus; - - try - { - List OutboundSmsList = jdbcTemplate.query( sql, new RowMapper() - { - public OutboundSms mapRow( ResultSet rs, int rowNum ) - throws SQLException - { - OutboundSms outboundSms = new OutboundSms( rs.getString( 2 ), rs.getString( 3 ) ); - outboundSms.setId( rs.getInt( 1 ) ); - outboundSms.setDate( rs.getDate( 4 ) ); - return outboundSms; - } - } ); - - return OutboundSmsList; - } - catch ( Exception ex ) - { - ex.printStackTrace(); - return null; - } + Session session = sessionFactory.getCurrentSession(); + + Criteria criteria = session.createCriteria( OutboundSms.class ).addOrder( Order.desc( "date" ) ); + + if ( status != null ) + { + criteria.add( Restrictions.eq( "status", status ) ); + } + return criteria.list(); } @Override === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-03 14:53:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-04 09:44:07 +0000 @@ -345,7 +345,6 @@ class="org.hisp.dhis.sms.hibernate.HibernateOutboundSmsStore"> - === 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 2013-09-03 15:04:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSentSMSAction.java 2013-09-04 09:44:07 +0000 @@ -33,6 +33,7 @@ import java.util.Iterator; import java.util.List; +import org.hisp.dhis.paging.ActionPagingSupport; import org.hisp.dhis.program.ProgramStageInstanceService; import org.hisp.dhis.program.SchedulingProgramObject; import org.hisp.dhis.sms.outbound.OutboundSms; @@ -41,10 +42,8 @@ import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserService; -import com.opensymphony.xwork2.Action; - public class ShowSentSMSAction - implements Action + extends ActionPagingSupport { // ------------------------------------------------------------------------- @@ -114,6 +113,13 @@ return recipientNames; } + private Integer total; + + public Integer getTotal() + { + return total; + } + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- @@ -122,36 +128,23 @@ public String execute() throws Exception { - List tempListOutboundSMS = outboundSmsService.getAllOutboundSms(); - listOutboundSMS = new ArrayList(); - + if ( filterStatusType != null && filterStatusType == 0 ) { - for ( OutboundSms each : tempListOutboundSMS ) - { - if ( each.getStatus().equals( OutboundSmsStatus.OUTBOUND ) ) - { - this.listOutboundSMS.add( each ); - } - } + listOutboundSMS = outboundSmsService.getOutboundSms( OutboundSmsStatus.OUTBOUND ); } 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 ); - } + listOutboundSMS = outboundSmsService.getOutboundSms( OutboundSmsStatus.SENT ); + } + if ( filterStatusType != null && filterStatusType == 2 ) + { + listOutboundSMS = outboundSmsService.getOutboundSms( OutboundSmsStatus.ERROR ); + } + if ( filterStatusType != null && filterStatusType == 3 || filterStatusType == null ) + { + listOutboundSMS = outboundSmsService.getAllOutboundSms(); } recipientNames = new ArrayList(); === 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 2013-08-28 07:52:09 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showSentSMSPage.vm 2013-09-04 09:44:07 +0000 @@ -72,7 +72,8 @@