dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40400
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20480: Resource tables. Converting to new framework.
------------------------------------------------------------
revno: 20480
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-02 18:14:33 +0200
message:
Resource tables. Converting to new framework.
removed:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryOptionGroupSetTableStatement.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryTableStatement.java
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
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java
added:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryOptionGroupSetResourceTable.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryResourceTable.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/DataElementGroupSetResourceTable.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/IndicatorGroupSetResourceTable.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/OrganisationUnitGroupSetResourceTable.java
modified:
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/jdbc/JdbcResourceTableStore.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/ResourceTableStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java 2015-10-02 13:58:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java 2015-10-02 16:14:33 +0000
@@ -31,11 +31,6 @@
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
/**
@@ -70,59 +65,6 @@
void batchUpdate( int columns, String tableName, List<Object[]> batchArgs );
/**
- * Creates a table.
- */
- void createOrganisationUnitStructure( int maxLevel );
-
- /**
- * Creates a table.
- */
- void createDataElementCategoryOptionComboName();
-
- /**
- * Creates a table.
- *
- * @param groupSets the group sets.
- */
- void createCategoryOptionGroupSetStructure( List<CategoryOptionGroupSet> groupSets );
-
- /**
- * Creates table.
- *
- * @param groupSets the group sets.
- */
- void createDataElementGroupSetStructure( List<DataElementGroupSet> groupSets );
-
- void populateDataElementGroupSetStructure( List<DataElementGroupSet> groupSets );
-
- /**
- * Creates table.
- *
- * @param groupSets the group sets.
- */
- void createIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets );
-
- void populateIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets );
-
- /**
- * Creates table.
- *
- * @param groupSets the group sets.
- */
- void createOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets );
-
- void populateOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets );
-
- /**
- * Creates table.
- *
- * @param categories the categories.
- */
- void createCategoryStructure( List<DataElementCategory> categories );
-
- void populateCategoryStructure( List<DataElementCategory> categories );
-
- /**
* Creates table.
*/
void createDataElementStructure();
=== 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 2015-10-02 13:58:22 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java 2015-10-02 16:14:33 +0000
@@ -48,12 +48,10 @@
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.commons.collection.UniqueArrayList;
import org.hisp.dhis.dataapproval.DataApprovalLevelService;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataset.DataSet;
@@ -67,8 +65,12 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.resourcetable.statement.CreateCategoryOptionGroupSetTableStatement;
import org.hisp.dhis.resourcetable.table.CategoryOptionComboNameResourceTable;
+import org.hisp.dhis.resourcetable.table.CategoryOptionGroupSetResourceTable;
+import org.hisp.dhis.resourcetable.table.CategoryResourceTable;
+import org.hisp.dhis.resourcetable.table.DataElementGroupSetResourceTable;
+import org.hisp.dhis.resourcetable.table.IndicatorGroupSetResourceTable;
+import org.hisp.dhis.resourcetable.table.OrganisationUnitGroupSetResourceTable;
import org.hisp.dhis.resourcetable.table.OrganisationUnitStructureResourceTable;
import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.sqlview.SqlViewService;
@@ -160,110 +162,44 @@
public void generateCategoryOptionComboNames()
{
resourceTableStore.generateResourceTable( new CategoryOptionComboNameResourceTable(
- "_categoryoptioncomboname", idObjectManager.getAll( DataElementCategoryCombo.class ), statementBuilder.getColumnQuote() ) );
+ "_categoryoptioncomboname", idObjectManager.getAllNoAcl( DataElementCategoryCombo.class ),
+ statementBuilder.getColumnQuote() ) );
}
@Override
@Transactional
public void generateCategoryOptionGroupSetTable()
{
- // ---------------------------------------------------------------------
- // Create table
- // ---------------------------------------------------------------------
-
- List<DataElementCategoryOptionCombo> categoryOptionCombos =
- new ArrayList<>( categoryService.getAllDataElementCategoryOptionCombos() );
-
- List<CategoryOptionGroupSet> groupSets = new ArrayList<>( idObjectManager.getAllNoAcl( CategoryOptionGroupSet.class ) );
-
- Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
-
- resourceTableStore.createCategoryOptionGroupSetStructure( groupSets );
-
- // ---------------------------------------------------------------------
- // Populate table
- // ---------------------------------------------------------------------
-
- List<Object[]> batchArgs = new ArrayList<>();
-
- for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos )
- {
- List<Object> values = new ArrayList<>();
-
- values.add( categoryOptionCombo.getId() );
-
- for ( CategoryOptionGroupSet groupSet : groupSets )
- {
- CategoryOptionGroup group = groupSet.getGroup( categoryOptionCombo );
-
- values.add( group != null ? group.getName() : null );
- values.add( group != null ? group.getUid() : null );
- }
-
- batchArgs.add( values.toArray() );
- }
-
- resourceTableStore.batchUpdate( (groupSets.size() * 2) + 1, CreateCategoryOptionGroupSetTableStatement.TABLE_NAME, batchArgs );
-
- log.info( "Category option group set table generated" );
+ resourceTableStore.generateResourceTable( new CategoryOptionGroupSetResourceTable(
+ "_categoryoptiongroupsetstructure", idObjectManager.getAllNoAcl( CategoryOptionGroupSet.class ),
+ statementBuilder.getColumnQuote(), categoryService.getAllDataElementCategoryOptionCombos() ) );
}
- // -------------------------------------------------------------------------
- // DataElementGroupSetTable
- // -------------------------------------------------------------------------
-
@Override
@Transactional
public void generateDataElementGroupSetTable()
{
- List<DataElementGroupSet> groupSets = new ArrayList<>( idObjectManager.getDataDimensionsNoAcl( DataElementGroupSet.class ) );
-
- Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
-
- resourceTableStore.createDataElementGroupSetStructure( groupSets );
-
- resourceTableStore.populateDataElementGroupSetStructure( groupSets );
-
- log.info( "Data element group set table generated" );
+ resourceTableStore.generateResourceTable( new DataElementGroupSetResourceTable(
+ "_dataelementgroupsetstructure", idObjectManager.getDataDimensionsNoAcl( DataElementGroupSet.class ),
+ statementBuilder.getColumnQuote() ) );
}
- // -------------------------------------------------------------------------
- // IndicatorGroupSetTable
- // -------------------------------------------------------------------------
-
@Override
@Transactional
public void generateIndicatorGroupSetTable()
{
- List<IndicatorGroupSet> groupSets = new ArrayList<>( idObjectManager.getAllNoAcl( IndicatorGroupSet.class ) );
-
- Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
-
- resourceTableStore.createIndicatorGroupSetStructure( groupSets );
-
- resourceTableStore.populateIndicatorGroupSetStructure( groupSets );
-
- log.info( "Indicator group set table generated" );
+ resourceTableStore.generateResourceTable( new IndicatorGroupSetResourceTable(
+ "_indicatorgroupsetstructure", idObjectManager.getAllNoAcl( IndicatorGroupSet.class ),
+ statementBuilder.getColumnQuote() ) );
}
- // -------------------------------------------------------------------------
- // OrganisationUnitGroupSetTable
- // -------------------------------------------------------------------------
-
@Override
@Transactional
public void generateOrganisationUnitGroupSetTable()
{
- List<OrganisationUnitGroupSet> groupSets = new ArrayList<>(
- idObjectManager.getDataDimensionsNoAcl( OrganisationUnitGroupSet.class ) );
-
- Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
-
- resourceTableStore.createOrganisationUnitGroupSetStructure( groupSets );
-
- resourceTableStore.populateOrganisationUnitGroupSetStructure( groupSets );
-
- log.info( "Organisation unit group set table generated" );
+ resourceTableStore.generateResourceTable( new OrganisationUnitGroupSetResourceTable(
+ "_organisationunitgroupsetstructure", idObjectManager.getDataDimensionsNoAcl( OrganisationUnitGroupSet.class ),
+ statementBuilder.getColumnQuote() ) );
}
// -------------------------------------------------------------------------
@@ -274,20 +210,9 @@
@Transactional
public void generateCategoryTable()
{
- // ---------------------------------------------------------------------
- // Create table - only using data dimension categories
- // ---------------------------------------------------------------------
-
- List<DataElementCategory> categories = new ArrayList<>(
- idObjectManager.getDataDimensionsNoAcl( DataElementCategory.class ) );
-
- Collections.sort( categories, IdentifiableObjectNameComparator.INSTANCE );
-
- resourceTableStore.createCategoryStructure( categories );
-
- resourceTableStore.populateCategoryStructure( categories );
-
- log.info( "Category table generated" );
+ resourceTableStore.generateResourceTable( new CategoryResourceTable(
+ "_categorystructure", idObjectManager.getDataDimensionsNoAcl( DataElementCategory.class ),
+ statementBuilder.getColumnQuote() ) );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java 2015-10-02 14:27:58 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java 2015-10-02 16:14:33 +0000
@@ -35,22 +35,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.commons.util.TextUtils;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dbms.DbmsManager;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.jdbc.StatementBuilder;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.resourcetable.ResourceTable;
import org.hisp.dhis.resourcetable.ResourceTableStore;
-import org.hisp.dhis.resourcetable.statement.CreateCategoryOptionGroupSetTableStatement;
-import org.hisp.dhis.resourcetable.statement.CreateCategoryTableStatement;
-import org.hisp.dhis.resourcetable.statement.CreateDataElementGroupSetTableStatement;
-import org.hisp.dhis.resourcetable.statement.CreateIndicatorGroupSetTableStatement;
-import org.hisp.dhis.resourcetable.statement.CreateOrganisationUnitGroupSetTableStatement;
-import org.hisp.dhis.resourcetable.ResourceTable;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -174,317 +164,7 @@
jdbcTemplate.batchUpdate( builder.toString(), batchArgs );
}
-
- // -------------------------------------------------------------------------
- // OrganisationUnitStructure
- // -------------------------------------------------------------------------
-
- @Override
- public void createOrganisationUnitStructure( int maxLevel )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + TABLE_NAME_ORGANISATION_UNIT_STRUCTURE );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- String quote = statementBuilder.getColumnQuote();
-
- StringBuilder sql = new StringBuilder();
-
- sql.append( "CREATE TABLE " ).append( TABLE_NAME_ORGANISATION_UNIT_STRUCTURE ).
- append( " ( organisationunitid INTEGER NOT NULL PRIMARY KEY, organisationunituid CHARACTER(11), level INTEGER" );
-
- for ( int k = 1 ; k <= maxLevel; k++ )
- {
- sql.append( ", " ).append( quote ).append( "idlevel" + k ).append( quote ).append (" INTEGER, " ).
- append( quote ).append( "uidlevel" + k ).append( quote ).append( " CHARACTER(11)" );
- }
-
- sql.append( ");" );
-
- log.info( "Create organisation unit structure table SQL: " + sql );
-
- jdbcTemplate.execute( sql.toString() );
-
- final String uidInSql = "create unique index in_orgunitstructure_organisationunituid on _orgunitstructure(organisationunituid)";
-
- jdbcTemplate.execute( uidInSql );
- }
-
- // -------------------------------------------------------------------------
- // DataElementCategoryOptionComboName
- // -------------------------------------------------------------------------
-
- @Override
- public void createDataElementCategoryOptionComboName()
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + TABLE_NAME_CATEGORY_OPTION_COMBO_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String sql = "CREATE TABLE " + TABLE_NAME_CATEGORY_OPTION_COMBO_NAME +
- " ( categoryoptioncomboid INTEGER NOT NULL PRIMARY KEY, categoryoptioncomboname VARCHAR(250), approvallevel INTEGER )";
-
- log.info( "Create category option combo name table SQL: " + sql );
-
- jdbcTemplate.execute( sql );
- }
-
- // -------------------------------------------------------------------------
- // CategoryOptionGroupSetTable
- // -------------------------------------------------------------------------
-
- @Override
- public void createCategoryOptionGroupSetStructure( List<CategoryOptionGroupSet> groupSets )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + CreateCategoryOptionGroupSetTableStatement.TABLE_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String statement = new CreateCategoryOptionGroupSetTableStatement( groupSets, statementBuilder.getColumnQuote() ).getStatement();
-
- log.info( "Create category option group set table SQL: " + statement );
-
- jdbcTemplate.execute( statement );
- }
-
- // -------------------------------------------------------------------------
- // DataElementGroupSetTable
- // -------------------------------------------------------------------------
-
- @Override
- public void createDataElementGroupSetStructure( List<DataElementGroupSet> groupSets )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + CreateDataElementGroupSetTableStatement.TABLE_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String statement = new CreateDataElementGroupSetTableStatement( groupSets, statementBuilder.getColumnQuote() ).getStatement();
-
- log.info( "Create data element group set table SQL: " + statement );
-
- jdbcTemplate.execute( statement );
- }
-
- @Override
- public void populateDataElementGroupSetStructure( List<DataElementGroupSet> groupSets )
- {
- String sql =
- "insert into " + CreateDataElementGroupSetTableStatement.TABLE_NAME + " " +
- "select d.dataelementid as dataelementid, d.name as dataelementname, ";
-
- for ( DataElementGroupSet groupSet : groupSets )
- {
- sql += "(" +
- "select deg.name from dataelementgroup deg " +
- "inner join dataelementgroupmembers degm on degm.dataelementgroupid = deg.dataelementgroupid " +
- "inner join dataelementgroupsetmembers degsm on degsm.dataelementgroupid = degm.dataelementgroupid and degsm.dataelementgroupsetid = " + groupSet.getId() + " " +
- "where degm.dataelementid = d.dataelementid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getName() ) + ", ";
-
- sql += "(" +
- "select deg.uid from dataelementgroup deg " +
- "inner join dataelementgroupmembers degm on degm.dataelementgroupid = deg.dataelementgroupid " +
- "inner join dataelementgroupsetmembers degsm on degsm.dataelementgroupid = degm.dataelementgroupid and degsm.dataelementgroupsetid = " + groupSet.getId() + " " +
- "where degm.dataelementid = d.dataelementid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getUid() ) + ", ";
- }
-
- sql = TextUtils.removeLastComma( sql ) + " ";
- sql += "from dataelement d";
-
- log.info( "Populate data element group set structure SQL: " + sql );
-
- jdbcTemplate.execute( sql );
- }
-
- // -------------------------------------------------------------------------
- // DataElementGroupSetTable
- // -------------------------------------------------------------------------
-
- @Override
- public void createIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + CreateIndicatorGroupSetTableStatement.TABLE_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String statement = new CreateIndicatorGroupSetTableStatement( groupSets, statementBuilder.getColumnQuote() ).getStatement();
-
- log.info( "Create indicator group set table SQL: " + statement );
-
- jdbcTemplate.execute( statement );
- }
-
- @Override
- public void populateIndicatorGroupSetStructure( List<IndicatorGroupSet> groupSets )
- {
- String sql =
- "insert into " + CreateIndicatorGroupSetTableStatement.TABLE_NAME + " " +
- "select i.indicatorid as indicatorid, i.name as indicatorname, ";
-
- for ( IndicatorGroupSet groupSet : groupSets )
- {
- sql += "(" +
- "select ig.name from indicatorgroup ig " +
- "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " +
- "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " +
- "where igm.indicatorid = i.indicatorid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getName() ) + ", ";
-
- sql += "(" +
- "select ig.uid from indicatorgroup ig " +
- "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " +
- "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " +
- "where igm.indicatorid = i.indicatorid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getUid() ) + ", ";
- }
-
- sql = TextUtils.removeLastComma( sql ) + " ";
- sql += "from indicator i";
-
- log.info( "Populate indicator group set structure SQL: " + sql );
-
- jdbcTemplate.execute( sql );
- }
-
- // -------------------------------------------------------------------------
- // OrganisationUnitGroupSetTable
- // -------------------------------------------------------------------------
-
- @Override
- public void createOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String statement = new CreateOrganisationUnitGroupSetTableStatement( groupSets, statementBuilder.getColumnQuote() ).getStatement();
-
- log.info( "Create organisation unit group set table SQL: " + statement );
-
- jdbcTemplate.execute( statement );
- }
-
- @Override
- public void populateOrganisationUnitGroupSetStructure( List<OrganisationUnitGroupSet> groupSets )
- {
- String sql =
- "insert into " + CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME + " " +
- "select ou.organisationunitid as organisationunitid, ou.name as organisationunitname, ";
-
- for ( OrganisationUnitGroupSet groupSet : groupSets )
- {
- sql += "(" +
- "select oug.name from orgunitgroup oug " +
- "inner join orgunitgroupmembers ougm on ougm.orgunitgroupid = oug.orgunitgroupid " +
- "inner join orgunitgroupsetmembers ougsm on ougsm.orgunitgroupid = ougm.orgunitgroupid and ougsm.orgunitgroupsetid = " + groupSet.getId() + " " +
- "where ougm.organisationunitid = ou.organisationunitid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getName() ) + ", ";
-
- sql += "(" +
- "select oug.uid from orgunitgroup oug " +
- "inner join orgunitgroupmembers ougm on ougm.orgunitgroupid = oug.orgunitgroupid " +
- "inner join orgunitgroupsetmembers ougsm on ougsm.orgunitgroupid = ougm.orgunitgroupid and ougsm.orgunitgroupsetid = " + groupSet.getId() + " " +
- "where ougm.organisationunitid = ou.organisationunitid " +
- "limit 1) as " + statementBuilder.columnQuote( groupSet.getUid() ) + ", ";
- }
-
- sql = TextUtils.removeLastComma( sql ) + " ";
- sql += "from organisationunit ou";
-
- log.info( "Populate organisation unit group set structure SQL: " + sql );
-
- jdbcTemplate.execute( sql );
- }
-
- // -------------------------------------------------------------------------
- // CategoryTable
- // -------------------------------------------------------------------------
-
- @Override
- public void createCategoryStructure( List<DataElementCategory> categories )
- {
- try
- {
- jdbcTemplate.execute( "DROP TABLE IF EXISTS " + CreateCategoryTableStatement.TABLE_NAME );
- }
- catch ( BadSqlGrammarException ex )
- {
- // Do nothing, table does not exist
- }
-
- final String statement = new CreateCategoryTableStatement( categories, statementBuilder.getColumnQuote() ).getStatement();
-
- log.info( "Create category structure table SQL: " + statement );
-
- jdbcTemplate.execute( statement );
- }
-
- @Override
- public void populateCategoryStructure( List<DataElementCategory> categories )
- {
- String sql =
- "insert into " + CreateCategoryTableStatement.TABLE_NAME + " " +
- "select coc.categoryoptioncomboid as cocid, coc.name as cocname, ";
-
- for ( DataElementCategory category : categories )
- {
- sql += "(" +
- "select co.name from categoryoptioncombos_categoryoptions cocco " +
- "inner join dataelementcategoryoption co on cocco.categoryoptionid = co.categoryoptionid " +
- "inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " +
- "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " +
- "and cco.categoryid = " + category.getId() + " " +
- "limit 1) as " + statementBuilder.columnQuote( category.getName() ) + ", ";
-
- sql += "(" +
- "select co.uid from categoryoptioncombos_categoryoptions cocco " +
- "inner join dataelementcategoryoption co on cocco.categoryoptionid = co.categoryoptionid " +
- "inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " +
- "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " +
- "and cco.categoryid = " + category.getId() + " " +
- "limit 1) as " + statementBuilder.columnQuote( category.getUid() ) + ", ";
- }
-
- sql = TextUtils.removeLastComma( sql ) + " ";
- sql +=
- "from categoryoptioncombo coc ";
-
- log.info( "Populate category structure SQL: " + sql );
-
- jdbcTemplate.execute( sql );
- }
-
+
// -------------------------------------------------------------------------
// DataElementStructure
// -------------------------------------------------------------------------
=== removed directory 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement'
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryOptionGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryOptionGroupSetTableStatement.java 2015-04-15 14:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryOptionGroupSetTableStatement.java 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
-package org.hisp.dhis.resourcetable.statement;
-
-/*
- * 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 java.util.List;
-
-import org.amplecode.quick.Statement;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
-
-/**
- * @author Lars Helge Overland
- */
-public class CreateCategoryOptionGroupSetTableStatement
- implements Statement
-{
- private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (250)";
-
- public static final String TABLE_NAME = "_categoryoptiongroupsetstructure";
-
- private List<CategoryOptionGroupSet> groupSets;
-
- private String quote;
-
- public CreateCategoryOptionGroupSetTableStatement( List<CategoryOptionGroupSet> groupSets, String quote )
- {
- this.groupSets = groupSets;
- this.quote = quote;
- }
-
- @Override
- public String getStatement()
- {
- String statement = "CREATE TABLE " + TABLE_NAME + " ( " +
- "categoryoptioncomboid " + NUMERIC_COLUMN_TYPE + SEPARATOR;
-
- for ( CategoryOptionGroupSet groupSet : groupSets )
- {
- statement += quote + groupSet.getName() + quote + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += quote + groupSet.getUid() + quote + SPACE + "CHARACTER(11)" + SEPARATOR;
- }
-
- statement += "PRIMARY KEY ( categoryoptioncomboid ) )";
-
- return statement;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryTableStatement.java 2015-04-15 14:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateCategoryTableStatement.java 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-package org.hisp.dhis.resourcetable.statement;
-
-/*
- * 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 java.util.List;
-
-import org.amplecode.quick.Statement;
-import org.hisp.dhis.dataelement.DataElementCategory;
-
-/**
- * @author Lars Helge Overland
- */
-public class CreateCategoryTableStatement
- implements Statement
-{
- private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (250)";
-
- public static final String TABLE_NAME = "_categorystructure";
-
- private List<DataElementCategory> categories;
-
- private String quote;
-
- public CreateCategoryTableStatement( List<DataElementCategory> categories, String quote )
- {
- this.categories = categories;
- this.quote = quote;
- }
-
- @Override
- public String getStatement()
- {
- String statement = "CREATE TABLE " + TABLE_NAME + " ( " +
- "categoryoptioncomboid " + NUMERIC_COLUMN_TYPE + SEPARATOR +
- "categoryoptioncomboname " + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
-
- for ( DataElementCategory category : categories )
- {
- statement += quote + category.getName() + quote + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += quote + category.getUid() + quote + SPACE + "CHARACTER(11)" + SEPARATOR;
- }
-
- statement += "PRIMARY KEY ( categoryoptioncomboid ) )";
-
- return statement;
- }
-}
=== removed 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 2015-04-15 14:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-package org.hisp.dhis.resourcetable.statement;
-
-/*
- * 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 java.util.List;
-
-import org.amplecode.quick.Statement;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
-
-/**
- * @author Lars Helge Overland
- */
-public class CreateDataElementGroupSetTableStatement
- implements Statement
-{
- private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (250)";
-
- public static final String TABLE_NAME = "_dataelementgroupsetstructure";
-
- private List<DataElementGroupSet> groupSets;
-
- private String quote;
-
- public CreateDataElementGroupSetTableStatement( List<DataElementGroupSet> groupSets, String quote )
- {
- this.groupSets = groupSets;
- this.quote = quote;
- }
-
- @Override
- 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 += quote + groupSet.getName() + quote + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += quote + groupSet.getUid() + quote + SPACE + "CHARACTER(11)" + SEPARATOR;
- }
-
- statement += "PRIMARY KEY ( dataelementid ) )";
-
- return statement;
- }
-}
=== removed 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 2015-04-15 14:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-package org.hisp.dhis.resourcetable.statement;
-
-/*
- * 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 java.util.List;
-
-import org.amplecode.quick.Statement;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-
-/**
- * @author Lars Helge Overland
- */
-public class CreateIndicatorGroupSetTableStatement
- implements Statement
-{
- private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (250)";
-
- public static final String TABLE_NAME = "_indicatorgroupsetstructure";
-
- private List<IndicatorGroupSet> groupSets;
-
- private String quote;
-
- public CreateIndicatorGroupSetTableStatement( List<IndicatorGroupSet> groupSets, String quote )
- {
- this.groupSets = groupSets;
- this.quote = quote;
- }
-
- @Override
- 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 += quote + groupSet.getName() + quote + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += quote + groupSet.getUid() + quote + SPACE + "CHARACTER(11)" + SEPARATOR;
- }
-
- statement += "PRIMARY KEY ( indicatorid ) )";
-
- return statement;
- }
-}
=== removed file '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/CreateOrganisationUnitGroupSetTableStatement.java 2015-04-15 14:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-package org.hisp.dhis.resourcetable.statement;
-
-/*
- * 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 java.util.List;
-
-import org.amplecode.quick.Statement;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-
-/**
- * @author Lars Helge Overland
- */
-public class CreateOrganisationUnitGroupSetTableStatement
- implements Statement
-{
- public static final String TABLE_NAME = "_organisationunitgroupsetstructure";
-
- private static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (250)";
-
- private List<OrganisationUnitGroupSet> groupSets;
-
- private String quote;
-
- public CreateOrganisationUnitGroupSetTableStatement( List<OrganisationUnitGroupSet> groupSets, String quote )
- {
- this.groupSets = groupSets;
- this.quote = quote;
- }
-
- @Override
- public String getStatement()
- {
- String statement = "CREATE TABLE " + TABLE_NAME + " ( " +
- "organisationunitid " + NUMERIC_COLUMN_TYPE + SEPARATOR +
- "organisationunitname " + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
-
- for ( OrganisationUnitGroupSet groupSet : groupSets )
- {
- statement += quote + groupSet.getName() + quote + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += quote + groupSet.getUid() + quote + SPACE + "CHARACTER(11)" + SEPARATOR;
- }
-
- statement += "PRIMARY KEY ( organisationunitid ) )";
-
- return statement;
- }
-}
=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryOptionGroupSetResourceTable.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryOptionGroupSetResourceTable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryOptionGroupSetResourceTable.java 2015-10-02 16:14:33 +0000
@@ -0,0 +1,108 @@
+package org.hisp.dhis.resourcetable.table;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.resourcetable.ResourceTable;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class CategoryOptionGroupSetResourceTable
+ extends ResourceTable<CategoryOptionGroupSet>
+{
+ private List<DataElementCategoryOptionCombo> categoryOptionCombos;
+
+ public CategoryOptionGroupSetResourceTable( String tableName,
+ List<CategoryOptionGroupSet> objects, String columnQuote, List<DataElementCategoryOptionCombo> categoryOptionCombos )
+ {
+ super( tableName, objects, columnQuote );
+ this.categoryOptionCombos = categoryOptionCombos;
+ }
+
+ @Override
+ public String getCreateTempTableStatement()
+ {
+ String statement = "create table " + getTempTableName() + " (" +
+ "categoryoptioncomboid integer not null, ";
+
+ for ( CategoryOptionGroupSet groupSet : objects )
+ {
+ statement += columnQuote + groupSet.getName() + columnQuote + " varchar(160), ";
+ statement += columnQuote + groupSet.getUid() + columnQuote + " character(11), ";
+ }
+
+ statement += "primary key (categoryoptioncomboid))";
+
+ return statement;
+ }
+
+ @Override
+ public Optional<String> getPopulateTempTableStatement()
+ {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<List<Object[]>> getPopulateTempTableContent()
+ {
+ List<Object[]> batchArgs = new ArrayList<>();
+
+ for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos )
+ {
+ List<Object> values = new ArrayList<>();
+
+ values.add( categoryOptionCombo.getId() );
+
+ for ( CategoryOptionGroupSet groupSet : objects )
+ {
+ CategoryOptionGroup group = groupSet.getGroup( categoryOptionCombo );
+
+ values.add( group != null ? group.getName() : null );
+ values.add( group != null ? group.getUid() : null );
+ }
+
+ batchArgs.add( values.toArray() );
+ }
+
+ return Optional.of( batchArgs );
+ }
+
+ @Override
+ public Optional<String> getCreateIndexStatement()
+ {
+ return Optional.empty();
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryResourceTable.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryResourceTable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/CategoryResourceTable.java 2015-10-02 16:14:33 +0000
@@ -0,0 +1,110 @@
+package org.hisp.dhis.resourcetable.table;
+
+/*
+ * 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 java.util.List;
+import java.util.Optional;
+
+import org.hisp.dhis.commons.util.TextUtils;
+import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.resourcetable.ResourceTable;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class CategoryResourceTable
+ extends ResourceTable<DataElementCategory>
+{
+ public CategoryResourceTable( String tableName, List<DataElementCategory> objects, String columnQuote )
+ {
+ super( tableName, objects, columnQuote );
+ }
+
+ @Override
+ public String getCreateTempTableStatement()
+ {
+ String statement = "create table " + getTempTableName() + " (" +
+ "categoryoptioncomboid integer not null, " +
+ "categoryoptioncomboname varchar(230), ";
+
+ for ( DataElementCategory category : objects )
+ {
+ statement += columnQuote + category.getName() + columnQuote + " varchar(230), ";
+ statement += columnQuote + category.getUid() + columnQuote + " character(11), ";
+ }
+
+ statement += "primary key (categoryoptioncomboid))";
+
+ return statement;
+ }
+
+ @Override
+ public Optional<String> getPopulateTempTableStatement()
+ {
+ String sql =
+ "insert into " + getTempTableName() + " " +
+ "select coc.categoryoptioncomboid as cocid, coc.name as cocname, ";
+
+ for ( DataElementCategory category : objects )
+ {
+ sql += "(" +
+ "select co.name from categoryoptioncombos_categoryoptions cocco " +
+ "inner join dataelementcategoryoption co on cocco.categoryoptionid = co.categoryoptionid " +
+ "inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " +
+ "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " +
+ "and cco.categoryid = " + category.getId() + " " +
+ "limit 1) as " + columnQuote + category.getName() + columnQuote + ", ";
+
+ sql += "(" +
+ "select co.uid from categoryoptioncombos_categoryoptions cocco " +
+ "inner join dataelementcategoryoption co on cocco.categoryoptionid = co.categoryoptionid " +
+ "inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " +
+ "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " +
+ "and cco.categoryid = " + category.getId() + " " +
+ "limit 1) as " + columnQuote + category.getUid() + columnQuote + ", ";
+ }
+
+ sql = TextUtils.removeLastComma( sql ) + " ";
+ sql += "from categoryoptioncombo coc ";
+
+ return Optional.of( sql );
+ }
+
+ @Override
+ public Optional<List<Object[]>> getPopulateTempTableContent()
+ {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<String> getCreateIndexStatement()
+ {
+ return Optional.empty();
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/DataElementGroupSetResourceTable.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/DataElementGroupSetResourceTable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/DataElementGroupSetResourceTable.java 2015-10-02 16:14:33 +0000
@@ -0,0 +1,108 @@
+package org.hisp.dhis.resourcetable.table;
+
+/*
+ * 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 java.util.List;
+import java.util.Optional;
+
+import org.hisp.dhis.commons.util.TextUtils;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.resourcetable.ResourceTable;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class DataElementGroupSetResourceTable
+ extends ResourceTable<DataElementGroupSet>
+{
+ public DataElementGroupSetResourceTable( String tableName, List<DataElementGroupSet> objects, String columnQuote )
+ {
+ super( tableName, objects, columnQuote );
+ }
+
+ @Override
+ public String getCreateTempTableStatement()
+ {
+ String statement = "create table " + getTempTableName() + " (" +
+ "dataelementid integer not null, " +
+ "dataelementname varchar(230), ";
+
+ for ( DataElementGroupSet groupSet : objects )
+ {
+ statement += columnQuote + groupSet.getName() + columnQuote + " varchar(230), ";
+ statement += columnQuote + groupSet.getUid() + columnQuote + " character(11), ";
+ }
+
+ statement += "primary key (dataelementid))";
+
+ return statement;
+ }
+
+ @Override
+ public Optional<String> getPopulateTempTableStatement()
+ {
+ String sql =
+ "insert into " + getTempTableName() + " " +
+ "select d.dataelementid as dataelementid, d.name as dataelementname, ";
+
+ for ( DataElementGroupSet groupSet : objects )
+ {
+ sql += "(" +
+ "select deg.name from dataelementgroup deg " +
+ "inner join dataelementgroupmembers degm on degm.dataelementgroupid = deg.dataelementgroupid " +
+ "inner join dataelementgroupsetmembers degsm on degsm.dataelementgroupid = degm.dataelementgroupid and degsm.dataelementgroupsetid = " + groupSet.getId() + " " +
+ "where degm.dataelementid = d.dataelementid " +
+ "limit 1) as " + columnQuote + groupSet.getName() + columnQuote + ", ";
+
+ sql += "(" +
+ "select deg.uid from dataelementgroup deg " +
+ "inner join dataelementgroupmembers degm on degm.dataelementgroupid = deg.dataelementgroupid " +
+ "inner join dataelementgroupsetmembers degsm on degsm.dataelementgroupid = degm.dataelementgroupid and degsm.dataelementgroupsetid = " + groupSet.getId() + " " +
+ "where degm.dataelementid = d.dataelementid " +
+ "limit 1) as " + columnQuote + groupSet.getUid() + columnQuote + ", ";
+ }
+
+ sql = TextUtils.removeLastComma( sql ) + " ";
+ sql += "from dataelement d";
+
+ return Optional.of( sql );
+ }
+
+ @Override
+ public Optional<List<Object[]>> getPopulateTempTableContent()
+ {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<String> getCreateIndexStatement()
+ {
+ return Optional.empty();
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/IndicatorGroupSetResourceTable.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/IndicatorGroupSetResourceTable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/IndicatorGroupSetResourceTable.java 2015-10-02 16:14:33 +0000
@@ -0,0 +1,108 @@
+package org.hisp.dhis.resourcetable.table;
+
+/*
+ * 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 java.util.List;
+import java.util.Optional;
+
+import org.hisp.dhis.commons.util.TextUtils;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.resourcetable.ResourceTable;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class IndicatorGroupSetResourceTable
+ extends ResourceTable<IndicatorGroupSet>
+{
+ public IndicatorGroupSetResourceTable( String tableName, List<IndicatorGroupSet> objects, String columnQuote )
+ {
+ super( tableName, objects, columnQuote );
+ }
+
+ @Override
+ public String getCreateTempTableStatement()
+ {
+ String statement = "create table " + getTempTableName() + " (" +
+ "indicatorid integer not null, " +
+ "indicatorname varchar(230), ";
+
+ for ( IndicatorGroupSet groupSet : objects )
+ {
+ statement += columnQuote + groupSet.getName() + columnQuote + " varchar(230), ";
+ statement += columnQuote + groupSet.getUid() + columnQuote + " character(11), ";
+ }
+
+ statement += "primary key (indicatorid))";
+
+ return statement;
+ }
+
+ @Override
+ public Optional<String> getPopulateTempTableStatement()
+ {
+ String sql =
+ "insert into " + getTempTableName() + " " +
+ "select i.indicatorid as indicatorid, i.name as indicatorname, ";
+
+ for ( IndicatorGroupSet groupSet : objects )
+ {
+ sql += "(" +
+ "select ig.name from indicatorgroup ig " +
+ "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " +
+ "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " +
+ "where igm.indicatorid = i.indicatorid " +
+ "limit 1) as " + columnQuote + groupSet.getName() + columnQuote + ", ";
+
+ sql += "(" +
+ "select ig.uid from indicatorgroup ig " +
+ "inner join indicatorgroupmembers igm on igm.indicatorgroupid = ig.indicatorgroupid " +
+ "inner join indicatorgroupsetmembers igsm on igsm.indicatorgroupid = igm.indicatorgroupid and igsm.indicatorgroupsetid = " + groupSet.getId() + " " +
+ "where igm.indicatorid = i.indicatorid " +
+ "limit 1) as " + columnQuote + groupSet.getUid() + columnQuote + ", ";
+ }
+
+ sql = TextUtils.removeLastComma( sql ) + " ";
+ sql += "from indicator i";
+
+ return Optional.of( sql );
+ }
+
+ @Override
+ public Optional<List<Object[]>> getPopulateTempTableContent()
+ {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<String> getCreateIndexStatement()
+ {
+ return Optional.empty();
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/OrganisationUnitGroupSetResourceTable.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/OrganisationUnitGroupSetResourceTable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/table/OrganisationUnitGroupSetResourceTable.java 2015-10-02 16:14:33 +0000
@@ -0,0 +1,108 @@
+package org.hisp.dhis.resourcetable.table;
+
+/*
+ * 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 java.util.List;
+import java.util.Optional;
+
+import org.hisp.dhis.commons.util.TextUtils;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.resourcetable.ResourceTable;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class OrganisationUnitGroupSetResourceTable
+ extends ResourceTable<OrganisationUnitGroupSet>
+{
+ public OrganisationUnitGroupSetResourceTable( String tableName, List<OrganisationUnitGroupSet> objects, String columnQuote )
+ {
+ super( tableName, objects, columnQuote );
+ }
+
+ @Override
+ public String getCreateTempTableStatement()
+ {
+ String statement = "create table " + getTempTableName() + " (" +
+ "organisationunitid integer not null, " +
+ "organisationunitname varchar(230), ";
+
+ for ( OrganisationUnitGroupSet groupSet : objects )
+ {
+ statement += columnQuote + groupSet.getName() + columnQuote + " varchar(230), ";
+ statement += columnQuote + groupSet.getUid() + columnQuote + " character(11), ";
+ }
+
+ statement += "primary key (organisationunitid))";
+
+ return statement;
+ }
+
+ @Override
+ public Optional<String> getPopulateTempTableStatement()
+ {
+ String sql =
+ "insert into " + getTempTableName() + " " +
+ "select ou.organisationunitid as organisationunitid, ou.name as organisationunitname, ";
+
+ for ( OrganisationUnitGroupSet groupSet : objects )
+ {
+ sql += "(" +
+ "select oug.name from orgunitgroup oug " +
+ "inner join orgunitgroupmembers ougm on ougm.orgunitgroupid = oug.orgunitgroupid " +
+ "inner join orgunitgroupsetmembers ougsm on ougsm.orgunitgroupid = ougm.orgunitgroupid and ougsm.orgunitgroupsetid = " + groupSet.getId() + " " +
+ "where ougm.organisationunitid = ou.organisationunitid " +
+ "limit 1) as " + columnQuote + groupSet.getName() + columnQuote + ", ";
+
+ sql += "(" +
+ "select oug.uid from orgunitgroup oug " +
+ "inner join orgunitgroupmembers ougm on ougm.orgunitgroupid = oug.orgunitgroupid " +
+ "inner join orgunitgroupsetmembers ougsm on ougsm.orgunitgroupid = ougm.orgunitgroupid and ougsm.orgunitgroupsetid = " + groupSet.getId() + " " +
+ "where ougm.organisationunitid = ou.organisationunitid " +
+ "limit 1) as " + columnQuote + groupSet.getUid() + columnQuote + ", ";
+ }
+
+ sql = TextUtils.removeLastComma( sql ) + " ";
+ sql += "from organisationunit ou";
+
+ return Optional.of( sql );
+ }
+
+ @Override
+ public Optional<List<Object[]>> getPopulateTempTableContent()
+ {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<String> getCreateIndexStatement()
+ {
+ return Optional.empty();
+ }
+}