← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2624: Data sets posted to api set to complete.

 

------------------------------------------------------------
revno: 2624
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-01-18 23:14:59 +0530
message:
  Data sets posted to api set to complete.
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	2011-01-17 16:26:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2011-01-18 17:44:59 +0000
@@ -40,8 +40,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.completeness.impl.RegistrationDataSetCompletenessService;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator;
+import org.hisp.dhis.dataset.CompleteDataSetRegistration;
+import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.DailyPeriodType;
 import org.hisp.dhis.period.MonthlyPeriodType;
@@ -87,6 +90,8 @@
 
     private org.hisp.dhis.web.api.service.ModelMapping modelMapping;
 
+    private CompleteDataSetRegistrationService registrationService;
+
     // -------------------------------------------------------------------------
     // Service methods
     // -------------------------------------------------------------------------
@@ -241,12 +246,30 @@
             saveValue(unit, period, dataElement, dataValue);
 
         }
+        
+        CompleteDataSetRegistration registration = 
+            registrationService.getCompleteDataSetRegistration( dataSet, period, unit );
+
+        if (registration != null) {
+            registrationService.deleteCompleteDataSetRegistration( registration );
+        }
+        
+        registration = new CompleteDataSetRegistration();
+        
+        registration.setDataSet( dataSet );
+        registration.setPeriod( period );
+        registration.setSource( unit );
+        registration.setDate( new Date() );
+
+        registrationService.saveCompleteDataSetRegistration( registration );
+
     }
 
     private Map<Integer, org.hisp.dhis.dataelement.DataElement> getDataElementIdMapping(
         org.hisp.dhis.dataset.DataSet dataSet )
     {
         Map<Integer, org.hisp.dhis.dataelement.DataElement> dataElementMap = new HashMap<Integer, org.hisp.dhis.dataelement.DataElement>();
+
         for ( org.hisp.dhis.dataelement.DataElement dataElement : dataSet.getDataElements() )
         {
             dataElementMap.put( dataElement.getId(), dataElement );
@@ -366,4 +389,11 @@
         this.modelMapping = modelMapping;
     }
 
+    @Required
+    public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
+    {
+        this.registrationService = registrationService;
+    }
+
+
 }

=== 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	2011-01-12 03:46:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2011-01-18 17:44:59 +0000
@@ -27,6 +27,7 @@
     <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" />
+    <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
 	<property name="modelMapping" ref="org.hisp.dhis.web.api.service.ModelMapping" />
   </bean>