← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20489: Removed unused code

 

------------------------------------------------------------
revno: 20489
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-10-03 11:03:51 +0200
message:
  Removed unused code
removed:
  dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/LoggingHashMap.java
  dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/DebugUtilsTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTable.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java
  dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/DebugUtils.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-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTable.java	2015-10-02 16:41:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTable.java	2015-10-03 09:03:51 +0000
@@ -103,8 +103,8 @@
     public abstract Optional<List<Object[]>> getPopulateTempTableContent();
     
     /**
-     * Creates a SQL index create statement. Note that the index name must have 
-     * a random component to avoid uniqueness conflicts.
+     * Creates a SQL index create statement for the temp table. Note that the 
+     * index name must have a random component to avoid uniqueness conflicts.
      * 
      * @return a SQL statement.
      */

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java	2015-10-03 09:03:51 +0000
@@ -29,6 +29,7 @@
  */
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.amplecode.quick.BatchHandler;
@@ -71,7 +72,6 @@
 import org.hisp.dhis.period.PeriodStore;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.commons.collection.LoggingHashMap;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -338,7 +338,7 @@
 
         batchHandler.init();
 
-        Map<Object, Integer> periodMap = new LoggingHashMap<>();
+        Map<Object, Integer> periodMap = new HashMap<>();
 
         Map<Object, Period> mapping = NameMappingUtil.getPeriodMap();
 
@@ -372,7 +372,7 @@
 
         batchHandler.init();
 
-        Map<Period, Integer> periodMap = new LoggingHashMap<>();
+        Map<Period, Integer> periodMap = new HashMap<>();
 
         Collection<Period> periods = NameMappingUtil.getPeriodMap().values();
 
