← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2526: Removed mobile module dependency on indian module by moving a method from the overridden ReportSe...

 

------------------------------------------------------------
revno: 2526
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-01-11 22:28:18 +0530
message:
  Removed mobile module dependency on indian module by moving a method from the overridden ReportService to CheckDataStatusJob.
modified:
  dhis-mobile/dhis-service-mobile/pom.xml
  dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java
  dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java
  local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java
  local/in/dhis-in-services/dhis-in-service-reports/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-mobile/dhis-service-mobile/pom.xml'
--- dhis-mobile/dhis-service-mobile/pom.xml	2010-12-29 06:38:03 +0000
+++ dhis-mobile/dhis-service-mobile/pom.xml	2011-01-11 16:58:18 +0000
@@ -32,11 +32,6 @@
 		<dependency>
 			<groupId>org.hisp.dhis</groupId>
 			<artifactId>dhis-service-core</artifactId>
-		</dependency>
-		<dependency>
-		  <groupId>org.hisp.dhis</groupId>
-		  <artifactId>dhis-in-service-reports</artifactId>
-		  <version>${project.version}</version>
 		</dependency>   
 	
 		<!-- Other -->
@@ -44,7 +39,7 @@
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-context-support</artifactId>
-			<version>3.0.4.RELEASE</version>
+			<version>${spring.version}</version>
 		</dependency>			
 		<dependency>
 			<groupId>opensymphony</groupId>

=== modified file 'dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java'
--- dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java	2010-12-03 13:29:28 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java	2011-01-11 16:58:18 +0000
@@ -15,11 +15,12 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.reports.ReportService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserStore;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
 import org.springframework.scheduling.quartz.QuartzJobBean;
 
 public class CheckDataStatusJob  extends QuartzJobBean
@@ -28,11 +29,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private ReportService reportService;
-
-    public void setReportService( ReportService reportService )
+    private JdbcTemplate jdbcTemplate;
+    
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
     {
-        this.reportService = reportService;
+        this.jdbcTemplate = jdbcTemplate;
     }
 
     private DataSetService dataSetService;
@@ -101,7 +102,7 @@
             
             for( OrganisationUnit rootOrgUnit : rootOrgUnits )
             {
-                orgUnitList.addAll( reportService.getDataNotSentOrgUnits( dataSet, period, rootOrgUnit ) );
+                orgUnitList.addAll( getDataNotSentOrgUnits( dataSet, period, rootOrgUnit ) );
             }
             
             String groupName = "datastatusgroup"+count;
@@ -146,5 +147,101 @@
 
         return storedPeriod;
     }
+
+    // -------------------------------------------------------------------------
+    // Get List of Orgunits that are not submiteed data for selected dataset and period 
+    // -------------------------------------------------------------------------
+    public List<OrganisationUnit> getDataNotSentOrgUnits( DataSet dataSet, Period period, OrganisationUnit rootOrgunit )
+    {
+        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( rootOrgunit.getId() ) );
+                
+        Iterator<OrganisationUnit> orgUnitIterator = orgUnitList.iterator();
+        while( orgUnitIterator.hasNext() )
+        {
+            OrganisationUnit orgUnit = orgUnitIterator.next();
+            
+            if( !dataSetService.getDataSetsBySource( orgUnit ).contains( dataSet ) )
+            {
+                orgUnitIterator.remove();
+            }
+        }
+        
+        String deInfoAndCount = getDataSetMembersUsingQuery( dataSet.getId() );
+        
+        String deInfo = deInfoAndCount.split( ":" )[0];
+        
+        int dataSetMemberCount = Integer.parseInt( deInfoAndCount.split( ":" )[1] );
+        
+        orgUnitIterator = orgUnitList.iterator();
+        while( orgUnitIterator.hasNext() )            
+        {
+            OrganisationUnit orgUnit = orgUnitIterator.next();
+            
+            String query = "SELECT COUNT(*) FROM datavalue WHERE dataelementid IN (" + deInfo + ") AND sourceid = " + orgUnit.getId() + " AND periodid = " + period.getId();
+            
+            SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
+
+            double dataStatusPercentatge = 0.0;
+
+            if ( sqlResultSet.next() )
+            {
+                try
+                {
+                    dataStatusPercentatge = ( (double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount) * 100.0;
+                }
+                catch( Exception e )
+                {
+                    dataStatusPercentatge = 0.0;
+                }
+            }
+            
+            if( dataStatusPercentatge > 0 )
+            {
+                orgUnitIterator.remove();
+            }
+        }
+        
+        return orgUnitList;
+    }
+    
+    
+    String getDataSetMembersUsingQuery( int dataSetId )
+    {
+        String query = "SELECT dataelementid FROM datasetmembers WHERE datasetid =" + dataSetId;
+        
+        StringBuffer deInfo = new StringBuffer( "-1" );
+
+        SqlRowSet result = jdbcTemplate.queryForRowSet( query );
+        
+        int dataSetMemberCount = 0;
+        if ( result != null )
+        {
+            result.beforeFirst();
+
+            while ( result.next() )
+            {
+                int deId = result.getInt( 1 );
+                deInfo.append( "," ).append( deId );
+                
+                String query1 = "SELECT COUNT(*) FROM categorycombos_optioncombos WHERE categorycomboid IN ( SELECT categorycomboid FROM dataelement WHERE dataelementid = "+ deId +")";
+                
+                SqlRowSet result1 = jdbcTemplate.queryForRowSet( query1 );
+                
+                if( result1 != null )
+                {
+                    result1.beforeFirst();
+                    result1.next();
+                    dataSetMemberCount += result1.getInt( 1 );
+                }
+            }
+        }
+        
+        deInfo.append( ":"+dataSetMemberCount );
+        
+        return deInfo.toString();
+    }
+    
+    
+
     
 }

