← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2276: Added Schedular to send remainders for ANMs who haven't submit their daily report

 

------------------------------------------------------------
revno: 2276
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-12-03 18:59:28 +0530
message:
  Added Schedular to send remainders for ANMs who haven't submit their daily report
added:
  dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/
  dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java
modified:
  dhis-2/dhis-web/dhis-web-portal/india-pom.xml
  dhis-mobile/dhis-service-mobile/pom.xml
  dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/SmsService.java
  dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml
  local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/welcome.vm
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java
  local/in/dhis-in-services/dhis-in-service-reports/pom.xml
  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
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/AddUserAction.java
  local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.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-portal/india-pom.xml'
--- dhis-2/dhis-web/dhis-web-portal/india-pom.xml	2010-11-03 04:34:08 +0000
+++ dhis-2/dhis-web/dhis-web-portal/india-pom.xml	2010-12-03 13:29:28 +0000
@@ -119,12 +119,14 @@
       <type>war</type>
     </dependency>
 -->	
+<!--
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-web-mapping</artifactId>
       <version>${version}</version>
       <type>war</type>
     </dependency>
+-->
 <!--   
    <dependency>
       <groupId>org.hisp.dhis</groupId>
@@ -163,7 +165,6 @@
       <type>war</type>
     </dependency>
 
-
 	<dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-web-dataentry-national</artifactId>
@@ -185,6 +186,15 @@
       <type>war</type>
     </dependency>
 
+<!-- SMS Mobile application -->
+
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-web-mobile</artifactId>
+      <version>${version}</version>
+      <type>war</type>
+    </dependency>
+
 	
 <!--
     <dependency>

=== modified file 'dhis-mobile/dhis-service-mobile/pom.xml'
--- dhis-mobile/dhis-service-mobile/pom.xml	2010-10-21 06:32:42 +0000
+++ dhis-mobile/dhis-service-mobile/pom.xml	2010-12-03 13:29:28 +0000
@@ -23,66 +23,56 @@
 
     <dependencies>
 
-        <!-- DHIS -->
-
-        <dependency>
-            <groupId>org.hisp.dhis</groupId>
-            <artifactId>dhis-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hisp.dhis</groupId>
-            <artifactId>dhis-service-core</artifactId>
-        </dependency>
-
+		<!-- DHIS -->
+	
+		<dependency>
+			<groupId>org.hisp.dhis</groupId>
+			<artifactId>dhis-api</artifactId>
+		</dependency>
+		<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>${version}</version>
+		</dependency>   
+	
 		<!-- Other -->
-		<!--
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>org.springframework.context.support</artifactId>
-			<version>3.0.0.M1</version>
-		</dependency>
-		-->
-		
-		
+			
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-context-support</artifactId>
 			<version>3.0.4.RELEASE</version>
-		</dependency>
-			
+		</dependency>			
 		<dependency>
 			<groupId>opensymphony</groupId>
 			<artifactId>quartz</artifactId>
 			<version>1.6.3</version>
-		</dependency>
-		
-        <dependency>
-            <groupId>smslib</groupId>
-            <artifactId>smslib-all</artifactId>
-            <version>3.4.5</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.5.11</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-jdk14</artifactId>
-            <version>1.5.11</version>
-        </dependency>
-        <!--<dependency>
-            <groupId>javax.comm</groupId>
-            <artifactId>comm</artifactId>
-            <version>2.0</version>
-        </dependency>-->
-        <dependency>
-            <groupId>org.rxtx</groupId>
-            <artifactId>rxtx</artifactId>
-            <version>2.1.7</version>
-        </dependency>
-
+		</dependency>		
+		<dependency>
+			<groupId>smslib</groupId>
+			<artifactId>smslib-all</artifactId>
+			<version>3.4.5</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.5.11</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-jdk14</artifactId>
+			<version>1.5.11</version>
+		</dependency>
+		<dependency>
+			<groupId>org.rxtx</groupId>
+			<artifactId>rxtx</artifactId>
+			<version>2.1.7</version>
+		</dependency>
     </dependencies>
