← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1932: Merged out r 1927, did not work properly

 

------------------------------------------------------------
revno: 1932
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Wed 2010-08-18 12:42:20 +0200
message:
  Merged out r 1927, did not work properly
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.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-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java	2010-08-18 10:42:20 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.de.state.SelectedStateManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.user.CurrentUserService;
 
@@ -87,19 +86,12 @@
     }
 
     private DataElementCategoryService categoryService;
-
+    
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -111,13 +103,6 @@
         this.comment = comment;
     }
 
-    private int organisationUnitId;
-
-    public void setOrganisationUnitId( int organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
     private int dataElementId;
 
     public void setDataElementId( int dataElementId )
@@ -129,7 +114,7 @@
     {
         return dataElementId;
     }
-
+    
     private Integer optionComboId;
 
     public void setOptionComboId( Integer optionComboId )
@@ -164,12 +149,12 @@
 
     public String execute()
     {
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         Period period = selectedStateManager.getSelectedPeriod();
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
+        
         DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
 
         storedBy = currentUserService.getCurrentUsername();
@@ -196,8 +181,7 @@
             {
                 LOG.debug( "Adding DataValue, comment added" );
 
-                dataValue = new DataValue( dataElement, period, organisationUnit, null, storedBy, new Date(), comment,
-                    optionCombo );
+                dataValue = new DataValue( dataElement, period, organisationUnit, null, storedBy, new Date(), comment, optionCombo );
 
                 dataValueService.addDataValue( dataValue );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2010-08-18 10:42:20 +0000
@@ -41,7 +41,6 @@
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.de.state.SelectedStateManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.user.CurrentUserService;
 
@@ -53,7 +52,7 @@
 public class SaveValueAction
     implements Action
 {
-    private static final Log log = LogFactory.getLog( SaveValueAction.class );
+    private static final Log log = LogFactory.getLog( SaveValueAction.class );    
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -86,28 +85,21 @@
     {
         this.dataValueAuditService = dataValueAuditService;
     }
-
+    
     private SelectedStateManager selectedStateManager;
 
     public void setSelectedStateManager( SelectedStateManager selectedStateManager )
     {
         this.selectedStateManager = selectedStateManager;
-    }
+    }    
 
     private DataElementCategoryService categoryService;
-
+    
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -119,13 +111,6 @@
         this.value = value;
     }
 
-    private int organisationUnitId;
-
-    public void setOrganisationUnitId( int organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
     private int dataElementId;
 
     public void setDataElementId( int dataElementId )
@@ -163,16 +148,16 @@
     // Action implementation
     // -------------------------------------------------------------------------
 
-    public String execute()
-    {
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+    public String execute()    
+    {    	
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         Period period = selectedStateManager.getSelectedPeriod();
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
-        storedBy = currentUserService.getCurrentUsername();
-
+        storedBy = currentUserService.getCurrentUsername();       
+        
         if ( storedBy == null )
         {
             storedBy = "[unknown]";
@@ -182,18 +167,18 @@
         {
             value = null;
         }
-
+        
         if ( value != null )
         {
             value = value.trim();
-        }
-
+        }   
+        
         // ---------------------------------------------------------------------
         // Save or update
         // ---------------------------------------------------------------------
-
+        
         DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-
+        
         DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, defaultOptionCombo );
 
         if ( dataValue == null )
@@ -202,8 +187,7 @@
             {
                 log.debug( "Adding DataValue" );
 
-                dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null,
-                    defaultOptionCombo );
+                dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null, defaultOptionCombo );
 
                 dataValueService.addDataValue( dataValue );
             }
@@ -211,22 +195,22 @@
         else
         {
             log.debug( "Updating DataValue" );
-
-            DataValueAudit audit = new DataValueAudit( dataValue, dataValue.getValue(), storedBy, new Date(), "" );
-
+            
+            DataValueAudit audit = new DataValueAudit(dataValue, dataValue.getValue(), storedBy, new Date(), "");
+            
             dataValue.setValue( value );
             dataValue.setTimestamp( new Date() );
             dataValue.setStoredBy( storedBy );
 
             dataValueService.updateDataValue( dataValue );
-
+            
             // -----------------------------------------------------------------
             // Add DataValueAudit
             // -----------------------------------------------------------------
-
+            
             if ( value != null )
             {
-                dataValueAuditService.addDataValueAudit( audit );
+            	dataValueAuditService.addDataValueAudit( audit );
             }
         }
 
@@ -236,6 +220,6 @@
             this.storedBy = dataValue.getStoredBy();
         }
 
-        return SUCCESS;
-    }
+        return SUCCESS;        
+    }    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/SaveValueAction.java	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/SaveValueAction.java	2010-08-18 10:42:20 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.de.state.SelectedStateManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.user.CurrentUserService;
 
