← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15881: custom message for sms import success

 

------------------------------------------------------------
revno: 15881
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2014-06-27 18:45:23 +0700
message:
  custom message for sms import success
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java
  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/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java
  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/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.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/smscommand/SMSCommand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2014-03-21 04:09:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2014-06-27 11:45:23 +0000
@@ -87,6 +87,8 @@
     private String noUserMessage;
     
     private String moreThanOneOrgUnitMessage;
+    
+    private String successMessage;
 
     public SMSCommand( String name, String parser, ParserType parserType, String separator, DataSet dataset,
         Set<SMSCode> codes, String codeSeparator, String defaultMessage, UserGroup userGroup, String receivedMessage, Set<SMSSpecialCharacter> specialCharacters )
@@ -361,6 +363,14 @@
     {
         this.completenessMethod = completenessMethod;
     }
-    
-    
+
+    public String getSuccessMessage()
+    {
+        return successMessage;
+    }
+
+    public void setSuccessMessage( String successMessage )
+    {
+        this.successMessage = successMessage;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2014-06-23 21:31:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2014-06-27 11:45:23 +0000
@@ -73,7 +73,7 @@
 public class DataValueSMSListener
     implements IncomingSmsListener
 {
-   
+
     private static final String defaultPattern = "([a-zA-Z]+)\\s*(\\d+)";
 
     private CompleteDataSetRegistrationService registrationService;
@@ -580,14 +580,22 @@
         }
         notInReport = notInReport.substring( 0, notInReport.length() - 1 );
 
-        if ( codesWithoutDataValues.size() > 0 )
+        if ( command.getSuccessMessage() != null && !StringUtils.isEmpty( command.getSuccessMessage() ) )
         {
-            smsSender.sendMessage( reportBack + notInReport, sender );
+            smsSender.sendMessage( command.getSuccessMessage(), sender );
         }
         else
         {
-            smsSender.sendMessage( reportBack, sender );
+            if ( codesWithoutDataValues.size() > 0 )
+            {
+                smsSender.sendMessage( reportBack + notInReport, sender );
+            }
+            else
+            {
+                smsSender.sendMessage( reportBack, sender );
+            }
         }
+
     }
 
     private void registerCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit,
@@ -595,8 +603,9 @@
     {
         CompleteDataSetRegistration registration = new CompleteDataSetRegistration();
 
-        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); //TODO
-        
+        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
+            .getDefaultDataElementCategoryOptionCombo(); // TODO
+
         if ( registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit, optionCombo ) == null )
         {
             registration.setDataSet( dataSet );
@@ -611,8 +620,9 @@
 
     private void deregisterCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit )
     {
-        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); //TODO
-        
+        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
+            .getDefaultDataElementCategoryOptionCombo(); // TODO
+
         CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period,
             organisationUnit, optionCombo );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java	2014-06-23 21:31:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java	2014-06-27 11:45:23 +0000
@@ -81,7 +81,7 @@
     private CompleteDataSetRegistrationService registrationService;
 
     private SmsSender smsSender;
-    
+
     @Transactional
     @Override
     public boolean accept( IncomingSms sms )
@@ -100,7 +100,7 @@
 
         return smsCommandService.getSMSCommand( commandString, ParserType.J2ME_PARSER ) != null;
     }
-    
+
     @Transactional
     @Override
     public void receive( IncomingSms sms )
@@ -287,7 +287,7 @@
             }
             throw new SMSParserException( messageListingOrgUnits );
         }
-        
+
         return orgUnit;
     }
 
@@ -345,8 +345,9 @@
     {
         CompleteDataSetRegistration registration = new CompleteDataSetRegistration();
 
-        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); //TODO
-        
+        DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
+            .getDefaultDataElementCategoryOptionCombo(); // TODO
+
         if ( registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit, optionCombo ) == null )
         {
             registration.setDataSet( dataSet );
@@ -403,6 +404,13 @@
         {
             reportBack += notInReport;
         }
+        
+        System.out.println("Success message :" + command.getSuccessMessage());
+        
+        if ( command.getSuccessMessage() != null && !StringUtils.isEmpty( command.getSuccessMessage() ) )
+        {
+            reportBack = command.getSuccessMessage();
+        }
 
         smsSender.sendMessage( reportBack, sender );
     }

