dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22584
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10892: Refactored ReportTable to use analytics engine instead of data mart.
------------------------------------------------------------
revno: 10892
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-05-19 20:49:47 +0200
message:
Refactored ReportTable to use analytics engine instead of data mart.
added:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java
modified:
dhis-2/dhis-api/pom.xml
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/ConfigurablePeriod.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm
dhis-2/pom.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/pom.xml'
--- dhis-2/dhis-api/pom.xml 2013-05-17 12:45:20 +0000
+++ dhis-2/dhis-api/pom.xml 2013-05-19 18:49:47 +0000
@@ -58,10 +58,10 @@
<dependency>
<groupId>org.smslib</groupId>
<artifactId>smslib</artifactId>
- </dependency><dependency>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
- <version>${spring.version}</version>
</dependency>
</dependencies>
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-05-15 15:00:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-05-19 18:49:47 +0000
@@ -38,6 +38,8 @@
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -53,6 +55,7 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -60,6 +63,8 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.RelativePeriodEnum;
import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.period.comparator.AscendingPeriodComparator;
+import org.hisp.dhis.user.User;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
@@ -127,6 +132,12 @@
protected transient Map<String, String> parentGraphMap = new HashMap<String, String>();
// -------------------------------------------------------------------------
+ // Transient properties
+ // -------------------------------------------------------------------------
+
+ protected transient List<OrganisationUnit> transientOrganisationUnits = new ArrayList<OrganisationUnit>();
+
+ // -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -142,16 +153,135 @@
return relatives != null && !relatives.isEmpty();
}
+ protected void addTransientOrganisationUnits( List<OrganisationUnit> organisationUnits )
+ {
+ if ( organisationUnits != null )
+ {
+ this.transientOrganisationUnits.addAll( organisationUnits );
+ }
+ }
+
+ /**
+ * Assembles a DimensionalObject. Collapses indicators, data elements, data
+ * element operands and data sets into the dx dimension.
+ *
+ * Collapses fixed and relative periods into the pe dimension. Collapses
+ * fixed and user organisation units into the ou dimension.
+ *
+ * @param dimension the dimension identifier.
+ * @param date the date used for generating relative periods.
+ * @param user the current user.
+ * @param dynamicNames whether to use dynamic or static names.
+ * @param format the I18nFormat.
+ * @return a DimensionalObject.
+ */
+ protected DimensionalObject getDimensionalObject( String dimension, Date date, User user, boolean dynamicNames, I18nFormat format )
+ {
+ List<NameableObject> items = new ArrayList<NameableObject>();
+
+ DimensionType type = null;
+
+ List<String> categoryDims = getCategoryDims();
+
+ if ( DATA_X_DIM_ID.equals( dimension ) )
+ {
+ items.addAll( indicators );
+ items.addAll( dataElements );
+ items.addAll( dataElementOperands );
+ items.addAll( dataSets );
+
+ type = DimensionType.DATA_X;
+ }
+ else if ( PERIOD_DIM_ID.equals( dimension ) )
+ {
+ items.addAll( periods );
+
+ if ( hasRelativePeriods() )
+ {
+ items.addAll( relatives.getRelativePeriods( date, format, dynamicNames ) ); //TODO dyn names if period is on rows
+ }
+
+ type = DimensionType.PERIOD;
+ }
+ else if ( ORGUNIT_DIM_ID.equals( dimension ) )
+ {
+ items.addAll( organisationUnits );
+ items.addAll( transientOrganisationUnits );
+
+ if ( userOrganisationUnit && user != null && user.hasOrganisationUnit() )
+ {
+ items.add( user.getOrganisationUnit() );
+ }
+
+ if ( userOrganisationUnitChildren && user != null && user.hasOrganisationUnit() )
+ {
+ items.addAll( user.getOrganisationUnit().getChildren() );
+ }
+
+ type = DimensionType.ORGANISATIONUNIT;
+ }
+ else if ( categoryDims.contains( dimension ) )
+ {
+ DataElementCategoryDimension categoryDimension = categoryDimensions.get( categoryDims.indexOf( dimension ) );
+
+ items.addAll( categoryDimension.getItems() );
+
+ type = DimensionType.CATEGORY;
+ }
+ else // Group set
+ {
+ ListMap<String, NameableObject> deGroupMap = new ListMap<String, NameableObject>();
+
+ for ( DataElementGroup group : dataElementGroups )
+ {
+ deGroupMap.putValue( group.getGroupSet().getDimension(), group );
+ }
+
+ if ( deGroupMap.containsKey( dimension ) )
+ {
+ items.addAll( deGroupMap.get( dimension ) );
+
+ type = DimensionType.DATAELEMENT_GROUPSET;
+ }
+
+ ListMap<String, NameableObject> ouGroupMap = new ListMap<String, NameableObject>();
+
+ for ( OrganisationUnitGroup group : organisationUnitGroups )
+ {
+ ouGroupMap.putValue( group.getGroupSet().getUid(), group );
+ }
+
+ if ( ouGroupMap.containsKey( dimension ) )
+ {
+ items.addAll( ouGroupMap.get( dimension ) );
+
+ type = DimensionType.ORGANISATIONUNIT_GROUPSET;
+ }
+ }
+
+ IdentifiableObjectUtils.removeDuplicates( items );
+
+ return new BaseDimensionalObject( dimension, type, items );
+ }
+
+ /**
+ * Assembles a list of DimensionalObjects based on the concrete objects in
+ * this BaseAnalyticalObject. Explodes the dx dimension into the in|de|dc|ds
+ * concrete objects and returns them as separate DimensionalObjects.
+ *
+ * Merges fixed and relative periods into the pe dimension, where the
+ * RelativePeriods object is represented by enums (e.g. LAST_MONTH). Merges
+ * fixed and user organisation units into the ou dimension, where user
+ * organisation units properties are represented by enums (e.g. USER_ORG_UNIT).
+ *
+ * @param dimension the dimension identifier.
+ * @return a list of DimensionalObjects.
+ */
protected List<DimensionalObject> getDimensionalObjectList( String dimension )
{
List<DimensionalObject> objects = new ArrayList<DimensionalObject>();
- List<String> categoryDims = new ArrayList<String>();
-
- for ( DataElementCategoryDimension dim : categoryDimensions )
- {
- categoryDims.add( dim.getDimension().getDimension() );
- }
+ List<String> categoryDims = getCategoryDims();
if ( DATA_X_DIM_ID.equals( dimension ) )
{
@@ -177,7 +307,7 @@
}
else if ( PERIOD_DIM_ID.equals( dimension ) && ( !periods.isEmpty() || hasRelativePeriods() ) )
{
- List<IdentifiableObject> periodList = new ArrayList<IdentifiableObject>( periods );
+ List<Period> periodList = new ArrayList<Period>( periods );
if ( hasRelativePeriods() )
{
@@ -189,11 +319,15 @@
}
}
+ Collections.sort( periodList, new AscendingPeriodComparator() );
+
objects.add( new BaseDimensionalObject( dimension, DimensionType.PERIOD, periodList ) );
}
else if ( ORGUNIT_DIM_ID.equals( dimension ) && ( !organisationUnits.isEmpty() || hasUserOrgUnit() ) )
{
- List<IdentifiableObject> ouList = new ArrayList<IdentifiableObject>( organisationUnits );
+ List<IdentifiableObject> ouList = new ArrayList<IdentifiableObject>();
+ ouList.addAll( organisationUnits );
+ ouList.addAll( transientOrganisationUnits );
if ( userOrganisationUnit )
{
@@ -204,7 +338,7 @@
{
ouList.add( new BaseIdentifiableObject( KEY_USER_ORGUNIT_CHILDREN, KEY_USER_ORGUNIT_CHILDREN, KEY_USER_ORGUNIT_CHILDREN ) );
}
-
+
objects.add( new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT, ouList ) );
}
else if ( categoryDims.contains( dimension ) )
@@ -226,14 +360,14 @@
{
objects.add( new BaseDimensionalObject( dimension, DimensionType.DATAELEMENT_GROUPSET, deGroupMap.get( dimension ) ) );
}
-
+
ListMap<String, IdentifiableObject> ouGroupMap = new ListMap<String, IdentifiableObject>();
for ( OrganisationUnitGroup group : organisationUnitGroups )
{
ouGroupMap.putValue( group.getGroupSet().getUid(), group );
}
-
+
if ( ouGroupMap.containsKey( dimension ) )
{
objects.add( new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT_GROUPSET, ouGroupMap.get( dimension ) ) );
@@ -243,6 +377,18 @@
return objects;
}
+ private List<String> getCategoryDims()
+ {
+ List<String> categoryDims = new ArrayList<String>();
+
+ for ( DataElementCategoryDimension dim : categoryDimensions )
+ {
+ categoryDims.add( dim.getDimension().getDimension() );
+ }
+
+ return categoryDims;
+ }
+
public void mergeWith( BaseAnalyticalObject other )
{
super.mergeWith( other );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2013-05-12 18:22:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2013-05-19 18:49:47 +0000
@@ -441,15 +441,15 @@
@Override
public String toString()
{
- return "IdentifiableObject{" +
- "id=" + id +
- ", uid='" + uid + '\'' +
- ", code='" + code + '\'' +
- ", name='" + name + '\'' +
- ", created=" + created +
- ", lastUpdated=" + lastUpdated +
- ", class=" + getClass().getSimpleName() +
- '}';
+ return "[IdentifiableObject: " +
+ "id='" + id +
+ "', uid='" + uid +
+ "', code='" + code +
+ "', name='" + name +
+ "', created='" + created +
+ "', lastUpdated='" + lastUpdated +
+ "', class='" + getClass().getSimpleName() +
+ "']";
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java 2013-05-13 11:54:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java 2013-05-19 18:49:47 +0000
@@ -29,10 +29,9 @@
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
/**
- * Inherits getName() and getDisplayName().
- *
* @author Lars Helge Overland
*/
public interface DimensionalObject
@@ -48,6 +47,12 @@
final List<String> DATA_X_DIMS = Arrays.asList( INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, DATAELEMENT_OPERAND_ID );
+ final Map<String, String> PRETTY_NAMES = DimensionalObjectUtils.asMap(
+ DATA_X_DIM_ID, "Data",
+ CATEGORYOPTIONCOMBO_DIM_ID, "Data details",
+ PERIOD_DIM_ID, "Period",
+ ORGUNIT_DIM_ID, "Organisation unit" );
+
String getDimension();
DimensionType getType();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java 2013-05-13 11:54:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java 2013-05-19 18:49:47 +0000
@@ -30,6 +30,11 @@
import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIMS;
import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Lars Helge Overland
*/
@@ -49,5 +54,47 @@
}
return identifier;
+ }
+
+ /**
+ * Creates a two-dimensional array of dimension items based on the list of
+ * DimensionalObjects. I.e. the list of items of each DimensionalObject is
+ * converted to an array and inserted into the outer array in the same order.
+ *
+ * @param dimensions the list of DimensionalObjects.
+ * @return a two-dimensional array of NameableObjects.
+ */
+ public static NameableObject[][] getItemArray( List<DimensionalObject> dimensions )
+ {
+ List<NameableObject[]> arrays = new ArrayList<NameableObject[]>();
+
+ for ( DimensionalObject dimension : dimensions )
+ {
+ arrays.add( dimension.getItems().toArray( new NameableObject[0] ) );
+ }
+
+ return arrays.toArray( new NameableObject[0][] );
+ }
+
+ /**
+ * Creates a map based on the given array of elements, where each pair of
+ * elements are put on them map as a key-value pair.
+ *
+ * @param elements the elements to put on the map.
+ * @return a map.
+ */
+ public static <T> Map<T, T> asMap( T... elements )
+ {
+ Map<T, T> map = new HashMap<T, T>();
+
+ if ( elements != null && ( elements.length % 2 == 0 ) )
+ {
+ for ( int i = 0; i < elements.length; i += 2 )
+ {
+ map.put( elements[i], elements[i+1] );
+ }
+ }
+
+ return map;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2013-05-08 10:15:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2013-05-19 18:49:47 +0000
@@ -170,6 +170,27 @@
}
/**
+ * Removes duplicates from the given list while maintaining the order.
+ *
+ * @param list the list.
+ */
+ public static <T extends IdentifiableObject> List<T> removeDuplicates( List<T> list )
+ {
+ final List<T> temp = new ArrayList<T>( list );
+ list.clear();
+
+ for ( T object : temp )
+ {
+ if ( !list.contains( object ) )
+ {
+ list.add( object );
+ }
+ }
+
+ return list;
+ }
+
+ /**
* Generates a tag reflecting the date of when the most recently updated
* IdentifiableObject in the given collection was modified.
*
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2013-05-11 08:22:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2013-05-19 18:49:47 +0000
@@ -34,6 +34,7 @@
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.view.DetailedView;
@@ -57,7 +58,7 @@
*/
@JacksonXmlRootElement( localName = "dataElementOperand", namespace = DxfNamespaces.DXF_2_0)
public class DataElementOperand
- extends BaseIdentifiableObject
+ extends BaseNameableObject
{
public static final String SEPARATOR = ".";
public static final String NAME_TOTAL = "(Total)";
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/ConfigurablePeriod.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/ConfigurablePeriod.java 2013-05-11 17:38:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/ConfigurablePeriod.java 2013-05-19 18:49:47 +0000
@@ -33,18 +33,57 @@
public class ConfigurablePeriod
extends Period
{
- private String isoDate;
+ private String value;
- public ConfigurablePeriod( String isoDate )
+ public ConfigurablePeriod( String value )
{
- this.isoDate = isoDate;
- this.name = isoDate;
- this.code = isoDate;
+ this.value = value;
+ this.name = value;
+ this.code = value;
}
@Override
public String getIsoDate()
{
- return isoDate;
+ return value;
+ }
+
+ // -------------------------------------------------------------------------
+ // hashCode, equals and toString
+ // -------------------------------------------------------------------------
+
+ @Override
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null )
+ {
+ return false;
+ }
+
+ if ( !(o instanceof Period) )
+ {
+ return false;
+ }
+
+ final Period other = (Period) o;
+
+ return value.equals( other.getIsoDate() );
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + value + "]";
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2013-05-07 13:47:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2013-05-19 18:49:47 +0000
@@ -126,6 +126,18 @@
{
return getIsoDate();
}
+
+ @Override
+ public String getName()
+ {
+ return name != null ? name : getIsoDate();
+ }
+
+ @Override
+ public String getShortName()
+ {
+ return shortName != null ? shortName : getIsoDate();
+ }
/**
* Returns an ISO8601 formatted string version of the period
@@ -287,7 +299,7 @@
@Override
public String toString()
{
- return "[" + (periodType == null ? "" : periodType.getName() + ": ") + startDate + " - " + endDate + "]";
+ return "[" + (periodType == null ? "" : periodType.getName() + ": ") + startDate + " - " + endDate + "] " + name;
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2013-05-08 22:56:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2013-05-19 18:49:47 +0000
@@ -698,7 +698,9 @@
}
/**
- * Sets the name and short name of the given Period.
+ * Sets the name and short name of the given Period. The name will be
+ * formatted to the real period name if the given dynamicNames argument is
+ * true. The short name will be formatted in any case.
*
* @param period the period.
* @param periodName the period name.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java 2013-03-14 10:12:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java 2013-05-19 18:49:47 +0000
@@ -63,8 +63,6 @@
private ReportTable reportTable;
- private Boolean usingOrgUnitGroupSets;
-
private RelativePeriods relatives;
private ReportParams reportParams;
@@ -116,11 +114,6 @@
return reportTable != null;
}
- public boolean isUsingOrganisationUnitGroupSets()
- {
- return usingOrgUnitGroupSets != null && usingOrgUnitGroupSets;
- }
-
/**
* Indicates whether this report has relative periods.
*/
@@ -226,19 +219,6 @@
this.reportTable = reportTable;
}
- @JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Boolean getUsingOrgUnitGroupSets()
- {
- return usingOrgUnitGroupSets;
- }
-
- public void setUsingOrgUnitGroupSets( Boolean usingOrgUnitGroupSets )
- {
- this.usingOrgUnitGroupSets = usingOrgUnitGroupSets;
- }
-
@JsonProperty( value = "relativePeriods" )
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -276,7 +256,6 @@
designContent = report.getDesignContent() == null ? designContent : report.getDesignContent();
reportTable = report.getReportTable() == null ? reportTable : report.getReportTable();
- usingOrgUnitGroupSets = report.isUsingOrganisationUnitGroupSets();
}
}
}
=== 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 2013-05-15 15:00:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2013-05-19 18:49:47 +0000
@@ -33,8 +33,8 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -59,10 +59,9 @@
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.comparator.AscendingPeriodComparator;
+import org.hisp.dhis.user.User;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -196,6 +195,7 @@
private static final String EMPTY = "";
private static final NameableObject[] IRT = new NameableObject[0];
+ private static final NameableObject[][] IRT2D = new NameableObject[0][];
private static final String[] SRT = new String[0];
@@ -280,31 +280,6 @@
// -------------------------------------------------------------------------
/**
- * Periods relative to the reporting month.
- */
- private List<Period> relativePeriods = new ArrayList<Period>();
-
- /**
- * Static Periods and relative Periods.
- */
- private List<Period> allPeriods = new ArrayList<Period>();
-
- /**
- * OrganisationUnits relative to a parent unit or current unit.
- */
- private List<OrganisationUnit> relativeUnits = new ArrayList<OrganisationUnit>();
-
- /**
- * Static OrganisationUnits and relative OrganisationUnits.
- */
- private List<NameableObject> allUnits = new ArrayList<NameableObject>();
-
- /**
- * All Indicators, including DateElements, Indicators and DataSets.
- */
- private List<NameableObject> allIndicators = new ArrayList<NameableObject>();
-
- /**
* All crosstabulated columns.
*/
private List<List<NameableObject>> gridColumns = new ArrayList<List<NameableObject>>();
@@ -315,40 +290,6 @@
private List<List<NameableObject>> gridRows = new ArrayList<List<NameableObject>>();
/**
- * Names of the columns used to query the datavalue table and as index
- * columns in the report table.
- */
- private List<String> indexColumns = new ArrayList<String>();
-
- /**
- * Names of the columns holding entry uids used to query the datavalue
- * table.
- */
- private List<String> indexUidColumns = new ArrayList<String>();
-
- /**
- * Names of the columns holding entry names used to query the datavalue
- * table.
- */
- private List<String> indexNameColumns = new ArrayList<String>();
-
- /**
- * Names of the columns holding entry codes used to query the datavalue
- * table.
- */
- private List<String> indexCodeColumns = new ArrayList<String>();
-
- /**
- * Names of the columns holding entry descriptions.
- */
- private List<String> indexDescriptionColumns = new ArrayList<String>();
-
- /**
- * The I18nFormat used for internationalization of ie. periods.
- */
- private I18nFormat i18nFormat;
-
- /**
* The name of the reporting month based on the report param.
*/
private String reportingPeriodName;
@@ -398,23 +339,19 @@
* @param i18nFormat the i18n format. Not persisted.
*/
public ReportTable( String name, List<DataElement> dataElements, List<Indicator> indicators,
- List<DataSet> dataSets, List<Period> periods, List<Period> relativePeriods, List<OrganisationUnit> organisationUnits,
- List<OrganisationUnit> relativeUnits, List<OrganisationUnitGroup> organisationUnitGroups,
+ List<DataSet> dataSets, List<Period> periods,
+ List<OrganisationUnit> organisationUnits,
boolean doIndicators, boolean doPeriods, boolean doUnits, RelativePeriods relatives, ReportParams reportParams,
- I18nFormat i18nFormat, String reportingPeriodName )
+ String reportingPeriodName )
{
this.name = name;
this.dataElements = dataElements;
this.indicators = indicators;
this.dataSets = dataSets;
this.periods = periods;
- this.relativePeriods = relativePeriods;
this.organisationUnits = organisationUnits;
- this.relativeUnits = relativeUnits;
- this.organisationUnitGroups = organisationUnitGroups;
this.relatives = relatives;
this.reportParams = reportParams;
- this.i18nFormat = i18nFormat;
this.reportingPeriodName = reportingPeriodName;
if ( doIndicators )
@@ -449,83 +386,47 @@
// Init
// -------------------------------------------------------------------------
- public void init()
+ public void init( User user, Date date, List<OrganisationUnit> relativeOrganisationUnits, I18nFormat format )
{
- verify( nonEmptyLists( dataElements, indicators, dataSets ) > 0,
- "Must contain dataelements, indicators or datasets" );
- verify( nonEmptyLists( periods, relativePeriods ) > 0, "Must contain periods or relative periods" );
- verify( nonEmptyLists( organisationUnits, relativeUnits, organisationUnitGroups ) > 0,
- "Must contain organisation units, relative organisation units or organisation unit groups" );
- verify( !(doTotal() && regression), "Cannot have regression columns with total columns" );
- verify( i18nFormat != null, "I18n format must be set" );
-
- // ---------------------------------------------------------------------
- // Init dimensions
- // ---------------------------------------------------------------------
-
+ verify( ( periods != null && !periods.isEmpty() ) || hasRelativePeriods(), "Must contain periods or relative periods" );
+
+ addTransientOrganisationUnits( relativeOrganisationUnits );
+
+ this.populateGridColumnsAndRows( date, user, format );
+
if ( isDimensional() )
{
categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>( getCategoryCombo().getOptionCombos() );
verify( nonEmptyLists( categoryOptionCombos ) == 1, "Category option combos size must be larger than 0" );
}
- // ---------------------------------------------------------------------
- // Init allPeriods, allUnits, allIndicators
- // ---------------------------------------------------------------------
-
- allIndicators.addAll( dataElements );
- allIndicators.addAll( indicators );
- allIndicators.addAll( dataSets );
-
- allPeriods.addAll( periods );
- allPeriods.addAll( relativePeriods );
- allPeriods = removeDuplicates( allPeriods );
-
- Collections.sort( allPeriods, new AscendingPeriodComparator() );
- setNames( allPeriods ); // Set names on periods
-
- if ( isOrganisationUnitGroupBased() )
- {
- allUnits.addAll( organisationUnitGroups );
- }
- else
- {
- allUnits.addAll( organisationUnits );
- allUnits.addAll( relativeUnits );
- allUnits = removeDuplicates( allUnits );
- }
-
- gridColumns = new CombinationGenerator<NameableObject>( getArrays( true ) ).getCombinations();
- gridRows = new CombinationGenerator<NameableObject>( getArrays( false ) ).getCombinations();
-
addIfEmpty( gridColumns ); // Allow for all or none crosstab dimensions
addIfEmpty( gridRows );
-
- add( indexColumns, INDICATOR_ID, isDoIndicators() );
- add( indexColumns, PERIOD_ID, isDoPeriods() );
- add( indexColumns, ORGANISATIONUNIT_ID, isDoUnits() );
-
- add( indexUidColumns, INDICATOR_UID, isDoIndicators() );
- add( indexUidColumns, PERIOD_UID, isDoPeriods() );
- add( indexUidColumns, ORGANISATIONUNIT_UID, isDoUnits() );
-
- add( indexNameColumns, INDICATOR_NAME, isDoIndicators() );
- add( indexNameColumns, PERIOD_NAME, isDoPeriods() );
- add( indexNameColumns, ORGANISATIONUNIT_NAME, isDoUnits() );
-
- add( indexCodeColumns, INDICATOR_CODE, isDoIndicators() );
- add( indexCodeColumns, PERIOD_CODE, isDoPeriods() );
- add( indexCodeColumns, ORGANISATIONUNIT_CODE, isDoUnits() );
-
- add( indexDescriptionColumns, INDICATOR_DESCRIPTION, isDoIndicators() );
- add( indexDescriptionColumns, PERIOD_DESCRIPTION, isDoPeriods() );
- add( indexDescriptionColumns, ORGANISATIONUNIT_DESCRIPTION, isDoUnits() );
}
-
+
// -------------------------------------------------------------------------
// Public methods
// -------------------------------------------------------------------------
+ public void populateGridColumnsAndRows( Date date, User user, I18nFormat format )
+ {
+ List<NameableObject[]> tableColumns = new ArrayList<NameableObject[]>();
+ List<NameableObject[]> tableRows = new ArrayList<NameableObject[]>();
+
+ for ( String dimension : columnDimensions )
+ {
+ tableColumns.add( getDimensionalObject( dimension, date, user, false, format ).getItems().toArray( IRT ) );
+ }
+
+ for ( String dimension : rowDimensions )
+ {
+ tableRows.add( getDimensionalObject( dimension, date, user, true, format ).getItems().toArray( IRT ) );
+ }
+
+ gridColumns = new CombinationGenerator<NameableObject>( tableColumns.toArray( IRT2D ) ).getCombinations();
+ gridRows = new CombinationGenerator<NameableObject>( tableRows.toArray( IRT2D ) ).getCombinations();
+ }
+
@Override
public void populateAnalyticalProperties()
{
@@ -544,53 +445,8 @@
filters.addAll( getDimensionalObjectList( filter ) );
}
}
-
- /**
- * Indicates whether this report table can be rendered by the report table
- * service. Stopgap method until report table UI will be replaced by pivot
- * table UI. TODO temporary
- */
- public boolean isReportTable()
- {
- List<String> STANDARD_DIMS = Arrays.asList( DATA_X_DIM_ID, PERIOD_DIM_ID, ORGUNIT_DIM_ID );
-
- return dataElementGroups.isEmpty() && filterDimensions.isEmpty() &&
- STANDARD_DIMS.containsAll( columnDimensions ) && STANDARD_DIMS.containsAll( filterDimensions );
- }
-
- /**
- * Creates a map which contains mappings between the organisation unit
- * identifier and the name of the group this organisation unit is a member
- * of in all of the given group sets for all organisation units in this
- * report table.
- *
- * @param groupSets the collection of organisation unit group sets.
- * @return a map.
- */
- @Deprecated
- public Map<String, Object> getOrganisationUnitGroupMap( Collection<OrganisationUnitGroupSet> groupSets )
- {
- Map<String, Object> organisationUnitGroupMap = new HashMap<String, Object>();
-
- for ( OrganisationUnitGroupSet groupSet : groupSets )
- {
- Map<Integer, String> map = new HashMap<Integer, String>();
-
- for ( NameableObject unit : allUnits )
- {
- if ( unit instanceof OrganisationUnit )
- {
- map.put( unit.getId(), ((OrganisationUnit) unit).getGroupNameInGroupSet( groupSet ) );
- }
- }
-
- organisationUnitGroupMap.put( columnEncode( KEY_ORGUNIT_GROUPSET + groupSet.getName() ), map );
- }
-
- return organisationUnitGroupMap;
- }
-
- public DataElementCategoryCombo getCategoryCombo()
+
+ private DataElementCategoryCombo getCategoryCombo()
{
if ( dataElements != null && !dataElements.isEmpty() )
{
@@ -609,26 +465,6 @@
}
/**
- * Indicates whether a total column should be included.
- */
- public boolean doTotal()
- {
- return !isDoIndicators() && !isDoPeriods() && !isDoUnits() && isDimensional();
- }
-
- /**
- * Indicates whether subtotal columns should be included. The category combo
- * of the report table must have more than one category if subtotal columns
- * will contribute.
- */
- public boolean doSubTotals()
- {
- DataElementCategoryCombo categoryCombo = getCategoryCombo();
-
- return doTotal() && categoryCombo != null && categoryCombo.getCategories() != null && categoryCombo.getCategories().size() > 1;
- }
-
- /**
* Generates a pretty column name based on short-names of the argument
* objects. Null arguments are ignored in the name.
*/
@@ -638,7 +474,7 @@
for ( NameableObject object : objects )
{
- buffer.append( object != null ? (object.getShortName() + SPACE) : EMPTY );
+ buffer.append( object != null ? ( object.getShortName() + SPACE ) : EMPTY );
}
return buffer.length() > 0 ? buffer.substring( 0, buffer.lastIndexOf( SPACE ) ) : TOTAL_COLUMN_PRETTY_NAME;
@@ -647,6 +483,10 @@
/**
* Generates a column name based on short-names of the argument objects.
* Null arguments are ignored in the name.
+ *
+ * The period column name must be static when on columns so it can be
+ * re-used in reports, hence the name property is used which will be formatted
+ * only when the period dimension is on rows.
*/
public static String getColumnName( List<NameableObject> objects )
{
@@ -656,15 +496,11 @@
{
if ( object != null && object instanceof Period )
{
- // -------------------------------------------------------------
- // Periods need static names when crosstab - set on name prop
- // -------------------------------------------------------------
-
buffer.append( object.getName() + SEPARATOR );
}
else
{
- buffer.append( object != null ? (object.getShortName() + SEPARATOR) : EMPTY );
+ buffer.append( object != null ? ( object.getShortName() + SEPARATOR ) : EMPTY );
}
}
@@ -813,15 +649,6 @@
return parentOrganisationUnit != null ? parentOrganisationUnit.getName() : EMPTY;
}
- /**
- * Indicates whether this report table is based on organisation unit groups
- * or the organisation unit hierarchy.
- */
- public boolean isOrganisationUnitGroupBased()
- {
- return organisationUnitGroups != null && organisationUnitGroups.size() > 0;
- }
-
public boolean isDoIndicators()
{
return columnDimensions.contains( DATA_X_DIM_ID );
@@ -871,33 +698,6 @@
// Supportive methods
// -------------------------------------------------------------------------
- private NameableObject[][] getArrays( boolean crosstab )
- {
- List<NameableObject[]> arrays = new ArrayList<NameableObject[]>();
-
- if ( (isDoIndicators() && crosstab) || (!isDoIndicators() && !crosstab) )
- {
- arrays.add( allIndicators.toArray( IRT ) );
- }
-
- if ( (isDoPeriods() && crosstab) || (!isDoPeriods() && !crosstab) )
- {
- arrays.add( allPeriods.toArray( IRT ) );
- }
-
- if ( (isDoUnits() && crosstab) || (!isDoUnits() && !crosstab) )
- {
- arrays.add( allUnits.toArray( IRT ) );
- }
-
- if ( isDimensional() && crosstab ) // Must be crosstab if exists
- {
- arrays.add( categoryOptionCombos.toArray( IRT ) );
- }
-
- return arrays.toArray( new NameableObject[0][] );
- }
-
/**
* Adds an empty list of NameableObjects to the given list if empty.
*/
@@ -928,56 +728,6 @@
}
/**
- * Sets the name and short name properties on the given Periods which don't
- * have the name property already set.
- */
- private void setNames( List<Period> periods )
- {
- for ( Period period : periods )
- {
- if ( period.getName() == null ) // Crosstabulated relative periods
- {
- // -------------------------------------------------------------
- // Static periods + index relative periods
- // -------------------------------------------------------------
-
- period.setName( i18nFormat.formatPeriod( period ) );
- period.setShortName( i18nFormat.formatPeriod( period ) );
- }
- }
- }
-
- /**
- * Adds the given object to the given list if not skip argument is true.
- */
- private static <T> void add( List<T> list, T object, boolean skip )
- {
- if ( !skip )
- {
- list.add( object );
- }
- }
-
- /**
- * Removes duplicates from the given list while maintaining the order.
- */
- private static <T> List<T> removeDuplicates( List<T> list )
- {
- final List<T> temp = new ArrayList<T>( list );
- list.clear();
-
- for ( T object : temp )
- {
- if ( !list.contains( object ) )
- {
- list.add( object );
- }
- }
-
- return list;
- }
-
- /**
* Supportive method.
*/
private static void verify( boolean expression, String falseMessage )
@@ -1207,53 +957,6 @@
// -------------------------------------------------------------------------
@JsonIgnore
- public List<Period> getRelativePeriods()
- {
- return relativePeriods;
- }
-
- @JsonIgnore
- public void setRelativePeriods( List<Period> relativePeriods )
- {
- this.relativePeriods = relativePeriods;
- }
-
- @JsonIgnore
- public List<Period> getAllPeriods()
- {
- return allPeriods;
- }
-
- @JsonIgnore
- public List<OrganisationUnit> getRelativeUnits()
- {
- return relativeUnits;
- }
-
- @JsonIgnore
- public void setRelativeUnits( List<OrganisationUnit> relativeUnits )
- {
- this.relativeUnits = relativeUnits;
- }
-
- @JsonIgnore
- public List<NameableObject> getAllUnits()
- {
- return allUnits;
- }
-
- @JsonIgnore
- public I18nFormat getI18nFormat()
- {
- return i18nFormat;
- }
-
- public void setI18nFormat( I18nFormat format )
- {
- i18nFormat = format;
- }
-
- @JsonIgnore
public String getReportingPeriodName()
{
return reportingPeriodName;
@@ -1278,36 +981,6 @@
}
@JsonIgnore
- public List<String> getIndexColumns()
- {
- return indexColumns;
- }
-
- @JsonIgnore
- public List<String> getIndexUidColumns()
- {
- return indexUidColumns;
- }
-
- @JsonIgnore
- public List<String> getIndexNameColumns()
- {
- return indexNameColumns;
- }
-
- @JsonIgnore
- public List<String> getIndexCodeColumns()
- {
- return indexCodeColumns;
- }
-
- @JsonIgnore
- public List<String> getIndexDescriptionColumns()
- {
- return indexDescriptionColumns;
- }
-
- @JsonIgnore
public OrganisationUnit getParentOrganisationUnit()
{
return parentOrganisationUnit;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2013-05-13 14:21:55 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2013-05-19 18:49:47 +0000
@@ -48,10 +48,29 @@
* @return aggregated data as a Grid object.
*/
Grid getAggregatedDataValues( DataQueryParams params );
-
+
+ /**
+ * Generates a mapping where the key represents the dimensional item identifiers
+ * concatenated by "-" and the value is the corresponding aggregated data value
+ * based on the given DataQueryParams.
+ *
+ * @param params the DataQueryParams.
+ * @return a mapping of dimensional items and aggregated data values.
+ */
Map<String, Double> getAggregatedDataValueMapping( DataQueryParams params );
/**
+ * Generates a mapping where the key represents the dimensional item identifiers
+ * concatenated by "-" and the value is the corresponding aggregated data value
+ * based on the given BaseAnalyticalObject.
+ *
+ * @param object the BaseAnalyticalObject.
+ * @param format the I18nFormat, can be null.
+ * @return a mapping of dimensional items and aggregated data values.
+ */
+ Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format );
+
+ /**
* Creates a data query parameter object from the given URL.
*
* @param dimensionParams the dimension URL parameters.
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-05-13 14:21:55 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-05-19 18:49:47 +0000
@@ -167,6 +167,7 @@
// Implementation
// -------------------------------------------------------------------------
+ @Override
public Grid getAggregatedDataValues( DataQueryParams params )
{
queryPlanner.validate( params );
@@ -353,7 +354,8 @@
return grid;
}
-
+
+ @Override
public Map<String, Double> getAggregatedDataValueMapping( DataQueryParams params )
{
Grid grid = getAggregatedDataValues( params );
@@ -381,6 +383,14 @@
return map;
}
+
+ @Override
+ public Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format )
+ {
+ DataQueryParams params = getFromAnalyticalObject( object, format );
+
+ return getAggregatedDataValueMapping( params );
+ }
/**
* Generates aggregated values for the given query. Creates a mapping between
@@ -467,6 +477,7 @@
return map;
}
+ @Override
public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
AggregationType aggregationType, String measureCriteria, I18nFormat format )
{
@@ -510,6 +521,7 @@
return params;
}
+ @Override
public DataQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format )
{
DataQueryParams params = new DataQueryParams();
@@ -542,8 +554,16 @@
// -------------------------------------------------------------------------
/**
- * Returns a list of dimensions generated from the given dimension identifier
- * and list of dimension options.
+ * Returns a list of persisted DimensionalObjects generated from the given
+ * dimension identifier and list of dimension options. The dx dimension
+ * will be exploded into concrete in|de|ds object identifiers and returned
+ * as separate DimensionalObjects.
+ *
+ * For the pe dimension items, relative periods represented by enums will be
+ * replaced by real ISO periods relative to the current date. For the ou
+ * dimension items, the user organisation unit enums
+ * USER_ORG_UNIT|USER_ORG_UNIT_CHILDREN will be replaced by the persisted
+ * organisation units for the current user.
*/
private List<DimensionalObject> getDimension( String dimension, List<String> items, I18nFormat format )
{
@@ -613,44 +633,7 @@
return Arrays.asList( object );
}
-
- if ( ORGUNIT_DIM_ID.equals( dimension ) )
- {
- User user = currentUserService.getCurrentUser();
-
- List<IdentifiableObject> ous = new ArrayList<IdentifiableObject>();
-
- for ( String ou : items )
- {
- if ( KEY_USER_ORGUNIT.equals( ou ) && user != null && user.getOrganisationUnit() != null )
- {
- ous.add( user.getOrganisationUnit() );
- }
- else if ( KEY_USER_ORGUNIT_CHILDREN.equals( ou ) && user != null && user.getOrganisationUnit() != null )
- {
- ous.addAll( user.getOrganisationUnit().getSortedChildren() );
- }
- else
- {
- OrganisationUnit unit = organisationUnitService.getOrganisationUnit( ou );
-
- if ( unit != null )
- {
- ous.add( unit );
- }
- }
- }
-
- if ( ous.isEmpty() )
- {
- throw new IllegalQueryException( "Dimension ou is present in query without any valid dimension options" );
- }
-
- DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT, null, DISPLAY_NAME_ORGUNIT, ous );
-
- return Arrays.asList( object );
- }
-
+
if ( PERIOD_DIM_ID.equals( dimension ) )
{
Set<Period> periods = new HashSet<Period>();
@@ -691,6 +674,43 @@
return Arrays.asList( object );
}
+ if ( ORGUNIT_DIM_ID.equals( dimension ) )
+ {
+ User user = currentUserService.getCurrentUser();
+
+ List<IdentifiableObject> ous = new ArrayList<IdentifiableObject>();
+
+ for ( String ou : items )
+ {
+ if ( KEY_USER_ORGUNIT.equals( ou ) && user != null && user.getOrganisationUnit() != null )
+ {
+ ous.add( user.getOrganisationUnit() );
+ }
+ else if ( KEY_USER_ORGUNIT_CHILDREN.equals( ou ) && user != null && user.getOrganisationUnit() != null )
+ {
+ ous.addAll( user.getOrganisationUnit().getSortedChildren() );
+ }
+ else
+ {
+ OrganisationUnit unit = organisationUnitService.getOrganisationUnit( ou );
+
+ if ( unit != null )
+ {
+ ous.add( unit );
+ }
+ }
+ }
+
+ if ( ous.isEmpty() )
+ {
+ throw new IllegalQueryException( "Dimension ou is present in query without any valid dimension options" );
+ }
+
+ DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT, null, DISPLAY_NAME_ORGUNIT, ous );
+
+ return Arrays.asList( object );
+ }
+
OrganisationUnitGroupSet ougs = organisationUnitGroupService.getOrganisationUnitGroupSet( dimension );
if ( ougs != null )
=== added file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 2013-05-19 18:49:47 +0000
@@ -0,0 +1,84 @@
+package org.hisp.dhis.analytics.data;
+
+/*
+ * Copyright (c) 2004-2012, 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.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.hisp.dhis.analytics.AggregationType;
+import org.hisp.dhis.analytics.AnalyticsService;
+import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nFormat;
+
+/**
+ * Configurable mock implementation of AnalyticsService for testing purposes.
+ */
+public class MockAnalyticsService
+ implements AnalyticsService
+{
+ private Map<String, Double> valueMap;
+
+ public MockAnalyticsService( Map<String, Double> valueMap )
+ {
+ this.valueMap = valueMap;
+ }
+
+ @Override
+ public Grid getAggregatedDataValues( DataQueryParams params )
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public Map<String, Double> getAggregatedDataValueMapping( DataQueryParams params )
+ {
+ return valueMap;
+ }
+
+ @Override
+ public Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format )
+ {
+ return valueMap;
+ }
+
+ @Override
+ public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
+ AggregationType aggregationType, String measureCriteria, I18nFormat format )
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public DataQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format )
+ {
+ throw new NotImplementedException();
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java 2013-05-13 11:54:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java 2013-05-19 18:49:47 +0000
@@ -137,12 +137,12 @@
public void testGetFromUrlA()
{
Set<String> dimensionParams = new HashSet<String>();
- dimensionParams.add( "dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D" );
+ dimensionParams.add( "dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid() );
dimensionParams.add( "pe:2012;2012S1;2012S2" );
dimensionParams.add( ouGroupSetA.getUid() + ":" + ouGroupA.getUid() + ";" + ouGroupB.getUid() + ";" + ouGroupC.getUid() );
Set<String> filterParams = new HashSet<String>();
- filterParams.add( "ou:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D;" + BASE_UID + "E" );
+ filterParams.add( "ou:" + ouA.getUid() + ";" + ouB.getUid() + ";" + ouC.getUid() + ";" + ouD.getUid() + ";" + ouE.getUid() );
DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, null );
@@ -156,10 +156,10 @@
public void testGetFromUrlB()
{
Set<String> dimensionParams = new HashSet<String>();
- dimensionParams.add( "dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D" );
+ dimensionParams.add( "dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid() );
Set<String> filterParams = new HashSet<String>();
- filterParams.add( "ou:" + BASE_UID + "A" );
+ filterParams.add( "ou:" + ouA.getUid() );
DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, null );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2013-05-13 15:26:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2013-05-19 18:49:47 +0000
@@ -200,7 +200,19 @@
// Supportive methods
//--------------------------------------------------------------------------
- private void mergeDimensionalObjects( BaseAnalyticalObject object, List<DimensionalObject> dimensions ) // TODO Add mergeAnalyticalObject to AnalyticsService
+ /**
+ * Sets persistent objects for dimensional associations on the given
+ * BaseAnalyticalObject based on the given list of transient DimensionalObjects.
+ *
+ * Relative periods represented by enums are converted into a RelativePeriods
+ * object. User organisation units represented by enums are converted and
+ * represented by the user organisation unit persisted properties on the
+ * BaseAnalyticalObject.
+ *
+ * @param object the BaseAnalyticalObject to merge.
+ * @param dimensions the
+ */
+ private void mergeDimensionalObjects( BaseAnalyticalObject object, List<DimensionalObject> dimensions )
{
for ( DimensionalObject dimension : dimensions )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-05-19 18:49:47 +0000
@@ -137,6 +137,7 @@
executeSql( "ALTER TABLE dataelement DROP COLUMN alternativename" );
executeSql( "ALTER TABLE indicator DROP COLUMN alternativename" );
executeSql( "ALTER TABLE orgunitgroup DROP COLUMN image" );
+ executeSql( "ALTER TABLE report DROP COLUMN usingorgunitgroupsets" );
executeSql( "DROP INDEX datamart_crosstab" );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-05-13 14:21:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-05-19 18:49:47 +0000
@@ -720,9 +720,7 @@
private CategoryDataset[] getCategoryDataSet( Chart chart, I18nFormat format )
{
- DataQueryParams params = analyticsService.getFromAnalyticalObject( chart, null );
-
- Map<String, Double> valueMap = analyticsService.getAggregatedDataValueMapping( params );
+ Map<String, Double> valueMap = analyticsService.getAggregatedDataValueMapping( chart, format );
DefaultCategoryDataset regularDataSet = new DefaultCategoryDataset();
DefaultCategoryDataset regressionDataSet = new DefaultCategoryDataset();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-05-02 18:35:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-05-19 18:49:47 +0000
@@ -44,15 +44,13 @@
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
-
import net.sf.jasperreports.engine.util.JRProperties;
-import org.amplecode.quick.StatementManager;
+
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -108,13 +106,6 @@
{
this.organisationUnitService = organisationUnitService;
}
-
- private OrganisationUnitGroupService organisationUnitGroupService;
-
- public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
- {
- this.organisationUnitGroupService = organisationUnitGroupService;
- }
private PeriodService periodService;
@@ -178,11 +169,6 @@
Grid grid = reportTableService.getReportTableGrid( reportTable.getUid(), format, reportDate, organisationUnitUid );
- if ( report.isUsingOrganisationUnitGroupSets() )
- {
- params.putAll( reportTable.getOrganisationUnitGroupMap( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ) );
- }
-
print = JasperFillManager.fillReport( jasperReport, params, grid );
}
else // Use JDBC data source
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2013-02-26 17:45:20 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2013-05-19 18:49:47 +0000
@@ -28,7 +28,6 @@
*/
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -143,20 +142,4 @@
}
}
}
-
- @Override
- public String allowDeleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
- {
- for ( ReportTable reportTable : reportTableService.getAllReportTables() )
- {
- DataElementCategoryCombo eachCatCombo = reportTable.getCategoryCombo();
-
- if ( eachCatCombo != null && eachCatCombo.equals( categoryCombo ) )
- {
- return reportTable.getName();
- }
- }
-
- return null;
- }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2013-05-14 21:14:22 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2013-05-19 18:49:47 +0000
@@ -27,36 +27,42 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.reporttable.ReportTable.ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.PARAM_ORGANISATIONUNIT_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.PRETTY_COLUMNS;
+import static org.hisp.dhis.reporttable.ReportTable.REPORTING_MONTH_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.SPACE;
+import static org.hisp.dhis.reporttable.ReportTable.getColumnName;
+import static org.hisp.dhis.reporttable.ReportTable.getPrettyColumnName;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.analytics.AnalyticsService;
+import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.NameableObject;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.report.ReportService;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
-import org.hisp.dhis.reporttable.jdbc.ReportTableManager;
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
+import org.hisp.dhis.user.CurrentUserService;
import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import static org.hisp.dhis.reporttable.ReportTable.*;
-
/**
* @author Lars Helge Overland
* @version $Id$
@@ -75,11 +81,11 @@
// Dependencies
// ---------------------------------------------------------------------
- private ReportTableManager reportTableManager;
+ private AnalyticsService analyticsService;
- public void setReportTableManager( ReportTableManager reportTableManager )
+ public void setAnalyticsService( AnalyticsService analyticsService )
{
- this.reportTableManager = reportTableManager;
+ this.analyticsService = analyticsService;
}
private GenericIdentifiableObjectStore<ReportTable> reportTableStore;
@@ -89,26 +95,26 @@
this.reportTableStore = reportTableStore;
}
- protected ReportService reportService;
+ private ReportService reportService;
public void setReportService( ReportService reportService )
{
this.reportService = reportService;
}
- private PeriodService periodService;
-
- public void setPeriodService( PeriodService periodService )
- {
- this.periodService = periodService;
- }
-
- protected OrganisationUnitService organisationUnitService;
+ private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
}
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
// -------------------------------------------------------------------------
// ReportTableService implementation
@@ -135,7 +141,7 @@
{
reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitUid, format );
- return getGrid( reportTable, minimal );
+ return getGrid( reportTable, format );
}
@Override
@@ -253,10 +259,12 @@
log.info( "Running report table: " + reportTable.getName() );
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
+
+ List<OrganisationUnit> relativeOrganisationUnits = new ArrayList<OrganisationUnit>();
+
if ( reportTable.hasRelativePeriods() && reportTable.getReportParams() != null && reportTable.getReportParams().isParamReportingMonth() )
{
- reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods(
- reportingPeriod, format, !reportTable.isDoPeriods() ) ) );
reportTable.setReportingPeriodName( reportTable.getRelatives().getReportingPeriodName( reportingPeriod,
format ) );
@@ -264,42 +272,22 @@
}
else if ( reportTable.hasRelativePeriods() )
{
- reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods(
- format, !reportTable.isDoPeriods() ) ) );
reportTable.setReportingPeriodName( reportTable.getRelatives().getReportingPeriodName( format ) );
log.info( "Reporting period date default: " + reportTable.getReportingPeriodName() );
}
// ---------------------------------------------------------------------
- // Grand parent organisation unit report parameter
- // ---------------------------------------------------------------------
-
- if ( reportTable.getReportParams() != null &&
- reportTable.getReportParams().isParamGrandParentOrganisationUnit() )
- {
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
- organisationUnit.setCurrentParent( true );
- reportTable.getRelativeUnits().addAll(
- new ArrayList<OrganisationUnit>( organisationUnit.getGrandChildren() ) );
- reportTable.getRelativeUnits().add( organisationUnit );
- reportTable.setParentOrganisationUnit( organisationUnit );
-
- log.info( "Grand parent organisation unit: " + organisationUnit.getName() );
- }
-
- // ---------------------------------------------------------------------
// Parent organisation unit report parameter
// ---------------------------------------------------------------------
if ( reportTable.getReportParams() != null &&
reportTable.getReportParams().isParamParentOrganisationUnit() )
{
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
organisationUnit.setCurrentParent( true );
- reportTable.getRelativeUnits().addAll( new ArrayList<OrganisationUnit>( organisationUnit.getChildren() ) );
- reportTable.getRelativeUnits().add( organisationUnit );
reportTable.setParentOrganisationUnit( organisationUnit );
+ relativeOrganisationUnits.addAll( organisationUnit.getChildren() );
+ relativeOrganisationUnits.add( organisationUnit );
log.info( "Parent organisation unit: " + organisationUnit.getName() );
}
@@ -311,9 +299,8 @@
if ( reportTable.getReportParams() != null &&
reportTable.getReportParams().isParamOrganisationUnit() )
{
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
- reportTable.getRelativeUnits().add( organisationUnit );
reportTable.setParentOrganisationUnit( organisationUnit );
+ relativeOrganisationUnits.add( organisationUnit );
log.info( "Organisation unit: " + organisationUnit.getName() );
}
@@ -322,8 +309,7 @@
// Set properties and initalize
// ---------------------------------------------------------------------
- reportTable.setI18nFormat( format );
- reportTable.init();
+ reportTable.init( currentUserService.getCurrentUser(), reportingPeriod, relativeOrganisationUnits, format );
return reportTable;
}
@@ -334,56 +320,35 @@
* @param reportTable the report table.
* @return a grid.
*/
- private Grid getGrid( ReportTable reportTable, boolean minimal )
+ private Grid getGrid( ReportTable reportTable, I18nFormat format )
{
final String subtitle = StringUtils.trimToEmpty( reportTable.getParentOrganisationUnitName() ) + SPACE
+ StringUtils.trimToEmpty( reportTable.getReportingPeriodName() );
final Grid grid = new ListGrid().setTitle( reportTable.getName() + " - " + subtitle );
- final Map<String, Double> map = reportTableManager.getAggregatedValueMap( reportTable );
+ Map<String, Double> map = analyticsService.getAggregatedDataValueMapping( reportTable, format );
// ---------------------------------------------------------------------
// Headers
// ---------------------------------------------------------------------
- if ( !minimal )
- {
- for ( String column : reportTable.getIndexColumns() ) // Index columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, Integer.class.getName(), true, true ) );
- }
-
- for ( String column : reportTable.getIndexUidColumns() ) // Index uid columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
- }
- }
-
- for ( String column : reportTable.getIndexNameColumns() ) // Index name columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), false, true ) );
- }
-
- if ( !minimal )
- {
- for ( String column : reportTable.getIndexCodeColumns() ) // Index code columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
- }
-
- for ( String column : reportTable.getIndexDescriptionColumns() ) // Index description columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
- }
-
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( REPORTING_MONTH_COLUMN_NAME ), REPORTING_MONTH_COLUMN_NAME,
- String.class.getName(), true, true ) );
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( PARAM_ORGANISATIONUNIT_COLUMN_NAME ),
- PARAM_ORGANISATIONUNIT_COLUMN_NAME, String.class.getName(), true, true ) );
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME ),
- ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, String.class.getName(), true, true ) );
- }
+ for ( String row : reportTable.getRowDimensions() )
+ {
+ String name = StringUtils.defaultIfEmpty( DimensionalObject.PRETTY_NAMES.get( row ), row );
+
+ grid.addHeader( new GridHeader( name + " ID", row + "_id", String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( name, row + "_name", String.class.getName(), false, true ) );
+ grid.addHeader( new GridHeader( name + " code", row + "_code", String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( name + " description", row + "_description", String.class.getName(), true, true ) );
+ }
+
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( REPORTING_MONTH_COLUMN_NAME ), REPORTING_MONTH_COLUMN_NAME,
+ String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( PARAM_ORGANISATIONUNIT_COLUMN_NAME ),
+ PARAM_ORGANISATIONUNIT_COLUMN_NAME, String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME ),
+ ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, String.class.getName(), true, true ) );
final int startColumnIndex = grid.getHeaders().size();
final int numberOfColumns = reportTable.getGridColumns().size();
@@ -394,21 +359,6 @@
.getName(), false, false ) );
}
- if ( reportTable.doSubTotals() )
- {
- for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() )
- {
- grid.addHeader( new GridHeader( categoryOption.getShortName(), columnEncode( categoryOption
- .getShortName() ), Double.class.getName(), false, false ) );
- }
- }
-
- if ( reportTable.doTotal() )
- {
- grid.addHeader( new GridHeader( TOTAL_COLUMN_PRETTY_NAME, TOTAL_COLUMN_NAME, Double.class.getName(), false,
- false ) );
- }
-
// ---------------------------------------------------------------------
// Values
// ---------------------------------------------------------------------
@@ -417,63 +367,35 @@
{
grid.addRow();
- if ( !minimal )
- {
- for ( NameableObject object : row ) // Index columns
- {
- grid.addValue( object.getId() );
- }
-
- for ( NameableObject object : row ) // Index uid columns
- {
- grid.addValue( object.getUid() );
- }
- }
-
- for ( NameableObject object : row ) // Index name columns
- {
+ // -----------------------------------------------------------------
+ // Row meta data
+ // -----------------------------------------------------------------
+
+ for ( NameableObject object : row )
+ {
+ grid.addValue( object.getUid() );
grid.addValue( object.getName() );
- }
-
- if ( !minimal )
- {
- for ( NameableObject object : row ) // Index code columns
- {
- grid.addValue( object.getCode() );
- }
-
- for ( NameableObject object : row ) // Index description columns
- {
- grid.addValue( object.getDescription() );
- }
-
- grid.addValue( reportTable.getReportingPeriodName() );
- grid.addValue( reportTable.getParentOrganisationUnitName() );
- grid.addValue( isCurrentParent( row ) ? YES : NO );
- }
-
- for ( List<NameableObject> column : reportTable.getGridColumns() ) // Values
- {
- grid.addValue( map.get( getIdentifier( row, column ) ) );
- }
-
- if ( reportTable.doSubTotals() )
- {
- for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() )
- {
- grid.addValue( map.get( getIdentifier( row, DataElementCategoryOption.class, categoryOption.getId() ) ) );
- }
- }
-
- if ( reportTable.doTotal() )
- {
- // -------------------------------------------------------------
- // Only category option combo is crosstab when total, row
- // identifier will return total
- // -------------------------------------------------------------
-
- grid.addValue( map.get( getIdentifier( row ) ) );
- }
+ grid.addValue( object.getCode() );
+ grid.addValue( object.getDescription() );
+ }
+
+ grid.addValue( reportTable.getReportingPeriodName() );
+ grid.addValue( reportTable.getParentOrganisationUnitName() );
+ grid.addValue( isCurrentParent( row ) ? YES : NO );
+
+ // -----------------------------------------------------------------
+ // Row data values
+ // -----------------------------------------------------------------
+
+ for ( List<NameableObject> column : reportTable.getGridColumns() )
+ {
+ String key = getId( column, row );
+ Double value = map.get( key );
+
+ grid.addValue( value );
+ }
+
+ //TODO totals and sub totals
}
if ( reportTable.isRegression() )
@@ -502,6 +424,23 @@
return grid;
}
+
+ private String getId( List<NameableObject> column, List<NameableObject> row )
+ {
+ StringBuilder id = new StringBuilder();
+
+ for ( NameableObject item : column )
+ {
+ id.append( item.getUid() ).append( "-" );
+ }
+
+ for ( NameableObject item : row )
+ {
+ id.append( item.getUid() ).append( "-" );
+ }
+
+ return id.substring( 0, id.length() - 1 );
+ }
/**
* Adds columns with regression values to the given grid.
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java 2013-05-08 10:15:29 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java 2013-05-19 18:49:47 +0000
@@ -43,14 +43,12 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.TextUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
-import org.springframework.util.Assert;
/**
* @author Lars Helge Overland
@@ -76,16 +74,8 @@
public Map<String, Double> getAggregatedValueMap( ReportTable reportTable )
{
- if ( reportTable.isOrganisationUnitGroupBased() )
- {
- return getAggregatedValueMapOrgUnitGroups( reportTable.getDataElements(), reportTable.getIndicators(), reportTable.getAllPeriods(),
- reportTable.getAllUnits(), reportTable.getParentOrganisationUnit(), reportTable.getCategoryCombo(), reportTable.isDimensional(), reportTable.doTotal() );
- }
- else
- {
- return getAggregatedValueMapOrgUnitHierarchy( reportTable.getDataElements(), reportTable.getIndicators(), reportTable.getDataSets(),
- reportTable.getAllPeriods(), reportTable.getAllUnits(), reportTable.getCategoryCombo(), reportTable.isDimensional(), reportTable.doTotal() );
- }
+ return getAggregatedValueMapOrgUnitHierarchy( reportTable.getDataElements(), reportTable.getIndicators(), reportTable.getDataSets(),
+ reportTable.getPeriods(), reportTable.getOrganisationUnits(), null, reportTable.isDimensional(), false );
}
public Map<String, Double> getAggregatedValueMap( Chart chart )
@@ -94,117 +84,6 @@
chart.getAllPeriods(), chart.getAllOrganisationUnits(), null, false, false );
}
- // -------------------------------------------------------------------------
- // Org unit groups
- // -------------------------------------------------------------------------
-
- private Map<String, Double> getAggregatedValueMapOrgUnitGroups( List<DataElement> dataElements, List<Indicator> indicators,
- List<Period> periods, Collection<? extends NameableObject> groups, OrganisationUnit organisationUnit, DataElementCategoryCombo categoryCombo,
- boolean isDimensional, boolean doTotal )
- {
- Assert.notNull( organisationUnit );
-
- Map<String, Double> map = new HashMap<String, Double>();
-
- String dataElementIds = TextUtils.getCommaDelimitedString(
- ConversionUtils.getIdentifiers( DataElement.class, dataElements ) );
- String indicatorIds = TextUtils.getCommaDelimitedString(
- ConversionUtils.getIdentifiers( Indicator.class, indicators ) );
- String periodIds = TextUtils.getCommaDelimitedString(
- ConversionUtils.getIdentifiers( Period.class, periods ) );
- String groupIds = TextUtils.getCommaDelimitedString(
- ConversionUtils.getIdentifiers( NameableObject.class, groups ) );
-
- if ( dataElementIds != null && !dataElementIds.isEmpty() )
- {
- final String sql = "SELECT dataelementid, periodid, organisationunitgroupid, SUM(value) FROM aggregatedorgunitdatavalue " +
- "WHERE dataelementid IN (" + dataElementIds + ") AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + groupIds + ") " +
- "AND organisationunitid = " + organisationUnit.getId() + " " +
- "GROUP BY dataelementid, periodid, organisationunitgroupid"; // Sum of category option combo
-
- SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
- while ( rowSet.next() )
- {
- String id = getIdentifier( getIdentifier( DataElement.class, rowSet.getInt( 1 ) ),
- getIdentifier( Period.class, rowSet.getInt( 2 ) ),
- getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 3 ) ) );
-
- map.put( id, rowSet.getDouble( 4 ) );
- }
- }
-
- if ( indicatorIds != null && !indicatorIds.isEmpty() )
- {
- final String sql = "SELECT indicatorid, periodid, organisationunitgroupid, value FROM aggregatedorgunitindicatorvalue " +
- "WHERE indicatorid IN (" + indicatorIds + ") AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + groupIds + ") " +
- "AND organisationunitid = " + organisationUnit.getId();
-
- SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
- while ( rowSet.next() )
- {
- String id = getIdentifier( getIdentifier( Indicator.class, rowSet.getInt( 1 ) ),
- getIdentifier( Period.class, rowSet.getInt( 2 ) ),
- getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 3 ) ) );
-
- map.put( id, rowSet.getDouble( 4 ) );
- }
- }
-
- if ( isDimensional ) // Category option combo values
- {
- final String sql = "SELECT dataelementid, categoryoptioncomboid, periodid, organisationunitgroupid, value FROM aggregatedorgunitdatavalue " +
- "WHERE dataelementid IN (" + dataElementIds + ") AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + groupIds + ")" +
- "AND organisationunitid = " + organisationUnit.getId();
-
- SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
- while ( rowSet.next() )
- {
- String id = getIdentifier( getIdentifier( DataElement.class, rowSet.getInt( 1 ) ),
- getIdentifier( DataElementCategoryOptionCombo.class, rowSet.getInt( 2 ) ),
- getIdentifier( Period.class, rowSet.getInt( 3 ) ),
- getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 4 ) ) );
-
- map.put( id, rowSet.getDouble( 5 ) );
- }
- }
-
- if ( doTotal ) // Category option sub totals
- {
- for ( DataElementCategoryOption categoryOption : categoryCombo.getCategoryOptions() )
- {
- String cocIds = TextUtils.getCommaDelimitedString(
- ConversionUtils.getIdentifiers( DataElementCategoryOptionCombo.class, categoryOption.getCategoryOptionCombos() ) );
-
- final String sql = "SELECT dataelementid, periodid, organisationunitgroupid, SUM(value) FROM aggregatedorgunitdatavalue " +
- "WHERE dataelementid IN (" + dataElementIds + ") AND categoryoptioncomboid IN (" + cocIds + ") " +
- "AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + groupIds + ") " +
- "AND organisationunitid = " + organisationUnit.getId() + " " +
- "GROUP BY dataelementid, periodid, organisationunitgroupid";
-
- SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
- while ( rowSet.next() )
- {
- String id = getIdentifier( getIdentifier( DataElement.class, rowSet.getInt( 1 ) ),
- getIdentifier( Period.class, rowSet.getInt( 2 ) ),
- getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 3 ) ),
- getIdentifier( DataElementCategoryOption.class, categoryOption.getId() ) );
-
- map.put( id, rowSet.getDouble( 4 ) );
- }
- }
- }
-
- return map;
- }
-
- // -------------------------------------------------------------------------
- // Org unit hierarchy
- // -------------------------------------------------------------------------
-
private Map<String, Double> getAggregatedValueMapOrgUnitHierarchy( List<DataElement> dataElements, List<Indicator> indicators,
List<DataSet> dataSets, List<Period> periods, Collection<? extends NameableObject> organisationUnits, DataElementCategoryCombo categoryCombo,
boolean isDimensional, boolean doTotal )
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-13 14:21:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-19 18:49:47 +0000
@@ -17,11 +17,11 @@
</bean>
<bean id="org.hisp.dhis.reporttable.ReportTableService" class="org.hisp.dhis.reporttable.impl.DefaultReportTableService">
- <property name="reportTableManager" ref="org.hisp.dhis.reporttable.jdbc.ReportTableManager" />
+ <property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
<property name="reportTableStore" ref="org.hisp.dhis.reporttable.ReportTableStore" />
<property name="reportService" ref="org.hisp.dhis.report.ReportService" />
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<!-- Report -->
@@ -37,7 +37,6 @@
<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="dataSource" ref="dataSource" />
</bean>
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml 2013-02-12 06:55:14 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml 2013-05-19 18:49:47 +0000
@@ -24,8 +24,6 @@
<many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
foreign-key="fk_report_reporttableid" />
- <property name="usingOrgUnitGroupSets" />
-
<many-to-one name="relatives" unique="true" class="org.hisp.dhis.period.RelativePeriods" column="relativeperiodsid"
cascade="all-delete-orphan" foreign-key="fk_report_relativeperiodsid" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2013-05-19 18:49:47 +0000
@@ -27,14 +27,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.analytics.DataQueryParams.DIMENSION_SEP;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.amplecode.quick.BatchHandler;
@@ -42,6 +45,8 @@
import org.hisp.dhis.DhisTest;
import org.hisp.dhis.aggregation.AggregatedDataValue;
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
+import org.hisp.dhis.analytics.AnalyticsService;
+import org.hisp.dhis.analytics.data.MockAnalyticsService;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
@@ -59,19 +64,15 @@
import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AggregatedIndicatorValueBatchHandler;
-import org.hisp.dhis.jdbc.batchhandler.AggregatedOrgUnitDataValueBatchHandler;
-import org.hisp.dhis.jdbc.batchhandler.AggregatedOrgUnitIndicatorValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetCompletenessResultBatchHandler;
import org.hisp.dhis.mock.MockI18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.RelativePeriods;
import org.junit.Test;
/**
@@ -84,14 +85,16 @@
private BatchHandlerFactory batchHandlerFactory;
+ private AnalyticsService analyticsService;
+
+ private Map<String, Double> valueMap;
+
private List<DataElement> dataElements;
private List<DataElementCategoryOptionCombo> categoryOptionCombos;
private List<Indicator> indicators;
private List<DataSet> dataSets;
private List<Period> periods;
- private List<Period> relativePeriods;
private List<OrganisationUnit> units;
- private List<OrganisationUnitGroup> groups;
private PeriodType montlyPeriodType;
@@ -122,9 +125,6 @@
private OrganisationUnit unitA;
private OrganisationUnit unitB;
- private OrganisationUnitGroup groupA;
- private OrganisationUnitGroup groupB;
-
private int dataElementIdA;
private int dataElementIdB;
@@ -141,9 +141,6 @@
private int unitIdA;
private int unitIdB;
-
- private int groupIdA;
- private int groupIdB;
private I18nFormat i18nFormat;
@@ -176,12 +173,20 @@
indicators = new ArrayList<Indicator>();
dataSets = new ArrayList<DataSet>();
periods = new ArrayList<Period>();
- relativePeriods = new ArrayList<Period>();
units = new ArrayList<OrganisationUnit>();
- groups = new ArrayList<OrganisationUnitGroup>();
montlyPeriodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
-
+
+ // ---------------------------------------------------------------------
+ // Mock injection
+ // ---------------------------------------------------------------------
+
+ valueMap = new HashMap<String, Double>();
+
+ analyticsService = new MockAnalyticsService( valueMap );
+
+ setDependency( reportTableService, "analyticsService", analyticsService );
+
// ---------------------------------------------------------------------
// Setup Dimensions
// ---------------------------------------------------------------------
@@ -290,15 +295,6 @@
// Setup OrganisationUnitGroups
// ---------------------------------------------------------------------
- groupA = createOrganisationUnitGroup( 'A' );
- groupB = createOrganisationUnitGroup( 'B' );
-
- groupIdA = organisationUnitGroupService.addOrganisationUnitGroup( groupA );
- groupIdB = organisationUnitGroupService.addOrganisationUnitGroup( groupB );
-
- groups.add( groupA );
- groups.add( groupB );
-
i18nFormat = new MockI18nFormat();
BatchHandler<AggregatedDataValue> dataValueBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
@@ -339,32 +335,6 @@
completenessBatchHandler.addObject( new DataSetCompletenessResult( dataSetIdB, periodIdB, null, unitIdB, null, 100, 18, 18 ) );
completenessBatchHandler.flush();
-
- BatchHandler<AggregatedDataValue> dataValueOrgUnitBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedOrgUnitDataValueBatchHandler.class ).init();
-
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdA, 8, 21 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdB, 8, 22 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdA, 8, 23 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdB, 8, 24 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdA, 8, 25 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdB, 8, 26 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdA, 8, 27 ) );
- dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdB, 8, 28 ) );
-
- dataValueOrgUnitBatchHandler.flush();
-
- BatchHandler<AggregatedIndicatorValue> indicatorOrgUnitValueBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedOrgUnitIndicatorValueBatchHandler.class ).init();
-
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, groupIdA, 8, "", 1, 21, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, groupIdB, 8, "", 1, 22, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, groupIdA, 8, "", 1, 23, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, groupIdB, 8, "", 1, 24, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, groupIdA, 8, "", 1, 25, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, groupIdB, 8, "", 1, 26, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, groupIdA, 8, "", 1, 27, 0, 0 ) );
- indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, groupIdB, 8, "", 1, 28, 0, 0 ) );
-
- indicatorOrgUnitValueBatchHandler.flush();
}
@Override
@@ -382,727 +352,550 @@
// Tests
// -------------------------------------------------------------------------
- // -------------------------------------------------------------------------
- // Org unit group
- // -------------------------------------------------------------------------
-
- @Test
- public void testGetOrgUnitIndicatorReportTableA()
- {
- ReportTable reportTable = new ReportTable( "Prescriptions",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, null, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 23.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 25.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 27.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 22.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 26.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 28.0, grid.getRow( 1 ).get( 11 ) );
- }
-
- @Test
- public void testGetIndicatorOrgUnitReportTableB()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 23.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 25.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 26.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 27.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 28.0, grid.getRow( 3 ).get( 14 ) );
- }
-
- @Test
- public void testGetIndicatorOrgUnitReportTableC()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 25.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 26.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 23.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 27.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 28.0, grid.getRow( 1 ).get( 11 ) );
- }
-
- @Test
- public void testGetDataElementOrgUnitReportTableA()
- {
- ReportTable reportTable = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 23.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 25.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 27.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 22.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 26.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 28.0, grid.getRow( 1 ).get( 11 ) );
- }
-
- @Test
- public void testGetDataElementOrgUnitReportTableB()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 23.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 25.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 26.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 27.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 28.0, grid.getRow( 3 ).get( 14 ) );
- }
-
- @Test
- public void testGetDataElementOrgUnitReportTableC()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
- groups, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- reportTable.setParentOrganisationUnit( unitA );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 21.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 25.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 26.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 23.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 27.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 28.0, grid.getRow( 1 ).get( 11 ) );
- }
-
- // -------------------------------------------------------------------------
- // Org unit hierarchy
- // -------------------------------------------------------------------------
-
@Test
public void testGetIndicatorReportTableA()
{
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 11d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 12d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 13d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 14d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 15d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 16d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 17d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, null, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
}
@Test
public void testGetIndicatorReportTableB()
{
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 14 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 12 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 12 ) );
+
+ assertEquals( 13d, grid.getRow( 2 ).get( 11 ) );
+ assertEquals( 17d, grid.getRow( 2 ).get( 12 ) );
+
+ assertEquals( 14d, grid.getRow( 3 ).get( 11 ) );
+ assertEquals( 18d, grid.getRow( 3 ).get( 12 ) );
}
@Test
public void testGetIndicatorReportTableC()
{
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
}
@Test
public void testGetDataElementReportTableA()
{
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 11d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 12d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 13d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 14d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 15d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 16d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 17d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ true, true, false, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
}
@Test
public void testGetDataElementReportTableB()
{
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 14 ) );
+
+ assertEquals( 11d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 12 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 12 ) );
+
+ assertEquals( 13d, grid.getRow( 2 ).get( 11 ) );
+ assertEquals( 17d, grid.getRow( 2 ).get( 12 ) );
+
+ assertEquals( 14d, grid.getRow( 3 ).get( 11 ) );
+ assertEquals( 18d, grid.getRow( 3 ).get( 12 ) );
}
@Test
public void testGetDataElementReportTableC()
{
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ true, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
}
@Test
public void testGetDataSetReportTableA()
{
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 11d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 12d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 13d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 14d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 15d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 16d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 17d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ true, true, false, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 12.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
}
@Test
public void testGetDataSetReportTableB()
{
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ false, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 14 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 12 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 12 ) );
+
+ assertEquals( 13d, grid.getRow( 2 ).get( 11 ) );
+ assertEquals( 17d, grid.getRow( 2 ).get( 12 ) );
+
+ assertEquals( 14d, grid.getRow( 3 ).get( 11 ) );
+ assertEquals( 18d, grid.getRow( 3 ).get( 12 ) );
}
@Test
public void testGetDataSetReportTableC()
{
- ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 11 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
- }
-
- /*
- @Test
- public void testGetCategoryComboReportTableA()
- {
- BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
-
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 11 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 12 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 13 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 14 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 15 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 16 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 17 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 18 ) );
-
- batchHandler.flush();
-
- ReportTable reportTable = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 11 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 15 ) );
-
- assertEquals( 12.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 11 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 15 ) );
- }
-
- @Test
- public void testGetCategoryComboReportTableB()
- {
- BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
-
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 11 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 12 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 13 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 14 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 15 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 16 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 17 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 18 ) );
-
- batchHandler.flush();
-
- ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 15 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 16 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 15 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 16 ) );
-
- assertEquals( 15.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 15.0, grid.getRow( 2 ).get( 14 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 15 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 16 ) );
-
- assertEquals( 17.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 17.0, grid.getRow( 3 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 15 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 16 ) );
- }
-
- @Test
- public void testGetCategoryComboReportTableC()
- {
- BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
-
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 11 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 12 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 13 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 14 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 15 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 16 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 17 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 18 ) );
-
- batchHandler.flush();
-
- ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
- int id = reportTableService.saveReportTable( reportTable );
-
- Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 11 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 15 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 11 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 15 ) );
- }
-
- @Test
- public void testGetCategoryComboReportTableTotal()
- {
- BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
-
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 11 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 12 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 13 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 14 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 15 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 16 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 17 ) );
- batchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 18 ) );
-
- batchHandler.flush();
-
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ true, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 18 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 19 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 20 ) );
-
- assertEquals( 12.0, grid.getRow( 1 ).get( 18 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 19 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 20 ) );
-
- assertEquals( 13.0, grid.getRow( 2 ).get( 18 ) );
- assertEquals( 13.0, grid.getRow( 2 ).get( 19 ) );
- assertEquals( 26.0, grid.getRow( 2 ).get( 20 ) );
-
- assertEquals( 14.0, grid.getRow( 3 ).get( 18 ) );
- assertEquals( 14.0, grid.getRow( 3 ).get( 19 ) );
- assertEquals( 28.0, grid.getRow( 3 ).get( 20 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10) );
- assertEquals( 15.0, grid.getRow( 4 ).get( 18 ) );
- assertEquals( 15.0, grid.getRow( 4 ).get( 19 ) );
- assertEquals( 30.0, grid.getRow( 4 ).get( 20 ) );
-
- assertEquals( 16.0, grid.getRow( 5 ).get( 18 ) );
- assertEquals( 16.0, grid.getRow( 5 ).get( 19 ) );
- assertEquals( 32.0, grid.getRow( 5 ).get( 20 ) );
-
- assertEquals( 17.0, grid.getRow( 6 ).get( 18 ) );
- assertEquals( 17.0, grid.getRow( 6 ).get( 19 ) );
- assertEquals( 34.0, grid.getRow( 6 ).get( 20 ) );
-
- assertEquals( 18.0, grid.getRow( 7 ).get( 18 ) );
- assertEquals( 18.0, grid.getRow( 7 ).get( 19 ) );
- assertEquals( 36.0, grid.getRow( 7 ).get( 20 ) );
- }*/
-
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
+ }
+
@Test
public void testGetMultiReportTableA()
{
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 11d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 12d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 13d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 14d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 15d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 16d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 17d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 18d );
+
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 21d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 22d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 23d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 24d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 25d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 26d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 27d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 28d );
+
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 31d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 32d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 33d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 34d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 35d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 36d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 37d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 38d );
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, indicators, dataSets, periods, units,
+ true, true, false, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 11 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 15 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 16 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 17 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 18 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 19 ) );
-
- assertEquals( 12.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 15 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 16 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 17 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 18 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 19 ) );
+
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10 ) );
+ assertEquals( 21d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 23d, grid.getRow( 0 ).get( 12 ) );
+ assertEquals( 25d, grid.getRow( 0 ).get( 13 ) );
+ assertEquals( 27d, grid.getRow( 0 ).get( 14 ) );
+ assertEquals( 31d, grid.getRow( 0 ).get( 15 ) );
+ assertEquals( 33d, grid.getRow( 0 ).get( 16 ) );
+ assertEquals( 35d, grid.getRow( 0 ).get( 17 ) );
+ assertEquals( 37d, grid.getRow( 0 ).get( 18 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
+ assertEquals( 22d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 24d, grid.getRow( 1 ).get( 12 ) );
+ assertEquals( 26d, grid.getRow( 1 ).get( 13 ) );
+ assertEquals( 28d, grid.getRow( 1 ).get( 14 ) );
+ assertEquals( 32d, grid.getRow( 1 ).get( 15 ) );
+ assertEquals( 34d, grid.getRow( 1 ).get( 16 ) );
+ assertEquals( 36d, grid.getRow( 1 ).get( 17 ) );
+ assertEquals( 38d, grid.getRow( 1 ).get( 18 ) );
}
@Test
public void testGetMultiReportTableB()
{
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodA.getUid(), 21d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodB.getUid(), 22d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodA.getUid(), 23d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodB.getUid(), 24d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodA.getUid(), 25d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementA.getUid() + DIMENSION_SEP + periodB.getUid(), 26d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodA.getUid(), 27d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataElementB.getUid() + DIMENSION_SEP + periodB.getUid(), 28d );
+
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodA.getUid(), 31d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodB.getUid(), 32d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodA.getUid(), 33d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodB.getUid(), 34d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodA.getUid(), 35d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetA.getUid() + DIMENSION_SEP + periodB.getUid(), 36d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodA.getUid(), 37d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + dataSetB.getUid() + DIMENSION_SEP + periodB.getUid(), 38d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, indicators, dataSets, periods, units,
+ false, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 2 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 3 ).get( 14 ) );
-
- assertEquals( 11.0, grid.getRow( 4 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 4 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 5 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 5 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 6 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 6 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 7 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 7 ).get( 14 ) );
-
- assertEquals( 11.0, grid.getRow( 8 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 8 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 9 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 9 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 10 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 10 ).get( 14 ) );
-
- assertEquals( 17.0, grid.getRow( 11 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 11 ).get( 14 ) );
+
+ assertEquals( 11d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 12 ) );
+
+ assertEquals( 12d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 12 ) );
+
+ assertEquals( 13d, grid.getRow( 2 ).get( 11 ) );
+ assertEquals( 17d, grid.getRow( 2 ).get( 12 ) );
+
+ assertEquals( 14d, grid.getRow( 3 ).get( 11 ) );
+ assertEquals( 18d, grid.getRow( 3 ).get( 12 ) );
+
+ assertEquals( 21d, grid.getRow( 4 ).get( 11 ) );
+ assertEquals( 25d, grid.getRow( 4 ).get( 12 ) );
+
+ assertEquals( 22d, grid.getRow( 5 ).get( 11 ) );
+ assertEquals( 26d, grid.getRow( 5 ).get( 12 ) );
+
+ assertEquals( 23d, grid.getRow( 6 ).get( 11 ) );
+ assertEquals( 27d, grid.getRow( 6 ).get( 12 ) );
+
+ assertEquals( 24d, grid.getRow( 7 ).get( 11 ) );
+ assertEquals( 28d, grid.getRow( 7 ).get( 12 ) );
+
+ assertEquals( 31d, grid.getRow( 8 ).get( 11 ) );
+ assertEquals( 35d, grid.getRow( 8 ).get( 12 ) );
+
+ assertEquals( 32d, grid.getRow( 9 ).get( 11 ) );
+ assertEquals( 36d, grid.getRow( 9 ).get( 12 ) );
+
+ assertEquals( 33d, grid.getRow( 10 ).get( 11 ) );
+ assertEquals( 37d, grid.getRow( 10 ).get( 12 ) );
+
+ assertEquals( 34d, grid.getRow( 11 ).get( 11 ) );
+ assertEquals( 38d, grid.getRow( 11 ).get( 12 ) );
}
@Test
public void testGetMultiReportTableC()
{
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 21d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 22d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 23d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 24d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 25d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 26d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 27d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 28d );
+
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 31d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 32d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 33d );
+ valueMap.put( dataSetA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 34d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 35d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 36d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 37d );
+ valueMap.put( dataSetB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 38d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, indicators, dataSets, periods, units,
+ true, false, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 11 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 15 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 16 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 17 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 18 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 19 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 10 ) );
+ assertEquals( 21d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 23d, grid.getRow( 0 ).get( 12 ) );
+ assertEquals( 25d, grid.getRow( 0 ).get( 13 ) );
+ assertEquals( 27d, grid.getRow( 0 ).get( 14 ) );
+ assertEquals( 31d, grid.getRow( 0 ).get( 15 ) );
+ assertEquals( 33d, grid.getRow( 0 ).get( 16 ) );
+ assertEquals( 35d, grid.getRow( 0 ).get( 17 ) );
+ assertEquals( 37d, grid.getRow( 0 ).get( 18 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 15 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 16 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 17 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 18 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 19 ) );
+ assertEquals( 12d, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14d, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16d, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 1 ).get( 10 ) );
+ assertEquals( 22d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 24d, grid.getRow( 1 ).get( 12 ) );
+ assertEquals( 26d, grid.getRow( 1 ).get( 13 ) );
+ assertEquals( 28d, grid.getRow( 1 ).get( 14 ) );
+ assertEquals( 32d, grid.getRow( 1 ).get( 15 ) );
+ assertEquals( 34d, grid.getRow( 1 ).get( 16 ) );
+ assertEquals( 36d, grid.getRow( 1 ).get( 17 ) );
+ assertEquals( 38d, grid.getRow( 1 ).get( 18 ) );
}
@Test
public void testGetIndicatorReportTableColumnsOnly()
{
+ putIndicatorData();
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, true, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 3 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 4 ) );
- assertEquals( 13.0, grid.getRow( 0 ).get( 5 ) );
- assertEquals( 14.0, grid.getRow( 0 ).get( 6 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 7 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 17.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 18.0, grid.getRow( 0 ).get( 10 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 3 ) );
+ assertEquals( 12d, grid.getRow( 0 ).get( 4 ) );
+ assertEquals( 13d, grid.getRow( 0 ).get( 5 ) );
+ assertEquals( 14d, grid.getRow( 0 ).get( 6 ) );
+ assertEquals( 15d, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 16d, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 17d, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 18d, grid.getRow( 0 ).get( 10 ) );
}
@Test
public void testGetIndicatorReportTableRowsOnly()
{
+ putIndicatorData();
+
ReportTable reportTable = new ReportTable( "Prescriptions",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, false, null, null, "january_2000" );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 18 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 18 ) );
- assertEquals( 13.0, grid.getRow( 2 ).get( 18 ) );
- assertEquals( 14.0, grid.getRow( 3 ).get( 18 ) );
- assertEquals( 15.0, grid.getRow( 4 ).get( 18 ) );
- assertEquals( 16.0, grid.getRow( 5 ).get( 18 ) );
- assertEquals( 17.0, grid.getRow( 6 ).get( 18 ) );
- assertEquals( 18.0, grid.getRow( 7 ).get( 18 ) );
+ assertEquals( 11d, grid.getRow( 0 ).get( 15 ) );
+ assertEquals( 12d, grid.getRow( 1 ).get( 15 ) );
+ assertEquals( 13d, grid.getRow( 2 ).get( 15 ) );
+ assertEquals( 14d, grid.getRow( 3 ).get( 15 ) );
+ assertEquals( 15d, grid.getRow( 4 ).get( 15 ) );
+ assertEquals( 16d, grid.getRow( 5 ).get( 15 ) );
+ assertEquals( 17d, grid.getRow( 6 ).get( 15 ) );
+ assertEquals( 18d, grid.getRow( 7 ).get( 15 ) );
}
-
+
@Test
public void testGetIndicatorReportTableTopLimit()
{
+ putIndicatorData();
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, true, null, null, "january_2000" );
reportTable.setTopLimit( 2 );
int id = reportTableService.saveReportTable( reportTable );
@@ -1110,45 +903,57 @@
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
assertEquals( 2, grid.getHeight() );
-
- assertEquals( 11.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 14 ) );
}
@Test
public void testGetIndicatorReportTableSortOrder()
{
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( unitA.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( unitB.getUid() + DIMENSION_SEP + indicatorB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, true, null, null, "january_2000" );
reportTable.setSortOrder( ReportTable.DESC );
int id = reportTableService.saveReportTable( reportTable );
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 17.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 18.0, grid.getRow( 0 ).get( 14 ) );
-
- assertEquals( 15.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 16.0, grid.getRow( 1 ).get( 14 ) );
-
- assertEquals( 13.0, grid.getRow( 2 ).get( 13 ) );
- assertEquals( 14.0, grid.getRow( 2 ).get( 14 ) );
+ assertEquals( 14d, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 18d, grid.getRow( 0 ).get( 12 ) );
+
+ assertEquals( 13d, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 17d, grid.getRow( 1 ).get( 12 ) );
+
+ assertEquals( 12d, grid.getRow( 2 ).get( 11 ) );
+ assertEquals( 16d, grid.getRow( 2 ).get( 12 ) );
- assertEquals( 11.0, grid.getRow( 3 ).get( 13 ) );
- assertEquals( 12.0, grid.getRow( 3 ).get( 14 ) );
+ assertEquals( 11d, grid.getRow( 3 ).get( 11 ) );
+ assertEquals( 15d, grid.getRow( 3 ).get( 12 ) );
}
@Test
public void testGetDataElementReportTableRegression()
{
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 11d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 12d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 13d );
+ valueMap.put( dataElementA.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 14d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodA.getUid(), 15d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitA.getUid() + DIMENSION_SEP + periodB.getUid(), 16d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodA.getUid(), 17d );
+ valueMap.put( dataElementB.getUid() + DIMENSION_SEP + unitB.getUid() + DIMENSION_SEP + periodB.getUid(), 18d );
+
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ true, false, true, null, null, "january_2000" );
reportTable.setRegression( true );
@@ -1156,24 +961,36 @@
Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, "0" );
- assertEquals( 11.0, grid.getRow( 0 ).get( 8 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 9 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 11.0, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 13.0, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 15.0, grid.getRow( 0 ).get( 9 ) );
+ assertEquals( 17.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 12.0, grid.getRow( 0 ).get( 13 ) );
- assertEquals( 15.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 16.0, grid.getRow( 0 ).get( 15 ) );
+ assertEquals( 11.0, grid.getRow( 0 ).get( 11 ) );
+ assertEquals( 13.0, grid.getRow( 0 ).get( 12 ) );
+ assertEquals( 15.0, grid.getRow( 0 ).get( 13 ) );
+ assertEquals( 17.0, grid.getRow( 0 ).get( 14 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 8 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 9 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 12.0, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 14.0, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 16.0, grid.getRow( 1 ).get( 9 ) );
+ assertEquals( 18.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 13.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 14.0, grid.getRow( 1 ).get( 13 ) );
- assertEquals( 17.0, grid.getRow( 1 ).get( 14 ) );
- assertEquals( 18.0, grid.getRow( 1 ).get( 15 ) );
- }
+ assertEquals( 12.0, grid.getRow( 1 ).get( 11 ) );
+ assertEquals( 14.0, grid.getRow( 1 ).get( 12 ) );
+ assertEquals( 16.0, grid.getRow( 1 ).get( 13 ) );
+ assertEquals( 18.0, grid.getRow( 1 ).get( 14 ) );
+ }
+
+ private void putIndicatorData()
+ {
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 11d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 12d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 13d );
+ valueMap.put( indicatorA.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 14d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitA.getUid(), 15d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodA.getUid() + DIMENSION_SEP + unitB.getUid(), 16d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitA.getUid(), 17d );
+ valueMap.put( indicatorB.getUid() + DIMENSION_SEP + periodB.getUid() + DIMENSION_SEP + unitB.getUid(), 18d );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java 2013-05-19 18:49:47 +0000
@@ -42,13 +42,10 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.mock.MockI18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
@@ -73,7 +70,6 @@
private List<Indicator> indicators;
private List<DataSet> dataSets;
private List<Period> periods;
- private List<Period> relativePeriods;
private List<OrganisationUnit> units;
private PeriodType periodType;
@@ -97,8 +93,6 @@
private RelativePeriods relativesB;
private RelativePeriods relativesC;
- private I18nFormat i18nFormat;
-
@Override
public void setUpTest()
throws Exception
@@ -182,23 +176,21 @@
relativesC = new RelativePeriods();
relativesC.setReportingMonth( true );
- relativesC.setThisYear( true );
-
- i18nFormat = new MockI18nFormat();
+ relativesC.setThisYear( true );
}
@Test
public void testSaveGetReportTable()
{
ReportTable reportTableA = new ReportTable( "Immunization",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relativesA, null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, relativesA, null, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relativesB, null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, relativesB, null, "january_2000" );
ReportTable reportTableC = new ReportTable( "Assualt",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relativesC, null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ false, false, true, relativesC, null, "january_2000" );
int idA = reportTableStore.save( reportTableA );
int idB = reportTableStore.save( reportTableB );
@@ -211,7 +203,6 @@
assertEquals( "Immunization", reportTableA.getName() );
assertEquals( indicators, reportTableA.getIndicators() );
assertEquals( periods, reportTableA.getPeriods() );
- assertEquals( relativePeriods, reportTableA.getRelativePeriods() );
assertEquals( units, reportTableA.getOrganisationUnits() );
assertEquals( true, reportTableA.isDoIndicators() );
assertEquals( true, reportTableA.isDoPeriods() );
@@ -221,7 +212,6 @@
assertEquals( "Prescriptions", reportTableB.getName() );
assertEquals( dataElements, reportTableB.getDataElements() );
assertEquals( periods, reportTableB.getPeriods() );
- assertEquals( relativePeriods, reportTableB.getRelativePeriods() );
assertEquals( units, reportTableB.getOrganisationUnits() );
assertEquals( false, reportTableB.isDoIndicators() );
assertEquals( false, reportTableB.isDoPeriods() );
@@ -231,7 +221,6 @@
assertEquals( "Assualt", reportTableC.getName() );
assertEquals( dataSets, reportTableC.getDataSets() );
assertEquals( periods, reportTableC.getPeriods() );
- assertEquals( relativePeriods, reportTableC.getRelativePeriods() );
assertEquals( units, reportTableC.getOrganisationUnits() );
assertEquals( false, reportTableC.isDoIndicators() );
assertEquals( false, reportTableC.isDoPeriods() );
@@ -243,11 +232,11 @@
public void testDeleteReportTable()
{
ReportTable reportTableA = new ReportTable( "Immunization",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relativesA, null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, relativesA, null, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relativesB, null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, relativesB, null, "january_2000" );
int idA = reportTableStore.save( reportTableA );
int idB = reportTableStore.save( reportTableB );
@@ -270,11 +259,11 @@
public void testGetAllReportTables()
{
ReportTable reportTableA = new ReportTable( "Immunization",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relativesA, null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, relativesA, null, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relativesB, null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, relativesB, null, "january_2000" );
reportTableStore.save( reportTableA );
reportTableStore.save( reportTableB );
@@ -289,11 +278,11 @@
public void testGetReportTableByName()
{
ReportTable reportTableA = new ReportTable( "Immunization",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relativesA, null, i18nFormat, "january_2000" );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, relativesA, null, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relativesB, null, i18nFormat, "january_2000" );
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, relativesB, null, "january_2000" );
reportTableStore.save( reportTableA );
reportTableStore.save( reportTableB );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java 2013-05-19 18:49:47 +0000
@@ -27,24 +27,24 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import static org.hisp.dhis.reporttable.ReportTable.DATAELEMENT_ID;
import static org.hisp.dhis.reporttable.ReportTable.INDICATOR_ID;
+import static org.hisp.dhis.reporttable.ReportTable.ORGANISATIONUNITGROUP_ID;
import static org.hisp.dhis.reporttable.ReportTable.PERIOD_ID;
-import static org.hisp.dhis.reporttable.ReportTable.ORGANISATIONUNITGROUP_ID;
import static org.hisp.dhis.reporttable.ReportTable.getColumnName;
import static org.hisp.dhis.reporttable.ReportTable.getIdentifier;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import org.hisp.dhis.DhisTest;
+import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -56,6 +56,7 @@
import org.hisp.dhis.mock.MockI18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
@@ -64,7 +65,6 @@
/**
* @author Lars Helge Overland
- * @version $Id$
*/
public class ReportTableTest
extends DhisTest
@@ -74,7 +74,6 @@
private List<Indicator> indicators;
private List<DataSet> dataSets;
private List<Period> periods;
- private List<Period> relativePeriods;
private List<OrganisationUnit> units;
private List<OrganisationUnit> relativeUnits;
private List<OrganisationUnitGroup> groups;
@@ -105,6 +104,8 @@
private OrganisationUnit unitA;
private OrganisationUnit unitB;
+ private OrganisationUnitGroupSet groupSet;
+
private OrganisationUnitGroup groupA;
private OrganisationUnitGroup groupB;
@@ -125,7 +126,6 @@
indicators = new ArrayList<Indicator>();
dataSets = new ArrayList<DataSet>();
periods = new ArrayList<Period>();
- relativePeriods = new ArrayList<Period>();
units = new ArrayList<OrganisationUnit>();
relativeUnits = new ArrayList<OrganisationUnit>();
groups = new ArrayList<OrganisationUnitGroup>();
@@ -179,22 +179,20 @@
periodA.setId( 'A' );
periodB.setId( 'B' );
-
+
periods.add( periodA );
periods.add( periodB );
-
- periodC = createPeriod( montlyPeriodType, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
- periodD = createPeriod( montlyPeriodType, getDate( 2008, 4, 1 ), getDate( 2008, 4, 30 ) );
-
- periodC.setId( 'C' );
- periodD.setId( 'D' );
-
- periodC.setName( RelativePeriods.REPORTING_MONTH );
- periodD.setName( RelativePeriods.THIS_YEAR );
-
- relativePeriods.add( periodC );
- relativePeriods.add( periodD );
-
+
+ relatives = new RelativePeriods();
+
+ relatives.setReportingMonth( true );
+ relatives.setThisYear( true );
+
+ List<Period> rp = relatives.getRelativePeriods();
+
+ periodC = rp.get( 0 );
+ periodD = rp.get( 1 );
+
unitA = createOrganisationUnit( 'A' );
unitB = createOrganisationUnit( 'B' );
@@ -205,20 +203,20 @@
units.add( unitB );
relativeUnits.add( unitA );
+ groupSet = createOrganisationUnitGroupSet( 'A' );
+
groupA = createOrganisationUnitGroup( 'A' );
groupB = createOrganisationUnitGroup( 'B' );
+ groupA.setGroupSet( groupSet );
+ groupB.setGroupSet( groupSet );
+
groupA.setId( 'A' );
groupB.setId( 'B' );
groups.add( groupA );
groups.add( groupB );
- relatives = new RelativePeriods();
-
- relatives.setReportingMonth( true );
- relatives.setThisYear( true );
-
i18nFormat = new MockI18nFormat();
}
@@ -233,7 +231,7 @@
for ( List<NameableObject> column : cols )
{
- columns.add( getColumnName( column ) );
+ columns.add( ReportTable.getColumnName( column ) );
}
return columns;
@@ -352,157 +350,39 @@
assertNotNull( getColumnName( a3 ) );
assertEquals( "organisationunitgroupshorta_indicatorshorta", getColumnName( a3 ) );
}
-
- @Test
- public void testOrganisationUnitGroupReportTableA()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits,
- groups, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.ORGANISATIONUNIT_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
-
- List<List<NameableObject>> columns = reportTable.getGridColumns();
-
- assertNotNull( columns );
- assertEquals( 8, columns.size() );
-
- Iterator<List<NameableObject>> iterator = columns.iterator();
-
- assertEquals( getList( indicatorA, periodA ), iterator.next() );
- assertEquals( getList( indicatorA, periodB ), iterator.next() );
- assertEquals( getList( indicatorA, periodC ), iterator.next() );
- assertEquals( getList( indicatorA, periodD ), iterator.next() );
- assertEquals( getList( indicatorB, periodA ), iterator.next() );
- assertEquals( getList( indicatorB, periodB ), iterator.next() );
- assertEquals( getList( indicatorB, periodC ), iterator.next() );
- assertEquals( getList( indicatorB, periodD ), iterator.next() );
-
- List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
-
- assertNotNull( columnNames );
- assertEquals( 8, columnNames.size() );
-
- assertTrue( columnNames.contains( "indicatorshorta_reporting_month" ) );
- assertTrue( columnNames.contains( "indicatorshorta_year" ) );
- assertTrue( columnNames.contains( "indicatorshortb_reporting_month" ) );
- assertTrue( columnNames.contains( "indicatorshortb_year" ) );
-
- List<List<NameableObject>> rows = reportTable.getGridRows();
-
- assertNotNull( rows );
- assertEquals( 2, rows.size() );
-
- iterator = rows.iterator();
-
- assertEquals( getList( groupA ), iterator.next() );
- assertEquals( getList( groupB ), iterator.next() );
- }
-
- @Test
- public void testOrganisationUnitGroupReportTableB()
- {
- ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits,
- groups, true, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
- List<List<NameableObject>> columns = reportTable.getGridColumns();
-
- assertNotNull( columns );
- assertEquals( 4, columns.size() );
-
- Iterator<List<NameableObject>> iterator = columns.iterator();
-
- assertEquals( getList( indicatorA, groupA ), iterator.next() );
- assertEquals( getList( indicatorA, groupB ), iterator.next() );
- assertEquals( getList( indicatorB, groupA ), iterator.next() );
- assertEquals( getList( indicatorB, groupB ), iterator.next() );
-
- List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
-
- assertNotNull( columnNames );
- assertEquals( 4, columnNames.size() );
-
- assertTrue( columnNames.contains( "indicatorshorta_organisationunitgroupshorta" ) );
- assertTrue( columnNames.contains( "indicatorshorta_organisationunitgroupshortb" ) );
- assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupshorta" ) );
- assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupshortb" ) );
-
- List<List<NameableObject>> rows = reportTable.getGridRows();
-
- assertNotNull( rows );
- assertEquals( 4, rows.size() );
-
- iterator = rows.iterator();
-
- assertEquals( getList( periodA ), iterator.next() );
- assertEquals( getList( periodB ), iterator.next() );
- assertEquals( getList( periodC ), iterator.next() );
- assertEquals( getList( periodD ), iterator.next() );
- }
@Test
public void testIndicatorReportTableA()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.ORGANISATIONUNIT_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, false, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 8, columns.size() );
- Iterator<List<NameableObject>> iterator = columns.iterator();
-
- assertEquals( getList( indicatorA, periodA ), iterator.next() );
- assertEquals( getList( indicatorA, periodB ), iterator.next() );
- assertEquals( getList( indicatorA, periodC ), iterator.next() );
- assertEquals( getList( indicatorA, periodD ), iterator.next() );
- assertEquals( getList( indicatorB, periodA ), iterator.next() );
- assertEquals( getList( indicatorB, periodB ), iterator.next() );
- assertEquals( getList( indicatorB, periodC ), iterator.next() );
- assertEquals( getList( indicatorB, periodD ), iterator.next() );
+ assertTrue( columns.contains( getList( indicatorA, periodA ) ) );
+ assertTrue( columns.contains( getList( indicatorA, periodB ) ) );
+ assertTrue( columns.contains( getList( indicatorA, periodC ) ) );
+ assertTrue( columns.contains( getList( indicatorA, periodD ) ) );
+ assertTrue( columns.contains( getList( indicatorB, periodA ) ) );
+ assertTrue( columns.contains( getList( indicatorB, periodB ) ) );
+ assertTrue( columns.contains( getList( indicatorB, periodC ) ) );
+ assertTrue( columns.contains( getList( indicatorB, periodD ) ) );
List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
@@ -518,45 +398,37 @@
assertNotNull( rows );
assertEquals( 2, rows.size() );
-
- iterator = rows.iterator();
-
- assertEquals( getList( unitA ), iterator.next() );
- assertEquals( getList( unitB ), iterator.next() );
+
+ assertTrue( rows.contains( getList( unitB ) ) );
+ assertTrue( rows.contains( getList( unitB ) ) );
}
@Test
public void testIndicatorReportTableB()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 2, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.INDICATOR_ID ) );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 2, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 1, columnDims.size() );
+ assertEquals( 2, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 2, columns.size() );
- Iterator<List<NameableObject>> iterator = columns.iterator();
-
- assertEquals( getList( unitA ), iterator.next() );
- assertEquals( getList( unitB ), iterator.next() );
+ assertTrue( columns.contains( getList( unitA ) ) );
+ assertTrue( columns.contains( getList( unitB ) ) );
List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
@@ -570,51 +442,45 @@
assertNotNull( rows );
assertEquals( 8, rows.size() );
-
- iterator = rows.iterator();
-
- assertEquals( getList( indicatorA, periodA ), iterator.next() );
- assertEquals( getList( indicatorA, periodB ), iterator.next() );
- assertEquals( getList( indicatorA, periodC ), iterator.next() );
- assertEquals( getList( indicatorA, periodD ), iterator.next() );
- assertEquals( getList( indicatorB, periodA ), iterator.next() );
- assertEquals( getList( indicatorB, periodB ), iterator.next() );
- assertEquals( getList( indicatorB, periodC ), iterator.next() );
- assertEquals( getList( indicatorB, periodD ), iterator.next() );
+
+ assertTrue( rows.contains( getList( indicatorA, periodA ) ) );
+ assertTrue( rows.contains( getList( indicatorA, periodB ) ) );
+ assertTrue( rows.contains( getList( indicatorA, periodC ) ) );
+ assertTrue( rows.contains( getList( indicatorA, periodD ) ) );
+ assertTrue( rows.contains( getList( indicatorB, periodA ) ) );
+ assertTrue( rows.contains( getList( indicatorB, periodB ) ) );
+ assertTrue( rows.contains( getList( indicatorB, periodC ) ) );
+ assertTrue( rows.contains( getList( indicatorB, periodD ) ) );
}
@Test
public void testIndicatorReportTableC()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 4, columns.size() );
- Iterator<List<NameableObject>> iterator = columns.iterator();
-
- assertEquals( getList( indicatorA, unitA ), iterator.next() );
- assertEquals( getList( indicatorA, unitB ), iterator.next() );
- assertEquals( getList( indicatorB, unitA ), iterator.next() );
- assertEquals( getList( indicatorB, unitB ), iterator.next() );
+ assertTrue( columns.contains( getList( indicatorA, unitA ) ) );
+ assertTrue( columns.contains( getList( indicatorA, unitB ) ) );
+ assertTrue( columns.contains( getList( indicatorB, unitA ) ) );
+ assertTrue( columns.contains( getList( indicatorB, unitB ) ) );
List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
@@ -631,32 +497,30 @@
assertNotNull( rows );
assertEquals( 4, rows.size() );
- iterator = rows.iterator();
-
- assertEquals( getList( periodA ), iterator.next() );
- assertEquals( getList( periodB ), iterator.next() );
- assertEquals( getList( periodC ), iterator.next() );
- assertEquals( getList( periodD ), iterator.next() );
+ assertTrue( rows.contains( getList( periodA ) ) );
+ assertTrue( rows.contains( getList( periodB ) ) );
+ assertTrue( rows.contains( getList( periodC ) ) );
+ assertTrue( rows.contains( getList( periodD ) ) );
}
@Test
public void testIndicatorReportTableColumnsOnly()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 0, indexColumns.size() );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 0, indexNameColumns.size() );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ true, true, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 3, columnDims.size() );
+ assertEquals( 0, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
List<List<NameableObject>> columns = reportTable.getGridColumns();
@@ -673,20 +537,20 @@
public void testIndicatorReportTableRowsOnly()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, false, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 3, indexColumns.size() );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 3, indexNameColumns.size() );
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, units,
+ false, false, false, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 0, columnDims.size() );
+ assertEquals( 3, rowDims.size() );
+
+ assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
List<List<NameableObject>> columns = reportTable.getGridColumns();
@@ -703,23 +567,21 @@
public void testDataElementReportTableA()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.ORGANISATIONUNIT_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
-
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ true, true, false, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
@@ -745,25 +607,21 @@
public void testDataElementReportTableB()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 2, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.INDICATOR_ID ) );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 2, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ false, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 1, columnDims.size() );
+ assertEquals( 2, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
@@ -787,23 +645,21 @@
public void testDataElementReportTableC()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, units,
+ true, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
@@ -829,23 +685,21 @@
public void testDataSetReportTableA()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, true, false, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.ORGANISATIONUNIT_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
-
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ true, true, false, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
@@ -871,25 +725,21 @@
public void testDataSetReportTableB()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), false, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 2, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.INDICATOR_ID ) );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 2, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ false, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 1, columnDims.size() );
+ assertEquals( 2, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
@@ -913,23 +763,21 @@
public void testDataSetReportTableC()
{
ReportTable reportTable = new ReportTable( "Embezzlement",
- new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), true, false, true, relatives, null, i18nFormat, "january_2000" );
-
- reportTable.init();
-
- List<String> indexColumns = reportTable.getIndexColumns();
-
- assertNotNull( indexColumns );
- assertEquals( 1, indexColumns.size() );
- assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
-
- List<String> indexNameColumns = reportTable.getIndexNameColumns();
-
- assertNotNull( indexNameColumns );
- assertEquals( 1, indexNameColumns.size() );
- assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
-
+ new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, units,
+ true, false, true, relatives, null, "january_2000" );
+
+ reportTable.init( null, null, null, i18nFormat );
+
+ List<String> columnDims = reportTable.getColumnDimensions();
+ List<String> rowDims = reportTable.getRowDimensions();
+
+ assertEquals( 2, columnDims.size() );
+ assertEquals( 1, rowDims.size() );
+
+ assertTrue( columnDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
+ assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
+ assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
+
List<List<NameableObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2013-05-08 22:56:40 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2013-05-19 18:49:47 +0000
@@ -109,6 +109,10 @@
public abstract class DhisConvenienceTest
{
protected static final String BASE_UID = "123456789a";
+ protected static final String BASE_IN_UID = "inabcdefgh";
+ protected static final String BASE_DE_UID = "deabcdefgh";
+ protected static final String BASE_DS_UID = "dsabcdefgh";
+ protected static final String BASE_OU_UID = "ouabcdefgh";
private static final String EXT_TEST_DIR = System.getProperty( "user.home" ) + File.separator + "dhis2_test_dir";
@@ -366,7 +370,7 @@
{
DataElement dataElement = new DataElement();
- dataElement.setUid( BASE_UID + uniqueCharacter );
+ dataElement.setUid( BASE_DE_UID + uniqueCharacter );
dataElement.setName( "DataElement" + uniqueCharacter );
dataElement.setShortName( "DataElementShort" + uniqueCharacter );
dataElement.setCode( "DataElementCode" + uniqueCharacter );
@@ -532,7 +536,7 @@
{
Indicator indicator = new Indicator();
- indicator.setUid( BASE_UID + uniqueCharacter );
+ indicator.setUid( BASE_IN_UID + uniqueCharacter );
indicator.setName( "Indicator" + uniqueCharacter );
indicator.setShortName( "IndicatorShort" + uniqueCharacter );
indicator.setCode( "IndicatorCode" + uniqueCharacter );
@@ -581,6 +585,7 @@
{
DataSet dataSet = new DataSet();
+ dataSet.setUid( BASE_DS_UID + uniqueCharacter );
dataSet.setName( "DataSet" + uniqueCharacter );
dataSet.setShortName( "DataSetShort" + uniqueCharacter );
dataSet.setCode( "DataSetCode" + uniqueCharacter );
@@ -596,7 +601,7 @@
{
OrganisationUnit unit = new OrganisationUnit();
- unit.setUid( BASE_UID + uniqueCharacter );
+ unit.setUid( BASE_OU_UID + uniqueCharacter );
unit.setName( "OrganisationUnit" + uniqueCharacter );
unit.setShortName( "OrganisationUnitShort" + uniqueCharacter );
unit.setCode( "OrganisationUnitCode" + uniqueCharacter );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java 2013-05-18 15:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java 2013-05-19 18:49:47 +0000
@@ -79,6 +79,7 @@
throws Exception
{
PatientRegistrationForm registrationForm = null;
+
if ( id != null )
{
Program program = programService.getProgram( id );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java 2013-04-30 11:25:21 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java 2013-05-19 18:49:47 +0000
@@ -109,13 +109,6 @@
this.reportTableId = reportTableId;
}
- private boolean usingOrgUnitGroupSets;
-
- public void setUsingOrgUnitGroupSets( boolean usingOrgUnitGroupSets )
- {
- this.usingOrgUnitGroupSets = usingOrgUnitGroupSets;
- }
-
private File file;
public void setUpload( File file )
@@ -207,7 +200,6 @@
report.setName( name );
report.setType( type );
report.setReportTable( reportTable );
- report.setUsingOrgUnitGroupSets( usingOrgUnitGroupSets );
report.setRelatives( getRelativePeriods() );
report.setReportParams( reportParams );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-10-01 15:58:02 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2013-05-19 18:49:47 +0000
@@ -40,10 +40,8 @@
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -76,13 +74,6 @@
this.constantService = constantService;
}
- private OrganisationUnitGroupService organisationUnitGroupService;
-
- public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
- {
- this.organisationUnitGroupService = organisationUnitGroupService;
- }
-
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -182,12 +173,9 @@
// Assemble report
// ---------------------------------------------------------------------
- ReportTable reportTable = reportTableService.getReportTable( uid );
-
if ( TYPE_JRXML.equals( format ) )
{
params.putAll( constantService.getConstantParameterMap() );
- params.putAll( reportTable.getOrganisationUnitGroupMap( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ) );
}
Period period = PeriodType.getPeriodFromIsoString( pe );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java 2013-05-19 18:49:47 +0000
@@ -303,8 +303,8 @@
if ( tableId == null )
{
reportTable = new ReportTable( tableName,
- dataElements, indicators, dataSets, periods, null, units, null, organisationUnitGroups,
- doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, null, null );
+ dataElements, indicators, dataSets, periods, units,
+ doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, null );
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-19 18:49:47 +0000
@@ -108,7 +108,6 @@
scope="prototype">
<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
</bean>
<bean id="org.hisp.dhis.reporting.tablecreator.action.GetCategoryComboDataElementsAction" class="org.hisp.dhis.reporting.tablecreator.action.GetCategoryComboDataElementsAction"
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2013-04-30 11:20:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2013-05-19 18:49:47 +0000
@@ -61,15 +61,6 @@
</td>
</tr>
#end
- <tr class="jasperReportTableDataSource">
- <td><label for="usingOrgUnitGroupSets">$i18n.getString( "include_organisation_unit_group_sets" )</label></td>
- <td>
- <select id="usingOrgUnitGroupSets" name="usingOrgUnitGroupSets">
- <option value="false"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "no" )</option>
- <option value="true"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "yes" )</option>
- </select>
- </td>
- </tr>
<tr class="jasperReportTableDataSource">
<td>$i18n.getString( "report_table" )</td>
<td>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2013-05-15 10:10:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2013-05-19 18:49:47 +0000
@@ -40,12 +40,8 @@
<tr id="tr${table.id}">
<td onclick="showTableDetails( $table.id )">$encoder.htmlEncode( $table.name )</td>
<td style="text-align:right">
- #if ( $table.isReportTable() )
<a href="getReportParams.action?uid=${table.uid}&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a>
- #else
- <img src="../images/start_process-denied.png">
- #end
-
+
#if ( $security.canManage( $table ) )
<a href="javascript:showSharingDialog('reportTable', '$table.uid');" title="$i18n.getString( 'sharing_settings' )"><img src="../images/relationship.png" alt="$i18n.getString( 'sharing_settings' )"></a>
#else
=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml 2013-05-15 15:15:05 +0000
+++ dhis-2/pom.xml 2013-05-19 18:49:47 +0000
@@ -62,6 +62,7 @@
<name>UK Central</name>
<url>http://uk.maven.org/maven2</url>
</repository>
+ <!--
<repository>
<id>org.springframework.maven.release</id>
<name>Spring Maven Repository</name>
@@ -72,6 +73,7 @@
<name>Spring Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
+ -->
<repository>
<id>amplecode_maven2_repo</id>
<name>AmpleCode Maven 2 repository</name>
@@ -87,9 +89,8 @@
<name>Dhis2 External Dependencies Repository</name>
<url>http://dhis.uio.no/maven/external</url>
</repository>
-
<!--
- <repository>
+ <repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
@@ -102,7 +103,7 @@
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
- </repository>
+ </repository>
-->
</repositories>