← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11611: extend and use HibernateGenericStore in HibernateOutboundSmsStore

 

------------------------------------------------------------
revno: 11611
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-08 13:59:54 +0700
message:
  extend and use HibernateGenericStore in HibernateOutboundSmsStore
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  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/smslib/SmsLibService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.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/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/menu.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/OutboundSmsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java	2012-10-22 08:51:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java	2013-08-08 06:59:54 +0000
@@ -31,15 +31,15 @@
 
 public interface OutboundSmsStore
 {
-    int save( OutboundSms sms );
+    int saveOutboundSms( OutboundSms sms );
     
-    void update( OutboundSms sms );
-
-    List<OutboundSms> getAll();
-
-    OutboundSms get( int id );
+    List<OutboundSms> getAllOutboundSms();
+
+    OutboundSms getOutboundSmsbyId( int id );
     
     List<OutboundSms> get( OutboundSmsStatus status );
     
-    void delete( OutboundSms sms );
+    void updateOutboundSms( OutboundSms sms );
+    
+    void deleteOutboundSms( OutboundSms sms );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2013-08-07 03:44:17 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2013-08-08 06:59:54 +0000
@@ -8,7 +8,7 @@
 	
 	<bean id="org.hisp.dhis.program.ProgramIndicatorStore"
 		class="org.hisp.dhis.program.hibernate.HibernateProgramIndicatorStore">
-	<property name="clazz" value="org.hisp.dhis.program.ProgramIndicator" />
+		<property name="clazz" value="org.hisp.dhis.program.ProgramIndicator" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 	

=== 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	2013-08-05 03:16:07 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	2013-08-08 06:59:54 +0000
@@ -32,28 +32,19 @@
 import java.util.Date;
 import java.util.List;
 
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Order;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
-import org.springframework.transaction.annotation.Transactional;
 
-@Transactional
 public class HibernateOutboundSmsStore
+    extends HibernateGenericStore<OutboundSms>
     implements OutboundSmsStore
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
     private JdbcTemplate jdbcTemplate;
 
     public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
@@ -66,10 +57,11 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public int save( OutboundSms sms )
+    public int saveOutboundSms( OutboundSms sms )
     {
         checkDate( sms );
-        return (Integer) sessionFactory.getCurrentSession().save( sms );
+        //return (Integer) sessionFactory.getCurrentSession().save( sms );
+        return save( sms );
     }
 
     private void checkDate( OutboundSms sms )
@@ -81,18 +73,20 @@
     }
 
     @Override
-    public OutboundSms get( int id )
+    public OutboundSms getOutboundSmsbyId( int id )
     {
-        Session session = sessionFactory.getCurrentSession();
-        return (OutboundSms) session.get( OutboundSms.class, id );
+        /*Session session = sessionFactory.getCurrentSession();
+        return (OutboundSms) session.get( OutboundSms.class, id );*/
+        return get( id );
     }
 
     @Override
     @SuppressWarnings( "unchecked" )
-    public List<OutboundSms> getAll()
+    public List<OutboundSms> getAllOutboundSms()
     {
-        Session session = sessionFactory.getCurrentSession();
-        return session.createCriteria( OutboundSms.class ).addOrder( Order.desc( "date" ) ).list();
+        /*Session session = sessionFactory.getCurrentSession();
+        return session.createCriteria( OutboundSms.class ).addOrder( Order.desc( "date" ) ).list();*/
+        return getCriteria().addOrder( Order.desc( "date" ) ).list();
     }
 
     @Override
@@ -141,14 +135,16 @@
     }
 
     @Override
-    public void update( OutboundSms sms )
+    public void updateOutboundSms( OutboundSms sms )
     {
-        sessionFactory.getCurrentSession().update( sms );
+        update( sms );
+        //sessionFactory.getCurrentSession().update( sms );
     }
 
     @Override
