=== removed directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable' === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java 1970-01-01 00:00:00 +0000 @@ -1,135 +0,0 @@ -package org.hisp.dhis.pivottable; - -/* - * 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.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hisp.dhis.aggregation.AggregatedIndicatorValue; -import org.hisp.dhis.common.BaseIdentifiableObject; -import org.hisp.dhis.common.AggregatedValue; -import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class PivotTable -{ - public static final String SEPARATOR = "-"; - - private List indicators = new ArrayList(); - - private List periods = new ArrayList(); - - private List organisationUnits = new ArrayList(); - - private Collection indicatorValues = new ArrayList(); - - // ------------------------------------------------------------------------- - // Constructor - // ------------------------------------------------------------------------- - - public PivotTable() - { - } - - // ------------------------------------------------------------------------- - // Logic - // ------------------------------------------------------------------------- - - public Map getValueMap() - { - Map map = new HashMap(); - - for ( AggregatedValue value : indicatorValues ) - { - String key = value.getElementId() + SEPARATOR + value.getPeriodId() + SEPARATOR + value.getOrganisationUnitId(); - - map.put( key, value.getValue() ); - } - - return map; - } - - public static String getKey( IdentifiableObject element, Period period, OrganisationUnit unit ) - { - String key = element.getId() + SEPARATOR + period.getId() + SEPARATOR + unit.getId(); - - return key; - } - - // ------------------------------------------------------------------------- - // Getters and setters - // ------------------------------------------------------------------------- - - public List getIndicators() - { - return indicators; - } - - public void setIndicators( List indicators ) - { - this.indicators = indicators; - } - - public List getPeriods() - { - return periods; - } - - public void setPeriods( List periods ) - { - this.periods = periods; - } - - public List getOrganisationUnits() - { - return organisationUnits; - } - - public void setOrganisationUnits( List organisationUnits ) - { - this.organisationUnits = organisationUnits; - } - - public Collection getIndicatorValues() - { - return indicatorValues; - } - - public void setIndicatorValues( Collection indicatorValues ) - { - this.indicatorValues = indicatorValues; - } -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTableService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTableService.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTableService.java 1970-01-01 00:00:00 +0000 @@ -1,58 +0,0 @@ -package org.hisp.dhis.pivottable; - -import java.util.List; - -import org.hisp.dhis.common.Grid; - - -/* - * 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. - */ - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public interface PivotTableService -{ - final int DATA_TYPE_INDICATOR = 0; - final int DATA_TYPE_DATA_ELEMENT = 1; - - /** - * Returns a PivotTable object. - * - * @param dataType the type of data, can be 1 for indicator and 2 for data element. - * @param groupId the identifier of the IndicatorGroup. - * @param periodTypeName the identifier of the PeriodType. - * @param startDate the start date string. - * @param endDate the end date string. - * @param level the OrganisationUnit level. - * @return a PivotTable object. - */ - PivotTable getPivotTable( int dataType, int groupId, String periodTypeName, String startDate, String endDate, int level ); - - List getGrids( PivotTable pivotTable ); -} === removed directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable' === removed directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl' === removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java 2012-04-19 20:57:28 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java 1970-01-01 00:00:00 +0000 @@ -1,219 +0,0 @@ -package org.hisp.dhis.pivottable.impl; - -/* - * 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 static org.hisp.dhis.system.util.DateUtils.getMediumDate; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import org.hisp.dhis.aggregation.AggregatedDataValueService; -import org.hisp.dhis.common.AggregatedValue; -import org.hisp.dhis.common.BaseIdentifiableObject; -import org.hisp.dhis.common.Grid; -import org.hisp.dhis.common.GridHeader; -import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.period.comparator.AscendingPeriodComparator; -import org.hisp.dhis.pivottable.PivotTable; -import org.hisp.dhis.pivottable.PivotTableService; -import org.hisp.dhis.system.grid.ListGrid; -import org.hisp.dhis.system.util.ConversionUtils; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DefaultPivotTableService - implements PivotTableService -{ - private static final Comparator PERIOD_COMPARATOR = new AscendingPeriodComparator(); - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private AggregatedDataValueService aggregatedDataValueService; - - public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService ) - { - this.aggregatedDataValueService = aggregatedDataValueService; - } - - private IndicatorService indicatorService; - - public void setIndicatorService( IndicatorService indicatorService ) - { - this.indicatorService = indicatorService; - } - - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - private PeriodService periodService; - - public void setPeriodService( PeriodService periodService ) - { - this.periodService = periodService; - } - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // PivotTableService implementation - // ------------------------------------------------------------------------- - - public PivotTable getPivotTable( int dataType, int groupId, String periodTypeName, String startDate, String endDate, int organisationUnitId ) - { - PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName ); - - List periods = new ArrayList( - periodService.getPeriodsBetweenDates( periodType, getMediumDate( startDate ), getMediumDate( endDate ) ) ); - - List organisationUnits = new ArrayList( - organisationUnitService.getOrganisationUnit( organisationUnitId ).getChildrenThisIfEmpty() ); - - List indicators = null; - Collection aggregatedValues = null; - - if ( dataType == DATA_TYPE_INDICATOR ) - { - if ( groupId == -1 ) // All - { - indicators = new ArrayList( indicatorService.getAllIndicators() ); - - aggregatedValues = aggregatedDataValueService.getAggregatedIndicatorValues( - ConversionUtils.getIdentifiers( Period.class, periods ), - ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnits ) ); - } - else - { - indicators = new ArrayList( indicatorService.getIndicatorGroup( groupId, true ).getMembers() ); - - aggregatedValues = aggregatedDataValueService.getAggregatedIndicatorValues( - ConversionUtils.getIdentifiers( Indicator.class, indicators ), - ConversionUtils.getIdentifiers( Period.class, periods ), - ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnits ) ); - } - } - else if ( dataType == DATA_TYPE_DATA_ELEMENT ) - { - if ( groupId == -1 ) // All - { - indicators = new ArrayList( dataElementService.getAggregateableDataElements() ); - - aggregatedValues = aggregatedDataValueService.getAggregatedDataValueTotals( - ConversionUtils.getIdentifiers( Period.class, periods ), - ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnits ) ); - } - else - { - indicators = new ArrayList( dataElementService.getDataElementGroup( groupId, true ).getMembers() ); - - aggregatedValues = aggregatedDataValueService.getAggregatedDataValueTotals( - ConversionUtils.getIdentifiers( DataElement.class, indicators ), - ConversionUtils.getIdentifiers( Period.class, periods ), - ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnits ) ); - } - } - else - { - throw new IllegalArgumentException( "Illegal data type: " + dataType ); - } - - PivotTable pivotTable = new PivotTable(); - - pivotTable.setIndicators( indicators ); - pivotTable.setPeriods( periods ); - pivotTable.setOrganisationUnits( organisationUnits ); - pivotTable.setIndicatorValues( aggregatedValues ); - - Collections.sort( pivotTable.getIndicators(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( pivotTable.getOrganisationUnits(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( pivotTable.getPeriods(), PERIOD_COMPARATOR ); - - return pivotTable; - } - - public List getGrids( PivotTable pivotTable ) - { - List grids = new ArrayList(); - - Map valueMap = pivotTable.getValueMap(); - - for ( Period period : pivotTable.getPeriods() ) - { - Grid grid = new ListGrid().setTitle( period.getName() ); - - grid.addHeader( new GridHeader( "Organisation unit", false, true ) ); - - for ( IdentifiableObject element : pivotTable.getIndicators() ) - { - grid.addHeader( new GridHeader( element.getName(), false, false ) ); - } - - for ( OrganisationUnit unit : pivotTable.getOrganisationUnits() ) - { - grid.addRow(); - - grid.addValue( unit.getName() ); - - for ( IdentifiableObject element : pivotTable.getIndicators() ) - { - grid.addValue( valueMap.get( PivotTable.getKey( element, period, unit ) ) ); - } - } - - grids.add( grid ); - } - - return grids; - } -} === 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-22 13:14:47 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-24 12:17:30 +0000 @@ -107,16 +107,6 @@ - - - - - - - - - -