← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1304: Implemented resource tables for DataElements/DataElementGroupSets and Indicators/IndicatorGroupSe...

 

------------------------------------------------------------
revno: 1304
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-01-12 09:12:04 +0100
message:
  Implemented resource tables for DataElements/DataElementGroupSets and Indicators/IndicatorGroupSets. GUI function can be found in administration module.
added:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java
renamed:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateExclusiveGroupSetTableStatement.java => dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/hibernate/HibernateResourceTableStore.java
  dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.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/ResourceTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java	2009-05-13 15:51:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java	2010-01-12 08:12:04 +0000
@@ -54,7 +54,17 @@
     void generateCategoryOptionComboNames();
     
     /**
+     * Generates a resource table for all data elements.
+     */
+    void generateDataElementGroupSetTable();
+
+    /**
+     * Generates a resource table for all indicators.
+     */
+    void generateIndicatorGroupSetTable();
+    
+    /**
      * Generates a resource table for all organisation units 
      */
-    void generateExclusiveGroupSetStructures();
+    void generateOrganisationUnitGroupSetTable();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java	2009-06-14 19:43:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java	2010-01-12 08:12:04 +0000
@@ -1,6 +1,11 @@
 package org.hisp.dhis.resourcetable;
 
 import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 
 public interface ResourceTableStore
 {
@@ -85,18 +90,28 @@
     int deleteDataElementCategoryOptionComboNames();
 
     // -------------------------------------------------------------------------
-    // ExclusiveGroupSetStructure
+    // GroupSetStructure
     // -------------------------------------------------------------------------
 
     /**
      * Creates table.
      * 
-     * @param statement the Statement.
-     */
-    void createExclusiveGroupSetStructureTable( String statement );
-    
-    /**
-     * Removes table.
-     */
-    void removeExclusiveGroupSetStructureTable();
+     * @param groupSets the group sets.
+     */
+    void createDataElementGroupSetStructure( List<DataElementGroupSet> groupSets );
+
+    /**
+     * Creates table.
+     * 
+     * @param groupSets the group sets.
+     */
+    void createIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets );
+    
+    /**
+     * Creates table.
+     * 
+     * @param groupSets the group sets.
+     */
+    void createOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets );
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2009-11-30 15:32:55 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2010-01-12 08:12:04 +0000
@@ -39,8 +39,20 @@
 import org.amplecode.quick.Statement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataelement.comparator.DataElementGroupSetNameComparator;
+import org.hisp.dhis.dataelement.comparator.DataElementNameComparator;
+import org.hisp.dhis.dimension.Dimension;
+import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.indicator.comparator.IndicatorGroupSetNameComparator;
+import org.hisp.dhis.indicator.comparator.IndicatorNameComparator;
 import org.hisp.dhis.jdbc.batchhandler.GenericBatchHandler;
 import org.hisp.dhis.jdbc.batchhandler.GroupSetStructureBatchHandler;
 import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitStructureBatchHandler;
@@ -51,7 +63,9 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
-import org.hisp.dhis.resourcetable.statement.CreateExclusiveGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateDataElementGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateIndicatorGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateOrganisationUnitGroupSetTableStatement;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -95,6 +109,20 @@
     {
         this.categoryService = categoryService;
     }
+    
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+    
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
 
     private BatchHandlerFactory batchHandlerFactory;
 
@@ -232,17 +260,111 @@
     }
 
     // -------------------------------------------------------------------------
