dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06887
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1927: send organisation unit id when save data value in data entry form
------------------------------------------------------------
revno: 1927
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Wed 2010-08-18 10:47:58 +0700
message:
send organisation unit id when save data value in data entry form
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-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java 2010-08-18 03:47:58 +0000
@@ -39,6 +39,7 @@
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;
@@ -86,12 +87,19 @@
}
private DataElementCategoryService categoryService;
-
+
public void setCategoryService( DataElementCategoryService categoryService )
{
this.categoryService = categoryService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -103,6 +111,13 @@
this.comment = comment;
}
+ private int organisationUnitId;
+
+ public void setOrganisationUnitId( int organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
private int dataElementId;
public void setDataElementId( int dataElementId )
@@ -114,7 +129,7 @@
{
return dataElementId;
}
-
+
private Integer optionComboId;
public void setOptionComboId( Integer optionComboId )
@@ -149,12 +164,12 @@
public String execute()
{
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
Period period = selectedStateManager.getSelectedPeriod();
DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
+
DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
storedBy = currentUserService.getCurrentUsername();
@@ -181,7 +196,8 @@
{
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-04 07:02:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java 2010-08-18 03:47:58 +0000
@@ -41,6 +41,7 @@
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 +53,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
@@ -85,21 +86,28 @@
{
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
// -------------------------------------------------------------------------
@@ -111,6 +119,13 @@
this.value = value;
}
+ private int organisationUnitId;
+
+ public void setOrganisationUnitId( int organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
private int dataElementId;
public void setDataElementId( int dataElementId )
@@ -148,16 +163,16 @@
// Action implementation
// -------------------------------------------------------------------------
- public String execute()
- {
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ public String execute()
+ {
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
Period period = selectedStateManager.getSelectedPeriod();
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- storedBy = currentUserService.getCurrentUsername();
-
+ storedBy = currentUserService.getCurrentUsername();
+
if ( storedBy == null )
{
storedBy = "[unknown]";
@@ -167,18 +182,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 )
@@ -187,7 +202,8 @@
{
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 );
}
@@ -195,22 +211,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 );
}
}
@@ -220,6 +236,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-04 07:02:13 +0000
+++ 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
@@ -39,6 +39,7 @@
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;
@@ -51,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,12 +87,19 @@
}
private DataElementCategoryService categoryService;
-
+
public void setCategoryService( DataElementCategoryService categoryService )
{
this.categoryService = categoryService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -103,6 +111,13 @@
this.value = value;
}
+ private int organisationUnitId;
+
+ public void setOrganisationUnitId( int organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
private int dataElementId;
public void setDataElementId( int dataElementId )
@@ -114,7 +129,7 @@
{
return dataElementId;
}
-
+
private int optionComboId;
public void setOptionComboId( int optionComboId )
@@ -146,18 +161,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;
}
// -------------------------------------------------------------------------
@@ -166,16 +181,16 @@
public String execute()
{
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
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]";
@@ -185,17 +200,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 )
{
@@ -203,7 +218,8 @@
{
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 );
}
}
@@ -214,7 +230,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-07-07 10:22:14 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2010-08-18 03:47:58 +0000
@@ -141,6 +141,7 @@
<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"
@@ -162,6 +163,7 @@
<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 2009-11-07 14:09:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js 2010-08-18 03:47:58 +0000
@@ -70,6 +70,7 @@
{
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';
@@ -112,7 +113,7 @@
if ( value < min )
{
- var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ffcccc' );
+ var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ffcccc' );
valueSaver.save();
window.alert( i18n_value_of_data_element_less + '\n\n' + dataElementName );
@@ -122,7 +123,7 @@
if ( value > max )
{
- var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ffcccc' );
+ var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ffcccc' );
valueSaver.save();
window.alert( i18n_value_of_data_element_greater + '\n\n' + dataElementName);
@@ -134,7 +135,7 @@
}
}
- var valueSaver = new ValueSaver( dataElementId, optionComboId, field.value, '#ccffcc', '' );
+ var valueSaver = new ValueSaver( organisationUnitId, dataElementId, optionComboId, field.value, '#ccffcc', '' );
valueSaver.save();
if ( type == 'int')
@@ -146,21 +147,23 @@
function saveBoolean( dataElementId, optionComboId, selectedOption )
{
+ var organisationUnitId = getFieldValue( 'organisationUnitId' );
+
selectedOption.style.backgroundColor = '#ffffcc';
- var valueSaver = new ValueSaver( dataElementId, optionComboId, selectedOption.options[selectedOption.selectedIndex].value, '#ccffcc', selectedOption );
+ var valueSaver = new ValueSaver( organisationUnitId, 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( dataElementId, '', field.value, '#ccffcc', '' );
+ var valueSaver = new ValueSaver( organisationUnitId, dataElementId, '', field.value, '#ccffcc', '' );
valueSaver.save();
}
@@ -168,11 +171,12 @@
{
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( dataElementId, optionComboId, commentValue );
+ var commentSaver = new CommentSaver( organisationUnitId, dataElementId, optionComboId, commentValue );
commentSaver.save();
}
@@ -192,16 +196,17 @@
// Saver objects
// -----------------------------------------------------------------------------
-function ValueSaver( dataElementId_, optionComboId_, value_, resultColor_, selectedOption_ )
+function ValueSaver( organisationUnitId_, 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()
{
@@ -209,7 +214,7 @@
request.setCallbackSuccess( handleResponse );
request.setCallbackError( handleHttpError );
request.setResponseTypeXML( 'status' );
- request.send( 'saveValue.action?dataElementId=' +
+ request.send( 'saveValue.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' +
dataElementId + '&value=' + value );
};
@@ -262,13 +267,14 @@
}
}
-function CommentSaver( dataElementId_, optionComboId_, value_ )
+function CommentSaver( organisationUnitId_, dataElementId_, optionComboId_, value_ )
{
var SUCCESS = '#ccffcc';
var ERROR = '#ccccff';
var dataElementId = dataElementId_;
var optionComboId = optionComboId_
+ var organisationUnitId = organisationUnitId_;
var value = value_;
this.save = function()
@@ -277,7 +283,7 @@
request.setCallbackSuccess( handleResponse );
request.setCallbackError( handleHttpError );
request.setResponseTypeXML( 'status' );
- request.send( 'saveComment.action?dataElementId=' +
+ request.send( 'saveComment.action?organisationUnitId=' + organisationUnitId+ '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-04 07:02:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2010-08-18 03:47:58 +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>