← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10198: add method to get only the J2ME SMSCommand

 

------------------------------------------------------------
revno: 10198
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Thu 2013-03-14 14:19:34 +0700
message:
  add method to get only the J2ME SMSCommand
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/HibernateSMSCommandStore.java
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java


--
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/smscommand/SMSCommandService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java	2013-03-09 14:12:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java	2013-03-14 07:19:34 +0000
@@ -43,4 +43,6 @@
     void save( Set<SMSCode> codes );
 
     void delete( SMSCommand cmd );
+    
+    Collection<SMSCommand> getJ2MESMSCommands();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java	2013-03-09 14:12:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java	2013-03-14 07:19:34 +0000
@@ -41,4 +41,6 @@
     void delete( SMSCommand cmd );
 
     void save( Set<SMSCode> codes );
+    
+    Collection<SMSCommand> getJ2MESMSCommands();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java	2012-06-13 08:44:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java	2013-03-14 07:19:34 +0000
@@ -40,4 +40,10 @@
     public void delete(SMSCommand cmd){
        smsCommandStore.delete(cmd);
     }
+
+    @Override
+    public Collection<SMSCommand> getJ2MESMSCommands()
+    {
+        return smsCommandStore.getJ2MESMSCommands();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/HibernateSMSCommandStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/HibernateSMSCommandStore.java	2012-08-24 12:14:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/HibernateSMSCommandStore.java	2013-03-14 07:19:34 +0000
@@ -9,6 +9,7 @@
 import org.hibernate.Transaction;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.sms.parse.ParserType;
 import org.springframework.beans.factory.annotation.Required;
 
 public class HibernateSMSCommandStore
@@ -76,5 +77,14 @@
         t.commit();
         s.flush();
     }
+    
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public Collection<SMSCommand> getJ2MESMSCommands()
+    {
+        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( SMSCommand.class );
+        criteria.add( Restrictions.eq( "parserType", ParserType.J2ME_PARSER ) );
+        return criteria.list();
+    }
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-03-14 07:19:34 +0000
@@ -196,7 +196,7 @@
         mobileModel.setDatasets( facilityReportingService.getMobileDataSetsForUnit( unit, locale ) );
         mobileModel.setServerCurrentDate( new Date() );
         mobileModel.setLocales( getLocalStrings( i18nService.getAvailableLocales() ) );
-        mobileModel.setSmsCommands( this.getMobileSMSCommands( smsCommandService.getSMSCommands() ) );
+        mobileModel.setSmsCommands( this.getMobileSMSCommands( smsCommandService.getJ2MESMSCommands() ) );
         return mobileModel;
     }