@@ -52,7 +51,7 @@
 public class SaveValueAction
     implements Action
 {
-    private static final Log LOG = LogFactory.getLog( SaveValueAction.class );
+    private static final Log LOG = LogFactory.getLog( SaveValueAction.class );   
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -87,19 +86,12 @@
     }
 
     private DataElementCategoryService categoryService;
-
+    
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -111,13 +103,6 @@
         this.value = value;
     }
 
-    private int organisationUnitId;
-
-    public void setOrganisationUnitId( int organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
     private int dataElementId;
 
     public void setDataElementId( int dataElementId )
@@ -129,7 +114,7 @@
     {
         return dataElementId;
     }
-
+    
     private int optionComboId;
 
     public void setOptionComboId( int optionComboId )
@@ -161,18 +146,18 @@
     public String getStoredBy()
     {
         return storedBy;
-    }
-
+    }    
+    
     private String inputId;
 
     public String getInputId()
     {
         return inputId;
     }
-
+    
     public void setInputId( String inputId )
     {
-        this.inputId = inputId;
+    	this.inputId = inputId;
     }
 
     // -------------------------------------------------------------------------
@@ -181,16 +166,16 @@
 
     public String execute()
     {
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         Period period = selectedStateManager.getSelectedPeriod();
-
-        DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
-        storedBy = currentUserService.getCurrentUsername();
-
-        DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
-
+        
+        DataElement dataElement = dataElementService.getDataElement( dataElementId );        
+
+        storedBy = currentUserService.getCurrentUsername();        
+        
+        DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );        
+                
         if ( storedBy == null )
         {
             storedBy = "[unknown]";
@@ -200,17 +185,17 @@
         {
             value = null;
         }
-
+        
         if ( value != null )
         {
             value = value.trim();
-        }
-
+        }          
+      
         // ---------------------------------------------------------------------
         // Update data
         // ---------------------------------------------------------------------
 
-        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
+        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period,optionCombo  );        
 
         if ( dataValue == null )
         {
@@ -218,8 +203,7 @@
             {
                 LOG.debug( "Adding DataValue" );
 
-                dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null,
-                    optionCombo );
+                dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null, optionCombo );
                 dataValueService.addDataValue( dataValue );
             }
         }
@@ -230,7 +214,7 @@
             dataValue.setValue( value );
             dataValue.setTimestamp( new Date() );
             dataValue.setStoredBy( storedBy );
-
+                        
             dataValueService.updateDataValue( dataValue );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-08-18 10:42:20 +0000
@@ -141,7 +141,6 @@
 		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
 		<property name="categoryService"
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
-		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.de.action.multidimensional.SaveValueAction"
@@ -163,7 +162,6 @@
 		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
 		<property name="categoryService"
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
-		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" class="org.hisp.dhis.de.action.SaveMinMaxLimitsAction"

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js	2010-08-18 10:42:20 +0000
@@ -70,7 +70,6 @@
 {
     var field = document.getElementById( 'value[' + dataElementId + '].value' + ':' +  'value[' + optionComboId + '].value');
     var type = document.getElementById( 'value[' + dataElementId + '].type' ).innerHTML; 
-	var organisationUnitId = getFieldValue( 'organisationUnitId' );
     
     field.style.backgroundColor = '#ffffcc';   
     
@@ -113,7 +112,7 @@
 
                     if ( value < min )
                     {
-                        var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ffcccc' );
+                        var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ffcccc' );
                         valueSaver.save();
                         
                         window.alert( i18n_value_of_data_element_less + '\n\n' + dataElementName );
@@ -123,7 +122,7 @@
 
                     if ( value > max )
                     {
-                        var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ffcccc' );
+                        var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ffcccc' );
                         valueSaver.save();
                         
                         window.alert( i18n_value_of_data_element_greater + '\n\n' + dataElementName);
@@ -135,7 +134,7 @@
         }
     }
 
-    var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ccffcc', '' );
+    var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ccffcc', '' );
     valueSaver.save();    
     
     if ( type == 'int')
@@ -147,23 +146,21 @@
 
 function saveBoolean( dataElementId, optionComboId, selectedOption )
 {
-	var organisationUnitId = getFieldValue( 'organisationUnitId' );
-	
     selectedOption.style.backgroundColor = '#ffffcc';
     
-    var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, selectedOption.options[selectedOption.selectedIndex].value, '#ccffcc', selectedOption );
+    var valueSaver = new ValueSaver( dataElementId, optionComboId, selectedOption.options[selectedOption.selectedIndex].value, '#ccffcc', selectedOption );
     valueSaver.save();
 }
 
 function saveDate( dataElementId, dataElementName )
 {
-	var organisationUnitId = getFieldValue( 'organisationUnitId' );	
+	
 	var field = document.getElementById( 'value[' + dataElementId + '].date' );
     var type = document.getElementById( 'value[' + dataElementId + '].valueType' ).innerHTML;
     
     field.style.backgroundColor = '#ffffcc';
     
-    var valueSaver = new ValueSaver( organisationUnitId, dataElementId, '', field.value, '#ccffcc', '' );
+    var valueSaver = new ValueSaver( dataElementId, '', field.value, '#ccffcc', '' );
     valueSaver.save();
 }
 
