← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11239: add filter by phone number for view received sms page

 

------------------------------------------------------------
revno: 11239
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Thu 2013-06-20 15:08:08 +0700
message:
  add filter by phone number for view received sms page
modified:
  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-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java
  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-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	2013-06-19 18:43:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java	2013-06-20 08:08:08 +0000
@@ -179,9 +179,9 @@
     }
 
     @Override
-    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
+    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status, String keyword )
     {
-        return incomingSmsStore.getSmsByStatus( status );
+        return incomingSmsStore.getSmsByStatus( status, keyword );
     }
 
     @Override

=== 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	2013-06-19 17:22:47 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java	2013-06-20 08:08:08 +0000
@@ -49,7 +49,7 @@
     // -------------------------------------------------------------------------
 
     private SessionFactory sessionFactory;
-    
+
     public void setSessionFactory( SessionFactory sessionFactory )
     {
         this.sessionFactory = sessionFactory;
@@ -73,16 +73,21 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
-    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
+    @SuppressWarnings( "unchecked" )
+    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status, String keyword )
     {
         Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( IncomingSms.class ).add( Restrictions.eq( "status", status ) );
+        Criteria criteria = session.createCriteria( IncomingSms.class );
+        if ( status != null )
+        {
+            criteria.add( Restrictions.eq( "status", status ) );
+        }
+        criteria.add( Restrictions.ilike( "originator", "%" + keyword + "%" ) );
         return criteria.list();
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public Collection<IncomingSms> getSmsByOriginator( String originator )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( IncomingSms.class );
@@ -91,10 +96,11 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public Collection<IncomingSms> getAllSmses()
     {
-        return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).addOrder( Order.desc( "id" ) ).list();
+        return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).addOrder( Order.desc( "id" ) )
+            .list();
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java	2013-06-19 18:43:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java	2013-06-20 08:08:08 +0000
@@ -65,7 +65,8 @@
     
     public void setIncomingSmsQueue( MessageQueue incomingSmsQueue );
     
-    Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status );
-    
+    Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status, String keyword );
+
     IncomingSms convertToIncomingSms( InboundMessage message );
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java	2013-06-19 18:43:51 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java	2013-06-20 08:08:08 +0000
@@ -42,7 +42,7 @@
 
     IncomingSms get( int id );
 
-    Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status );
+    Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status, String keyword );
 
     Collection<IncomingSms> getSmsByOriginator( String originator );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2013-05-23 08:05:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2013-06-20 08:08:08 +0000
@@ -102,6 +102,18 @@
         this.smsStatus = smsStatus;
     }
 
+    private String keyword;
+
+    public String getKeyword()
+    {
+        return keyword;
+    }
+
+    public void setKeyword( String keyword )
+    {
+        this.keyword = keyword;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -134,9 +146,12 @@
             incomingSmsService.deleteAllFromModem();
         }
 
+        if ( keyword == null )
+            keyword = "";
+
         if ( smsStatus == null || smsStatus.trim().equals( "" ) )
         {
-            listIncomingSms = incomingSmsService.listAllMessage();
+            listIncomingSms = new ArrayList<IncomingSms>( incomingSmsService.getSmsByStatus( null, keyword.trim() ) );
         }
         else
         {
@@ -146,7 +161,8 @@
             {
                 if ( statusArray[i].toString().equalsIgnoreCase( smsStatus ) )
                 {
-                    listIncomingSms = new ArrayList<IncomingSms>( incomingSmsService.getSmsByStatus( statusArray[i] ) );
+                    listIncomingSms = new ArrayList<IncomingSms>( incomingSmsService.getSmsByStatus( statusArray[i],
+                        keyword.trim() ) );
                     break;
                 }
             }

=== 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	2013-05-30 04:16:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm	2013-06-20 08:08:08 +0000
@@ -156,16 +156,19 @@
 </script>
 <input id="pollingInterval" name="pollingInterval" type="hidden" value="$pollingInterval"/>
 <h3>$i18n.getString( "show_receive_sms_form" )</h3>
-<form id="receiveSmsPage" name="receiveSmsPage" action="showReceivingPage.action" method="post" >
+<form id="receiveSmsPage" name="receiveSmsPage" action="showReceivingPage.action" method="get" >
 	<div style="text-align:right; width:840px">	
 		<div style="float: left">
-			<select style="width: 150px" name="smsStatus" onchange="criteriaChanged(this)">
+			<select style="width: 150px" name="smsStatus" onchange="javascript:document.forms['receiveSmsPage'].submit();">
 				<option value="">$i18n.getString( "all" )</option>
 				<option value="INCOMING" #if($smsStatus == 'INCOMING') selected='selected' #end>$i18n.getString( "incoming" )</option>
 				<option value="PROCESSED" #if($smsStatus == 'PROCESSED') selected='selected' #end>$i18n.getString( "processed" )</option>
 				<option value="FAILED" #if($smsStatus == 'FAILED') selected='selected' #end>$i18n.getString( "failed" )</option>
 				<option value="UNHANDLED" #if($smsStatus == 'UNHANDLED') selected='selected' #end>$i18n.getString( "unhandled" )</option>
 			</select>
+			<input type="text" name="keyword" #if($keyword) value="$keyword" #else value="" #end style="width: 150px"/>
+			<input type="submit" name="filer" value="Filer"/>
+			<input type="reset" name="clear" value="Clear"/>
 		</div>
 		<div style="float: right">
 			<input type="button" name="btnDelete" value="$i18n.getString( 'delete_checked_option' )" onclick="deleteChecked()"/>