dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42503
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21721: Report table, changed from using NameableObject to DimensionalItemObject
------------------------------------------------------------
revno: 21721
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-01-14 13:24:11 +0100
message:
Report table, changed from using NameableObject to DimensionalItemObject
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2016-01-06 14:52:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2016-01-14 12:24:11 +0000
@@ -64,7 +64,6 @@
import org.hisp.dhis.dataelement.DataElementCategoryDimension;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -767,24 +766,17 @@
* Generates an identifier based on the given lists of NameableObjects. Uses
* the UIDs for each NameableObject, sorts them and writes them out as a key.
*/
- public static String getIdentifier( List<NameableObject> column, List<NameableObject> row )
+ public static String getIdentifier( List<DimensionalItemObject> column, List<DimensionalItemObject> row )
{
List<String> ids = new ArrayList<>();
- List<NameableObject> dimensions = new ArrayList<>();
+ List<DimensionalItemObject> dimensions = new ArrayList<>();
dimensions.addAll( column != null ? column : new ArrayList<>() );
dimensions.addAll( row != null ? row : new ArrayList<>() );
- for ( NameableObject item : dimensions )
+ for ( DimensionalItemObject item : dimensions )
{
- if ( item.getClass().equals( DataElementOperand.class ) )
- {
- ids.add( ((DataElementOperand) item).getDimensionItem() );
- }
- else
- {
- ids.add( item.getUid() );
- }
+ ids.add( item.getDimensionItem() );
}
Collections.sort( ids );
=== 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 2016-01-06 13:45:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2016-01-14 12:24:11 +0000
@@ -54,7 +54,6 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.common.MergeStrategy;
-import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.DimensionalView;
import org.hisp.dhis.common.view.ExportView;
@@ -94,8 +93,8 @@
public static final String TOTAL_COLUMN_NAME = "total";
public static final String TOTAL_COLUMN_PRETTY_NAME = "Total";
- public static final NameableObject[] IRT = new NameableObject[0];
- public static final NameableObject[][] IRT2D = new NameableObject[0][];
+ public static final DimensionalItemObject[] IRT = new DimensionalItemObject[0];
+ public static final DimensionalItemObject[][] IRT2D = new DimensionalItemObject[0][];
private static final String EMPTY = "";
@@ -204,12 +203,12 @@
/**
* All crosstabulated columns.
*/
- private transient List<List<NameableObject>> gridColumns = new ArrayList<>();
+ private transient List<List<DimensionalItemObject>> gridColumns = new ArrayList<>();
/**
* All rows.
*/
- private transient List<List<NameableObject>> gridRows = new ArrayList<>();
+ private transient List<List<DimensionalItemObject>> gridRows = new ArrayList<>();
/**
* The name of the reporting month based on the report param.
@@ -347,8 +346,8 @@
public void populateGridColumnsAndRows( Date date, User user,
List<OrganisationUnit> organisationUnitsAtLevel, List<OrganisationUnit> organisationUnitsInGroups, I18nFormat format )
{
- List<NameableObject[]> tableColumns = new ArrayList<>();
- List<NameableObject[]> tableRows = new ArrayList<>();
+ List<DimensionalItemObject[]> tableColumns = new ArrayList<>();
+ List<DimensionalItemObject[]> tableRows = new ArrayList<>();
List<DimensionalItemObject> filterItems = new ArrayList<>();
for ( String dimension : columnDimensions )
@@ -407,11 +406,11 @@
* Generates a pretty column name based on short-names of the argument
* objects. Null arguments are ignored in the name.
*/
- public static String getPrettyColumnName( List<NameableObject> objects )
+ public static String getPrettyColumnName( List<DimensionalItemObject> objects )
{
StringBuilder builder = new StringBuilder();
- for ( NameableObject object : objects )
+ for ( DimensionalItemObject object : objects )
{
builder.append( object != null ? (object.getShortName() + SPACE) : EMPTY );
}
@@ -427,11 +426,11 @@
* 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 )
+ public static String getColumnName( List<DimensionalItemObject> objects )
{
StringBuffer buffer = new StringBuffer();
- for ( NameableObject object : objects )
+ for ( DimensionalItemObject object : objects )
{
if ( object != null && object instanceof Period )
{
@@ -502,13 +501,13 @@
}
/**
- * Adds an empty list of NameableObjects to the given list if empty.
+ * Adds an empty list of DimensionalItemObjects to the given list if empty.
*/
- public static void addIfEmpty( List<List<NameableObject>> list )
+ public static void addIfEmpty( List<List<DimensionalItemObject>> list )
{
if ( list != null && list.size() == 0 )
{
- list.add( Arrays.asList( new NameableObject[0] ) );
+ list.add( Arrays.asList( new DimensionalItemObject[0] ) );
}
}
@@ -573,7 +572,7 @@
final int startColumnIndex = grid.getHeaders().size();
final int numberOfColumns = getGridColumns().size();
- for ( List<NameableObject> column : gridColumns )
+ for ( List<DimensionalItemObject> column : gridColumns )
{
grid.addHeader( new GridHeader( getPrettyColumnName( column ), getColumnName( column ), Double.class
.getName(), false, false ) );
@@ -583,7 +582,7 @@
// Values
// ---------------------------------------------------------------------
- for ( List<NameableObject> row : gridRows )
+ for ( List<DimensionalItemObject> row : gridRows )
{
grid.addRow();
@@ -591,7 +590,7 @@
// Row meta data
// -----------------------------------------------------------------
- for ( NameableObject object : row )
+ for ( DimensionalItemObject object : row )
{
grid.addValue( object.getUid() );
grid.addValue( object.getName() );
@@ -612,7 +611,7 @@
boolean hasValue = false;
- for ( List<NameableObject> column : gridColumns )
+ for ( List<DimensionalItemObject> column : gridColumns )
{
String key = getIdentifier( column, row );
@@ -996,23 +995,23 @@
}
@JsonIgnore
- public List<List<NameableObject>> getGridColumns()
+ public List<List<DimensionalItemObject>> getGridColumns()
{
return gridColumns;
}
- public void setGridColumns( List<List<NameableObject>> gridColumns )
+ public void setGridColumns( List<List<DimensionalItemObject>> gridColumns )
{
this.gridColumns = gridColumns;
}
@JsonIgnore
- public List<List<NameableObject>> getGridRows()
+ public List<List<DimensionalItemObject>> getGridRows()
{
return gridRows;
}
- public void setGridRows( List<List<NameableObject>> gridRows )
+ public void setGridRows( List<List<DimensionalItemObject>> gridRows )
{
this.gridRows = gridRows;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2016-01-13 13:38:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2016-01-14 12:24:11 +0000
@@ -38,7 +38,6 @@
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
-import org.hisp.dhis.setting.SystemSetting;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java 2016-01-06 14:52:32 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java 2016-01-14 12:24:11 +0000
@@ -143,11 +143,11 @@
oB.setUid( "b1" );
oC.setUid( "c1" );
- List<NameableObject> column = new ArrayList<>();
+ List<DimensionalItemObject> column = new ArrayList<>();
column.add( oC );
column.add( oA );
- List<NameableObject> row = new ArrayList<>();
+ List<DimensionalItemObject> row = new ArrayList<>();
row.add( oB );
assertEquals( "a1-b1-c1", BaseAnalyticalObject.getIdentifier( column, row ) );
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java 2016-01-14 12:24:11 +0000
@@ -39,8 +39,8 @@
import java.util.List;
import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.DimensionalItemObject;
import org.hisp.dhis.common.DimensionalObject;
-import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -215,16 +215,16 @@
i18nFormat = new MockI18nFormat();
}
- private static List<NameableObject> getList( NameableObject... objects )
+ private static List<DimensionalItemObject> getList( DimensionalItemObject... objects )
{
return Arrays.asList( objects );
}
- private static List<String> getColumnNames( List<List<NameableObject>> cols )
+ private static List<String> getColumnNames( List<List<DimensionalItemObject>> cols )
{
List<String> columns = new ArrayList<>();
- for ( List<NameableObject> column : cols )
+ for ( List<DimensionalItemObject> column : cols )
{
columns.add( ReportTable.getColumnName( column ) );
}
@@ -239,17 +239,17 @@
@Test
public void testGetColumnName()
{
- List<NameableObject> a1 = getList( unitA, periodC );
+ List<DimensionalItemObject> a1 = getList( unitA, periodC );
assertNotNull( getColumnName( a1 ) );
assertEquals( "organisationunitshorta_reporting_month", getColumnName( a1 ) );
- List<NameableObject> a2 = getList( unitB, periodD );
+ List<DimensionalItemObject> a2 = getList( unitB, periodD );
assertNotNull( getColumnName( a2 ) );
assertEquals( "organisationunitshortb_year", getColumnName( a2 ) );
- List<NameableObject> a3 = getList( groupA, indicatorA );
+ List<DimensionalItemObject> a3 = getList( groupA, indicatorA );
assertNotNull( getColumnName( a3 ) );
assertEquals( "organisationunitgroupshorta_indicatorshorta", getColumnName( a3 ) );
@@ -274,7 +274,7 @@
assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 8, columns.size() );
@@ -298,7 +298,7 @@
assertTrue( columnNames.contains( "indicatorshortb_reporting_month" ) );
assertTrue( columnNames.contains( "indicatorshortb_year" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 2, rows.size() );
@@ -326,7 +326,7 @@
assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 2, columns.size() );
@@ -342,7 +342,7 @@
assertTrue( columnNames.contains( "organisationunitshorta" ) );
assertTrue( columnNames.contains( "organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 8, rows.size() );
@@ -376,7 +376,7 @@
assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 4, columns.size() );
@@ -396,7 +396,7 @@
assertTrue( columnNames.contains( "indicatorshortb_organisationunitshorta" ) );
assertTrue( columnNames.contains( "indicatorshortb_organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 4, rows.size() );
@@ -426,12 +426,12 @@
assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 16, columns.size() );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 1, rows.size() );
@@ -456,12 +456,12 @@
assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 1, columns.size() );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 16, rows.size() );
@@ -486,7 +486,7 @@
assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 8, columns.size() );
@@ -501,7 +501,7 @@
assertTrue( columnNames.contains( "dataelementshortb_year" ) );
assertTrue( columnNames.contains( "dataelementshortb_reporting_month" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 2, rows.size() );
@@ -526,7 +526,7 @@
assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 2, columns.size() );
@@ -539,7 +539,7 @@
assertTrue( columnNames.contains( "organisationunitshorta" ) );
assertTrue( columnNames.contains( "organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 8, rows.size() );
@@ -564,7 +564,7 @@
assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 4, columns.size() );
@@ -579,7 +579,7 @@
assertTrue( columnNames.contains( "dataelementshortb_organisationunitshorta" ) );
assertTrue( columnNames.contains( "dataelementshortb_organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 4, rows.size() );
@@ -604,7 +604,7 @@
assertTrue( columnDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 8, columns.size() );
@@ -619,7 +619,7 @@
assertTrue( columnNames.contains( "datasetshortb_year" ) );
assertTrue( columnNames.contains( "datasetshortb_reporting_month" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 2, rows.size() );
@@ -644,7 +644,7 @@
assertTrue( rowDims.contains( DimensionalObject.DATA_X_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 2, columns.size() );
@@ -657,7 +657,7 @@
assertTrue( columnNames.contains( "organisationunitshorta" ) );
assertTrue( columnNames.contains( "organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 8, rows.size() );
@@ -682,7 +682,7 @@
assertTrue( columnDims.contains( DimensionalObject.ORGUNIT_DIM_ID ) );
assertTrue( rowDims.contains( DimensionalObject.PERIOD_DIM_ID ) );
- List<List<NameableObject>> columns = reportTable.getGridColumns();
+ List<List<DimensionalItemObject>> columns = reportTable.getGridColumns();
assertNotNull( columns );
assertEquals( 4, columns.size() );
@@ -697,7 +697,7 @@
assertTrue( columnNames.contains( "datasetshortb_organisationunitshorta" ) );
assertTrue( columnNames.contains( "datasetshortb_organisationunitshortb" ) );
- List<List<NameableObject>> rows = reportTable.getGridRows();
+ List<List<DimensionalItemObject>> rows = reportTable.getGridRows();
assertNotNull( rows );
assertEquals( 4, rows.size() );