-    public void delete( OutboundSms sms )
+    public void deleteOutboundSms( OutboundSms sms )
     {
-        sessionFactory.getCurrentSession().delete( sms );
+        delete( 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	2013-08-01 03:02:12 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2013-08-08 06:59:54 +0000
@@ -149,7 +149,7 @@
     @Override
     public List<OutboundSms> getAllOutboundSms()
     {
-        return outboundSmsStore.getAll();
+        return outboundSmsStore.getAllOutboundSms();
     }
 
     @Override
@@ -161,26 +161,26 @@
     @Override
     public void updateOutboundSms( OutboundSms sms )
     {
-        outboundSmsStore.update( sms );
+        outboundSmsStore.updateOutboundSms( sms );
     }
 
     @Override
     public int saveOutboundSms( OutboundSms sms )
     {
-        return outboundSmsStore.save( sms );
+        return outboundSmsStore.saveOutboundSms( sms );
     }
 
     @Override
-    public void deleteById( Integer outboundSmsId )
+    public void deleteById( Integer id )
     {
-        OutboundSms sms = outboundSmsStore.get( outboundSmsId );
-        outboundSmsStore.delete( sms );
+        OutboundSms sms = outboundSmsStore.getOutboundSmsbyId( id );
+        outboundSmsStore.deleteOutboundSms( sms );
     }
 
     @Override
     public OutboundSms getOutboundSms( int id )
     {
-        return outboundSmsStore.get( id );
+        return outboundSmsStore.getOutboundSmsbyId( id );
     }
 
     // -------------------------------------------------------------------------

=== 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	2013-08-01 03:02:12 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2013-08-08 06:59:54 +0000
@@ -102,7 +102,7 @@
     
     public OutboundSms getOutboundSms( int id )
     {
-        return outboundSmsStore.get( id );
+        return outboundSmsStore.getOutboundSmsbyId( id );
     }
     
     @Override
@@ -231,11 +231,11 @@
 
         if ( sms.getId() == 0 )
         {
-            outboundSmsStore.save( sms );
+            outboundSmsStore.saveOutboundSms( sms );
         }
         else
         {
-            outboundSmsStore.update( sms );
+            outboundSmsStore.updateOutboundSms( sms );
         }
         
         return message;
@@ -510,13 +510,13 @@
     @Override
     public int saveOutboundSms( OutboundSms sms )
     {
-        return outboundSmsStore.save( sms );
+        return outboundSmsStore.saveOutboundSms( sms );
     }
 
     @Override
     public void updateOutboundSms( OutboundSms sms )
     {
-        outboundSmsStore.update( sms );
+        outboundSmsStore.updateOutboundSms( sms );
     }
 
     @Override
@@ -526,11 +526,11 @@
     }
 
     @Override
-    public void deleteById( Integer outboundSmsId )
+    public void deleteById( Integer id )
     {
-        OutboundSms sms = outboundSmsStore.get( outboundSmsId );
+        OutboundSms sms = outboundSmsStore.getOutboundSmsbyId( id );
 
-        outboundSmsStore.delete( sms );
+        outboundSmsStore.deleteOutboundSms( sms );
     }
 
     public String getDefaultGateway()

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2013-08-01 07:38:07 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2013-08-08 06:59:54 +0000
@@ -14,6 +14,7 @@
   </bean>
 
   <bean id="outboundSmsStore" class="org.hisp.dhis.sms.outbound.HibernateOutboundSmsStore">
+  	<property name="clazz" value="org.hisp.dhis.sms.outbound.OutboundSms" />
     <property name="sessionFactory" ref="sessionFactory" />
     <property name="jdbcTemplate" ref="jdbcTemplate" />
   </bean>
@@ -65,4 +66,6 @@
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
   </bean>
   
+  <!-- Phone Number Pattern -->
+  
 </beans>

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java	2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java	2013-08-08 06:59:54 +0000
@@ -69,7 +69,7 @@
 
         outboundSmsService.sendMessage( outboundSms, gatewayId );
 
-        List<OutboundSms> smses = outboundSmsStore.getAll();
+        List<OutboundSms> smses = outboundSmsStore.getAllOutboundSms();
         assertNotNullSize( smses, 1 );
 
         verifySms( outboundSms, smses.iterator().next() );
@@ -144,7 +144,7 @@
 
         verify( transportService ).sendMessage( any( OutboundSms.class ), anyString() );
         ArgumentCaptor<OutboundSms> argument = ArgumentCaptor.forClass( OutboundSms.class );
-        verify( tmpStore, times( 1 ) ).save( argument.capture() );
+        verify( tmpStore, times( 1 ) ).saveOutboundSms( argument.capture() );
 
         // Is the SMS Marked with error status in store?
         // Can't test this without using hibernate or adding update on store...

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java	2012-03-07 14:05:05 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java	2013-08-08 06:59:54 +0000
@@ -13,12 +13,12 @@
     public void testSimpleSaveGet() {
         OutboundSms sms = getOutboundSms();
 
-        int id = outboundSmsStore.save( sms );
+        int id = outboundSmsStore.saveOutboundSms( sms );
 
         flush();
         evict( sms );
         
-        OutboundSms outboundSms = outboundSmsStore.get( id );
+        OutboundSms outboundSms = outboundSmsStore.getOutboundSmsbyId( id );
 
         verifySms( sms, outboundSms );
     }    

=== 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-06-20 08:08:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2013-08-08 06:59:54 +0000
@@ -166,9 +166,7 @@
                     break;
                 }
             }
