← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21615: ADX, code style

 

------------------------------------------------------------
revno: 21615
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-01-06 12:43:22 +0100
message:
  ADX, code style
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataSetMetadata.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.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-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2016-01-06 11:43:22 +0000
@@ -61,7 +61,7 @@
     /**
      * Cache for system settings. Does not accept nulls.
      */
-    private static Cache<String, Optional<Serializable>> SETTING_CACHE = CacheBuilder.newBuilder()
+    private static final Cache<String, Optional<Serializable>> SETTING_CACHE = CacheBuilder.newBuilder()
         .expireAfterAccess( 1, TimeUnit.HOURS )
         .initialCapacity( 200 )
         .maximumSize( 400 )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataSetMetadata.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataSetMetadata.java	2016-01-06 11:26:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataSetMetadata.java	2016-01-06 11:43:22 +0000
@@ -1,3 +1,5 @@
+package org.hisp.dhis.dxf2.adx;
+
 /*
  * Copyright (c) 2015, UiO
  * All rights reserved.
@@ -23,7 +25,6 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-package org.hisp.dhis.dxf2.adx;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -40,67 +41,73 @@
  *
  * @author bobj
  */
-public class AdxDataSetMetadata {
-    
+public class AdxDataSetMetadata
+{
     private final DataSet dataSet;
-   
-    // lookup categoryoptions per catoptcombo
+
+    // Lookup category options per catoptcombo
+    
     private final Map<Integer, Map<String, String>> categoryOptionMap;
 
-    AdxDataSetMetadata(DataSet dataSet) throws AdxException
+    AdxDataSetMetadata( DataSet dataSet )
+        throws AdxException
     {
         this.dataSet = dataSet;
-        
+
         categoryOptionMap = new HashMap<>();
-        
+
         Set<DataElementCategoryCombo> catCombos = new HashSet<>();
+
+        catCombos.add( dataSet.getCategoryCombo() );
         
-        catCombos.add(dataSet.getCategoryCombo());
-        for (DataElement dataElement : dataSet.getDataElements())
+        for ( DataElement dataElement : dataSet.getDataElements() )
         {
-            catCombos.add(dataElement.getCategoryCombo());
+            catCombos.add( dataElement.getCategoryCombo() );
         }
-        
-        for (DataElementCategoryCombo categoryCombo : catCombos)
+
+        for ( DataElementCategoryCombo categoryCombo : catCombos )
         {
-            for (DataElementCategoryOptionCombo catOptCombo : categoryCombo.getOptionCombos())
+            for ( DataElementCategoryOptionCombo catOptCombo : categoryCombo.getOptionCombos() )
             {
-                addExplodedCategoryAttributes(catOptCombo);
+                addExplodedCategoryAttributes( catOptCombo );
             }
         }
     }
-    
-    private void addExplodedCategoryAttributes( DataElementCategoryOptionCombo coc ) 
-            throws AdxException
+
+    private void addExplodedCategoryAttributes( DataElementCategoryOptionCombo coc )
+        throws AdxException
     {
         Map<String, String> categoryAttributes = new HashMap<>();
-        
-        if (!coc.isDefault())
-        {            
-            for (DataElementCategory category : coc.getCategoryCombo().getCategories()) 
+
+        if ( !coc.isDefault() )
+        {
+            for ( DataElementCategory category : coc.getCategoryCombo().getCategories() )
             {
                 String categoryCode = category.getCode();
-                if (categoryCode == null || !XMLChar.isValidName(categoryCode)) {
-                    throw new AdxException(
-                            "Category code for " + category.getName() + " is missing or invalid: " + categoryCode);
-                }
-
-                String catOptCode = category.getCategoryOption(coc).getCode();
-                if (catOptCode == null || catOptCode.isEmpty()) {
-                    throw new AdxException(
-                            "CategoryOption code for " + category.getCategoryOption(coc).getName() + " is missing");
-                }
-
-                categoryAttributes.put(categoryCode, catOptCode);
+                
+                if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
+                {
+                    throw new AdxException(
+                        "Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
+                }
+
+                String catOptCode = category.getCategoryOption( coc ).getCode();
+                
+                if ( catOptCode == null || catOptCode.isEmpty() )
+                {
+                    throw new AdxException(
+                        "CategoryOption code for " + category.getCategoryOption( coc ).getName() + " is missing" );
+                }
+
+                categoryAttributes.put( categoryCode, catOptCode );
             }
         }
-        
-        categoryOptionMap.put(coc.getId(), categoryAttributes);
-    }    
-    
+
+        categoryOptionMap.put( coc.getId(), categoryAttributes );
+    }
+
     public Map<String, String> getExplodedCategoryAttributes( int cocId )
     {
-        return this.categoryOptionMap.get(cocId);
+        return this.categoryOptionMap.get( cocId );
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java	2016-01-06 11:26:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java	2016-01-06 11:43:22 +0000
@@ -135,16 +135,18 @@
         for ( DataSet dataSet : params.getDataSets() )
         {
             AdxDataSetMetadata metadata;
-            try 
-            {
-                metadata = new AdxDataSetMetadata(dataSet);
-            } catch (AdxException ex) 
-            {
-                log.info("Export failed for dataset: " + dataSet.getName());
-                log.info("Error: " + ex.getMessage());
+
+            try
+            {
+                metadata = new AdxDataSetMetadata( dataSet );
+            }
+            catch ( AdxException ex )
+            {
+                log.info( "Export failed for dataset: " + dataSet.getName() );
+                log.info( "Error: " + ex.getMessage() );
                 continue;
             }
-            
+
             DataElementCategoryCombo categoryCombo = dataSet.getCategoryCombo();
 
             List<DataElementCategory> categories = categoryCombo.getCategories();
@@ -169,8 +171,7 @@
                             adxWriter.writeAttribute( attribute, attributeDimensions.get( attribute ) );
                         }
 
-                        for ( DataValue dv : dataValueService.getDataValues( orgUnit, period, dataSet.getDataElements(),
-                            aoc ) )
+                        for ( DataValue dv : dataValueService.getDataValues( orgUnit, period, dataSet.getDataElements(), aoc ) )
                         {
                             adxWriter.openElement( AdxDataService.DATAVALUE );