@@ -406,7 +406,7 @@
     @Transactional
     public Map<String, Integer> getPeriodTypeMapping()
     {
-        Map<String, Integer> periodTypeMap = new LoggingHashMap<>();
+        Map<String, Integer> periodTypeMap = new HashMap<>();
 
         Collection<PeriodType> periodTypes = periodStore.getAllPeriodTypes();
 
@@ -427,7 +427,7 @@
     {
         batchHandler.init();
 
-        Map<Object, Integer> identifierMap = new LoggingHashMap<>();
+        Map<Object, Integer> identifierMap = new HashMap<>();
 
         if ( nameMap != null )
         {
@@ -452,7 +452,7 @@
     private Map<Object, Integer> getMapping( Map<Object, DataElementCategoryOptionCombo> categoryOptionComboMap,
         boolean skipMapping )
     {
-        Map<Object, Integer> identifierMap = new LoggingHashMap<>();
+        Map<Object, Integer> identifierMap = new HashMap<>();
 
         if ( categoryOptionComboMap != null )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java	2015-09-03 03:11:47 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java	2015-10-03 09:03:51 +0000
@@ -33,7 +33,6 @@
 
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.commons.collection.LoggingHashMap;
 
 /**
  * @author Lars Helge Overland
@@ -486,7 +485,7 @@
     
     public static Map<Object, String> getDataElementAggregationOperatorMap()
     {
-        return dataElementAggregationOperatorMap.get() != null ? new LoggingHashMap<>( dataElementAggregationOperatorMap.get() ) : new HashMap<>();
+        return dataElementAggregationOperatorMap.get() != null ? new HashMap<>( dataElementAggregationOperatorMap.get() ) : new HashMap<>();
     }
 
     // -------------------------------------------------------------------------

=== removed file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/LoggingHashMap.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/LoggingHashMap.java	2015-06-16 17:57:23 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/LoggingHashMap.java	1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
-package org.hisp.dhis.commons.collection;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * HashMap that logs the key if the requested value is null.
- * 
- * @author Lars Helge Overland
- */
-public class LoggingHashMap<K, V>
-    extends HashMap<K, V>
-{
-    /**
-     * Determines if a de-serialized file is compatible with this class.
-     */
-    private static final long serialVersionUID = -8527416574033355571L;
-
-    private static final Log log = LogFactory.getLog( LoggingHashMap.class );
-    
-    public LoggingHashMap()
-    {
-        super();
-    }
-    
-    public LoggingHashMap( Map<? extends K, ? extends V> map )
-    {
-        super( map );
-    }
-    
-    @Override
-    public V get( Object key )
-    {
-        final V value = super.get( key );
-        
-        if ( value == null )
-        {
-            if ( key != null )
-            {
-                log.warn( "Value is null for key: '" + key.toString() + "'" );
-            }
-            else
-            {
-                log.warn( "Key is null" );
-            }
-        }
-        
-        return value;
-    }
-}

=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/DebugUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/DebugUtils.java	2015-09-25 12:41:17 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/DebugUtils.java	2015-10-03 09:03:51 +0000
@@ -28,15 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 /**
  * Utility class for retrieving debugging information.
@@ -45,96 +38,6 @@
  */
 public class DebugUtils
 {
-    private static final Log log = LogFactory.getLog( DebugUtils.class );
-    
-    public static final String SEPARATOR = "-";
-    
-    private static ThreadLocal<Map<String, List<String>>> DUPLICATE_MAP_PEG = new ThreadLocal<>();
-    
-    public static String logDuplicates( String key, Integer... values )
-    {
-        StringBuffer buffer = new StringBuffer();
-        
-        for ( Integer value : values )
-        {
-            buffer.append( value + SEPARATOR );
-        }
-        
-        String value = buffer.toString();
-        
-        value = value.substring( 0, value.length() - 1 );
-        
-        return log( key, value );
-    }
-    
-    public static String logDuplicates( String key, String... values )
-    {
-        StringBuffer buffer = new StringBuffer();
-        
-        for ( String value : values )
-        {
-            buffer.append( value + SEPARATOR );
-        }
-
-        String value = buffer.toString();
-        
-        value = value.substring( 0, value.length() - 1 );
-        
-        return log( key, value );
-    }
-    
-    private static String log( String key, String value )
-    {   
-        Map<String, List<String>> duplicateMap = DUPLICATE_MAP_PEG.get();
-        
-        if ( duplicateMap == null )
-        {
-            duplicateMap = new HashMap<>();
-        }
-        
-        List<String> list = duplicateMap.get( key );
-
-        if ( list == null )
-        {
-            list = new ArrayList<>();
-        }
-                
-        String duplicate = null;
-        
-        if ( list.contains( value ) )
-        {
-            log.warn( "Duplicate found: '" + value + "' for key: '" + key + "'" );
-            
-            duplicate = value;
-        }
-        
-        list.add( value );
-        
-        duplicateMap.put( key, list );
-        
-        DUPLICATE_MAP_PEG.set( duplicateMap );
-
-        return duplicate;
-    }
-    
-    public static boolean resetDuplicates( String key )
-    {
-        Map<String, List<String>> duplicateMap = DUPLICATE_MAP_PEG.get();
-        
-        if ( duplicateMap != null )
-        {
-            duplicateMap.remove( key );
-        
-            DUPLICATE_MAP_PEG.set( duplicateMap );
-            
-            log.info( "Reset duplicate for key: '" + key + "'" );
-            
-            return true;
-        }
-        
-        return false;
-    }
-
     public static String getStackTrace( Throwable t )
     {
         StringWriter sw = new StringWriter();

=== removed file 'dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/DebugUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/DebugUtilsTest.java	2015-09-25 12:29:08 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/DebugUtilsTest.java	1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
-package org.hisp.dhis.commons.util;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.hisp.dhis.commons.util.DebugUtils.SEPARATOR;
-import static org.hisp.dhis.commons.util.DebugUtils.logDuplicates;
-import static org.hisp.dhis.commons.util.DebugUtils.resetDuplicates;
-import junit.framework.TestCase;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class DebugUtilsTest
-    extends TestCase
-{
-    public void testLogDuplicate()
-    {
-        String keyA = "name";
-        String keyB = "code";
-        String keyC = "identifier";
-        
-        assertNull( logDuplicates( keyA, "john" ) );
-        assertNull( logDuplicates( keyA, "tom" ) );
-        assertNull( logDuplicates( keyA, "george" ) );
-        assertEquals( "tom", logDuplicates( keyA, "tom" ) );
-        assertNull( logDuplicates( keyA, "will" ) );
-        assertEquals( "john", logDuplicates( keyA, "john" ) );
-                
-        assertNull( logDuplicates( keyB, "john" ) );
-        assertNull( logDuplicates( keyB, "A2", "A3" ) );
-        assertNull( logDuplicates( keyB, "B1" ) );
-        assertEquals( "A2" + SEPARATOR + "A3", logDuplicates( keyB, "A2", "A3" ) );
-        assertEquals( "A2" + SEPARATOR + "A3", logDuplicates( keyB, "A2", "A3" ) );
-        assertNull( logDuplicates( keyB, "C1" ) );
-        
-        assertNull( logDuplicates( keyC, 1, 2, 3 ) );
-        assertNull( logDuplicates( keyC, 1, 2, 4 ) );
-        assertEquals( 1 + SEPARATOR + 2 + SEPARATOR + 3, logDuplicates( keyC, 1, 2, 3 ) );        
-        
-        assertTrue( resetDuplicates( keyA ) );
-        assertNull( logDuplicates( keyA, "tom" ) );
-    }
-}