-    // Exclusive GroupSetStructure
-    // -------------------------------------------------------------------------
-
-    public void generateExclusiveGroupSetStructures()
-    {
-        // ---------------------------------------------------------------------
-        // Drop table
-        // ---------------------------------------------------------------------
-
-        resourceTableStore.removeExclusiveGroupSetStructureTable();
-
+    // DataElementGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void generateDataElementGroupSetTable()
+    {
+        // ---------------------------------------------------------------------
+        // Create table
+        // ---------------------------------------------------------------------
+
+        List<DataElement> dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
+        
+        Collections.sort( dataElements, new DataElementNameComparator() );
+        
+        List<DataElementGroupSet> groupSets = new ArrayList<DataElementGroupSet>( dataElementService.getAllDataElementGroupSets() );
+        
+        Collections.sort( groupSets, new DataElementGroupSetNameComparator() );
+        
+        resourceTableStore.createDataElementGroupSetStructure( groupSets );
+
+        // ---------------------------------------------------------------------
+        // Populate table
+        // ---------------------------------------------------------------------
+
+        BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
+
+        batchHandler.setTableName( CreateDataElementGroupSetTableStatement.TABLE_NAME );
+
+        batchHandler.init();
+
+        for ( DataElement dataElement : dataElements )
+        {
+            final List<String> values = new ArrayList<String>();
+
+            values.add( String.valueOf( dataElement.getId() ) );
+            values.add( dataElement.getName() );
+            
+            for ( Dimension groupSet : groupSets )
+            {
+                DimensionOption dimensionOption = groupSet.getDimensionOption( dataElement );
+                
+                values.add( dimensionOption != null ? dimensionOption.getName() : null );    
+            }
+            
+            batchHandler.addObject( values );
+        }
+        
+        batchHandler.flush();
+    }
+
+    // -------------------------------------------------------------------------
+    // IndicatorGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void generateIndicatorGroupSetTable()
+    {
+        // ---------------------------------------------------------------------
+        // Create table
+        // ---------------------------------------------------------------------
+
+        List<Indicator> indicators = new ArrayList<Indicator>( indicatorService.getAllIndicators() );
+        
+        Collections.sort( indicators, new IndicatorNameComparator() );
+        
+        List<IndicatorGroupSet> groupSets = new ArrayList<IndicatorGroupSet>( indicatorService.getAllIndicatorGroupSets() );
+        
+        Collections.sort( groupSets, new IndicatorGroupSetNameComparator() );
+        
+        resourceTableStore.createIndicatorGroupSetStructure( groupSets );
+
+        // ---------------------------------------------------------------------
+        // Populate table
+        // ---------------------------------------------------------------------
+
+        BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
+
+        batchHandler.setTableName( CreateIndicatorGroupSetTableStatement.TABLE_NAME );
+
+        batchHandler.init();
+
+        for ( Indicator indicator : indicators )
+        {
+            final List<String> values = new ArrayList<String>();
+            
+            values.add( String.valueOf( indicator.getId() ) );
+            values.add( indicator.getName() );
+            
+            for ( Dimension groupSet : groupSets )
+            {
+                DimensionOption dimensionOption = groupSet.getDimensionOption( indicator );
+                
+                values.add( dimensionOption != null ? dimensionOption.getName() : null );    
+            }
+            
+            batchHandler.addObject( values );
+        }
+        
+        batchHandler.flush();        
+    }
+    
+    // -------------------------------------------------------------------------
+    // OrganisationUnitGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void generateOrganisationUnitGroupSetTable()
+    {
         // ---------------------------------------------------------------------
         // Create table
         // ---------------------------------------------------------------------
@@ -257,9 +379,7 @@
 
         Collections.sort( groupSets, new OrganisationUnitGroupSetNameComparator() );
 
-        Statement statement = new CreateExclusiveGroupSetTableStatement( groupSets );
-
-        resourceTableStore.createExclusiveGroupSetStructureTable( statement.getStatement() );
+        resourceTableStore.createOrganisationUnitGroupSetStructure( groupSets );
 
         // ---------------------------------------------------------------------
         // Populate table
@@ -267,7 +387,7 @@
 
         BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
 
-        batchHandler.setTableName( CreateExclusiveGroupSetTableStatement.TABLE_NAME );
+        batchHandler.setTableName( CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME );
 
         batchHandler.init();
 

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/hibernate/HibernateResourceTableStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/hibernate/HibernateResourceTableStore.java	2009-09-03 20:04:45 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/hibernate/HibernateResourceTableStore.java	2010-01-12 08:12:04 +0000
@@ -28,16 +28,23 @@
  */
 
 import java.util.Collection;
+import java.util.List;
 
+import org.amplecode.quick.Statement;
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.resourcetable.DataElementCategoryOptionComboName;
 import org.hisp.dhis.resourcetable.GroupSetStructure;
 import org.hisp.dhis.resourcetable.OrganisationUnitStructure;
 import org.hisp.dhis.resourcetable.ResourceTableStore;
-import org.hisp.dhis.resourcetable.statement.CreateExclusiveGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateDataElementGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateIndicatorGroupSetTableStatement;
+import org.hisp.dhis.resourcetable.statement.CreateOrganisationUnitGroupSetTableStatement;
 import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.core.JdbcTemplate;
 
@@ -157,23 +164,62 @@
     }
 
     // -------------------------------------------------------------------------
-    // ExclusiveGroupSetStructure
-    // -------------------------------------------------------------------------
-
-    public void createExclusiveGroupSetStructureTable( String statement )
-    {
-        jdbcTemplate.update( statement );
-    }
-
-    public void removeExclusiveGroupSetStructureTable()
-    {
-        try
-        {
-            jdbcTemplate.update( "DROP TABLE " + CreateExclusiveGroupSetTableStatement.TABLE_NAME );
-        }
-        catch ( BadSqlGrammarException ex )
-        {
-            // Do nothing, table does not exist
-        }
+    // DataElementGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void createDataElementGroupSetStructure( List<DataElementGroupSet> groupSets )
+    {
+        try
+        {
+            jdbcTemplate.update( "DROP TABLE " + CreateDataElementGroupSetTableStatement.TABLE_NAME );
+        }
+        catch ( BadSqlGrammarException ex )
+        {
+            // Do nothing, table does not exist
+        }
+        
+        Statement statement = new CreateDataElementGroupSetTableStatement( groupSets );
+        
+        jdbcTemplate.update( statement.getStatement() );
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void createIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets )
+    {
+        try
+        {
+            jdbcTemplate.update( "DROP TABLE " + CreateIndicatorGroupSetTableStatement.TABLE_NAME );
+        }
+        catch ( BadSqlGrammarException ex )
+        {
+            // Do nothing, table does not exist
+        }
+        
+        Statement statement = new CreateIndicatorGroupSetTableStatement( groupSets );
+        
+        jdbcTemplate.update( statement.getStatement() );
+    }
+    
+    // -------------------------------------------------------------------------
+    // OrganisationUnitGroupSetTable
+    // -------------------------------------------------------------------------
+
+    public void createOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets )
+    {
+        try
+        {
+            jdbcTemplate.update( "DROP TABLE " + CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME );
+        }
+        catch ( BadSqlGrammarException ex )
+        {
+            // Do nothing, table does not exist
+        }
+        
+        Statement statement = new CreateOrganisationUnitGroupSetTableStatement( groupSets );
+        
+        jdbcTemplate.update( statement.getStatement() );
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java	2010-01-12 08:12:04 +0000
@@ -0,0 +1,74 @@
+package org.hisp.dhis.resourcetable.statement;
+
+/*
+ * 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 java.util.List;
+
+import org.amplecode.quick.Statement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.system.util.CodecUtils;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class CreateDataElementGroupSetTableStatement
+    implements Statement
+{
+    private static final Log log = LogFactory.getLog( CreateDataElementGroupSetTableStatement.class );
+    
+    private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (160)";
+    
+    public static final String TABLE_NAME = "_dataelementgroupsetstructure";
+    
+    private List<DataElementGroupSet> groupSets;
+    
+    public CreateDataElementGroupSetTableStatement( List<DataElementGroupSet> groupSets )
+    {
+        this.groupSets = groupSets;
+    }
+    
+    public String getStatement()
+    {
+        String statement = "CREATE TABLE " + TABLE_NAME + " ( " +
+            "dataelementid " + NUMERIC_COLUMN_TYPE + SEPARATOR +
+            "dataelementname " + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
+        
+        for ( DataElementGroupSet groupSet : groupSets )
+        {
+            statement += CodecUtils.databaseEncode( groupSet.getName() ) + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
+        }
+        
+        statement += "PRIMARY KEY ( dataelementid ) )";
+                
+        log.info( "Create data element group set table SQL: " + statement );
+        
+        return statement;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java	2010-01-12 08:12:04 +0000
@@ -0,0 +1,74 @@
+package org.hisp.dhis.resourcetable.statement;
+
+/*
+ * 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 java.util.List;
+
+import org.amplecode.quick.Statement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.system.util.CodecUtils;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class CreateIndicatorGroupSetTableStatement
+    implements Statement
+{
+    private static final Log log = LogFactory.getLog( CreateIndicatorGroupSetTableStatement.class );
+
+    private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (160)";
+    
+    public static final String TABLE_NAME = "_indicatorgroupsetstructure";
+    
+    private List<IndicatorGroupSet> groupSets;
+    
+    public CreateIndicatorGroupSetTableStatement( List<IndicatorGroupSet> groupSets )
+    {
+        this.groupSets = groupSets;
+    }
+    
+    public String getStatement()
+    {
+        String statement = "CREATE TABLE " + TABLE_NAME + " ( " +
+            "indicatorid " + NUMERIC_COLUMN_TYPE + SEPARATOR +
+            "indicatorname " + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
+        
+        for ( IndicatorGroupSet groupSet : groupSets )
+        {
+            statement += CodecUtils.databaseEncode( groupSet.getName() ) + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
+        }
+        
+        statement += "PRIMARY KEY ( indicatorid ) )";
+                
+        log.info( "Create indicator group set table SQL: " + statement );
+        
+        return statement;
+    }
+}

=== renamed file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateExclusiveGroupSetTableStatement.java' => 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateExclusiveGroupSetTableStatement.java	2009-11-30 15:32:55 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java	2010-01-12 08:12:04 +0000
@@ -35,24 +35,21 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
-public class CreateExclusiveGroupSetTableStatement
+public class CreateOrganisationUnitGroupSetTableStatement
     implements Statement
 {
-    public static final String TABLE_NAME = "orgunitgroupsetexclusivestructure";
+    public static final String TABLE_NAME = "_organisationunitgroupsetstructure";
+
+    private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (160)";
     
     private List<OrganisationUnitGroupSet> groupSets;
     
-    protected CreateExclusiveGroupSetTableStatement()
-    {   
-    }
-    
-    public CreateExclusiveGroupSetTableStatement( List<OrganisationUnitGroupSet> groupSets )
+    public CreateOrganisationUnitGroupSetTableStatement( List<OrganisationUnitGroupSet> groupSets )
     {
         this.groupSets = groupSets;
     }
-
+    
     public String getStatement()
     {
         StringBuffer buffer = new StringBuffer( "CREATE TABLE " + TABLE_NAME + " ( organisationunitid " );

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2009-12-25 18:41:08 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2010-01-12 08:12:04 +0000
@@ -39,6 +39,10 @@
       ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
     <property name="categoryService"
       ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
+	<property name="dataElementService"
+	  ref="org.hisp.dhis.dataelement.DataElementService"/>
+	<property name="indicatorService"
+      ref="org.hisp.dhis.indicator.IndicatorService"/>
     <property name="batchHandlerFactory" ref="batchHandlerFactory"/>
   </bean>
   

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java	2009-06-14 19:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java	2010-01-12 08:12:04 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.amplecode.quick.Statement;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.reporttable.ReportTable;
 
@@ -35,6 +36,7 @@
  * @version $Id$
  */
 public abstract class ReportTableStatement
+    implements Statement
 {
     protected static final String NUMERIC_COLUMN_TYPE = "INTEGER NOT NULL";
     protected static final String SHORT_TEXT_COLUMN_TYPE = "VARCHAR (15)";

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java	2010-01-12 08:12:04 +0000
@@ -67,13 +67,27 @@
         this.groupSet = groupSet;
     }
 
-    private boolean exclusiveGroupSet;
+    private boolean dataElementGroupSetStructure;
 
-    public void setExclusiveGroupSet( boolean exclusiveGroupSet )
+    public void setDataElementGroupSetStructure( boolean dataElementGroupSetStructure )
     {
-        this.exclusiveGroupSet = exclusiveGroupSet;
+        this.dataElementGroupSetStructure = dataElementGroupSetStructure;
     }
     
+    private boolean indicatorGroupSetStructure;
+
+    public void setIndicatorGroupSetStructure( boolean indicatorGroupSetStructure )
+    {
+        this.indicatorGroupSetStructure = indicatorGroupSetStructure;
+    }
+
+    private boolean organisationUnitGroupSetStructure;
+
+    public void setOrganisationUnitGroupSetStructure( boolean organisationUnitGroupSetStructure )
+    {
+        this.organisationUnitGroupSetStructure = organisationUnitGroupSetStructure;
+    }
+
     private boolean categoryOptionComboName; 
 
     public void setCategoryOptionComboName( boolean categoryOptionComboName )
@@ -98,9 +112,19 @@
             resourceTableService.generateGroupSetStructures();
         }
 
-        if ( exclusiveGroupSet )
-        {
-            resourceTableService.generateExclusiveGroupSetStructures();
+        if ( dataElementGroupSetStructure )
+        {
+            resourceTableService.generateDataElementGroupSetTable();
+        }
+        
+        if ( indicatorGroupSetStructure )
+        {
+            resourceTableService.generateIndicatorGroupSetTable();
+        }
+        
+        if ( organisationUnitGroupSetStructure )
+        {
+            resourceTableService.generateOrganisationUnitGroupSetTable();
         }
         
         if ( categoryOptionComboName )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2009-12-29 07:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2010-01-12 08:12:04 +0000
@@ -9,7 +9,7 @@
 organisation_units_lock            									= Organization Units [ Black = Unassigned ][ Orange = Assigned,Unlocked ][ Green = Assigned,Locked ]
 save																= Save
 cancel                                                              = Cancel
-done                    =Done
+done                    											=Done
 noaction                        									= Please Sellect Only Assigned or Locked Organisation Unit.
 loading																= Loading, please wait...
 data_administration													= Data Administration
@@ -106,7 +106,9 @@
 data_elements_assigned_to_period_types_with_different_period_types	= Data elements assigned to data sets with different period types
 select_a_period_type												= Please select a period type
 select_a_period														= Please select a period
-exclusive_group_set_structure										= Exclusive group set structure
+data_element_group_set_structure									= Data element group set structure
+indicator_group_set_structure										= Indicator group set structure
+organisation_unit_group_set_structure								= Organisation unit group set structure
 period																= Period
 value																= Value
 org_unit															= Organisation Unit

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js	2009-05-13 15:51:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js	2010-01-12 08:12:04 +0000
@@ -3,16 +3,21 @@
 {
     var organisationUnit = document.getElementById( "organisationUnit" ).checked;
     var groupSet = document.getElementById( "groupSet" ).checked;
-    var exclusiveGroupSet = document.getElementById( "exclusiveGroupSet" ).checked;
+    var dataElementGroupSetStructure = document.getElementById( "dataElementGroupSetStructure" ).checked;
+    var indicatorGroupSetStructure = document.getElementById( "indicatorGroupSetStructure" ).checked;
+    var organisationUnitGroupSetStructure = document.getElementById( "organisationUnitGroupSetStructure" ).checked;
     var categoryOptionComboName = document.getElementById( "categoryOptionComboName" ).checked;
     
-    if ( organisationUnit || groupSet || exclusiveGroupSet || categoryOptionComboName )
+    if ( organisationUnit || groupSet || dataElementGroupSetStructure || 
+        indicatorGroupSetStructure || organisationUnitGroupSetStructure || categoryOptionComboName )
     {
         setMessage( i18n_generating_resource_tables );
             
         var params = "organisationUnit=" + organisationUnit + 
             "&groupSet=" + groupSet + 
-            "&exclusiveGroupSet=" + exclusiveGroupSet +
+            "&dataElementGroupSetStructure=" + dataElementGroupSetStructure +
+            "&indicatorGroupSetStructure=" + indicatorGroupSetStructure +
+            "&organisationUnitGroupSetStructure=" + organisationUnitGroupSetStructure +
             "&categoryOptionComboName=" + categoryOptionComboName;
             
         var url = "generateResourceTable.action";

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm	2009-12-21 09:33:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm	2010-01-12 08:12:04 +0000
@@ -12,8 +12,18 @@
 </p>
 
 <p>
-    <input type="checkbox" id="exclusiveGroupSet">
-    <label for="exclusiveGroupSet">$i18n.getString( "exclusive_group_set_structure" ) <span style="color:#606060">(orgunitgroupsetexclusivestructure)</span></label>
+	<input type="checkbox" id="dataElementGroupSetStructure">
+	<label for="dataElementGroupSetStructure">$i18n.getString( "data_element_group_set_structure" ) <span style="color:#606060">(_dataelementgroupsetstructure)</span></label>
+</p>
+
+<p>
+    <input type="checkbox" id="indicatorGroupSetStructure">
+    <label for="indicatorGroupSetStructure">$i18n.getString( "indicator_group_set_structure" ) <span style="color:#606060">(_indicatorgroupsetstructure)</span></label>
+</p>
+
+<p>
+    <input type="checkbox" id="organisationUnitGroupSetStructure">
+    <label for="organisationUnitGroupSetStructure">$i18n.getString( "organisation_unit_group_set_structure" ) <span style="color:#606060">(_organisationunitgroupsetstructure)</span></label>
 </p>
 
 <p>