dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16085
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6021: do not complete a set if dataset is locked
------------------------------------------------------------
revno: 6021
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-02-17 19:29:45 +0700
message:
do not complete a set if dataset is locked
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonResponseSuccess.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonResponseSuccess.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonResponseSuccess.vm 2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonResponseSuccess.vm 2012-02-17 12:29:45 +0000
@@ -1,4 +1,5 @@
{
"response": "success",
"message": "$!encoder.jsonEncode( ${message} )"
+ #if( $statusCode ),"status": $statusCode#end
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2012-02-16 19:58:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2012-02-17 12:29:45 +0000
@@ -123,6 +123,13 @@
this.organisationUnitId = organisationUnitId;
}
+ private int statusCode;
+
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -137,6 +144,19 @@
String storedBy = currentUserService.getCurrentUsername();
+ // ---------------------------------------------------------------------
+ // Check locked status
+ // ---------------------------------------------------------------------
+
+ if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
+ {
+ return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
+ }
+
+ // ---------------------------------------------------------------------
+ // Register as completed dataSet
+ // ---------------------------------------------------------------------
+
if ( registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit ) == null )
{
registration.setDataSet( dataSet );
@@ -156,4 +176,22 @@
return SUCCESS;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String logError( String message )
+ {
+ return logError( message, 1 );
+ }
+
+ private String logError( String message, int statusCode )
+ {
+ log.info( message );
+
+ this.statusCode = statusCode;
+
+ return SUCCESS;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java 2012-02-16 19:58:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java 2012-02-17 12:29:45 +0000
@@ -97,6 +97,13 @@
this.organisationUnitId = organisationUnitId;
}
+ private int statusCode;
+
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -105,9 +112,22 @@
{
DataSet dataSet = dataSetService.getDataSet( dataSetId );
Period period = PeriodType.createPeriodExternalId( periodId );
- OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, unit );
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ // ---------------------------------------------------------------------
+ // Check locked status
+ // ---------------------------------------------------------------------
+
+ if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
+ {
+ return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
+ }
+
+ // ---------------------------------------------------------------------
+ // Un-register as completed dataSet
+ // ---------------------------------------------------------------------
+
+ CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit );
if ( registration != null )
{
@@ -118,4 +138,22 @@
return SUCCESS;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String logError( String message )
+ {
+ return logError( message, 1 );
+ }
+
+ private String logError( String message, int statusCode )
+ {
+ log.info( message );
+
+ this.statusCode = statusCode;
+
+ return SUCCESS;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2012-02-17 06:58:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2012-02-17 12:29:45 +0000
@@ -154,4 +154,6 @@
next_year=Next year
see_details = See details
username = Username
-user_roles = User roles
\ No newline at end of file
+user_roles = User roles
+register_complete_failed_dataset_is_locked=Data set is locked, registration failed, please contact admin
+unregister_complete_failed_dataset_is_locked=Data set is locked, un-registration failed, please contact admin
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2012-02-17 11:21:53 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2012-02-17 12:29:45 +0000
@@ -205,13 +205,21 @@
cache: false,
success: function( data, textStatus, jqXHR )
{
- log( 'Successfully saved complete dataset with value: ' + value );
- storageManager.clearCompleteDataSet( value );
- ( array = array.slice( 1 ) ).length && pushCompleteDataSets( array );
+ if( data.status == 2 )
+ {
+ log( 'DataSet is locked' );
+ setHeaderMessage( i18n_register_complete_failed_dataset_is_locked );
+ }
+ else
+ {
+ log( 'Successfully saved complete dataset with value: ' + value );
+ storageManager.clearCompleteDataSet( value );
+ ( array = array.slice( 1 ) ).length && pushCompleteDataSets( array );
- if ( array.length < 1 )
- {
- setHeaderDelayMessage( i18n_sync_success );
+ if ( array.length < 1 )
+ {
+ setHeaderDelayMessage( i18n_sync_success );
+ }
}
},
error: function( jqXHR, textStatus, errorThrown )
@@ -251,11 +259,10 @@
success: function( data, textStatus, jqXHR )
{
if ( data.c == 2 ) {
- log( 'DataSet is now locked' );
-
+ log( 'DataSet is locked' );
setHeaderMessage( i18n_saving_value_failed_dataset_is_locked );
}
- else
+ else
{
storageManager.clearDataValueJSON( value );
log( 'Successfully saved data value with value: ' + value );
@@ -885,8 +892,6 @@
{
var params = storageManager.getCurrentCompleteDataSetParams();
- disableCompleteButton();
-
$.ajax( { url: 'getValidationViolations.action',
cache: false,
data: params,
@@ -914,13 +919,23 @@
url: 'registerCompleteDataSet.action',
data: params,
cache: false,
- success: function()
+ success: function(data)
{
- storageManager.clearCompleteDataSet( params );
-
- if ( json.response == 'input' )
- {
- validate();
+ if( data.status == 2 )
+ {
+ log( 'DataSet is locked' );
+ setHeaderMessage( i18n_register_complete_failed_dataset_is_locked );
+ }
+ else
+ {
+ disableCompleteButton();
+
+ storageManager.clearCompleteDataSet( params );
+
+ if ( json.response == 'input' )
+ {
+ validate();
+ }
}
}
} );
@@ -933,15 +948,23 @@
if ( confirmed )
{
- disableUndoButton();
-
$.ajax( {
url: 'undoCompleteDataSet.action',
data: params,
cache: false,
- success: function()
+ success: function(data)
{
- storageManager.clearCompleteDataSet( params );
+ if( data.status == 2 )
+ {
+ log( 'DataSet is locked' );
+ setHeaderMessage( i18n_unregister_complete_failed_dataset_is_locked );
+ }
+ else
+ {
+ disableUndoButton();
+ storageManager.clearCompleteDataSet( params );
+ }
+
},
error: function()
{
=== 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 2012-02-16 19:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2012-02-17 12:29:45 +0000
@@ -34,6 +34,8 @@
var i18n_ajax_login_failed = '$encoder.jsEscape( $i18n.getString( "ajax_login_failed" ) , "'")';
var i18n_no_dataelement_selected = '$encoder.jsEscape( $i18n.getString( "no_dataelement_selected" ) , "'")';
var i18n_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "dataset_is_locked" ) , "'")';
+var i18n_register_complete_failed_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "register_complete_failed_dataset_is_locked" ) , "'")';
+var i18n_unregister_complete_failed_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "unregister_complete_failed_dataset_is_locked" ) , "'")';
</script>
<h3>$i18n.getString( "data_entry" ) #openHelp( "dataEntry" )</h3>