dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11027
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3061: Implemented resource table _dataelementstructure
------------------------------------------------------------
revno: 3061
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-17 20:31:16 +0100
message:
Implemented resource table _dataelementstructure
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-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
--
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 2010-09-16 08:49:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java 2011-03-17 19:31:16 +0000
@@ -66,4 +66,9 @@
* Generates a resource table for all category option combos.
*/
void generateCategoryTable();
+
+ /**
+ * Generates a resource table for all data elements.
+ */
+ void generateDataElementTable();
}
=== 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 2010-09-16 08:49:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java 2011-03-17 19:31:16 +0000
@@ -43,6 +43,7 @@
final String TABLE_NAME_CATEGORY_OPTION_COMBO_NAME = "_categoryoptioncomboname";
final String TABLE_NAME_ORGANISATION_UNIT_STRUCTURE = "_orgunitstructure";
+ final String TABLE_NAME_DATA_ELEMENT_STRUCTURE = "_dataelementstructure";
// -------------------------------------------------------------------------
// OrganisationUnitStructure
@@ -94,4 +95,8 @@
*/
void createCategoryStructure( 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 2011-01-31 19:47:04 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java 2011-03-17 19:31:16 +0000
@@ -61,6 +61,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.resourcetable.statement.CreateCategoryTableStatement;
import org.hisp.dhis.resourcetable.statement.CreateDataElementGroupSetTableStatement;
import org.hisp.dhis.resourcetable.statement.CreateIndicatorGroupSetTableStatement;
@@ -135,12 +136,9 @@
{
resourceTableStore.createOrganisationUnitStructure();
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( ResourceTableStore.TABLE_NAME_ORGANISATION_UNIT_STRUCTURE );
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( ResourceTableStore.TABLE_NAME_ORGANISATION_UNIT_STRUCTURE ).init();
- batchHandler.init();
-
for ( int i = 0; i < 8; i++ )
{
int level = i + 1;
@@ -189,11 +187,8 @@
Collection<DataElementCategoryOptionCombo> combos = categoryService.getAllDataElementCategoryOptionCombos();
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( ResourceTableStore.TABLE_NAME_CATEGORY_OPTION_COMBO_NAME );
-
- batchHandler.init();
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( ResourceTableStore.TABLE_NAME_CATEGORY_OPTION_COMBO_NAME ).init();
for ( DataElementCategoryOptionCombo combo : combos )
{
@@ -232,11 +227,8 @@
// Populate table
// ---------------------------------------------------------------------
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( CreateDataElementGroupSetTableStatement.TABLE_NAME );
-
- batchHandler.init();
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( CreateDataElementGroupSetTableStatement.TABLE_NAME ).init();
for ( DataElement dataElement : dataElements )
{
@@ -282,11 +274,8 @@
// Populate table
// ---------------------------------------------------------------------
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( CreateIndicatorGroupSetTableStatement.TABLE_NAME );
-
- batchHandler.init();
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( CreateIndicatorGroupSetTableStatement.TABLE_NAME ).init();
for ( Indicator indicator : indicators )
{
@@ -334,11 +323,8 @@
// Populate table
// ---------------------------------------------------------------------
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME );
-
- batchHandler.init();
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( CreateOrganisationUnitGroupSetTableStatement.TABLE_NAME ).init();
for ( OrganisationUnit unit : units )
{
@@ -383,11 +369,8 @@
// Populate table
// ---------------------------------------------------------------------
- BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
- batchHandler.setTableName( CreateCategoryTableStatement.TABLE_NAME );
-
- batchHandler.init();
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( CreateCategoryTableStatement.TABLE_NAME ).init();
for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos )
{
@@ -408,4 +391,42 @@
batchHandler.flush();
}
+
+ // -------------------------------------------------------------------------
+ // DataElementTable
+ // -------------------------------------------------------------------------
+
+ public void generateDataElementTable()
+ {
+ // ---------------------------------------------------------------------
+ // Create table
+ // ---------------------------------------------------------------------
+
+ Collection<DataElement> dataElements = dataElementService.getAllDataElements();
+
+ resourceTableStore.createDataElementStructure();
+
+ // ---------------------------------------------------------------------
+ // Populate table
+ // ---------------------------------------------------------------------
+
+ BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
+ setTableName( ResourceTableStore.TABLE_NAME_DATA_ELEMENT_STRUCTURE ).init();
+
+ for ( DataElement dataElement : dataElements )
+ {
+ final List<String> values = new ArrayList<String>();
+
+ final PeriodType periodType = dataElement.getPeriodType();
+
+ values.add( String.valueOf( dataElement.getId() ) );
+ values.add( dataElement.getName() );
+ values.add( periodType != null ? String.valueOf( periodType.getId() ) : null );
+ values.add( periodType != null ? periodType.getName() : null );
+
+ batchHandler.addObject( values );
+ }
+
+ batchHandler.flush();
+ }
}
=== 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 2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/hibernate/HibernateResourceTableStore.java 2011-03-17 19:31:16 +0000
@@ -199,4 +199,27 @@
jdbcTemplate.update( statement.getStatement() );
}
+
+ // -------------------------------------------------------------------------
+ // DataElementStructure
+ // -------------------------------------------------------------------------
+
+ public void createDataElementStructure()
+ {
+ try
+ {
+ jdbcTemplate.update( "DROP TABLE " + TABLE_NAME_DATA_ELEMENT_STRUCTURE );
+ }
+ catch ( BadSqlGrammarException ex )
+ {
+ // Do nothing, table does not exist
+ }
+
+ String sql = "CREATE TABLE " + TABLE_NAME_DATA_ELEMENT_STRUCTURE +
+ " ( dataelementid INTEGER NOT NULL, dataelementname VARCHAR(250), periodtypeid INTEGER, periodtypename VARCHAR(250) )";
+
+ log.info( "Create data element structure SQL: " + sql );
+
+ jdbcTemplate.update( sql );
+ }
}
=== 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 2010-09-16 10:04:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2011-03-17 19:31:16 +0000
@@ -107,6 +107,13 @@
this.categoryOptionComboName = categoryOptionComboName;
}
+ private boolean dataElementStructure;
+
+ public void setDataElementStructure( boolean dataElementStructure )
+ {
+ this.dataElementStructure = dataElementStructure;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -148,6 +155,11 @@
resourceTableService.generateCategoryOptionComboNames();
}
+ if ( dataElementStructure )
+ {
+ resourceTableService.generateDataElementTable();
+ }
+
log.info( "Generated resource tables" );
sqlViewService.createAllViewTables();
=== 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 2011-03-14 05:00:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2011-03-17 19:31:16 +0000
@@ -315,4 +315,5 @@
raw_data = Raw data
get_report_as_xls = Download as Excel
get_report_as_csv = Download as CSV
-get_report_as_pdf = Download as PDF
\ No newline at end of file
+get_report_as_pdf = Download as PDF
+data_element_structure = Data element structure
\ No newline at end of file
=== 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 2010-09-16 10:04:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js 2011-03-17 19:31:16 +0000
@@ -9,9 +9,10 @@
var organisationUnitGroupSetStructure = document.getElementById( "organisationUnitGroupSetStructure" ).checked;
var categoryStructure = document.getElementById( "categoryStructure" ).checked;
var categoryOptionComboName = document.getElementById( "categoryOptionComboName" ).checked;
+ var dataElementStructure = document.getElementById( "dataElementStructure" ).checked;
if ( organisationUnit || dataElementGroupSetStructure || indicatorGroupSetStructure ||
- organisationUnitGroupSetStructure || categoryStructure || categoryOptionComboName )
+ organisationUnitGroupSetStructure || categoryStructure || categoryOptionComboName || dataElementStructure )
{
setWaitMessage( i18n_generating_resource_tables );
@@ -20,7 +21,8 @@
"&indicatorGroupSetStructure=" + indicatorGroupSetStructure +
"&organisationUnitGroupSetStructure=" + organisationUnitGroupSetStructure +
"&categoryStructure=" + categoryStructure +
- "&categoryOptionComboName=" + categoryOptionComboName;
+ "&categoryOptionComboName=" + categoryOptionComboName +
+ "&dataElementStructure=" + dataElementStructure;
var url = "generateResourceTable.action";
@@ -50,4 +52,5 @@
document.getElementById( "organisationUnitGroupSetStructure" ).checked = selected;
document.getElementById( "categoryStructure" ).checked = selected;
document.getElementById( "categoryOptionComboName" ).checked = selected;
+ document.getElementById( "dataElementStructure" ).checked = selected;
}
=== 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 2011-03-17 14:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm 2011-03-17 19:31:16 +0000
@@ -40,6 +40,10 @@
<label for="categoryOptionComboName">$i18n.getString( "data_element_category_option_combo_name" ) <span style="color:#606060">(_categoryoptioncomboname)</span></label>
</p>
+<p>
+ <input type="checkbox" name="resourceTableCheckBox" id="dataElementStructure"/>
+ <label for="dataElementStructure">$i18n.getString( "data_element_structure" ) <span style="color:#606060">(_dataelementstructure)</span></label>
+</p>
<table>
<tr>