← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6958: [mobile] clean up

 

------------------------------------------------------------
revno: 6958
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-16 16:33:38 +0700
message:
  [mobile] clean up
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/completedProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/programStageForm.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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java	2012-05-15 09:48:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java	2012-05-16 09:33:38 +0000
@@ -83,9 +83,9 @@
     {
         this.programStageInstanceService = programStageInstanceService;
     }
-    
+
     private PatientDataValueService patientDataValueService;
-    
+
     public PatientDataValueService getPatientDataValueService()
     {
         return patientDataValueService;
@@ -95,7 +95,6 @@
     {
         this.patientDataValueService = patientDataValueService;
     }
-    
 
     // -------------------------------------------------------------------------
     // Input & Output
@@ -112,9 +111,9 @@
     {
         this.programInstanceId = programInstanceId;
     }
-    
+
     private int programStageInstanceId;
-    
+
     public int getProgramStageInstanceId()
     {
         return programStageInstanceId;
@@ -221,7 +220,7 @@
     }
 
     private boolean current;
-    
+
     private Map<String, String> prevDataValues = new HashMap<String, String>();
 
     public Map<String, String> getPrevDataValues()
@@ -247,16 +246,15 @@
     public String execute()
         throws Exception
     {
-        // organisationUnit = organisationUnitService.getOrganisationUnit(
-        // Integer.parseInt( orgUnitId ) );
         prevDataValues.clear();
         programStage = util.getProgramStage( Integer.parseInt( programId ), Integer.parseInt( programStageId ) );
         dataElements = programStage.getDataElements();
-        Collection<PatientDataValue> patientDataValues =  patientDataValueService.getPatientDataValues( programStageInstanceService.getProgramStageInstance( programStageInstanceId ) );
-        for (PatientDataValue patientDataValue : patientDataValues) {
-            prevDataValues.put( "DE" + patientDataValue.getDataElement().getId() + "OC" + 4, patientDataValue.getValue() );
+        Collection<PatientDataValue> patientDataValues = patientDataValueService
+            .getPatientDataValues( programStageInstanceService.getProgramStageInstance( programStageInstanceId ) );
+        for ( PatientDataValue patientDataValue : patientDataValues )
+        {
+            prevDataValues.put( "DE" + patientDataValue.getDataElement().getId(), patientDataValue.getValue() );
         }
-        
         return SUCCESS;
 
     }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-05-15 07:40:06 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-05-16 09:33:38 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.api.mobile.model.DataElement;
 import org.hisp.dhis.api.mobile.model.DataValue;
 import org.hisp.dhis.api.mobile.model.ProgramStage;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.light.utils.NamebasedUtils;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -101,6 +102,18 @@
         this.patientService = patientService;
     }
 
+    private DataElementCategoryService dataElementCategoryService;
+
+    public DataElementCategoryService getDataElementCategoryService()
+    {
+        return dataElementCategoryService;
+    }
+
+    public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
+    {
+        this.dataElementCategoryService = dataElementCategoryService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -226,7 +239,7 @@
     {
         if ( orgUnitId != 0 )
         {
-            organisationUnit = organisationUnitService.getOrganisationUnit(  orgUnitId  );
+            organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
         }
         else
         {
@@ -236,7 +249,7 @@
         programStage = util.getProgramStage( Integer.parseInt( programId ), Integer.parseInt( programStageId ) );
 
         dataElements = programStage.getDataElements();
-
+        int defaultCategoryOptionId = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId();
         HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(
             ServletActionContext.HTTP_REQUEST );
         Map<String, String> parameterMap = ContextUtils.getParameterMap( request );
@@ -248,11 +261,10 @@
 
         for ( String key : parameterMap.keySet() )
         {
-            if ( key.startsWith( "DE" ) && key.indexOf( "OC" ) != -1 )
+            if ( key.startsWith( "DE" ) )
             {
-                String[] splitKey = key.split( "OC" );
-                Integer dataElementId = Integer.parseInt( splitKey[0].substring( 2 ) );
-                Integer categoryOptComboId = Integer.parseInt( splitKey[1] );
+                Integer dataElementId = Integer.parseInt( key.substring( 2, key.length()) );
+                // Integer categoryOptComboId = Integer.parseInt( splitKey[1] );
                 String value = parameterMap.get( key );
 
                 // validate types
@@ -275,7 +287,8 @@
                 DataValue dataValue = new DataValue();
                 dataValue.setId( dataElementId );
                 dataValue.setValue( value );
-                dataValue.setCategoryOptComboID( categoryOptComboId );
+
+                dataValue.setCategoryOptComboID( defaultCategoryOptionId );
 
                 dataValues.add( dataValue );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-05-15 09:48:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-05-16 09:33:38 +0000
@@ -197,7 +197,8 @@
 		<property name="dataElementService"
 			ref="org.hisp.dhis.dataelement.DataElementService"/>
 		<property name="util" ref="org.hisp.dhis.light.utils.NamebasedUtils"/>
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService"/>
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService"/>
+		<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
 	</bean>
 	
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/completedProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/completedProgramStageForm.vm	2012-05-15 07:40:06 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/completedProgramStageForm.vm	2012-05-16 09:33:38 +0000
@@ -28,9 +28,9 @@
 			#else
 				#set( $dataElementName = $dataElement.name )
 			#end
-				#if ($dataElement.getCategoryOptionCombos().getModels().size() == 1)			
+				#if (! $dataElement.getOptionSet())			
 					#set( $categoryOptionCombo = $dataElement.getCategoryOptionCombos().getModels().get( 0 ) )
-					#set( $key = "DE${dataElement.id}OC${categoryOptionCombo.id}" )
+					#set( $key = "DE${dataElement.id}" )
 
 					<label>$encoder.htmlEncode( $dataElementName ) #if( $categoryOptionCombo.name!="(default)")$encoder.htmlEncode( $categoryOptionCombo.name )#end 
 					#if($dataElement.type=="date") [yyyy-MM-dd] #end
@@ -51,10 +51,10 @@
 					#end 
 					name="$key" value="$!prevDataValues.get($key)" DISABLED/>
 				
-				#elseif ($dataElement.getCategoryOptionCombos().getModels().size() > 1)
+				#elseif ($dataElement.getOptionSet())
 					
-					#set( $categoryOptionCombo = $dataElement.getCategoryOptionCombos().getModels().get( 0 ) )
-					#set( $key = "DE${dataElement.id}OC${categoryOptionCombo.id}" )
+					#set( $options = $dataElement.getOptionSet().getOptions() )
+					#set( $key = "DE${dataElement.id}")
 
 					$dataElementName
 
@@ -75,13 +75,13 @@
 				
 					#set( $selected=false )
 
-					#foreach ($categoryOptionCombo in $dataElement.categoryOptionCombos.models)
-						<option value="$categoryOptionCombo.name"
-						#if( !$typeViolations.containsKey( $key ) && $prevDataValues.get( $key ) == $categoryOptionCombo.name ) 
+					#foreach ($option in $options)
+						<option value="$option"
+						#if( $prevDataValues.get( $key ) == $option ) 
 							selected
 							#set( $selected=true )
 						#end
-						> $categoryOptionCombo.name </option>
+						> $option </option>
 					#end
 
 					#if( !$selected ) 
@@ -94,12 +94,6 @@
 	</p>
 </div>
 
-<div class="header-box" align="center">
-	<p>
-		<input type="submit" style="width: 100%;" value="$i18n.getString("save")" />
-	</p>
-</div>
-
 </form>
 
 <div id="footer">

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/programStageForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/programStageForm.vm	2012-05-15 07:40:06 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/programStageForm.vm	2012-05-16 09:33:38 +0000
@@ -29,9 +29,9 @@
 			#else
 				#set( $dataElementName = $dataElement.name )
 			#end
-				#if ($dataElement.getCategoryOptionCombos().getModels().size() == 1)			
+				#if (! $dataElement.getOptionSet())			
 					#set( $categoryOptionCombo = $dataElement.getCategoryOptionCombos().getModels().get( 0 ) )
-					#set( $key = "DE${dataElement.id}OC${categoryOptionCombo.id}" )
+					#set( $key = "DE${dataElement.id}" )
 
 					<label>$encoder.htmlEncode( $dataElementName ) #if( $categoryOptionCombo.name!="(default)")$encoder.htmlEncode( $categoryOptionCombo.name )#end 
 					#if($dataElement.type=="date") [yyyy-MM-dd] #end
@@ -52,10 +52,10 @@
 					#end 
 					name="$key" value="$!prevDataValues.get($key)" />
 				
-				#elseif ($dataElement.getCategoryOptionCombos().getModels().size() > 1)
+				#elseif ($dataElement.getOptionSet())
 					
-					#set( $categoryOptionCombo = $dataElement.getCategoryOptionCombos().getModels().get( 0 ) )
-					#set( $key = "DE${dataElement.id}OC${categoryOptionCombo.id}" )
+					#set( $options = $dataElement.getOptionSet().getOptions() )
+					#set( $key = "DE${dataElement.id}" )
 
 					$dataElementName
 
@@ -76,13 +76,13 @@
 				
 					#set( $selected=false )
 
-					#foreach ($categoryOptionCombo in $dataElement.categoryOptionCombos.models)
-						<option value="$categoryOptionCombo.name"
-						#if( !$typeViolations.containsKey( $key ) && $prevDataValues.get( $key ) == $categoryOptionCombo.name ) 
+					#foreach ($option in $options)
+						<option value="$option"
+						#if( $prevDataValues.get( $key ) == $option ) 
 							selected
 							#set( $selected=true )
 						#end
-						> $categoryOptionCombo.name </option>
+						> $option </option>
 					#end
 
 					#if( !$selected )