← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9676: Additional null/empty checks

 

------------------------------------------------------------
revno: 9676
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-31 20:39:18 +0200
message:
  Additional null/empty checks
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitBatchHandler.java


--
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-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java	2012-10-01 11:28:38 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java	2013-01-31 18:39:18 +0000
@@ -76,7 +76,7 @@
 
     public Integer getCompleteDataSetRegistrations( DataSet dataSet, Collection<Integer> periods, Collection<Integer> relevantSources )
     {
-        if ( relevantSources == null || relevantSources.size() == 0 )
+        if ( relevantSources == null || relevantSources.isEmpty() || periods == null || periods.isEmpty() )
         {
             return 0;
         }        
@@ -93,7 +93,7 @@
 
     public Integer getCompleteDataSetRegistrations( DataSet dataSet, Collection<Integer> periods, Collection<Integer> relevantSources, int completenessOffset )
     {
-        if ( relevantSources == null || relevantSources.size() == 0 )
+        if ( relevantSources == null || relevantSources.isEmpty() || periods == null || periods.isEmpty() )
         {
             return 0;
         }        
@@ -120,7 +120,12 @@
     }
     
     public Integer getCompulsoryDataElementRegistrations( DataSet dataSet, Collection<Integer> children, Collection<Integer> periods, int completenessOffset )
-    {           
+    {
+        if ( children == null || children.isEmpty() || periods == null || periods.isEmpty() )
+        {
+            return 0;
+        }
+        
         final int compulsoryElements = dataSet.getCompulsoryDataElementOperands().size();
         
         final String deadlineCriteria = completenessOffset >= 0 ? "AND lastupdated <= " + statementBuilder.getAddDate( "pe.enddate", completenessOffset ) : "";
@@ -182,6 +187,11 @@
     
     public void deleteDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
     {
+        if ( dataSetIds == null || dataSetIds.isEmpty() || periodIds == null || periodIds.isEmpty() || organisationUnitIds == null || organisationUnitIds.isEmpty() )
+        {
+            return;
+        }
+        
         final String sql = 
             "DELETE FROM aggregateddatasetcompleteness " +
             "WHERE datasetid IN ( " + getCommaDelimitedString( dataSetIds ) + " ) " +

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitBatchHandler.java	2012-05-24 05:13:57 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitBatchHandler.java	2013-01-31 18:39:18 +0000
@@ -95,6 +95,7 @@
         statementBuilder.setColumn( "parentid" );
         statementBuilder.setColumn( "shortname" );
         statementBuilder.setColumn( "code" );
+        statementBuilder.setColumn( "description" );
         statementBuilder.setColumn( "openingdate" );
         statementBuilder.setColumn( "closeddate" );
         statementBuilder.setColumn( "active" );
@@ -112,6 +113,7 @@
         statementBuilder.setValue( unit.getParent() != null ? unit.getParent().getId() : null );
         statementBuilder.setValue( unit.getShortName() );
         statementBuilder.setValue( unit.getCode() );
+        statementBuilder.setValue( unit.getDescription() );
         statementBuilder.setValue( unit.getOpeningDate() );
         statementBuilder.setValue( unit.getClosedDate() );
         statementBuilder.setValue( unit.isActive() );