dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14565
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4988: format cleanups
------------------------------------------------------------
revno: 4988
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-20 15:05:27 +0200
message:
format cleanups
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.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/completeness/DataSetCompletenessResult.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java 2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java 2011-10-20 13:05:27 +0000
@@ -48,23 +48,23 @@
// -------------------------------------------------------------------------
private int dataSetId;
-
+
private int periodId;
private String periodName;
-
+
private int organisationUnitId;
-
+
// -------------------------------------------------------------------------
// Properties 2
// -------------------------------------------------------------------------
private String name;
-
+
private int sources;
-
+
private int registrations;
-
+
private int registrationsOnTime;
// -------------------------------------------------------------------------
@@ -72,7 +72,7 @@
// -------------------------------------------------------------------------
public DataSetCompletenessResult()
- {
+ {
}
/**
@@ -88,7 +88,7 @@
this.registrations = registrations;
this.registrationsOnTime = registrationsOnTime;
}
-
+
/**
* @param dataSetId the dataset identifier.
* @param periodId the period identifier.
@@ -112,7 +112,7 @@
this.registrations = registrations;
this.registrationsOnTime = registrationsOnTime;
}
-
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -121,23 +121,23 @@
{
if ( sources > 0 )
{
- double percentage = (double)registrations / (double)sources * 100;
-
+ double percentage = (double) registrations / (double) sources * 100;
+
return getRounded( percentage, 1 );
}
-
+
return 0.0;
}
-
+
public double getPercentageOnTime()
{
if ( sources > 0 )
{
- double percentage = (double)registrationsOnTime / (double)sources * 100;
-
+ double percentage = (double) registrationsOnTime / (double) sources * 100;
+
return getRounded( percentage, 1 );
}
-
+
return 0.0;
}
@@ -152,7 +152,7 @@
{
return registrations;
}
-
+
// -------------------------------------------------------------------------
// HashCode, equals, and toString
// -------------------------------------------------------------------------
@@ -161,14 +161,14 @@
public int hashCode()
{
final int prime = 31;
-
+
int result = 1;
-
- result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
+
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + sources;
result = prime * result + registrations;
result = prime * result + registrationsOnTime;
-
+
return result;
}
@@ -179,30 +179,29 @@
{
return true;
}
-
+
if ( object == null )
{
return false;
}
-
+
if ( getClass() != object.getClass() )
{
return false;
}
-
+
final DataSetCompletenessResult other = (DataSetCompletenessResult) object;
-
- return name.equals( other.getName() ) &&
- sources == other.getSources() &&
- registrations == other.getRegistrations() &&
- registrationsOnTime == other.getRegistrationsOnTime();
+
+ return name.equals( other.getName() ) && sources == other.getSources()
+ && registrations == other.getRegistrations() && registrationsOnTime == other.getRegistrationsOnTime();
}
-
+
@Override
public String toString()
{
- String toString = "[Name: " + name + ", Reg: " + registrations + ", On time: " + registrationsOnTime + ", Src: " + sources + "]";
-
+ String toString = "[Name: " + name + ", Reg: " + registrations + ", On time: " + registrationsOnTime
+ + ", Src: " + sources + "]";
+
return toString;
}
@@ -263,7 +262,7 @@
{
this.name = name;
}
-
+
public int getSources()
{
return sources;
@@ -307,7 +306,7 @@
private double getRounded( double value, int decimals )
{
double factor = Math.pow( 10, decimals );
-
+
return Math.round( value * factor ) / factor;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-09-02 13:11:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-10-20 13:05:27 +0000
@@ -38,54 +38,58 @@
public interface DataSetCompletenessService
{
String ID = DataSetCompletenessService.class.getName();
-
+
/**
*
* @param dataSetIds
* @param relatives
* @param organisationUnitIds
*/
- void exportDataSetCompleteness( Collection<Integer> dataSetIds, RelativePeriods relatives, Collection<Integer> organisationUnitIds );
-
+ void exportDataSetCompleteness( Collection<Integer> dataSetIds, RelativePeriods relatives,
+ Collection<Integer> organisationUnitIds );
+
/**
*
* @param dataSetIds
* @param periodIds
* @param organisationUnitIds
*/
- void exportDataSetCompleteness( Collection<Integer> dataSetIds,
- Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
-
+ void exportDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds );
+
/**
- * Returns a Collection of DataSetCompletenessResults. The DataSetCompletenessResult
- * object contains the name of the associated DataSet, the number of
- * sources being associated with the DataSet AND being a child of the given
- * OrganisationUnit, and the number of CompleteDataSetRegistrations for the
- * mentioned sources. One DataSetCompletenessResult is included for each
- * distinct DataSet associated with any of the given OrganisationUnit
- * or its children.
+ * Returns a Collection of DataSetCompletenessResults. The
+ * DataSetCompletenessResult object contains the name of the associated
+ * DataSet, the number of sources being associated with the DataSet AND
+ * being a child of the given OrganisationUnit, and the number of
+ * CompleteDataSetRegistrations for the mentioned sources. One
+ * DataSetCompletenessResult is included for each distinct DataSet
+ * associated with any of the given OrganisationUnit or its children.
*
* @param periodId the identifier of the Period.
* @param organisationUnitId the identifier of the root OrganisationUnit.
* @return a Collection of DataSetCompletenessResults.
*/
Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId, int organisationUnitId );
-
+
/**
- * Returns a Collection of DataSetCompletenessResults. The DataSetCompletenessResult
- * object contains the name of the associated OrganisationUnit, the number of
- * sources being associated with the DataSet AND being a child of the OrganisationUnit,
- * and the number of CompleteDataSetRegistrations for the mentioned sources
- * for the DataSet. One DataSetCompletenessResult is included for each child
- * of the OrganisationUnit.
+ * Returns a Collection of DataSetCompletenessResults. The
+ * DataSetCompletenessResult object contains the name of the associated
+ * OrganisationUnit, the number of sources being associated with the DataSet
+ * AND being a child of the OrganisationUnit, and the number of
+ * CompleteDataSetRegistrations for the mentioned sources for the DataSet.
+ * One DataSetCompletenessResult is included for each child of the
+ * OrganisationUnit.
*
* @param periodId the identifier of the Period.
- * @param parentOrganisationUnitId the identifier of the parent OrganisationUnit.
+ * @param parentOrganisationUnitId the identifier of the parent
+ * OrganisationUnit.
* @param dataSetId the identifier of the DataSet.
* @return a Collection of DataSetCompletenessResults.
*/
- Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId, Collection<Integer> organisationUnitIds, int dataSetId );
-
+ Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId,
+ Collection<Integer> organisationUnitIds, int dataSetId );
+
/**
* Creates an index on the aggregateddatasetcompleteness table.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-10-20 13:05:27 +0000
@@ -66,7 +66,7 @@
implements DataSetCompletenessService
{
private static final Log log = LogFactory.getLog( AbstractDataSetCompletenessService.class );
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -77,9 +77,9 @@
{
this.batchHandlerFactory = batchHandlerFactory;
}
-
+
protected OrganisationUnitService organisationUnitService;
-
+
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
@@ -91,9 +91,9 @@
{
this.dataSetService = dataSetService;
}
-
+
protected DataElementService dataElementService;
-
+
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
@@ -112,7 +112,7 @@
{
this.completenessStore = completenessStore;
}
-
+
private SystemSettingManager systemSettingManager;
public void setSystemSettingManager( SystemSettingManager systemSettingManager )
@@ -127,74 +127,81 @@
// -------------------------------------------------------------------------
// Abstract methods
// -------------------------------------------------------------------------
-
+
public abstract int getRegistrations( DataSet dataSet, Collection<Integer> relevantSources, Period period );
-
- public abstract int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Period period, Date deadline );
-
+
+ public abstract int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Period period,
+ Date deadline );
+
public abstract int getSources( DataSet dataSet, Collection<Integer> relevantSources );
-
+
// -------------------------------------------------------------------------
// DataSetCompleteness
// -------------------------------------------------------------------------
- public void exportDataSetCompleteness( Collection<Integer> dataSetIds, RelativePeriods relatives, Collection<Integer> organisationUnitIds )
+ public void exportDataSetCompleteness( Collection<Integer> dataSetIds, RelativePeriods relatives,
+ Collection<Integer> organisationUnitIds )
{
if ( relatives != null )
{
- Collection<Integer> periodIds = ConversionUtils.getIdentifiers( Period.class, periodService.reloadPeriods( relatives.getRelativePeriods() ) );
-
+ Collection<Integer> periodIds = ConversionUtils.getIdentifiers( Period.class,
+ periodService.reloadPeriods( relatives.getRelativePeriods() ) );
+
exportDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds );
}
}
-
- public void exportDataSetCompleteness( Collection<Integer> dataSetIds,
- Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
+
+ public void exportDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds )
{
log.info( "Data completeness export process started" );
-
+
completenessStore.dropIndex();
-
+
log.info( "Dropped potential index" );
-
- int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET );
-
+
+ int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
+ DEFAULT_COMPLETENESS_OFFSET );
+
completenessStore.deleteDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds );
-
+
log.info( "Deleted existing completeness data" );
-
- BatchHandler<DataSetCompletenessResult> batchHandler = batchHandlerFactory.createBatchHandler( DataSetCompletenessResultBatchHandler.class );
-
+
+ BatchHandler<DataSetCompletenessResult> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataSetCompletenessResultBatchHandler.class );
+
batchHandler.init();
-
+
Collection<Period> periods = periodService.getPeriods( periodIds );
Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnits( organisationUnitIds );
Collection<DataSet> dataSets = dataSetService.getDataSets( dataSetIds );
-
+
periods = completenessStore.getPeriodsWithRegistrations( periods );
dataSets = completenessStore.getDataSetsWithRegistrations( dataSets );
-
+
OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
hierarchy.prepareChildren( units );
-
- //TODO Re-implement period aggregation with sql to improve performance
-
+
+ // TODO Re-implement period aggregation with sql to improve performance
+
for ( final DataSet dataSet : dataSets )
- {
+ {
for ( final OrganisationUnit unit : units )
{
Collection<Integer> sources = hierarchy.getChildren( unit.getId() );
-
+
Collection<Integer> relevantSources = getRelevantSources( dataSet, sources );
-
+
for ( final Period period : periods )
{
- if ( period.getPeriodType() != null && dataSet.getPeriodType() != null && period.getPeriodType().equals( dataSet.getPeriodType() ) )
+ if ( period.getPeriodType() != null && dataSet.getPeriodType() != null
+ && period.getPeriodType().equals( dataSet.getPeriodType() ) )
{
final Date deadline = getDeadline( period, days );
-
- final DataSetCompletenessResult result = getDataSetCompleteness( period, deadline, unit, relevantSources, dataSet );
-
+
+ final DataSetCompletenessResult result = getDataSetCompleteness( period, deadline, unit,
+ relevantSources, dataSet );
+
if ( result.getSources() > 0 )
{
batchHandler.addObject( result );
@@ -202,94 +209,101 @@
}
}
}
-
+
log.info( "Exported completeness for data set: " + dataSet );
}
-
+
batchHandler.flush();
-
+
completenessStore.createIndex();
-
+
log.info( "Created index" );
-
+
log.info( "Completeness export process done" );
}
-
+
public Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId, int organisationUnitId )
{
final Period period = periodService.getPeriod( periodId );
-
- int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET );
+
+ int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
+ DEFAULT_COMPLETENESS_OFFSET );
Date deadline = getDeadline( period, days );
-
- final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( organisationUnitId );
-
+
+ final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+ organisationUnitId );
+
final Collection<DataSet> dataSets = dataSetService.getAllDataSets();
-
+
final Collection<DataSetCompletenessResult> results = new ArrayList<DataSetCompletenessResult>();
-
+
for ( final DataSet dataSet : dataSets )
{
final Collection<Integer> relevantSources = getRelevantSources( dataSet, children );
-
+
final DataSetCompletenessResult result = new DataSetCompletenessResult();
-
+
result.setSources( getSources( dataSet, relevantSources ) );
-
+
if ( result.getSources() > 0 )
{
result.setName( dataSet.getName() );
result.setRegistrations( getRegistrations( dataSet, relevantSources, period ) );
- result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources, period, deadline ) : 0 );
-
+ result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources,
+ period, deadline ) : 0 );
+
result.setDataSetId( dataSet.getId() );
result.setPeriodId( periodId );
result.setOrganisationUnitId( organisationUnitId );
-
+
results.add( result );
}
}
-
+
return results;
}
-
- public Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId, Collection<Integer> organisationUnitIds, int dataSetId )
+
+ public Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId,
+ Collection<Integer> organisationUnitIds, int dataSetId )
{
final Period period = periodService.getPeriod( periodId );
- int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET );
+ int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
+ DEFAULT_COMPLETENESS_OFFSET );
Date deadline = getDeadline( period, days );
-
+
final DataSet dataSet = dataSetService.getDataSet( dataSetId );
-
+
final Collection<DataSetCompletenessResult> results = new ArrayList<DataSetCompletenessResult>();
-
+
for ( final Integer unitId : organisationUnitIds )
{
final OrganisationUnit unit = organisationUnitService.getOrganisationUnit( unitId );
-
- final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( unit.getId() );
-
+
+ final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+ unit.getId() );
+
final Collection<Integer> relevantSources = getRelevantSources( dataSet, children );
-
+
final DataSetCompletenessResult result = new DataSetCompletenessResult();
result.setSources( getSources( dataSet, relevantSources ) );
-
+
if ( result.getSources() > 0 )
{
result.setName( unit.getName() );
result.setRegistrations( getRegistrations( dataSet, relevantSources, period ) );
- result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources, period, deadline ) : 0 );
-
+ result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources,
+ period, deadline ) : 0 );
+
result.setDataSetId( dataSetId );
result.setPeriodId( periodId );
result.setOrganisationUnitId( unit.getId() );
-
+
results.add( result );
}
}
-
+
return results;
}
@@ -301,7 +315,7 @@
{
completenessStore.createIndex();
}
-
+
public void dropIndex()
{
completenessStore.dropIndex();
@@ -311,50 +325,53 @@
// Supportive methods
// -------------------------------------------------------------------------
- private DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, Collection<Integer> relevantSources, DataSet dataSet )
- {
+ private DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit,
+ Collection<Integer> relevantSources, DataSet dataSet )
+ {
final DataSetCompletenessResult result = new DataSetCompletenessResult();
-
+
result.setName( unit.getName() );
result.setSources( getSources( dataSet, relevantSources ) );
-
+
if ( result.getSources() > 0 )
- {
+ {
result.setRegistrations( getRegistrations( dataSet, relevantSources, period ) );
- result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources, period, deadline ) : 0 );
-
+ result.setRegistrationsOnTime( deadline != null ? getRegistrationsOnTime( dataSet, relevantSources, period,
+ deadline ) : 0 );
+
result.setDataSetId( dataSet.getId() );
result.setPeriodId( period.getId() );
result.setPeriodName( period.getName() );
result.setOrganisationUnitId( unit.getId() );
}
-
+
return result;
}
-
- @SuppressWarnings("unchecked")
+
+ @SuppressWarnings( "unchecked" )
private Collection<Integer> getRelevantSources( DataSet dataSet, Collection<Integer> sources )
{
- Collection<Integer> dataSetSources = ConversionUtils.getIdentifiers( OrganisationUnit.class, dataSet.getSources() );
-
+ Collection<Integer> dataSetSources = ConversionUtils.getIdentifiers( OrganisationUnit.class,
+ dataSet.getSources() );
+
return CollectionUtils.intersection( dataSetSources, sources );
}
-
+
private Date getDeadline( Period period, int days )
{
Calendar cal = Calendar.getInstance();
-
+
Date date = null;
-
+
if ( period != null )
{
- cal.clear();
- cal.setTime( period.getEndDate() );
+ cal.clear();
+ cal.setTime( period.getEndDate() );
cal.add( Calendar.DAY_OF_MONTH, days );
-
+
date = cal.getTime();
}
-
+
return date;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java 2011-09-02 13:11:12 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java 2011-10-20 13:05:27 +0000
@@ -57,8 +57,11 @@
implements Action
{
private static final String KEY_DATA_COMPLETENESS = "dataSetCompletenessResults";
- private static final String DEFAULT_TYPE = "html";
+
+ private static final String DEFAULT_TYPE = "html";
+
private static final String SPACE = " ";
+
private static final String EMPTY = "";
// -------------------------------------------------------------------------
@@ -92,7 +95,7 @@
{
this.selectionTreeManager = selectionTreeManager;
}
-
+
private I18n i18n;
public void setI18n( I18n i18n )
@@ -151,70 +154,82 @@
throws Exception
{
Grid _grid = (Grid) SessionUtils.getSessionVar( KEY_DATA_COMPLETENESS );
-
- if ( _grid != null && type != null && !type.equals( DEFAULT_TYPE ) ) // Use last grid for any format except html
+
+ if ( _grid != null && type != null && !type.equals( DEFAULT_TYPE ) ) // Use
+ // last
+ // grid
+ // for
+ // any
+ // format
+ // except
+ // html
{
grid = _grid;
-
+
return type;
}
else
- {
+ {
OrganisationUnit selectedUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
-
+
if ( periodId == null || selectedUnit == null || criteria == null )
{
return INPUT;
- }
+ }
else
{
Integer _periodId = periodService.getPeriodByExternalId( periodId ).getId();
-
+
DataSet dataSet = null;
List<DataSetCompletenessResult> mainResults = new ArrayList<DataSetCompletenessResult>();
List<DataSetCompletenessResult> footerResults = new ArrayList<DataSetCompletenessResult>();
-
+
DataSetCompletenessService completenessService = serviceProvider.provide( criteria );
-
- if ( dataSetId != null && dataSetId != 0 ) // One data set for one organisation unit
+
+ if ( dataSetId != null && dataSetId != 0 )
+ // One data set for one organisation unit
{
mainResults = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness(
_periodId, getIdentifiers( OrganisationUnit.class, selectedUnit.getChildren() ), dataSetId ) );
-
- footerResults = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness(
- _periodId, Arrays.asList( selectedUnit.getId() ), dataSetId ) );
-
+
+ footerResults = new ArrayList<DataSetCompletenessResult>(
+ completenessService.getDataSetCompleteness( _periodId, Arrays.asList( selectedUnit.getId() ),
+ dataSetId ) );
+
dataSet = dataSetService.getDataSet( dataSetId );
}
- else // All data sets for children of one organisation unit
+ else
+ // All data sets for children of one organisation unit
{
mainResults = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness(
_periodId, selectedUnit.getId() ) );
}
-
+
grid = getGrid( mainResults, footerResults, selectedUnit, dataSet );
-
- SessionUtils.setSessionVar( KEY_DATA_COMPLETENESS, grid );
+
+ SessionUtils.setSessionVar( KEY_DATA_COMPLETENESS, grid );
}
-
+
return type != null ? type : DEFAULT_TYPE;
- }
+ }
}
-
- private Grid getGrid( List<DataSetCompletenessResult> mainResults, List<DataSetCompletenessResult> footerResults, OrganisationUnit unit, DataSet dataSet )
+
+ private Grid getGrid( List<DataSetCompletenessResult> mainResults, List<DataSetCompletenessResult> footerResults,
+ OrganisationUnit unit, DataSet dataSet )
{
String title = i18n.getString( "data_completeness_report" );
- String subtitle = ( unit != null ? unit.getName() : EMPTY ) + SPACE + ( dataSet != null ? dataSet.getName() : EMPTY );
-
+ String subtitle = (unit != null ? unit.getName() : EMPTY) + SPACE
+ + (dataSet != null ? dataSet.getName() : EMPTY);
+
Grid grid = new ListGrid().setTitle( title ).setSubtitle( subtitle );
-
+
grid.addHeader( new GridHeader( i18n.getString( "name" ), false, true ) );
grid.addHeader( new GridHeader( i18n.getString( "actual" ), false, false ) );
grid.addHeader( new GridHeader( i18n.getString( "target" ), false, false ) );
grid.addHeader( new GridHeader( i18n.getString( "percent" ), false, false ) );
grid.addHeader( new GridHeader( i18n.getString( "on_time" ), false, false ) );
grid.addHeader( new GridHeader( i18n.getString( "percent" ), false, false ) );
-
+
for ( DataSetCompletenessResult result : mainResults )
{
addRow( grid, result );
@@ -224,15 +239,15 @@
{
grid.sortGrid( 4, 1 );
}
-
+
for ( DataSetCompletenessResult result : footerResults )
{
addRow( grid, result );
}
-
+
return grid;
}
-
+
private void addRow( Grid grid, DataSetCompletenessResult result )
{
grid.addRow();