← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3476: Bumped version to 2.3-SNAPSHOT, fixed some compile errors due to core refactoring.

 

------------------------------------------------------------
revno: 3476
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-04-27 17:58:10 +0200
message:
  Bumped version to 2.3-SNAPSHOT, fixed some compile errors due to core refactoring.
modified:
  dhis-mobile/dhis-service-mobile/pom.xml
  dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/api/DefaultMobileImportService.java
  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/sms/DefaultSmsImportService.java
  dhis-mobile/dhis-web-mobile/pom.xml
  dhis-mobile/pom.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	2011-03-27 15:43:20 +0000
+++ dhis-mobile/dhis-service-mobile/pom.xml	2011-04-27 15:58:10 +0000
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.hisp.dhis</groupId>
         <artifactId>dhis-services</artifactId>
-        <version>2.2-SNAPSHOT</version>
+        <version>2.3-SNAPSHOT</version>
     </parent>
 
     <artifactId>dhis-service-mobile</artifactId>

=== modified file 'dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/api/DefaultMobileImportService.java'
--- dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/api/DefaultMobileImportService.java	2011-04-05 01:04:43 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/api/DefaultMobileImportService.java	2011-04-27 15:58:10 +0000
@@ -56,7 +56,6 @@
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.mobile.SmsService;
-import org.hisp.dhis.mobile.api.ReceiveSMSService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.DailyPeriodType;
@@ -66,7 +65,6 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.WeeklyPeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.source.Source;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserStore;
@@ -1174,9 +1172,9 @@
                     return "Phone number is not registered to any facility. Please contact admin";
                 }
 
-                List<Source> sources = new ArrayList<Source>( curUser.getOrganisationUnits() );
+                List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( curUser.getOrganisationUnits() );
 
-                if ( sources == null || sources.size() <= 0 )
+                if ( units == null || units.size() <= 0 )
                 {
                     LOG.error( " No User Exists with corresponding Phone Numbers : "
                         + mobImportParameters.getMobileNumber() );
@@ -1185,7 +1183,7 @@
                     return "Phone number is not registered to any facility. Please contact admin";
                 }
                 
-                Source source = sources.get( 0 );
+                OrganisationUnit unit = units.get( 0 );
 
                 Period period = getPeriodInfo( mobImportParameters.getStartDate(), mobImportParameters.getPeriodType() );
 
@@ -1213,7 +1211,7 @@
                 {
                     LOG.error( "dataValue map is null" );
                 }
-                else if ( source == null )
+                else if ( unit == null )
                 {
                     LOG.error( "source is null" );
                 }
@@ -1226,7 +1224,7 @@
                     LOG.error( "timeStamp is null" );
                 }
 
-                if ( source == null || period == null || timeStamp == null || dataValueMap == null
+                if ( unit == null || period == null || timeStamp == null || dataValueMap == null
                     || dataValueMap.size() <= 0 )
                 {
 
@@ -1255,13 +1253,13 @@
                     optionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( Integer
                         .valueOf( optStr ) );
 
-                    DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, optionCombo );
+                    DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, optionCombo );
 
                     if ( dataValue == null )
                     {
                         if ( value != null )
                         {
-                            insertQuery += "( "+ dataElement.getId() + ", " + period.getId() + ", "+ source.getId() +", " + optionCombo.getId() + ", '" + value + "', '" + storedBy + "', '" + lastUpdatedDate + "' ), ";
+                            insertQuery += "( "+ dataElement.getId() + ", " + period.getId() + ", "+ unit.getId() +", " + optionCombo.getId() + ", '" + value + "', '" + storedBy + "', '" + lastUpdatedDate + "' ), ";
 
                             insertFlag = 2;
                         }

=== 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	2011-04-05 01:04:43 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/scheduler/CheckDataStatusJob.java	2011-04-27 15:58:10 +0000
@@ -16,21 +16,21 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 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
+public class CheckDataStatusJob
+    extends QuartzJobBean
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
     private JdbcTemplate jdbcTemplate;
-    
+
     public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
     {
         this.jdbcTemplate = jdbcTemplate;
@@ -57,15 +57,8 @@
         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;
@@ -75,55 +68,57 @@
     // implementation
     // -------------------------------------------------------------------------
 
-    protected void executeInternal( JobExecutionContext context ) throws JobExecutionException 
+    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();        
-        
+        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");
-        
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+
         Period period = dailyPeriodType.createPeriod( curDate );
-        
-        if( period == null )
+
+        if ( period == null )
         {
             period = reloadPeriodForceAdd( period );
         }
-        
+
         int count = 1;
-        List<DataSet> dataSetList = new ArrayList<DataSet>( dataSetService.getDataSetsByPeriodType( dailyPeriodType ) ); 
-        for( DataSet dataSet : dataSetList )
+        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 )
+
+            for ( OrganisationUnit rootOrgUnit : rootOrgUnits )
             {
                 orgUnitList.addAll( getDataNotSentOrgUnits( dataSet, period, rootOrgUnit ) );
             }
-            
-            String groupName = "datastatusgroup"+count;
-            for( OrganisationUnit orgUnit : orgUnitList )
+
+            String groupName = "datastatusgroup" + count;
+            for ( OrganisationUnit orgUnit : orgUnitList )
             {
-                List<User> users = new ArrayList<User>( userStore.getUsersByOrganisationUnit( orgUnit ) );
-                for( User user : users )
+                for ( User user : orgUnit.getUsers() )
                 {
-                    if( user.getPhoneNumber() != null && !user.getPhoneNumber().trim().equalsIgnoreCase( "" ) )
+                    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.";
-            
+
+            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() );
+
+        System.out.println( "CheckDataStatus Job Ended at : " + new Date() );
     }
 
     // -------------------------------------------------------------------------
@@ -149,36 +144,39 @@
     }
 
     // -------------------------------------------------------------------------
