← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13599: smscommand support for anonymous program

 

------------------------------------------------------------
revno: 13599
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2014-01-07 13:53:01 +0700
message:
  smscommand support for anonymous program
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
  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/CreateSMSCommandForm.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/resources/META-INF/dhis/beans.xml
  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


--
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	2013-12-13 16:03:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2014-01-07 06:53:01 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.sms.parse.ParserType;
 import org.hisp.dhis.user.UserGroup;
 
@@ -48,6 +49,10 @@
 
     private DataSet dataset;
 
+    // Support only anonymous program for now
+    
+    private Program program;
+
     private Set<SMSCode> codes;
 
     private String codeSeparator;
@@ -63,7 +68,8 @@
     private boolean currentPeriodUsedForReporting = false; // default is prev
 
     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 )
+        Set<SMSCode> codes, String codeSeparator, String defaultMessage, UserGroup userGroup, String receivedMessage,
+        Set<SMSSpecialCharacter> specialCharacters )
     {
         super();
         this.name = name;
@@ -129,6 +135,15 @@
         this.codes = codes;
     }
 
+    public SMSCommand( String name, String parser, String separator, Program program, Set<SMSCode> codes )
+    {
+        this.name = name;
+        this.parser = parser;
+        this.separator = separator;
+        this.program = program;
+        this.codes = codes;
+    }
+
     public SMSCommand( String parser, String name, DataSet dataset, Set<SMSCode> codes )
     {
         this.parser = parser;
@@ -296,4 +311,13 @@
         this.specialCharacters = specialCharacters;
     }
 
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    public void setProgram( Program program )
+    {
+        this.program = program;
+    }
 }

=== 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	2013-12-13 16:03:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml	2014-01-07 06:53:01 +0000
@@ -28,6 +28,8 @@
     <property name="currentPeriodUsedForReporting" type="boolean" />
 
     <many-to-one name="dataset" class="org.hisp.dhis.dataset.DataSet" column="datasetid" foreign-key="fk_dataset_datasetid" />
+    
+    <many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid" foreign-key="fk_program_programid" />
 
     <set name="codes" table="smscommandcodes">
       <key column="id" />

=== modified 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	2014-01-05 20:29:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java	2014-01-07 06:53:01 +0000
@@ -30,6 +30,8 @@
 
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.sms.parse.ParserType;
 import org.hisp.dhis.smscommand.SMSCommand;
 import org.hisp.dhis.smscommand.SMSCommandService;
@@ -66,12 +68,12 @@
         this.userGroupService = userGroupService;
     }
 
-    // private ProgramService programService;
-    //
-    // public void setProgramService( ProgramService programService )
-    // {
-    // this.programService = programService;
-    // }
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
 
     // -------------------------------------------------------------------------
     // Input && Output
@@ -104,7 +106,19 @@
     {
         this.userGroupID = userGroupID;
     }
+    
+    private Integer selectedProgramId;
+    
+    public Integer getSelectedProgramId()
+    {
+        return selectedProgramId;
+    }
 
+    public void setSelectedProgramId( Integer selectedProgramId )
+    {
+        this.selectedProgramId = selectedProgramId;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -130,7 +144,8 @@
         }
         else if ( parserType.equals( ParserType.ANONYMOUS_PROGRAM_PARSER ) )
         {
-
+            Program program = programService.getProgram( selectedProgramId );
+            command.setProgram(program);
         }
 
         smsCommandService.save( command );

=== modified 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	2013-12-24 08:11:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java	2014-01-07 06:53:01 +0000
@@ -166,12 +166,19 @@
         if ( smsCommand != null )
         {
             DataSet d = smsCommand.getDataset();
+            Program program = smsCommand.getProgram();
             if ( d != null )
             {
                 dataElements = new ArrayList<DataElement>( d.getDataElements() );
                 Collections.sort( dataElements, new DataElementSortOrderComparator() );
                 return dataElements;
             }
+            else if ( program != null )
+            {
+                dataElements = new ArrayList<DataElement>( program.getAllDataElements() );
+                Collections.sort( dataElements, new DataElementSortOrderComparator() );
+                return dataElements;
+            }
         }
         return null;
     }

=== 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	2013-12-24 08:11:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 06:53:01 +0000
@@ -162,6 +162,7 @@
 		<property name="smsCommandService" ref="smsCommandService" />
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.mobile.action.smscommand.DeleteSMSCommandAction"

=== 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	2013-11-29 09:50:53 +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-01-07 06:53:01 +0000
@@ -127,7 +127,7 @@
 			<td>#if($smsCommand.parserType) $smsCommand.parserType #end</td>
 		</tr>
 		
-		#if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' )
+		#if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' || $smsCommand.parserType == 'ANONYMOUS_PROGRAM_PARSER' )
 		<tr>
 			<td>$i18n.getString( "dataset" )</td>
 			<td>#if($smsCommand.dataset.name) $smsCommand.dataset.name #end</td>
@@ -170,7 +170,7 @@
 	
 	</br>
 	</br>
-	#if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' )
+	#if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' || $smsCommand.parserType == 'ANONYMOUS_PROGRAM_PARSER')
     <table id="codes">
 	<col style="width:350px"/><col/>
     <thead>

=== modified 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	2013-12-24 08:11:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/new-sms-command.vm	2014-01-07 06:53:01 +0000
@@ -61,9 +61,9 @@
 			<tr>
 				<td>$i18n.getString( "program" )</td>
 				<td>
-					<select name="programId" >
+					<select name="selectedProgramId" >
 					#foreach( $anonymousProgram in $anonymousProgramList )
-						<option value="$userGroup.id">$anonymousProgram.name</option>
+						<option value="$anonymousProgram.id">$anonymousProgram.name</option>
 					#end
 					</select>
 				</td>