dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17614
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7075: Add receiving SMS function by modem gateway
------------------------------------------------------------
revno: 7075
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-29 14:58:51 +0700
message:
Add receiving SMS function by modem gateway
removed:
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java
added:
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/
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-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/DeleteReceiveSMSAction.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/jsonCheckMessage.vm
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/showModemConfigPage.vm
modified:
dhis-2/dhis-api/pom.xml
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java
dhis-2/dhis-services/dhis-service-sms/pom.xml
dhis-2/dhis-services/dhis-service-sms/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
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
dhis-2/dhis-web/dhis-web-portal/pom.xml
dhis-mobile/dhis-service-sms/pom.xml
dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSService.java
dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSStore.java
dhis-mobile/dhis-web-sms/pom.xml
dhis-mobile/pom.xml
--
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/pom.xml'
--- dhis-2/dhis-api/pom.xml 2012-05-10 09:57:03 +0000
+++ dhis-2/dhis-api/pom.xml 2012-05-29 07:58:51 +0000
@@ -49,6 +49,11 @@
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.smslib</groupId>
+ <artifactId>smslib</artifactId>
+ <version>3.5.2-r2307</version>
+ </dependency>
</dependencies>
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java 2012-05-29 07:58:51 +0000
@@ -1,5 +1,10 @@
package org.hisp.dhis.sms.incoming;
+import java.util.List;
+
+import org.hisp.dhis.sms.config.ModemGatewayConfig;
+import org.smslib.InboundMessage;
+
/*
* Copyright (c) 2011, University of Oslo
* All rights reserved.
@@ -45,4 +50,8 @@
IncomingSms get(int id);
void update( IncomingSms sms );
+
+ List<IncomingSms> listAllMessage ();
+
+ List<InboundMessage> getMsgList();
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/pom.xml'
--- dhis-2/dhis-services/dhis-service-sms/pom.xml 2012-05-10 09:57:03 +0000
+++ dhis-2/dhis-services/dhis-service-sms/pom.xml 2012-05-29 07:58:51 +0000
@@ -36,11 +36,23 @@
<artifactId>smslib</artifactId>
<version>3.5.2-r2307</version>
</dependency>
- <dependency>
- <groupId>org.rxtx</groupId>
- <artifactId>rxtx</artifactId>
- <version>2.1.7</version>
- </dependency>
+
+ <!-- rxtx -->
+
+ <dependency>
+ <groupId>org.rxtx</groupId>
+ <artifactId>rxtx</artifactId>
+ <version>2.1.7</version>
+ </dependency>
+
+ <!-- log4j -->
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+
</dependencies>
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound'
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/DefaultInboundSmsService.java 2012-05-29 07:58:51 +0000
@@ -0,0 +1,99 @@
+package org.hisp.dhis.sms.inbound;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.sms.incoming.IncomingSms;
+import org.hisp.dhis.sms.incoming.IncomingSmsService;
+import org.smslib.InboundMessage;
+import org.smslib.Service;
+
+public class DefaultInboundSmsService
+ implements IncomingSmsService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private List<InboundMessage> msgList = new ArrayList<InboundMessage>();
+
+ public void setMsgList( List<InboundMessage> msgList )
+ {
+ this.msgList = msgList;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public List<IncomingSms> listAllMessage()
+ {
+ List<IncomingSms> result = new ArrayList<IncomingSms>();
+
+ try
+ {
+ Service.getInstance().readMessages( msgList, InboundMessage.MessageClasses.ALL );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ if ( msgList.size() > 0 )
+ {
+ for ( InboundMessage each : msgList )
+ {
+ IncomingSms incomingSms = new IncomingSms();
+
+ incomingSms.setGatewayId( each.getGatewayId() );
+
+ incomingSms.setOriginator( each.getOriginator() );
+
+ incomingSms.setText( each.getText() );
+
+ result.add( incomingSms );
+ }
+
+ msgList.clear();
+ }
+
+ return result;
+ }
+
+ @Override
+ public List<InboundMessage> getMsgList()
+ {
+ try
+ {
+ Service.getInstance().readMessages( msgList, InboundMessage.MessageClasses.ALL );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ return msgList;
+ }
+
+ @Override
+ public IncomingSms getNextUnprocessed()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IncomingSms get( int id )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void update( IncomingSms sms )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java 2012-05-29 07:58:51 +0000
@@ -0,0 +1,129 @@
+package org.hisp.dhis.sms.inbound;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * SmsHIS SOFSmsWARE IS PROVIDED BY SmsHE COPYRIGHSms HOLDERS AND CONSmsRIBUSmsORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANSmsIES, INCLUDING, BUSms NOSms LIMISmsED SmsO, SmsHE IMPLIED
+ * WARRANSmsIES OF MERCHANSmsABILISmsY AND FISmsNESS FOR A PARSmsICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENSms SHALL SmsHE COPYRIGHSms OWNER OR CONSmsRIBUSmsORS BE LIABLE FOR
+ * ANY DIRECSms, INDIRECSms, INCIDENSmsAL, SPECIAL, EXEMPLARY, OR CONSEQUENSmsIAL DAMAGES
+ * (INCLUDING, BUSms NOSms LIMISmsED SmsO, PROCUREMENSms OF SUBSSmsISmsUSmsE GOODS OR SERVICES;
+ * LOSS OF USE, DASmsA, OR PROFISmsS; OR BUSINESS INSmsERRUPSmsION) HOWEVER CAUSED AND ON
+ * ANY SmsHEORY OF LIABILISmsY, WHESmsHER IN CONSmsRACSms, SSmsRICSms LIABILISmsY, OR SmsORSms
+ * (INCLUDING NEGLIGENCE OR OSmsHERWISE) ARISING IN ANY WAY OUSms OF SmsHE USE OF SmsHIS
+ * SOFSmsWARE, EVEN IF ADVISED OF SmsHE POSSIBILISmsY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.sms.incoming.IncomingSms;
+import org.hisp.dhis.sms.incoming.IncomingSmsStore;
+import org.hisp.dhis.sms.incoming.SmsMessageStatus;
+
+@SuppressWarnings( "unchecked" )
+public class HibernateIncomingSmsStore
+ implements IncomingSmsStore
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public int save( IncomingSms sms )
+ {
+ return (Integer) sessionFactory.getCurrentSession().save( sms );
+ }
+
+ @Override
+ public IncomingSms get( int id )
+ {
+ Session session = sessionFactory.getCurrentSession();
+ return (IncomingSms) session.get( IncomingSms.class, id );
+ }
+
+ @Override
+ public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
+ {
+ Session session = sessionFactory.getCurrentSession();
+ Criteria criteria = session.createCriteria( IncomingSms.class ).add( Restrictions.eq( "status", status ) );
+ return (Collection<IncomingSms>) criteria.list();
+ }
+
+ @Override
+ public Collection<IncomingSms> getSmsByOriginator( String originator )
+ {
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria( IncomingSms.class );
+ criteria.add( Restrictions.eq( "originator", originator ) );
+ return criteria.list();
+ }
+
+ @Override
+ public Collection<IncomingSms> getAllSmses()
+ {
+ return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).list();
+ }
+
+ @Override
+ public long getSmsCount()
+ {
+ Session session = sessionFactory.getCurrentSession();
+ Criteria criteria = session.createCriteria( IncomingSms.class );
+ criteria.setProjection( Projections.rowCount() );
+ Long count = (Long) criteria.uniqueResult();
+ return count != null ? count.longValue() : (long) 0;
+ }
+
+ // @Override
+ // public Collection<IncomingSms> getSms( String originator, Date startDate,
+ // Date endDate )
+ // {
+ // Criteria crit = sessionFactory.getCurrentSession().createCriteria(
+ // IncomingSms.class );
+ // if ( originator != null && !originator.equals( "" ) )
+ // {
+ // crit.add( Restrictions.eq( "originator", originator ) );
+ // }
+ // if ( startDate != null && endDate != null )
+ // {
+ // crit.add( Restrictions.between( "receiveDate", startDate, endDate ) );
+ // }
+ // return crit.list();
+ // }
+ //
+ // @Override
+ // public Collection<IncomingSms> getSmsByDate( Date startDate, Date endDate
+ // )
+ // {
+ // return getSms( null, startDate, endDate );
+ // }
+
+}
=== removed directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming'
=== removed file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java 2012-03-01 08:56:47 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java 1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
-package org.hisp.dhis.sms.incoming;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * SmsHIS SOFSmsWARE IS PROVIDED BY SmsHE COPYRIGHSms HOLDERS AND CONSmsRIBUSmsORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANSmsIES, INCLUDING, BUSms NOSms LIMISmsED SmsO, SmsHE IMPLIED
- * WARRANSmsIES OF MERCHANSmsABILISmsY AND FISmsNESS FOR A PARSmsICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENSms SHALL SmsHE COPYRIGHSms OWNER OR CONSmsRIBUSmsORS BE LIABLE FOR
- * ANY DIRECSms, INDIRECSms, INCIDENSmsAL, SPECIAL, EXEMPLARY, OR CONSEQUENSmsIAL DAMAGES
- * (INCLUDING, BUSms NOSms LIMISmsED SmsO, PROCUREMENSms OF SUBSSmsISmsUSmsE GOODS OR SERVICES;
- * LOSS OF USE, DASmsA, OR PROFISmsS; OR BUSINESS INSmsERRUPSmsION) HOWEVER CAUSED AND ON
- * ANY SmsHEORY OF LIABILISmsY, WHESmsHER IN CONSmsRACSms, SSmsRICSms LIABILISmsY, OR SmsORSms
- * (INCLUDING NEGLIGENCE OR OSmsHERWISE) ARISING IN ANY WAY OUSms OF SmsHE USE OF SmsHIS
- * SOFSmsWARE, EVEN IF ADVISED OF SmsHE POSSIBILISmsY OF SUCH DAMAGE.
- */
-
-import java.util.Collection;
-
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.sms.incoming.IncomingSms;
-import org.hisp.dhis.sms.incoming.IncomingSmsStore;
-import org.hisp.dhis.sms.incoming.SmsMessageStatus;
-
-@SuppressWarnings( "unchecked" )
-public class HibernateIncomingSmsStore
- implements IncomingSmsStore
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private SessionFactory sessionFactory;
-
- public void setSessionFactory( SessionFactory sessionFactory )
- {
- this.sessionFactory = sessionFactory;
- }
-
- // -------------------------------------------------------------------------
- // Implementation
- // -------------------------------------------------------------------------
-
- @Override
- public int save( IncomingSms sms )
- {
- return (Integer) sessionFactory.getCurrentSession().save( sms );
- }
-
- @Override
- public IncomingSms get( int id )
- {
- Session session = sessionFactory.getCurrentSession();
- return (IncomingSms) session.get( IncomingSms.class, id );
- }
-
- @Override
- public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
- {
- Session session = sessionFactory.getCurrentSession();
- Criteria criteria = session.createCriteria( IncomingSms.class ).add( Restrictions.eq( "status", status ) );
- return (Collection<IncomingSms>) criteria.list();
- }
-
- @Override
- public Collection<IncomingSms> getSmsByOriginator( String originator )
- {
- Criteria criteria = sessionFactory.getCurrentSession().createCriteria( IncomingSms.class );
- criteria.add( Restrictions.eq( "originator", originator ) );
- return criteria.list();
- }
-
- @Override
- public Collection<IncomingSms> getAllSmses()
- {
- return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).list();
- }
-
- @Override
- public long getSmsCount()
- {
- Session session = sessionFactory.getCurrentSession();
- Criteria criteria = session.createCriteria( IncomingSms.class );
- criteria.setProjection( Projections.rowCount() );
- Long count = (Long) criteria.uniqueResult();
- return count != null ? count.longValue() : (long) 0;
- }
-
- // @Override
- // public Collection<IncomingSms> getSms( String originator, Date startDate,
- // Date endDate )
- // {
- // Criteria crit = sessionFactory.getCurrentSession().createCriteria(
- // IncomingSms.class );
- // if ( originator != null && !originator.equals( "" ) )
- // {
- // crit.add( Restrictions.eq( "originator", originator ) );
- // }
- // if ( startDate != null && endDate != null )
- // {
- // crit.add( Restrictions.between( "receiveDate", startDate, endDate ) );
- // }
- // return crit.list();
- // }
- //
- // @Override
- // public Collection<IncomingSms> getSmsByDate( Date startDate, Date endDate
- // )
- // {
- // return getSms( null, startDate, endDate );
- // }
-
-}
=== 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 2012-03-21 08:24:25 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml 2012-05-29 07:58:51 +0000
@@ -25,5 +25,15 @@
<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
<property name="userService" ref="org.hisp.dhis.user.UserService" />
</bean>
-
+
+ <!-- Inbound SMS service -->
+
+ <bean id="inboundSmsStore" class="org.hisp.dhis.sms.inbound.HibernateIncomingSmsStore">
+ <property name="sessionFactory" ref="sessionFactory" />
+ </bean>
+
+ <bean id="org.hisp.dhis.sms.inbound.ModemService" class="org.hisp.dhis.sms.inbound.DefaultModemService"/>
+
+ <bean id="org.hisp.dhis.sms.incoming.IncomingSmsService" class="org.hisp.dhis.sms.inbound.DefaultInboundSmsService"/>
+
</beans>
=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/DeleteReceiveSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/DeleteReceiveSMSAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/DeleteReceiveSMSAction.java 2012-05-29 07:58:51 +0000
@@ -0,0 +1,68 @@
+package org.hisp.dhis.mobile.action.incoming;
+
+import java.util.List;
+import org.hisp.dhis.sms.incoming.IncomingSmsService;
+import org.smslib.InboundMessage;
+import org.smslib.Service;
+
+import com.opensymphony.xwork2.Action;
+
+public class DeleteReceiveSMSAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private IncomingSmsService incomingSmsService;
+
+ public void setIncomingSmsService( IncomingSmsService incomingSmsService )
+ {
+ this.incomingSmsService = incomingSmsService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer[] ids;
+
+ public void setIds( Integer[] ids )
+ {
+ this.ids = ids;
+ }
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ List<InboundMessage> msgList = incomingSmsService.getMsgList();
+
+ if ( ids != null && ids.length > 0 )
+ {
+ for ( Integer index : ids )
+ {
+ Service.getInstance().deleteMessage( msgList.get( index - 1 ) );
+ }
+ }
+ if ( id != null )
+ {
+ Service.getInstance().deleteMessage( msgList.get( id - 1 ) );
+ }
+ msgList.clear();
+
+ return SUCCESS;
+ }
+
+}
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java 2012-05-29 07:58:51 +0000
@@ -0,0 +1,84 @@
+package org.hisp.dhis.mobile.action.incoming;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.sms.config.ModemGatewayConfig;
+import org.hisp.dhis.sms.incoming.IncomingSms;
+import org.hisp.dhis.sms.incoming.IncomingSmsService;
+
+import com.opensymphony.xwork2.Action;
+
+public class ReceivingSMSAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private IncomingSmsService incomingSmsService;
+
+ public void setIncomingSmsService( IncomingSmsService incomingSmsService )
+ {
+ this.incomingSmsService = incomingSmsService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private List<IncomingSms> listIncomingSms = new ArrayList<IncomingSms>();
+
+ public List<IncomingSms> getListIncomingSms()
+ {
+ return listIncomingSms;
+ }
+
+ private int currentMessages;
+
+ public int getCurrentMessages()
+ {
+ return currentMessages;
+ }
+
+ public void setCurrentMessages( int currentMessages )
+ {
+ this.currentMessages = currentMessages;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ listIncomingSms = incomingSmsService.listAllMessage();
+
+ if ( listIncomingSms.size() > currentMessages )
+ {
+ message = i18n.getString( "new_message" );
+
+ currentMessages = listIncomingSms.size();
+ }
+
+ 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 2012-05-09 02:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-05-29 07:58:51 +0000
@@ -18,6 +18,16 @@
<bean id="org.hisp.dhis.mobile.action.ShowSendSMSFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSFormAction"
scope="prototype" />
+
+ <bean id="org.hisp.dhis.mobile.action.incoming.ReceivingSMSAction" class="org.hisp.dhis.mobile.action.incoming.ReceivingSMSAction"
+ scope="prototype" >
+ <property name="incomingSmsService" ref="org.hisp.dhis.sms.incoming.IncomingSmsService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.mobile.action.incoming.DeleteReceiveSMSAction" class="org.hisp.dhis.mobile.action.incoming.DeleteReceiveSMSAction"
+ scope="prototype" >
+ <property name="incomingSmsService" ref="org.hisp.dhis.sms.incoming.IncomingSmsService"/>
+ </bean>
<bean id="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction"
scope="prototype" />
=== 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 2012-05-09 02:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-05-29 07:58:51 +0000
@@ -14,6 +14,11 @@
mobile_configuration=Mobile Configuration
sms_service_configuration=SMS Service Configuration
service_status=Service Status
+status=Status
+no.=No.
+delete=Delete
+error_delete=Please check before delete
+new_message=You have new messages, press F5 to view them
sms_service_is_runnning=SMS Service is running
sms_service_is_stopped=SMS Service is stopped
reload_configuration=Reload Configuration
@@ -55,6 +60,7 @@
add_update_gateway_success=The gateway was added/updated successfully.
add_update_gateway_management=Gateway Configuration Management
confirm_delete_gateway=Do you want to delete this gateway configuration?
+confirm_delete_sms=Do you want to delete this SMS?
smsconfiguration_not_available=SMS Configuration is not available
outboundsmsservice_is_null_or_unable=SMS Service is not available or unable to be started.
service_started=SMS Service is started
@@ -64,6 +70,7 @@
message_not_sent=Message not sent
message=Message
send_sms_to_target=Send SMS to
+show_receive_sms_form =Receive SMS
phone_number=Phone number
raw_phone_number=Raw phone numbers
assigned_user_number=User assigned to organisation unit
=== 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 2012-05-24 05:13:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-05-29 07:58:51 +0000
@@ -32,6 +32,24 @@
<param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
<param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
</action>
+
+ <!-- Receiving SMS Action -->
+
+ <action name="showReceivingPage" class="org.hisp.dhis.mobile.action.incoming.ReceivingSMSAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-mobile/receiveSMSPage.vm</param>
+ <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+ </action>
+
+ <action name="checkNewMessage" class="org.hisp.dhis.mobile.action.incoming.ReceivingSMSAction">
+ <result name="success" type="velocity-json">/dhis-web-maintenance-mobile/jsonCheckMessage.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="deleteReceiveSMS" class="org.hisp.dhis.mobile.action.incoming.DeleteReceiveSMSAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
<action name="showBeneficiarySMSForm" class="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction">
<result name="success" type="velocity">/main.vm</result>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/jsonCheckMessage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/jsonCheckMessage.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/jsonCheckMessage.vm 2012-05-29 07:58:51 +0000
@@ -0,0 +1,4 @@
+{
+ "message": "$!encoder.jsonEncode( ${message} )",
+ "currentMessages": "${currentMessages}"
+}
\ 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/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm 2012-05-09 02:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm 2012-05-29 07:58:51 +0000
@@ -5,4 +5,5 @@
<li><a href="showMobileDataSet.action">$i18n.getString( "mobile_dataset" ) </a></li>
<li><a href="showSMSConfigureForm.action">$i18n.getString( "sms_service_configuration" )</a></li>
<li><a href="showSMSForm.action">$i18n.getString( "show_send_sms_form" )</a></li>
+ <li><a href="showReceivingPage.action">$i18n.getString( "show_receive_sms_form" )</a></li>
</ul>
\ No newline at end of file
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/receiveSMSPage.vm 2012-05-29 07:58:51 +0000
@@ -0,0 +1,116 @@
+
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+ checkNewMsg();
+ });
+
+ function checkNewMsg()
+ {
+ $.get( 'checkNewMessage.action',
+ {
+ currentMessages: getFieldValue('currentMessageHidden')
+ },
+ function ( json ){
+
+ if ( json.message )
+ {
+ setHeaderDelayMessage( json.message );
+ }
+ setFieldValue( "currentMessageHidden", json.currentMessages );
+
+ });
+
+ setTimeout( "checkNewMsg()", 10000 );
+ };
+
+ checked = false;
+
+ function checkAll(){
+ var aa = document.getElementById( 'receiveSmsPage' );
+ if (checked == false)
+ {
+ checked = true
+ }
+ else
+ {
+ checked = false
+ }
+ for (var i = 0; i < aa.elements.length; i++)
+ {
+ aa.elements[i].checked = checked;
+ }
+ };
+
+ function deleteChecked()
+ {
+ var aa = document.getElementById( 'receiveSmsPage' );
+ var result = "";
+ for (var i = 0; i < aa.elements.length; i++)
+ {
+ if ( aa.elements[i].checked )
+ {
+ result += "ids=" + aa.elements[i].value + "&";
+ }
+ }
+ result = result.substring(0 , result.length - 1);
+
+ if( result != "")
+ {
+ jQuery.get( 'deleteReceiveSMS.action?' + result, {},
+ function ( json ) {
+ if ( json.response == "success" ) {
+ window.location = "showReceivingPage.action";
+ } else {
+ showMessage( json.message );
+ }
+ }
+ );
+ }
+ else
+ {
+ showErrorMessage( "$i18n.getString( 'error_delete' )", 7000 );
+ }
+ };
+ function removeSingleItem( key, name )
+ {
+ removeItem( key, name, i18n_confirm_delete, "deleteReceiveSMS.action" );
+ };
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_sms" ) , "'")';
+</script>
+
+<h3>$i18n.getString( "show_receive_sms_form" )</h3>
+
+<form id="receiveSmsPage" name="receiveSmsPage" action="showReceivingPage.action" method="post" >
+ <input type="hidden" id="currentMessageHidden" value="$currentMessages"/>
+ <br/>
+ <table id="detailsSmsList" class="listTable" style="width:800px">
+ <col width="40px"/>
+ <col width="400px"/>
+ <col width="150px"/>
+ <col width="60px"/>
+ <thead>
+ <th style="text-align:center">$i18n.getString( "no." )</th>
+ <th>$i18n.getString( "message" )</th>
+ <th>$i18n.getString( "phone_number" )</th>
+ <th>$i18n.getString( "status" )</th>
+ <th style="text-align:center">$i18n.getString( "delete" )</th>
+ <th style="text-align:center"><a href="#" onclick="checkAll()" title="Click Here To Check All"><img src="../images/check.png"/></a></th>
+ </thead>
+ #foreach( $incomingSms in $listIncomingSms )
+ <tr id="tr${velocityCount}">
+ <td style="text-align:center">$velocityCount</td>
+ <td>$incomingSms.getText()</td>
+ <td>$incomingSms.getOriginator()</td>
+ <td>update</td>
+ <td style="text-align:center"><a href="javascript:removeSingleItem( '$velocityCount', '$incomingSms.getText()' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></td>
+ <td style="text-align:center"><input type="checkbox" name="mycheck" value="$velocityCount"/></td>
+ </tr>
+ #end
+ </table>
+ <br/>
+ <input type="button" name="btnShowConfig" value="Configurate My Modem" onclick="window.location='showSMSConfigureForm.action'"/>
+ <input type="button" name="btnDelete" value="Delete Checked Options" onclick="deleteChecked()"/>
+ <input type="button" name="btnImport" value="Import"/>
+
+</form>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showModemConfigPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showModemConfigPage.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/showModemConfigPage.vm 2012-05-29 07:58:51 +0000
@@ -0,0 +1,23 @@
+<form id="showModemConfigForm" name="showModemConfigForm" action="showModemConfigForm.action" method="post">
+ <table>
+ <tr>
+ <th colspan="2">Modem Configuration</th>
+ </tr>
+ <tr>
+ <td>Port Name :</td>
+ <td><input type="text" id="txtPortName" name="txtPortName"/></td>
+ </tr>
+ <tr>
+ <td>Baud Rate :</td>
+ <td><input type="text" id="txtPortSpeed" name="txtPortSpeed"/></td>
+ </tr>
+ <tr>
+ <td style="text-align:right">
+ <input type="submit" id ="btnAddModem" name ="btnAddModem" value="Add Modem" style="width:8em"/>
+ </td>
+ <td>
+ <input type="button" id ="btnBack" name ="btnBack" value="Back" style="width:8em" onclick="window.location.href='showReceivingPage.action'"/>
+ </td>
+ </tr>
+ </table>
+</form>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-portal/pom.xml'
--- dhis-2/dhis-web/dhis-web-portal/pom.xml 2012-05-11 07:01:26 +0000
+++ dhis-2/dhis-web/dhis-web-portal/pom.xml 2012-05-29 07:58:51 +0000
@@ -151,6 +151,12 @@
<version>${project.version}</version>
<type>war</type>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web-sms</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
</dependencies>
<properties>
=== modified file 'dhis-mobile/dhis-service-sms/pom.xml'
--- dhis-mobile/dhis-service-sms/pom.xml 2011-05-24 08:47:57 +0000
+++ dhis-mobile/dhis-service-sms/pom.xml 2012-05-29 07:58:51 +0000
@@ -7,7 +7,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-services</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.9-SNAPSHOT</version>
</parent>
<artifactId>dhis-service-sms</artifactId>
=== modified file 'dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSService.java'
--- dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSService.java 2011-05-06 14:31:30 +0000
+++ dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSService.java 2012-05-29 07:58:51 +0000
@@ -4,7 +4,7 @@
public interface ReceiveSMSService
{
-
+
String ID = ReceiveSMSService.class.getName();
void addReceiveSMS ( ReceiveSMS receiveSMS );
=== modified file 'dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSStore.java'
--- dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSStore.java 2011-05-06 14:31:30 +0000
+++ dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/api/ReceiveSMSStore.java 2012-05-29 07:58:51 +0000
@@ -7,11 +7,11 @@
String ID = ReceiveSMSService.class.getName();
- void addReceiveSMS( ReceiveSMS receiveSMS );
+ void addReceiveSMS ( ReceiveSMS receiveSMS );
void updateReceiveSMS ( ReceiveSMS receiveSMS );
- void deleteReceiveSMS( ReceiveSMS receiveSMS );
+ void deleteReceiveSMS ( ReceiveSMS receiveSMS );
Collection<ReceiveSMS> getReceiveSMS( int start, int end );
=== modified file 'dhis-mobile/dhis-web-sms/pom.xml'
--- dhis-mobile/dhis-web-sms/pom.xml 2011-05-06 14:31:30 +0000
+++ dhis-mobile/dhis-web-sms/pom.xml 2012-05-29 07:58:51 +0000
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.9-SNAPSHOT</version>
</parent>
<artifactId>dhis-web-sms</artifactId>
@@ -32,7 +32,7 @@
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-sms</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.9-SNAPSHOT</version>
<type>jar</type>
</dependency>
=== modified file 'dhis-mobile/pom.xml'
--- dhis-mobile/pom.xml 2011-05-06 14:31:30 +0000
+++ dhis-mobile/pom.xml 2012-05-29 07:58:51 +0000
@@ -5,7 +5,7 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-sms</artifactId>
- <version>2.3-SNAPSHOT</version>
+ <version>2.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Mobile SMS Modules</name>