← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7285: [mobile] moving sms commands object to dhis-web-maintenance-mobile

 

------------------------------------------------------------
revno: 7285
committer: Em <em.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-13 15:44:07 +0700
message:
  [mobile] moving sms commands object to dhis-web-maintenance-mobile
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
  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/
  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-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/DeleteSMSCommandAction.java
  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/SMSCommandAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/incoming/
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/
  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/new-sms-command.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/sms-commands.vm
modified:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java
  dhis-2/dhis-services/dhis-service-core/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/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
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,48 @@
+package org.hisp.dhis.smscommand;
+
+import org.hisp.dhis.dataelement.DataElement;
+
+public class SMSCode {
+    
+    int id; // hibernate
+    
+    String code;
+    DataElement dataElement;
+    int optionId;
+    
+    public SMSCode(String code, DataElement dataElement, int optionId) {
+        this.code = code;
+        this.dataElement = dataElement;
+        this.optionId = optionId;
+    }
+    
+    public SMSCode(){
+        
+    }
+    
+    public int getId() {
+        return id;
+    }
+    public void setId(int id) {
+        this.id = id;
+    }
+    public String getCode() {
+        return code;
+    }
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public DataElement getDataElement() {
+        return dataElement;
+    }
+    public void setDataElement(DataElement dataElement) {
+        this.dataElement = dataElement;
+    }
+    public int getOptionId() {
+        return optionId;
+    }
+    public void setOptionId(int optionId) {
+        this.optionId = optionId;
+    }
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,118 @@
+package org.hisp.dhis.smscommand;
+
+import java.util.Set;
+
+import org.hisp.dhis.dataset.DataSet;
+
+public class SMSCommand {
+
+    private int id; // id for this element
+    private String name;
+    
+    private String parser; // message type
+    private String seperator;
+
+    private DataSet dataset; 
+    private Set<SMSCode> codes;
+    private String codeSeperator; 
+    
+    public SMSCommand(String name, String parser, String seperator, DataSet dataset, Set<SMSCode> codes,
+            String codeSeperator) {
+        this.name = name;
+        this.parser = parser;
+        this.seperator = seperator;
+        this.dataset = dataset;
+        this.codes = codes;
+        this.setCodeSeperator(codeSeperator);
+    }
+
+    public SMSCommand(String name, String parser, String seperator, DataSet dataset, Set<SMSCode> codes) {
+        this.name = name;
+        this.parser = parser;
+        this.seperator = seperator;
+        this.dataset = dataset;
+        this.codes = codes;
+    }
+
+
+
+    public SMSCommand(String parser, String name, DataSet dataset, Set<SMSCode> codes) {
+        this.parser = parser;
+        this.name = name;
+        this.dataset = dataset;
+        this.codes = codes;
+    }
+
+    public SMSCommand(String parser, String name, DataSet dataset) {
+        this.parser = parser;
+        this.name = name;
+        this.dataset = dataset;
+    }
+
+    public SMSCommand(String name, String parser) {
+        this.name = name;
+        this.parser = parser;
+    }
+
+    public SMSCommand() {
+
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getParser() {
+        return parser;
+    }
+
+    public void setParser(String parser) {
+        this.parser = parser;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public DataSet getDataset() {
+        return dataset;
+    }
+
+    public void setDataset(DataSet dataset) {
+        this.dataset = dataset;
+    }
+
+    public Set<SMSCode> getCodes() {
+        return codes;
+    }
+
+    public void setCodes(Set<SMSCode> codes) {
+        this.codes = codes;
+    }
+
+    public String getSeperator() {
+        return seperator;
+    }
+
+    public void setSeperator(String seperator) {
+        this.seperator = seperator;
+    }
+
+    public String getCodeSeperator() {
+        return codeSeperator;
+    }
+
+    public void setCodeSeperator(String codeSeperator) {
+        this.codeSeperator = codeSeperator;
+    }
+
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,13 @@
+package org.hisp.dhis.smscommand;
+
+import java.util.Collection;
+import java.util.Set;
+
+public interface SMSCommandService {
+    void updateSMSCommand(SMSCommand cmd);
+    Collection<SMSCommand> getSMSCommands();
+    SMSCommand getSMSCommand(int id);
+    void save(SMSCommand cmd);
+    void save(Set<SMSCode> codes);
+    void delete(SMSCommand cmd);
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,15 @@
+package org.hisp.dhis.smscommand;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.hisp.dhis.common.GenericNameableObjectStore;
+
+public interface SMSCommandStore  {
+    Collection<SMSCommand> getSMSCommands();
+    SMSCommand getSMSCommand(int id);
+    int save(SMSCommand cmd);
+    void delete(SMSCommand cmd);
+    void save(Set<SMSCode> codes);
+    
+}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java	2012-04-14 16:17:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java	2012-06-13 08:44:07 +0000
@@ -60,6 +60,7 @@
     {
     }
 
+    
     //--------------------------------------------------------------------------
     // Getters and setters
     //--------------------------------------------------------------------------

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,43 @@
+package org.hisp.dhis.smscommand;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.hisp.dhis.smscommand.SMSCommandStore;
+
+public class DefaultSMSCommandService implements SMSCommandService{
+    
+    private SMSCommandStore smsCommandStore;
+
+    @Override
+    public void updateSMSCommand(SMSCommand cmd) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public Collection<SMSCommand> getSMSCommands() {
+        return smsCommandStore.getSMSCommands();
+    }
+
+    public void setSmsCommandStore(SMSCommandStore smsCommandStore) {
+        this.smsCommandStore = smsCommandStore;
+    }
+
+    public void save(SMSCommand cmd){
+        smsCommandStore.save(cmd);
+    }
+    
+    public SMSCommand getSMSCommand(int id){
+        return smsCommandStore.getSMSCommand(id);
+    }
+    
+
+    public void save(Set<SMSCode> codes){
+        smsCommandStore.save(codes);
+    }
+    
+    public void delete(SMSCommand cmd){
+       smsCommandStore.delete(cmd);
+    }
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/HibernateSMSCommandStore.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.smscommand;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.smscommand.SMSCommandStore;
+import org.hisp.dhis.smscommand.SMSCode;
+import org.hisp.dhis.smscommand.SMSCommand;
+import org.springframework.beans.factory.annotation.Required;
+
+public class HibernateSMSCommandStore implements SMSCommandStore {
+
+    protected SessionFactory sessionFactory;
+
+    @Required
+    public void setSessionFactory(SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Collection<SMSCommand> getSMSCommands() {
+        System.out.println("her: " + sessionFactory.getCurrentSession().createQuery("from SMSCommand").list());
+        return sessionFactory.getCurrentSession().createQuery("from SMSCommand").list();
+    }
+
+    public int save(SMSCommand cmd) {
+        Session s = sessionFactory.getCurrentSession();
+        Transaction t = s.beginTransaction();
+        s.saveOrUpdate(cmd);
+        t.commit();
+        s.flush();
+        return 0;
+    }
+    
+    public void save(Set<SMSCode> codes){
+        Session s = sessionFactory.getCurrentSession();
+        Transaction t = s.beginTransaction();
+        for(SMSCode x : codes){
+            s.saveOrUpdate(x);
+        }
+        t.commit();
+        s.flush();   
+    }
+
+    public SMSCommand getSMSCommand(int id) {
+        Criteria criteria = sessionFactory.getCurrentSession().createCriteria(SMSCommand.class);
+        criteria.add(Restrictions.eq("id", id));
+        if (criteria.list() != null && criteria.list().size() > 0)
+            return (SMSCommand) criteria.list().get(0);
+        else
+            return null;
+    }
+    
+    public void delete(SMSCommand cmd) {
+        Session s = sessionFactory.getCurrentSession();
+        Transaction t = s.beginTransaction();     
+        for(SMSCode x : cmd.getCodes()){
+            s.delete(x);
+        }
+        s.delete(cmd);
+        t.commit();
+        s.flush();
+    }
+    
+
+}

=== 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	2012-05-03 16:28:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-06-13 08:44:07 +0000
@@ -7,6 +7,14 @@
 http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd";>
 
   <!-- Store definitions -->
+  
+  <bean id="smsCommandService" class="org.hisp.dhis.smscommand.DefaultSMSCommandService">
+    <property name="smsCommandStore" ref="smsCommandStore" />
+  </bean>
+  
+   <bean id="smsCommandStore" class="org.hisp.dhis.smscommand.HibernateSMSCommandStore">
+    <property name="sessionFactory" ref="sessionFactory" /> 
+  </bean>
 
   <bean id="org.hisp.dhis.dataelement.DataElementOperandStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="clazz" value="org.hisp.dhis.dataelement.DataElementOperand" />

=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.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/smscommand/CreateSMSCommandForm.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,66 @@
+package org.hisp.dhis.mobile.action.smscommand;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.smscommand.SMSCommand;
+import org.hisp.dhis.smscommand.SMSCommandService;
+
+import com.opensymphony.xwork2.Action;
+
+public class CreateSMSCommandForm implements Action {
+
+    private SMSCommandService smsCommandService;
+    private DataSetService dataSetService;
+    
+    private String name;
+    private String parser;
+    private int selectedDataSetID; //
+    
+    @Override
+    public String execute() throws Exception {
+        DataSet dataset = getDataSetService().getDataSet(getSelectedDataSetID());
+        smsCommandService.save(new SMSCommand(parser,name,dataset));
+        return SUCCESS;
+    }
+
+    public SMSCommandService getSmsCommandService() {
+        return smsCommandService;
+    }
+
+    public void setSmsCommandService(SMSCommandService smsCommandService) {
+        this.smsCommandService = smsCommandService;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getParser() {
+        return parser;
+    }
+
+    public void setParser(String parser) {
+        this.parser = parser;
+    }
+
+    public int getSelectedDataSetID() {
+        return selectedDataSetID;
+    }
+
+    public void setSelectedDataSetID(int selectedDataSetID) {
+        this.selectedDataSetID = selectedDataSetID;
+    }
+
+    public DataSetService getDataSetService() {
+        return dataSetService;
+    }
+
+    public void setDataSetService(DataSetService dataSetService) {
+        this.dataSetService = dataSetService;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/DeleteSMSCommandAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/DeleteSMSCommandAction.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/smscommand/DeleteSMSCommandAction.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,35 @@
+package org.hisp.dhis.mobile.action.smscommand;
+
+import org.hisp.dhis.smscommand.SMSCommandService;
+
+import com.opensymphony.xwork2.Action;
+
+public class DeleteSMSCommandAction implements Action{
+
+    private SMSCommandService smsCommandService;
+   
+    private int deleteCommandId;
+    
+    public String execute() throws Exception {
+        smsCommandService.delete(smsCommandService.getSMSCommand(deleteCommandId));
+        return SUCCESS;
+        
+    }
+
+    public int getDeleteCommandId() {
+        return deleteCommandId;
+    }
+
+    public void setDeleteCommandId(int deleteCommandId) {
+        this.deleteCommandId = deleteCommandId;
+    }
+
+    public SMSCommandService getSmsCommandService() {
+        return smsCommandService;
+    }
+
+    public void setSmsCommandService(SMSCommandService smsCommandService) {
+        this.smsCommandService = smsCommandService;
+    }
+
+}

=== added 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	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/smscommand/EditSMSCommandForm.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,161 @@
+package org.hisp.dhis.mobile.action.smscommand;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sf.json.JSONObject;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.smscommand.SMSCode;
+import org.hisp.dhis.smscommand.SMSCommand;
+import org.hisp.dhis.smscommand.SMSCommandService;
+
+import com.opensymphony.xwork2.Action;
+
+public class EditSMSCommandForm implements Action {
+
+    // services
+    private SMSCommandService smsCommandService;
+    private DataSetService dataSetService;
+    private DataElementService dataElementService;
+
+    // input fields
+    private String name; // for lista
+    private int selectedDataSetID; //
+    private String codeDataelementOption;
+    private String seperator;
+    private String codeSeperator;
+
+    private int selectedCommandID = -1;
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception {
+        
+        Set<SMSCode> codeSet = new HashSet<SMSCode>();
+        
+        @SuppressWarnings("unchecked")
+        List<JSONObject> jsonCodes = (List<JSONObject>) JSONObject.fromObject(codeDataelementOption).get("codes");
+        for(JSONObject x : jsonCodes){
+            System.out.println(x.get("dataElementId") + " " + x.get("optionId") + " " + x.get("code"));
+            SMSCode c = new SMSCode();
+            c.setCode(x.getString("code"));
+            c.setDataElement(dataElementService.getDataElement(x.getInt("dataElementId")));
+            c.setOptionId(x.getInt("optionId"));
+            codeSet.add(c);
+        }
+        
+        if(codeSet.size() > 0){
+            smsCommandService.save(codeSet);
+        }
+        
+        SMSCommand c = getSMSCommand();
+        if (selectedDataSetID > -1 && c != null) {
+            c.setDataset(getDataSetService().getDataSet(getSelectedDataSetID()));
+            c.setName(name);
+            c.setSeperator(seperator);
+            c.setCodes(codeSet);
+            c.setCodeSeperator(codeSeperator);
+            smsCommandService.save(c);
+        }
+        
+        return SUCCESS;
+    }
+
+    public Collection<DataSet> getDataSets() {
+        return getDataSetService().getAllDataSets();
+    }
+
+    public Set<DataElement> getDataSetElements() {
+        DataSet d = dataSetService.getDataSet(selectedDataSetID);
+        if (d != null) {
+            return d.getDataElements();
+        }
+        return null;
+    }
+
+    public SMSCommand getSMSCommand() {
+        return smsCommandService.getSMSCommand(selectedCommandID);
+
+    }
+
+    public DataSetService getDataSetService() {
+        return dataSetService;
+    }
+
+    public void setDataSetService(DataSetService dataSetService) {
+        this.dataSetService = dataSetService;
+    }
+
+    public int getSelectedDataSetID() {
+        return selectedDataSetID;
+    }
+
+    public void setSelectedDataSetID(int selectedDataSetID) {
+        this.selectedDataSetID = selectedDataSetID;
+    }
+
+    public String getCodeDataelementOption() {
+        return codeDataelementOption;
+    }
+
+    public void setCodeDataelementOption(String codeDataelementOption) {
+        this.codeDataelementOption = codeDataelementOption;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public SMSCommandService getSmsCommandService() {
+        return smsCommandService;
+    }
+
+    public void setSmsCommandService(SMSCommandService smsCommandService) {
+        this.smsCommandService = smsCommandService;
+    }
+
+    public int getSelectedCommandID() {
+        return selectedCommandID;
+    }
+
+    public void setSelectedCommandID(int selectedCommandID) {
+        this.selectedCommandID = selectedCommandID;
+    }
+
+    public String getSeperator() {
+        return seperator;
+    }
+
+    public void setSeperator(String seperator) {
+        this.seperator = seperator;
+    }
+
+    public DataElementService getDataElementService() {
+        return dataElementService;
+    }
+
+    public void setDataElementService(DataElementService dataElementService) {
+        this.dataElementService = dataElementService;
+    }
+
+    public String getCodeSeperator() {
+        return codeSeperator;
+    }
+
+    public void setCodeSeperator(String codeSeperator) {
+        this.codeSeperator = codeSeperator;
+    }
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.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/smscommand/SMSCommandAction.java	2012-06-13 08:44:07 +0000
@@ -0,0 +1,111 @@
+package org.hisp.dhis.mobile.action.smscommand;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.smscommand.SMSCode;
+import org.hisp.dhis.smscommand.SMSCommandService;
+import org.hisp.dhis.smscommand.SMSCommand;
+
+import com.opensymphony.xwork2.Action;
+
+public class SMSCommandAction
+    implements Action
+{
+    private SMSCommandService smsCommandService;
+
+    private DataSetService dataSetService;
+
+    private int selectedCommandID = -1;
+
+    private Map<String, String> codes = new HashMap<String, String>();
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        if ( getSMSCommand() != null && getSMSCommand().getCodes() != null )
+        {
+            for ( SMSCode x : getSMSCommand().getCodes() )
+            {
+                codes.put( "" + x.getDataElement().getId() + x.getOptionId(), x.getCode() );
+            }
+        }
+        return SUCCESS;
+    }
+
+    public Set<DataElement> getDataSetElements()
+    {
+        if ( getSMSCommand() != null )
+        {
+            DataSet d = getSMSCommand().getDataset();
+            if ( d != null )
+            {
+                return d.getDataElements();
+            }
+        }
+        return null;
+    }
+
+    public Collection<DataSet> getDataSets()
+    {
+        return dataSetService.getAllDataSets();
+    }
+
+    public Collection<SMSCommand> getSMSCommands()
+    {
+        System.out.println( "get:" + smsCommandService.getSMSCommands() );
+        return smsCommandService.getSMSCommands();
+    }
+
+    public SMSCommand getSMSCommand()
+    {
+        if ( selectedCommandID > -1 )
+        {
+            return smsCommandService.getSMSCommand( selectedCommandID );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    public void setSmsCommandService( SMSCommandService smsCommandService )
+    {
+        this.smsCommandService = smsCommandService;
+    }
+
+    public int getSelectedCommandID()
+    {
+        return selectedCommandID;
+    }
+
+    public void setSelectedCommandID( int selectedCommandID )
+    {
+        this.selectedCommandID = selectedCommandID;
+    }
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    public Map<String, String> getCodes()
+    {
+        return codes;
+    }
+
+    public void setCodes( Map<String, String> codes )
+    {
+        this.codes = codes;
+    }
+
+}

=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/incoming'
=== 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-06-06 07:48:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-06-13 08:44:07 +0000
@@ -32,7 +32,7 @@
 		<property name="incomingSmsService"
 			ref="org.hisp.dhis.sms.incoming.IncomingSmsService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
 		class="org.hisp.dhis.mobile.action.incoming.UpdateReceiveSMSAction"
 		scope="prototype">
@@ -129,4 +129,30 @@
 		class="org.hisp.dhis.mobile.action.ReloadStartStopServiceAction"
 		scope="prototype" />
 
+	 <bean id="org.hisp.dhis.mobile.action.smscommand.SMSCommandAction" class="org.hisp.dhis.mobile.action.smscommand.SMSCommandAction"
+    scope="prototype">
+    <property name="smsCommandService" ref="smsCommandService" />
+    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+
+  </bean>
+
+  <bean id="org.hisp.dhis.mobile.action.smscommand.EditSMSCommandForm" class="org.hisp.dhis.mobile.action.smscommand.EditSMSCommandForm"
+    scope="prototype">
+    <property name="smsCommandService" ref="smsCommandService" />
+    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+
+  </bean>
+
+  <bean id="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm" class="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm"
+    scope="prototype">
+    <property name="smsCommandService" ref="smsCommandService" />
+    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction" class="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction"
+    scope="prototype">
+    <property name="smsCommandService" ref="smsCommandService" />
+  </bean>
+
 </beans>

=== 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-06-06 07:48:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2012-06-13 08:44:07 +0000
@@ -22,6 +22,7 @@
       <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
       <param name="requiredAuthorities">F_MOBILE_SETTINGS</param>
     </action>
+  
 
 	<!-- Sending SMS Action -->
   
@@ -164,6 +165,51 @@
       <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
+    
+      
+    <!-- SMSCommmand start -->
+     <action name="SMSCommands" class="org.hisp.dhis.mobile.action.smscommand.SMSCommandAction">
+      <result name="success" type="velocity">/main.vm</result>
+       <param name="page">/dhis-web-maintenance-mobile/smscommand/sms-commands.vm</param>
+        <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
+      <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>  
+    </action>
+    
+    <action name="newSMSCommand" class="org.hisp.dhis.mobile.action.smscommand.SMSCommandAction">
+      <result name="success" type="velocity">/main.vm</result>
+       <param name="page">/dhis-web-maintenance-mobile/smscommand/new-sms-command.vm</param>
+        <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
+      <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>  
+    </action>
+    
+    <action name="editSMSCommand" class="org.hisp.dhis.mobile.action.smscommand.SMSCommandAction">
+      <result name="success" type="velocity">/main.vm</result>
+       <param name="page">/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm</param>
+        <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
+      <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>  
+    </action>
+    
+    <action name="saveEditSMSCommandForm" class="org.hisp.dhis.mobile.action.smscommand.EditSMSCommandForm">
+          <result name="success" type="redirect">SMSCommands.action</result>
+    </action>
+
+    <action name="createSMSCommandForm" class="org.hisp.dhis.mobile.action.smscommand.CreateSMSCommandForm">
+          <result name="success" type="redirect">SMSCommands.action</result>
+    </action>
+    
+    <action name="deleteSMSCommand" class="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction">
+          <result name="success" type="redirect">SMSCommands.action</result>
+    </action>
+    
+    <!--  SMSCommand end -->
+     <action name="sendSMS" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction">
+      <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+      <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
+      <param name="onExceptionReturn">plainTextError</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	2012-05-29 07:58:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm	2012-06-13 08:44:07 +0000
@@ -6,4 +6,6 @@
 	<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>
+	<li><a href="SMSCommands.action">$i18n.getString( "sms_command_from" )</a></li>
+	
 </ul>
\ No newline at end of file

=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand'
=== added 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	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/smscommand/edit-sms-command.vm	2012-06-13 08:44:07 +0000
@@ -0,0 +1,72 @@
+<script langauge="Javascript">
+    function prepSubmit(){
+ 
+      var selectedDataOptions = '{"codes":[';      
+      $("#codes input").each(function(){
+            selectedDataOptions += '{"dataElementId" :' + $(this).attr('name').split('.')[0] +  ',';  
+            selectedDataOptions += '"optionId" :' + $(this).attr('name').split('.')[1] + ',';
+            selectedDataOptions += '"code" :"' + $(this).val() + '"},';
+            $(this).attr('name',''); // avoid error in struts 
+      });
+      selectedDataOptions += ']}';
+     
+      $("#codeDataelementOption").val(selectedDataOptions);
+      $("#updateSMSCommand").submit(); 
+    }
+</script>
+
+
+<div>
+    </div>
+
+<form id="updateSMSCommand" name="updateSMSCommand" action="saveEditSMSCommandForm.action" method="post">
+
+ <!-- 
+    * Unik kommando navn
+    * OID
+ -->
+    <input type="hidden" value="$selectedCommandID" name="selectedCommandID" />
+    Name: <input type="text" name="name" value="$SMSCommand.name" />
+   
+    <div>
+    DataSet: 
+    <!-- onchange="window.location.href='editSMSCommand.action?selectedDataSetID=' + this.options[this.selectedIndex].value" -->
+    <select name="selectedDataSetID" >
+        #foreach( $dataSet in $dataSets )
+          <option value="$dataSet.id" #if ($SMSCommand.dataset.id == $dataSet.id) selected #end >$dataSet.name</option>
+        #end
+    </select> 
+    </div>
+    <div>
+    Separator: <input type="text" #if($SMSCommand.seperator) value="$SMSCommand.seperator" #end name="seperator" />
+    </div>
+    <div>
+    Code seperator: <input type="text" #if($SMSCommand.codeSeperator) value="$SMSCommand.codeSeperator" #end name="codeSeperator" />
+    </div>
+    <table id="codes">
+        <tr>
+            <td>Data Element Category Combination</td>
+            <td>Code</td>
+        </tr>     
+         #foreach( $dataElement in $dataSetElements)
+            #if ($dataElement.categoryCombo && $dataElement.categoryCombo.categories) 
+                #foreach($category in $dataElement.categoryCombo.categories)
+                    #foreach($option in $category.categoryOptions)
+                    <tr>
+                        <td>$dataElement.name $option.name</td>
+                        #set ($str = ""+$dataElement.id+""+$option.id)
+                        <td><input type="text" name="$dataElement.id.$option.id" value='$!codes[$str]'></td>
+                    </tr>         
+                    #end
+                #end
+            #else
+            <tr>
+               <td>$dataElement.name</td>
+               <td><input type="text" name="$dataElement.id"></td>   
+            </tr>         
+            #end  
+         #end
+    </table>
+    <input type="hidden" name="codeDataelementOption" id="codeDataelementOption" />
+    <input type="button" onclick="prepSubmit()" value="save" />
+</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/smscommand/new-sms-command.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/new-sms-command.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/smscommand/new-sms-command.vm	2012-06-13 08:44:07 +0000
@@ -0,0 +1,23 @@
+<form id="newSMSCommand" name="updateSMSCommand" action="createSMSCommandForm.action" method="post">
+    <div>
+     Name: <input type="text" value="" id="name" name="name" />
+    </div>
+    
+    <div>
+    Parser: 
+    <select name="parser">
+          <option value="syntax1">Syntax1</option>
+          <option value="syntax2">Syntax2</option>
+    </select> 
+    </div>
+    <div>
+  
+    Dataset:
+    <select name="selectedDataSetID" >
+        #foreach( $dataSet in $dataSets )
+          <option value="$dataSet.id" #if ($SMSCommand.dataset.id == $dataSet.id) selected #end >$dataSet.name</option>
+        #end
+    </select> 
+    </div>
+    <input id="save" type="submit" />
+</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/smscommand/sms-commands.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/sms-commands.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/smscommand/sms-commands.vm	2012-06-13 08:44:07 +0000
@@ -0,0 +1,12 @@
+<a href="newSMSCommand.action">New command</a>
+
+<br>
+<br>
+<div>
+   #foreach( $command in $SMSCommands )
+    <div>    
+    $command.name <a href="editSMSCommand.action?selectedCommandID=$command.id">Edit</a>
+    <a href="deleteSMSCommand.action?deleteCommandId=$command.id">Delete</a>
+    </div>
+    #end
+</div>
\ No newline at end of file