-    // Get List of Orgunits that are not submiteed data for selected dataset and period 
+    // 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() ) );
-                
+        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>(
+            organisationUnitService.getOrganisationUnitWithChildren( rootOrgunit.getId() ) );
+
         Iterator<OrganisationUnit> orgUnitIterator = orgUnitList.iterator();
-        while( orgUnitIterator.hasNext() )
+        while ( orgUnitIterator.hasNext() )
         {
             OrganisationUnit orgUnit = orgUnitIterator.next();
-            
-            /*if( !dataSetService.getDataSetsBySource( orgUnit ).contains( dataSet ) )
-            {
-                orgUnitIterator.remove();
-            }*/
+
+            /*
+             * 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() )            
+        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();
-            
+
+            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;
@@ -187,32 +185,31 @@
             {
                 try
                 {
-                    dataStatusPercentatge = ( (double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount) * 100.0;
+                    dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount) * 100.0;
                 }
-                catch( Exception e )
+                catch ( Exception e )
                 {
                     dataStatusPercentatge = 0.0;
                 }
             }
-            
-            if( dataStatusPercentatge > 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 )
         {
@@ -222,12 +219,13 @@
             {
                 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 +")";
-                
+
+                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 )
+
+                if ( result1 != null )
                 {
                     result1.beforeFirst();
                     result1.next();
@@ -235,13 +233,10 @@
                 }
             }
         }
-        
-        deInfo.append( ":"+dataSetMemberCount );
-        
+
+        deInfo.append( ":" + dataSetMemberCount );
+
         return deInfo.toString();
     }
-    
-    
 
-    
 }

=== modified file 'dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/sms/DefaultSmsImportService.java'
--- dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/sms/DefaultSmsImportService.java	2011-04-05 01:04:43 +0000
+++ dhis-mobile/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/sms/DefaultSmsImportService.java	2011-04-27 15:58:10 +0000
@@ -34,6 +34,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
+
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -44,6 +45,7 @@
 import org.hisp.dhis.mobile.sms.api.SmsImportService;
 import org.hisp.dhis.mobile.sms.api.SmsInbound;
 import org.hisp.dhis.mobile.sms.api.SmsInboundStoreService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.DailyPeriodType;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
@@ -51,7 +53,6 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.WeeklyPeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.source.Source;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserStore;
@@ -231,14 +232,14 @@
                                 + sms.getOriginator(), null, null );
                             return -1;
                         }
-                        List<Source> sources = new ArrayList<Source>( curUser.getOrganisationUnits() );
-                        if ( sources == null || sources.size() <= 0 )
+                        List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( curUser.getOrganisationUnits() );
+                        if ( units == null || units.size() <= 0 )
                         {
                             Logger.getInstance().logError( " User with phone number not assigned any organization unit : "
                                 + sms.getOriginator(), null, null );
                             return -1;
                         }
-                        Source source = sources.get( 0 );
+                        OrganisationUnit unit = units.get( 0 );
                         Period period = getPeriodInfo( dataSms.getPeriodText(), dataSms.getPeriodTypeId() );
 
                         String[] deIds = props.getProperty( dataSms.getFormId() ).split( "\\," );
@@ -260,13 +261,13 @@
 
                                 optionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( Integer.valueOf( optStr ) );
 
-                                DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, optionCombo );
+                                DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, optionCombo );
 
                                 if ( dataValue == null )
                                 {
                                     if ( dataValues[i] != null )
                                     {
-                                        dataValue = new DataValue( dataElement, period, source, optionCombo );
+                                        dataValue = new DataValue( dataElement, period, unit, optionCombo );
                                         dataValueService.addDataValue( dataValue );
                                         saveCount++;
                                     }

=== modified file 'dhis-mobile/dhis-web-mobile/pom.xml'
--- dhis-mobile/dhis-web-mobile/pom.xml	2011-04-05 01:04:43 +0000
+++ dhis-mobile/dhis-web-mobile/pom.xml	2011-04-27 15:58:10 +0000
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.hisp.dhis</groupId>
     <artifactId>dhis-web</artifactId>
-    <version>2.2-SNAPSHOT</version>
+    <version>2.3-SNAPSHOT</version>
   </parent>
 
   <artifactId>dhis-web-mobile</artifactId>
@@ -32,7 +32,7 @@
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-mobile</artifactId>
-      <version>2.2-SNAPSHOT</version>
+      <version>2.3-SNAPSHOT</version>
       <type>jar</type>
     </dependency>
 

=== modified file 'dhis-mobile/pom.xml'
--- dhis-mobile/pom.xml	2011-03-02 03:38:25 +0000
+++ dhis-mobile/pom.xml	2011-04-27 15:58:10 +0000
@@ -5,7 +5,7 @@
   
   <groupId>org.hisp.dhis</groupId>
   <artifactId>dhis-sms</artifactId>
-  <version>2.2-SNAPSHOT</version>
+  <version>2.3-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>Mobile SMS Modules</name>