@@ -171,12 +168,11 @@
 {
     var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
     var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
-	var organisationUnitId = getFieldValue( 'organisationUnitId' );
     
     field.style.backgroundColor = '#ffffcc';
     select.style.backgroundColor = '#ffffcc';
     
-    var commentSaver = new CommentSaver( organisationUnitId, dataElementId, optionComboId, commentValue );
+    var commentSaver = new CommentSaver( dataElementId, optionComboId, commentValue );
     commentSaver.save();
 }
 
@@ -196,17 +192,16 @@
 // Saver objects
 // -----------------------------------------------------------------------------
 
-function ValueSaver( organisationUnitId_, dataElementId_, optionComboId_, value_, resultColor_, selectedOption_ )
+function ValueSaver( dataElementId_, optionComboId_, value_, resultColor_, selectedOption_ )
 {
     var SUCCESS = '#ccffcc';
     var ERROR = '#ccccff';
 
-	var organisationUnitId = organisationUnitId_;
     var dataElementId = dataElementId_;
     var optionComboId = optionComboId_;
     var value = value_;
     var resultColor = resultColor_;
-    var selectedOption = selectedOption_; 	
+    var selectedOption = selectedOption_; 
     
     this.save = function()
     {
@@ -214,7 +209,7 @@
         request.setCallbackSuccess( handleResponse );
         request.setCallbackError( handleHttpError );
         request.setResponseTypeXML( 'status' );
-        request.send( 'saveValue.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' +
+        request.send( 'saveValue.action?dataElementId=' +
                 dataElementId + '&value=' + value );
     };
     
@@ -267,14 +262,13 @@
     }
 }
 
-function CommentSaver( organisationUnitId_, dataElementId_, optionComboId_, value_ )
+function CommentSaver( dataElementId_, optionComboId_, value_ )
 {
     var SUCCESS = '#ccffcc';
     var ERROR = '#ccccff';
 
     var dataElementId = dataElementId_;
     var optionComboId = optionComboId_
-	var organisationUnitId = organisationUnitId_;    
     var value = value_;
     
     this.save = function()
@@ -283,7 +277,7 @@
         request.setCallbackSuccess( handleResponse );
         request.setCallbackError( handleHttpError );
         request.setResponseTypeXML( 'status' );
-        request.send( 'saveComment.action?organisationUnitId=' + organisationUnitId+ 'dataElementId=' +
+        request.send( 'saveComment.action?dataElementId=' +
                 dataElementId + '&optionComboId=' + optionComboId + '&comment=' + value );
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2010-08-18 03:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2010-08-18 10:42:20 +0000
@@ -8,7 +8,7 @@
 </div>
 
 <form id="selectForm" name="selectForm" method="post" action="select.action">
-<input type="hidden" value="$organisationUnit.id" id="organisationUnitId"/>
+
 <div id="actions" style="width:200px text-align:right">
 	
     <input type="button" value="$i18n.getString( "change_order" )" onclick="changeOrder()" style="width:150px" #if( !$selectedDataSetId || !$auth.hasAccess( "dhis-web-dataentry", "getDataElementOrder" ) || !$useDefaultForm) disabled="disabled" #end><br>