dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03952
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1314: Allowing - characters in report table columns by replacing them with _ . Put it some verification...
------------------------------------------------------------
revno: 1314
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-01-19 14:51:49 +0100
message:
Allowing - characters in report table columns by replacing them with _ . Put it some verifications in report tables for easier debugging.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.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/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2009-12-21 10:54:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2010-01-19 13:51:49 +0000
@@ -414,15 +414,8 @@
public void init()
{
- if ( nonEmptyLists( dataElements, indicators, dataSets ) > 1 )
- {
- throw new IllegalArgumentException( "ReportTable cannot contain more than one out of dataelements, indicators, and datasets" );
- }
-
- if ( doIndicators && doPeriods && doUnits )
- {
- throw new IllegalArgumentException( "ReportTable cannot crosstab on all dimensions" );
- }
+ verify( nonEmptyLists( dataElements, indicators, dataSets ) == 1, "One of dataelements, indicators, and datasets size must be larger than 0" );
+ verify( !( doIndicators && doPeriods && doUnits ), "Cannot crosstab on all dimensions" );
// ---------------------------------------------------------------------
// Init tableName, allPeriods and allUnits
@@ -436,6 +429,9 @@
allUnits.addAll( units );
allUnits.addAll( relativeUnits );
+ verify( nonEmptyLists( allPeriods ) == 1, "All periods size must be larger than 0" );
+ verify( nonEmptyLists( allUnits ) == 1, "All units size must be larger than 0" );
+
// ---------------------------------------------------------------------
// Init dimensional lists
// ---------------------------------------------------------------------
@@ -447,6 +443,8 @@
// -----------------------------------------------------------------
categoryOptionCombos = categoryCombo.getDimensionOptionElements();
+
+ verify( nonEmptyLists( categoryOptionCombos ) == 1, "Category option combos size must be larger than 0" );
}
else if ( isDimensional( DimensionType.DATAELEMENTGROUPSET ) )
{
@@ -462,6 +460,8 @@
}
dimensionalDataElements = elements;
+
+ verify( nonEmptyLists( dimensionalDataElements ) == 1, "Dimensional data elements size must be larger than 0" );
}
// ---------------------------------------------------------------------
@@ -538,7 +538,7 @@
{
crossTabUnits = new ArrayList<OrganisationUnit>( allUnits );
reportUnits.add( null );
- selectColumns.add( ORGANISATIONUNIT_ID );
+ selectColumns.add( ORGANISATIONUNIT_ID );
}
else
{
@@ -572,15 +572,17 @@
}
}
+ verify( nonEmptyLists( crossTabColumns ) == 1, "Crosstab columns size must be larger than 0" );
+
// ---------------------------------------------------------------------
// Init dimensionOptions and dimensionOptionColumns
// ---------------------------------------------------------------------
if ( doTotal() )
{
- List<? extends Dimension> dimensions = isDimensional( DimensionType.CATEGORY ) ? categoryCombo.getDimensions() : dataElementGroupSets;
+ verify ( nonEmptyLists( categoryCombo.getDimensions() ) == 1, "Category combo dimensions size must be larger than 0" );
- for ( Dimension dimension : dimensions )
+ for ( Dimension dimension : categoryCombo.getDimensions() )
{
for ( DimensionOption dimensionOption : dimension.getDimensionOptions() )
{
@@ -592,6 +594,8 @@
prettyCrossTabColumns.put( columnName, prettyColumnName );
}
}
+
+ verify( nonEmptyLists( dimensionOptions, dimensionOptionColumns ) == 2, "Dimension options size must be larger than 0" );
}
}
@@ -607,9 +611,11 @@
{
if ( dimensionSet != null )
{
- this.dimensionType = dimensionSet.getDimensionType();
- this.categoryCombo = dimensionType.equals( DimensionType.CATEGORY ) ? dimensionSet : null;
- this.dataElementGroupSets = dimensionType.equals( DimensionType.DATAELEMENTGROUPSET ) ? dimensionSet.getDimensions() : null;
+ dimensionType = dimensionSet.getDimensionType();
+ categoryCombo = dimensionType.equals( DimensionType.CATEGORY ) ? dimensionSet : null;
+ dataElementGroupSets = dimensionType.equals( DimensionType.DATAELEMENTGROUPSET ) ? dimensionSet.getDimensions() : null;
+
+ verify( dimensionType != null, "Dimension type cannot be null" );
}
}
@@ -957,6 +963,7 @@
string = string.toLowerCase();
string = string.replaceAll( " ", EMPTY_REPLACEMENT );
+ string = string.replaceAll( "-", EMPTY_REPLACEMENT );
string = string.replaceAll( "<", EMPTY_REPLACEMENT + "lt" + EMPTY_REPLACEMENT );
string = string.replaceAll( ">", EMPTY_REPLACEMENT + "gt" + EMPTY_REPLACEMENT );
@@ -996,6 +1003,17 @@
return string;
}
+
+ /**
+ * Supportive method.
+ */
+ private void verify( boolean expression, String falseMessage )
+ {
+ if ( !expression )
+ {
+ throw new IllegalStateException( falseMessage );
+ }
+ }
// -------------------------------------------------------------------------
// Equals and hashCode
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2009-11-10 11:45:58 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2010-01-19 13:51:49 +0000
@@ -40,8 +40,6 @@
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.translation.Translation;
import org.hisp.dhis.translation.TranslationService;
@@ -52,8 +50,6 @@
public class DefaultI18nService
implements I18nService
{
- private static final Log log = LogFactory.getLog( DefaultI18nService.class );
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -447,8 +443,6 @@
return i18nObject;
}
}
-
- log.debug( "Object not enabled for i18n: " + object );
}
return null;
=== 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 2010-01-15 11:32:18 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java 2010-01-19 13:51:49 +0000
@@ -36,7 +36,6 @@
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
-import org.amplecode.quick.Statement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataelement.DataElement;