← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 858: Minor simplifications.

 

------------------------------------------------------------
revno: 858
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-10-14 09:30:28 +0200
message:
  Minor simplifications.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryComboService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryOptionComboService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.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-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2009-10-06 08:49:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2009-10-14 07:30:28 +0000
@@ -28,6 +28,7 @@
  */
 
 // import java.io.Serializable;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -55,15 +56,12 @@
     extends IdentifiableObject
 {
     public static final String TYPE_STRING = "string";
-
     public static final String TYPE_INT = "int";
-
     public static final String TYPE_BOOL = "bool";
+    public static final String TYPE_DATE = "date";
 
     public static final String AGGREGATION_OPERATOR_SUM = "sum";
-
-    public static final String AGGREGATION_OPERATOR_AVERAGE ="average";
-    
+    public static final String AGGREGATION_OPERATOR_AVERAGE ="average";    
     public static final String AGGREGATION_OPERATOR_COUNT = "count";
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryComboService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryComboService.java	2009-10-13 20:08:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryComboService.java	2009-10-14 07:30:28 +0000
@@ -101,6 +101,5 @@
     public DataElementCategoryCombo getDataElementCategoryComboByName( String name )
     {
         return dataElementCategoryComboStore.getByName( name );
-    }
-    
+    }    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryOptionComboService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryOptionComboService.java	2009-10-13 20:08:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryOptionComboService.java	2009-10-14 07:30:28 +0000
@@ -48,7 +48,6 @@
 public class DefaultDataElementCategoryOptionComboService
     implements DataElementCategoryOptionComboService
 {
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -156,10 +155,10 @@
     }
 
     public Collection<DataElementCategoryOptionCombo> sortDataElementCategoryOptionCombos(
-        DataElementCategoryCombo catCombo )
+        DataElementCategoryCombo categoryCombo )
     {
         Collection<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>(
-            catCombo.getOptionCombos() );       
+            categoryCombo.getOptionCombos() );       
 
         // ---------------------------------------------------------------------
         // Determine the number of times each category is going to repeat
@@ -169,17 +168,16 @@
 
         Map<Integer, Integer> categoryRepeat = new HashMap<Integer, Integer>();
 
-        for ( DataElementCategory category : catCombo.getCategories() )
+        for ( DataElementCategory category : categoryCombo.getCategories() )
         {
             categoryColSpan = categoryColSpan / category.getCategoryOptions().size();
 
             categoryRepeat.put( category.getId(), categoryColSpan );
-
         }
 
         Map<Integer, Collection<DataElementCategoryOption>> orderedOptions = new HashMap<Integer, Collection<DataElementCategoryOption>>();
 
-        for ( DataElementCategory cat : catCombo.getCategories() )
+        for ( DataElementCategory cat : categoryCombo.getCategories() )
         {
             int outerForLoopCount = optionCombos.size();
             int innerForLoopCount = categoryRepeat.get( cat.getId() );
@@ -209,9 +207,9 @@
 
         for ( int i = 0; i < optionCombos.size(); i++ )
         {
-            Collection<DataElementCategoryOption> options = new ArrayList<DataElementCategoryOption>( catCombo
+            Collection<DataElementCategoryOption> options = new ArrayList<DataElementCategoryOption>( categoryCombo
                 .getCategories().size() );
-            Collection<DataElementCategory> copyOforderedCategories = catCombo.getCategories();
+            Collection<DataElementCategory> copyOforderedCategories = categoryCombo.getCategories();
             Iterator<DataElementCategory> categoryIterator = copyOforderedCategories.iterator();
 
             while ( categoryIterator.hasNext() )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java	2009-10-13 20:08:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java	2009-10-14 07:30:28 +0000
@@ -1,14 +1,42 @@
 package org.hisp.dhis.dataelement;
 
-import java.sql.SQLException;
+/*
+ * Copyright (c) 2004-2007, 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.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.system.startup.AbstractStartupRoutine;
 import org.springframework.transaction.annotation.Transactional;
 
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
 public class OptionsCategoriesDefaultSortOrderPopulator
     extends AbstractStartupRoutine
 {
@@ -28,86 +56,21 @@
     // -------------------------------------------------------------------------
     // Execute
     // -------------------------------------------------------------------------
+    
     @Transactional
     public void execute()
         throws Exception
-    {
-        
-        updateCategoryOptionComboAndOptionsTable();
-        
-        updateCategoryComboAndCategoriesTable();
-        
-        updateCategoryAndOptionsTable();
-        
-    }
-    
-    // -------------------------------------------------------------------------
-    // Custom SQL update stmt
-    // -------------------------------------------------------------------------
-    
-    public void updateCategoryOptionComboAndOptionsTable()
-    {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {         
-            final String sql = "update categoryoptioncombos_categoryoptions set sort_order=0 where sort_order is NULL";
-            
-            holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            LOG.warn( "Failed to update categoryoptioncombos_categoryoptions", ex  );            
-        }
-        finally
-        {
-            holder.close();
-        }
-        
-        LOG.info( "Updated  categoryoptioncombos_categoryoptions" );
-    }
-    
-    public void updateCategoryComboAndCategoriesTable()
-    {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {            
-            final String sql = "update categorycombos_categories set sort_order=0 where sort_order is NULL";
-            
-            holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            LOG.warn( "Failed to update categorycombos_categories", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-        
-        LOG.info( "Updated  categorycombos_categories" );
-    }
-    
-    public void updateCategoryAndOptionsTable()
-    {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {            
-            final String sql = "update categories_categoryoptions set sort_order=0 where sort_order is NULL";
-            
-            holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            LOG.warn( "Failed to update categories_categoryoptions", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-        
-        LOG.info( "Updated  categories_categoryoptions" );
+    {       
+        statementManager.getHolder().executeUpdate( "update categoryoptioncombos_categoryoptions set sort_order=0 where sort_order is NULL" );
+        
+        LOG.info( "Updated categoryoptioncombos_categoryoptions" );
+        
+        statementManager.getHolder().executeUpdate( "update categorycombos_categories set sort_order=0 where sort_order is NULL" );
+        
+        LOG.info( "Updated categorycombos_categories" );
+        
+        statementManager.getHolder().executeUpdate( "update categories_categoryoptions set sort_order=0 where sort_order is NULL" );
+        
+        LOG.info( "Updated categories_categoryoptions" );  
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2009-10-13 20:08:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2009-10-14 07:30:28 +0000
@@ -274,10 +274,9 @@
       ref="org.hisp.dhis.dataelement.DataElementCategoryComboService"/>
     <property name="optionComboService"
       ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>
-    <property name="runlevel" value="1"/>
+    <property name="runlevel" value="2"/>
   </bean>
-	
-  
+	  
   <bean id="org.hisp.dhis.dataelement.OptionsCategoriesDefaultSortOrderPopulator"
     class="org.hisp.dhis.dataelement.OptionsCategoriesDefaultSortOrderPopulator">
     <property name="statementManager" ref="statementManager"/>