+	
     <properties>
         <rootDir>../../</rootDir>
     </properties>

=== modified file 'dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/SmsService.java'
--- dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/SmsService.java	2010-10-21 06:32:42 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/SmsService.java	2010-12-03 13:29:28 +0000
@@ -36,6 +36,7 @@
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -213,16 +214,21 @@
         {
             serv.createGroup( groupName );
             
+            //Collection<OutboundMessage> messages = new ArrayList<OutboundMessage>();
             for( String recepient : recepients )
             {
+                //OutboundMessage message = new OutboundMessage( recepient, msg );
+                //System.out.println("Phone:"+recepient);
+                //messages.add( message );
                 serv.addToGroup( groupName, recepient );
             }
-            
+
             OutboundMessage message = new OutboundMessage( groupName, msg );
-
+            
             try
             {
-                serv.sendMessage( message );
+               serv.sendMessage( message );
+                //serv.sendMessages( messages );
                 getService().getLogger().logInfo( "Message Sent to Group: " + groupName, null, null );
                 return "SUCCESS";
             } 

=== added directory 'dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java	2010-12-03 13:29:28 +0000
@@ -0,0 +1,150 @@
+package org.hisp.dhis.mobile.scheduler;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.mobile.SmsService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.DailyPeriodType;
+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.scheduling.quartz.QuartzJobBean;
+
+public class CheckDataStatusJob  extends QuartzJobBean
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ReportService reportService;
+
+    public void setReportService( ReportService reportService )
+    {
+        this.reportService = reportService;
+    }
+
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    private UserStore userStore;
+
+    public void setUserStore( UserStore userStore )
+    {
+        this.userStore = userStore;
+    }
+
+    private SmsService smsService;
+    
+    public void setSmsService( SmsService smsService )
+    {
+        this.smsService = smsService;
+    }
+
+    // -------------------------------------------------------------------------
+    // implementation
+    // -------------------------------------------------------------------------
+
+    protected void executeInternal( JobExecutionContext context ) throws JobExecutionException 
+    {
+        System.out.println("CheckDataStatus Job Started at : "+new Date() );
+        
+        List<OrganisationUnit> rootOrgUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getRootOrganisationUnits() );        
+        PeriodType dailyPeriodType = new DailyPeriodType();        
+        
+        Date curDate = new Date();
+        
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        
+        Period period = dailyPeriodType.createPeriod( curDate );
+        
+        if( period == null )
+        {
+            period = reloadPeriodForceAdd( period );
+        }
+        
+        int count = 1;
+        List<DataSet> dataSetList = new ArrayList<DataSet>( dataSetService.getDataSetsByPeriodType( dailyPeriodType ) ); 
+        for( DataSet dataSet : dataSetList )
+        {
+            List<String> phoneNumbers = new ArrayList<String>();
+            List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
+            
+            for( OrganisationUnit rootOrgUnit : rootOrgUnits )
+            {
+                orgUnitList.addAll( reportService.getDataNotSentOrgUnits( dataSet, period, rootOrgUnit ) );
+            }
+            
+            String groupName = "datastatusgroup"+count;
+            for( OrganisationUnit orgUnit : orgUnitList )
+            {
+                List<User> users = new ArrayList<User>( userStore.getUsersByOrganisationUnit( orgUnit ) );
+                for( User user : users )
+                {
+                    if( user.getPhoneNumber() != null && !user.getPhoneNumber().trim().equalsIgnoreCase( "" ) )
+                        phoneNumbers.add( user.getPhoneNumber() );
+                }
+            }
+            
+            String message = "YOU HAVE NOT SUBMIT UR REPORT FOR "+dataSet.getName()+" FOR "+simpleDateFormat.format( curDate )+"; PLEASE SUBMIT.";
+            
+            smsService.sendMessageToGroup( groupName, phoneNumbers, message );
+            
+            count++;
+        }
+        
+        System.out.println("CheckDataStatus Job Ended at : "+new Date() );
+    }
+
+    // -------------------------------------------------------------------------
+    // Support methods for reloading periods
+    // -------------------------------------------------------------------------
+    private final Period reloadPeriod( Period period )
+    {
+        return periodService.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
+    }
+
+    private final Period reloadPeriodForceAdd( Period period )
+    {
+        Period storedPeriod = reloadPeriod( period );
+
+        if ( storedPeriod == null )
+        {
+            periodService.addPeriod( period );
+
+            return period;
+        }
+
+        return storedPeriod;
+    }
+    
+}