-
         }
-
         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	2013-08-05 03:16:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2013-08-08 06:59:54 +0000
@@ -169,8 +169,7 @@
 
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm"
+	<bean id="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm"
 		class="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm"
 		scope="prototype">
 		<property name="smsCommandService" ref="smsCommandService" />
@@ -180,8 +179,7 @@
 			ref="org.hisp.dhis.user.UserGroupService" />
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction"
+	<bean id="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction"
 		class="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction"
 		scope="prototype">
 		<property name="smsCommandService" ref="smsCommandService" />
@@ -193,5 +191,10 @@
 		<property name="patientMobileSettingService"
 			ref="org.hisp.dhis.mobile.service.PatientMobileSettingService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.mobile.action.MobilePhonesPatternAction"
+		class="org.hisp.dhis.mobile.action.MobilePhonesPatternAction"
+		scope="prototype">
+	</bean>
 
 </beans>

=== 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	2013-05-30 11:20:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2013-08-08 06:59:54 +0000
@@ -122,4 +122,5 @@
 no_codes_message=Reply message if no codes are sent (only the command):
 validation_error_space=*White space not allowed
 key_value_parser=Key Value Parser
-j2me_parser=J2ME Parser
\ No newline at end of file
+j2me_parser=J2ME Parser
+mobile_phones_pattern=Mobile Phones Pattern
\ No newline at end of file

=== 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	2013-07-29 07:52:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2013-08-08 06:59:54 +0000
@@ -204,6 +204,13 @@
       <param name="javascripts">javascript/gateway.js</param>
       <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>  
     </action>
+    
+    <!-- Mobile Phones Pattern -->
+    <action name="mobilePhonesPattern" class="org.hisp.dhis.mobile.action.MobilePhonesPatternAction">
+  	  <result name="success" type="velocity">/main.vm</result>
+  	  <param name="page">/dhis-web-maintenance-mobile/phonePatternPage.vm</param>
+  	  <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+    </action>
 	
   </package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm	2013-03-12 05:40:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm	2013-08-08 06:59:54 +0000
@@ -8,5 +8,5 @@
 	<li><a href="showReceivingPage.action">$i18n.getString( "show_receive_sms_form" )</a></li>
 	<li><a href="SMSCommands.action">$i18n.getString( "sms_command_form" )</a></li>
 	<li><a href="showJ2meClientUpdatePage.action">$i18n.getString( "j2me_client_update" )</a></li>
-	
+	<!--<li><a href="mobilePhonesPattern.action">$i18n.getString( "mobile_phones_pattern" )</a></li>-->	
 </ul>
\ No newline at end of file