=== 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	2014-06-25 13:41:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-06-27 11:45:23 +0000
@@ -26,6 +26,10 @@
   <bean id="smsCommandService" class="org.hisp.dhis.smscommand.DefaultSMSCommandService">
     <property name="smsCommandStore" ref="smsCommandStore" />
   </bean>
+  
+   <bean id="org.hisp.dhis.sms.task.SmsTaskStore" class="org.hisp.dhis.sms.task.hibernate.HibernateSmsTaskStore">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
 
   <bean id="smsCommandStore" class="org.hisp.dhis.sms.hibernate.HibernateSMSCommandStore">
     <property name="sessionFactory" ref="sessionFactory" />
@@ -819,6 +823,10 @@
 
   <!-- SMS Services -->
 
+  <bean id="org.hisp.dhis.sms.task.SmsTaskService" class="org.hisp.dhis.sms.task.DefaultSmsTaskService">
+    <property name="smsTaskStore" ref="org.hisp.dhis.sms.task.SmsTaskStore" />
+  </bean>
+  
   <bean id="org.hisp.dhis.sms.MessageQueue" class="org.hisp.dhis.sms.DatabaseSupportedInternalMemoryMessageQueue">
     <property name="smsStore" ref="org.hisp.dhis.sms.hibernate.IncomingSmsStore" />
   </bean>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml	2014-03-21 04:09:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml	2014-06-27 11:45:23 +0000
@@ -28,6 +28,7 @@
     <property name="wrongFormatMessage" type="text" />
     <property name="noUserMessage" type="text" />
     <property name="moreThanOneOrgUnitMessage" type="text" />
+     <property name="successMessage" type="text" />
     <property name="currentPeriodUsedForReporting" type="boolean" />
     <property name="completenessMethod" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java	2014-03-21 04:09:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java	2014-06-27 11:45:23 +0000
@@ -110,6 +110,8 @@
 
     private String moreThanOneOrgUnitMessage;
 
+    private String successMessage;
+
     private Integer completenessMethod;
 
     private int selectedCommandID = -1;
@@ -184,6 +186,7 @@
             c.setMoreThanOneOrgUnitMessage( moreThanOneOrgUnitMessage );
             c.setNoUserMessage( noUserMessage );
             c.setWrongFormatMessage( wrongFormatMessage );
+            c.setSuccessMessage( successMessage );
 
             if ( userGroupID != null && userGroupID > -1 )
             {
@@ -362,4 +365,15 @@
     {
         this.completenessMethod = completenessMethod;
     }
+
+    public String getSuccessMessage()
+    {
+        return successMessage;
+    }
+
+    public void setSuccessMessage( String successMessage )
+    {
+        this.successMessage = successMessage;
+    }
+
 }
\ No newline at end of file

=== 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	2014-03-21 04:09:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2014-06-27 11:45:23 +0000
@@ -142,4 +142,5 @@
 completeness_method=Completeness method
 receive_at_least_one_datavalue=Receive at least one data value
 do_not_mark_complete=Do not mark as complete
-receive_all_datavalue=Receive all data value
\ No newline at end of file
+receive_all_datavalue=Receive all data value
+success_message=Success Message
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2014-03-21 04:09:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2014-06-27 11:45:23 +0000
@@ -171,6 +171,11 @@
             <td style="width:130px">$i18n.getString( "more_than_one_orgunit_message" )</td>
             <td><textarea cols="35" type="text" name="moreThanOneOrgUnitMessage">#if($smsCommand.moreThanOneOrgUnitMessage)$smsCommand.moreThanOneOrgUnitMessage#end</textarea></td>
         </tr>
+        
+        <tr>
+            <td style="width:130px">$i18n.getString( "success_message" )</td>
+            <td><textarea cols="35" type="text" name="successMessage">#if($smsCommand.successMessage)$smsCommand.successMessage#end</textarea></td>
+        </tr>
 		 
 		#elseif( $smsCommand.parserType == 'ALERT_PARSER' || $smsCommand.parserType == 'UNREGISTERED_PARSER' )
 		<tr>