=== 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-11-24 13:37:22 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2010-12-03 13:29:28 +0000
@@ -105,6 +105,32 @@
    </bean>
  -->
 
+<!-- CheckDataStatus Job -->
+    <bean id="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob"
+        class="org.hisp.dhis.mobile.scheduler.CheckDataStatusJob">
+    </bean>
+
+    <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="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"/>
+				<entry key="organisationUnitService" value-ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+				<entry key="periodService" value-ref="org.hisp.dhis.period.PeriodService"/>
+				<entry key="userStore" value-ref="org.hisp.dhis.user.UserStore"/>
+            </map>
+        </property>
+   </bean>
+
+   <bean id="cronTriggerForCheckDataStatusJob"
+        class="org.springframework.scheduling.quartz.CronTriggerBean">
+        <property name="jobDetail" ref="schedulerForCheckDataStatusJob" />
+        <property name="cronExpression" value="0 38 18 * * ?" />
+   </bean>
+
 <!-- Scheduler for all Jobs -->
 
 	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
@@ -115,8 +141,8 @@
 		-->
 		<property name="triggers">
 			<list>
-				<!--<ref bean="cronTriggerForSMSImport" />-->
-				<ref bean="simpleTriggerForSendSMS" />
+				<ref bean="cronTriggerForCheckDataStatusJob" />
+				<!--<ref bean="simpleTriggerForSendSMS" />-->
 			</list>
 		</property>
    </bean>

=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/welcome.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/welcome.vm	2010-11-15 08:26:40 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/welcome.vm	2010-12-03 13:29:28 +0000
@@ -1,7 +1,7 @@
 
 <H1><font face"Arial" color="blue">Home Page</font></H1>
 
-<H3><font face"Arial" color="red">List of Employees who got transferred but not yet Joined...</font></H3>
+<H3><font face"Arial" color="red">List of Employees who got transferred but not yet Posted...</font></H3>
 
 <table class="mainPageTable">
     <tr>

=== 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	2010-11-08 06:10:18 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2010-12-03 13:29:28 +0000
@@ -33,6 +33,7 @@
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -117,5 +118,7 @@
     List<Calendar> getStartingEndingPeriods( String deType , Period selectedPeriod );
     
     Period getPreviousPeriod( Period selectedPeriod );
+    
+    List<OrganisationUnit> getDataNotSentOrgUnits( DataSet dataSet, Period period, OrganisationUnit rootOrgunit );
 
 }

=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-reports/pom.xml	2010-08-20 09:13:09 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/pom.xml	2010-12-03 13:29:28 +0000
@@ -35,7 +35,11 @@
       <artifactId>dhis-in-service-configuration</artifactId>
       <version>${version}</version>
     </dependency>   
-	  
+	<dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-aggregationengine-default</artifactId>
+      <version>${version}</version>   
+    </dependency>	  
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-system</artifactId>

=== 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	2010-11-22 13:02:23 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2010-12-03 13:29:28 +0000
@@ -28,6 +28,7 @@
 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;
@@ -121,6 +122,14 @@
     {
         this.dataValueService = dataValueService;
     }
+    
+    private OrganisationUnitService organisationUnitService;
+    
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+    
     // -------------------------------------------------------------------------
     // Report_in
     // -------------------------------------------------------------------------
@@ -1384,4 +1393,98 @@
         return reportDesignList;
     }
     