=== modified file 'dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2010-12-30 05:17:07 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2011-01-11 16:58:18 +0000
@@ -105,15 +105,16 @@
  -->
 
 <!-- CheckDataStatus Job -->
+
     <bean id="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob"
-        class="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob">
-    </bean>
+        class="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob" />
 
     <bean name="schedulerForCheckDataStatusJob"
         class="org.springframework.scheduling.quartz.JobDetailBean">
         <property name="jobClass" value="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob" />
         <property name="jobDataAsMap">
             <map>
+                <entry key="jdbcTemplate" value-ref="jdbcTemplate"/>
                 <entry key="smsService" value-ref="org.hisp.dhis.mobile.SmsService"/>
                 <entry key="reportService" value-ref="org.hisp.dhis.reports.ReportService"/>
 				<entry key="dataSetService" value-ref="org.hisp.dhis.dataset.DataSetService"/>

=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-01-10 07:58:36 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-01-11 16:58:18 +0000
@@ -119,7 +119,7 @@
     
     Period getPreviousPeriod( Period selectedPeriod );
     
-    List<OrganisationUnit> getDataNotSentOrgUnits( DataSet dataSet, Period period, OrganisationUnit rootOrgunit );
+    // List<OrganisationUnit> getDataNotSentOrgUnits( DataSet dataSet, Period period, OrganisationUnit rootOrgunit );
 
     String getResultSurveyValue( String formula, OrganisationUnit organisationUnit );
     

=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2011-01-10 07:58:36 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2011-01-11 16:58:18 +0000
@@ -29,7 +29,6 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -128,13 +127,6 @@
         this.dataValueService = dataValueService;
     }
     
-    private OrganisationUnitService organisationUnitService;
-    
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-    
     private SurveyService surveyService;
 
     public void setSurveyService( SurveyService surveyService )
@@ -1418,100 +1410,6 @@
     }
     
     
-    // -------------------------------------------------------------------------
-    // Get List of Orgunits that are not submiteed data for selected dataset and period 
-    // -------------------------------------------------------------------------
-    public List<OrganisationUnit> getDataNotSentOrgUnits( DataSet dataSet, Period period, OrganisationUnit rootOrgunit )
-    {
-        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( rootOrgunit.getId() ) );
-                
-        Iterator<OrganisationUnit> orgUnitIterator = orgUnitList.iterator();
-        while( orgUnitIterator.hasNext() )
-        {
-            OrganisationUnit orgUnit = orgUnitIterator.next();
-            
-            if( !dataSetService.getDataSetsBySource( orgUnit ).contains( dataSet ) )
-            {
-                orgUnitIterator.remove();
-            }
-        }
-        
-        String deInfoAndCount = getDataSetMembersUsingQuery( dataSet.getId() );
-        
-        String deInfo = deInfoAndCount.split( ":" )[0];
-        
-        int dataSetMemberCount = Integer.parseInt( deInfoAndCount.split( ":" )[1] );
-        
-        orgUnitIterator = orgUnitList.iterator();
-        while( orgUnitIterator.hasNext() )            
-        {
-            OrganisationUnit orgUnit = orgUnitIterator.next();
-            
-            String query = "SELECT COUNT(*) FROM datavalue WHERE dataelementid IN (" + deInfo + ") AND sourceid = " + orgUnit.getId() + " AND periodid = " + period.getId();
-            
-            SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
-
-            double dataStatusPercentatge = 0.0;
-
-            if ( sqlResultSet.next() )
-            {
-                try
-                {
-                    dataStatusPercentatge = ( (double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount) * 100.0;
-                }
-                catch( Exception e )
-                {
-                    dataStatusPercentatge = 0.0;
-                }
-            }
-            
-            if( dataStatusPercentatge > 0 )
-            {
-                orgUnitIterator.remove();
-            }
-        }
-        
-        return orgUnitList;
-    }
-    
-    
-    String getDataSetMembersUsingQuery( int dataSetId )
-    {
-        String query = "SELECT dataelementid FROM datasetmembers WHERE datasetid =" + dataSetId;
-        
-        StringBuffer deInfo = new StringBuffer( "-1" );
-
-        SqlRowSet result = jdbcTemplate.queryForRowSet( query );
-        
-        int dataSetMemberCount = 0;
-        if ( result != null )
-        {
-            result.beforeFirst();
-
-            while ( result.next() )
-            {
-                int deId = result.getInt( 1 );
-                deInfo.append( "," ).append( deId );
-                
-                String query1 = "SELECT COUNT(*) FROM categorycombos_optioncombos WHERE categorycomboid IN ( SELECT categorycomboid FROM dataelement WHERE dataelementid = "+ deId +")";
-                
-                SqlRowSet result1 = jdbcTemplate.queryForRowSet( query1 );
-                
-                if( result1 != null )
-                {
-                    result1.beforeFirst();
-                    result1.next();
-                    dataSetMemberCount += result1.getInt( 1 );
-                }
-            }
-        }
-        
-        deInfo.append( ":"+dataSetMemberCount );
-        
-        return deInfo.toString();
-    }
-    
-    
     public String getResultSurveyValue( String formula, OrganisationUnit organisationUnit )
     {
         try

=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/resources/META-INF/dhis/beans.xml	2011-01-08 05:58:26 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/resources/META-INF/dhis/beans.xml	2011-01-11 16:58:18 +0000
@@ -26,7 +26,6 @@
 		<property name="aggregationService" ref="org.hisp.dhis.aggregation.AggregationService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
-		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="surveyService" ref="org.hisp.dhis.survey.SurveyService" />
         <property name="surveyDataValueService" ref="org.hisp.dhis.surveydatavalue.SurveyDataValueService" />
 		<property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />