dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23901
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11646: Using listener to reimport sms
------------------------------------------------------------
revno: 11646
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2013-08-13 10:24:10 +0700
message:
Using listener to reimport sms
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReimportSMSAction.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-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReimportSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReimportSMSAction.java 2013-08-12 03:29:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReimportSMSAction.java 2013-08-13 03:24:10 +0000
@@ -1,8 +1,13 @@
package org.hisp.dhis.mobile.action.incoming;
+import java.util.List;
+
import org.hisp.dhis.sms.incoming.IncomingSms;
+import org.hisp.dhis.sms.incoming.IncomingSmsListener;
import org.hisp.dhis.sms.incoming.IncomingSmsService;
-import org.hisp.dhis.sms.parse.ParserManager;
+import org.hisp.dhis.sms.incoming.SmsMessageStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+
import com.opensymphony.xwork2.Action;
public class ReimportSMSAction
@@ -14,6 +19,8 @@
private IncomingSmsService incomingSmsService;
+ private List<IncomingSmsListener> listeners;
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -22,6 +29,12 @@
private IncomingSms incomingSMS;
+ @Autowired
+ public void setListeners( List<IncomingSmsListener> listeners )
+ {
+ this.listeners = listeners;
+ }
+
public IncomingSmsService getIncomingSmsService()
{
return incomingSmsService;
@@ -51,9 +64,9 @@
{
this.incomingSMS = incomingSMS;
}
-
+
private String message;
-
+
public String getMessage()
{
return message;
@@ -78,11 +91,21 @@
{
return "error";
}
-
+
try
{
-// parserManager.parse( incomingSMS );
- message = "SMS imported";
+ for ( IncomingSmsListener listener : listeners )
+ {
+ if ( listener.accept( incomingSMS ) )
+ {
+ listener.receive( incomingSMS );
+ incomingSMS.setStatus( SmsMessageStatus.PROCESSED );
+ incomingSmsService.update( incomingSMS );
+ message = "SMS imported";
+ return SUCCESS;
+ }
+ }
+ message = "No Command Found";
}
catch ( Exception e )
{