+    
+    // -------------------------------------------------------------------------
+    // 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 '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	2010-09-18 12:30:36 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/resources/META-INF/dhis/beans.xml	2010-12-03 13:29:28 +0000
@@ -17,22 +17,16 @@
 	<bean id="org.hisp.dhis.reports.ReportService"
 		class="org.hisp.dhis.reports.DefaultReportService">
 		<property name="reportStore" ref="org.hisp.dhis.reports.ReportStore"/>
-		<property name="configurationService"
-			ref="org.hisp.dhis.config.ConfigurationService"/>
+		<property name="configurationService" ref="org.hisp.dhis.config.ConfigurationService"/>
 		<property name="jdbcTemplate" ref="jdbcTemplate"/>
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService"/>
-		<property name="dataSetService"
-			ref="org.hisp.dhis.dataset.DataSetService"/>
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService">
-		</property>
-		<property name="dataElementCategoryOptionComboService" ref="org.hisp.dhis.dataelement.DataElementCategoryService">
-		</property>
-		<property name="aggregationService" ref="org.hisp.dhis.aggregation.AggregationService">
-		</property>
-		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService">
-		</property>
-		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService">
-		</property>
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService"/>
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataElementCategoryOptionComboService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<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" />
 	</bean>
 	
 	<!-- DeletionHandlers -->

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/AddUserAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/AddUserAction.java	2010-08-28 10:15:38 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/AddUserAction.java	2010-12-03 13:29:28 +0000
@@ -7,6 +7,8 @@
 import java.util.Set;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.security.PasswordManager;
 import org.hisp.dhis.user.User;
@@ -44,6 +46,13 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private OrganisationUnitGroupService organisationUnitGroupService;
+    
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -59,11 +68,14 @@
 
         int userRoles[] = { 0, 1, 1, 3, 4, 6, 5 };
 //        int orgUnitLevels = organisationUnitService.getNumberOfOrganisationalLevels();
-        for ( int i = 4; i <= 4; i++ )
+        //for ( int i = 4; i <= 4; i++ )
         {
-            List<OrganisationUnit> ouList = new ArrayList<OrganisationUnit>( organisationUnitService
-                .getOrganisationUnitsAtLevel( i ) );
+           // List<OrganisationUnit> ouList = new ArrayList<OrganisationUnit>( organisationUnitService
+           //     .getOrganisationUnitsAtLevel( i ) );
 
+            //Hard Coded with orgunitgroupid for Himachal
+            OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( 7 );
+            List<OrganisationUnit> ouList = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
             for ( OrganisationUnit orgU : ouList )
             {
                 username = orgU.getShortName();
@@ -107,7 +119,8 @@
                 userCredentials.setUsername( username );
                 userCredentials.setPassword( passwordManager.encodePassword( username, rawPassword ) );
 
-                UserAuthorityGroup group = userStore.getUserAuthorityGroup( userRoles[i] );
+                //Hard Coded with the Subcenter UserRole Id
+                UserAuthorityGroup group = userStore.getUserAuthorityGroup( 8 );
                 userCredentials.getUserAuthorityGroups().add( group );
 
                 userStore.addUser( user );
@@ -116,7 +129,7 @@
             }// OrgUnit For Loop End
 
             System.out.println( "**********************************************" );
-            System.out.println( "User Creation for Level " + i + " is completed" );
+            //System.out.println( "User Creation for Level " + i + " is completed" );
         }// OrgUnitLevel for loop end
 
         System.out.println( "**********************************************" );

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-11-09 15:02:39 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-12-03 13:29:28 +0000
@@ -1321,6 +1321,9 @@
 		<property name="organisationUnitService">
 			<ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
 		</property>
+        <property name="organisationUnitGroupService">
+            <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+        </property>
 	</bean>
 	
 	<!-- AJAX Requests -->

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2010-11-02 09:31:44 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2010-12-03 13:29:28 +0000
@@ -27,5 +27,6 @@
         <li><a href = "quarterlyPhysicalReport.action ">Quarterly Physical Output Reports</a></li>              
         <li><a href = "csReviewReportForm.action">CS Review Reports</a></li>  
         <!--<li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>-->
+		<li><a href = "populateUsers.action">Populate Users</a></li>
     </ul>
 </ul>