← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2241: [DHIS Mobile] Do not allow save datavalue belonging to locked dataset

 

------------------------------------------------------------
revno: 2241
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: dhis2
timestamp: Wed 2010-12-01 14:03:19 +0700
message:
  [DHIS Mobile] Do not allow save datavalue belonging to locked dataset
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml


--
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-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-11-30 19:36:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-12-01 07:03:19 +0000
@@ -81,6 +81,8 @@
     private org.hisp.dhis.dataset.DataSetService dataSetService;
 
     private org.hisp.dhis.i18n.I18nService i18nService;
+    
+    private org.hisp.dhis.datalock.DataSetLockService dataSetLockService;
 
     // -------------------------------------------------------------------------
     // Service methods
@@ -124,6 +126,7 @@
 
         ds.setId( dataSet.getId() );
         ds.setName( dataSet.getName() );
+//        ds.setVersionDataSet( dataSet.getVersionDataSet() );
         ds.setPeriodType( dataSet.getPeriodType().getName() );
 
         List<Section> sectionList = new ArrayList<Section>();
@@ -196,6 +199,10 @@
         {
             return "INVALID_PERIOD";
         }
+        
+        if (isDataSetLocked(unit, dataSet, selectedPeriod)){
+            return "DATASET_LOCKED";
+        }
 
         Collection<org.hisp.dhis.dataelement.DataElement> dataElements = dataSet.getDataElements();
         Collection<Integer> dataElementIds = new ArrayList<Integer>( dataSetValue.getDataValues().size() );
@@ -228,6 +235,13 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
+    private boolean isDataSetLocked(OrganisationUnit unit, org.hisp.dhis.dataset.DataSet dataSet, Period selectedPeriod){
+        if(dataSetLockService.getDataSetLockByDataSetPeriodAndSource( dataSet, selectedPeriod, unit )!=null)
+            return true;
+            return false;        
+    }
+        
+    
     private void saveDataValues( DataSetValue dataSetValue,
         Map<Integer, org.hisp.dhis.dataelement.DataElement> dataElementMap, Period period, OrganisationUnit orgUnit,
         DataElementCategoryOptionCombo optionCombo )
@@ -266,9 +280,12 @@
             }
             else
             {
+                if ( value != null )
+                {
                 dataValue.setValue( value );
                 dataValue.setTimestamp( new Date() );
                 dataValueService.updateDataValue( dataValue );
+                }
             }
 
         }
@@ -327,5 +344,13 @@
     {
         this.i18nService = i18nService;
     }
+    
+    @Required
+    public void setDataSetLockService( org.hisp.dhis.datalock.DataSetLockService dataSetLockService )
+    {
+        this.dataSetLockService = dataSetLockService;
+    }
+    
+    
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-12-01 07:03:19 +0000
@@ -26,6 +26,7 @@
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+    <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
   </bean>
 
   <bean id="org.hisp.dhis.web.api.service.ActivityReportingService" class="org.hisp.dhis.web.api.service.ActivityReportingServiceImpl">