=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-05-10 12:07:51 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-05-10 16:29:19 +0000 @@ -57,6 +57,7 @@ import org.hisp.dhis.common.view.DimensionalView; import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryDimension; import org.hisp.dhis.dataelement.DataElementGroup; import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataset.DataSet; @@ -153,6 +154,9 @@ private RelativePeriods relatives; @Scanned + private List categoryDimensions = new ArrayList(); + + @Scanned private List dataElementGroups = new ArrayList(); @Scanned @@ -242,6 +246,13 @@ { List objects = new ArrayList(); + List categoryDims = new ArrayList(); + + for ( DataElementCategoryDimension dim : categoryDimensions ) + { + categoryDims.add( dim.getDimension().getDimension() ); + } + if ( DATA_X_DIM_ID.equals( dimension ) ) { if ( !indicators.isEmpty() ) @@ -284,7 +295,13 @@ { objects.add( new BaseDimensionalObject( dimension, organisationUnits ) ); } - else // Dynamic dimension + else if ( categoryDims.contains( dimension ) ) + { + DataElementCategoryDimension categoryDimension = categoryDimensions.get( categoryDims.indexOf( dimension ) ); + + objects.add( new BaseDimensionalObject( dimension, categoryDimension.getItems() ) ); + } + else // Group set { ListMap listMap = new ListMap(); @@ -297,9 +314,7 @@ { listMap.putValue( group.getGroupSet().getUid(), group ); } - - //TODO categories - + if ( listMap.containsKey( dimension ) ) { objects.add( new BaseDimensionalObject( dimension, listMap.get( dimension ) ) ); @@ -709,7 +724,7 @@ } @JsonProperty - @JsonSerialize( contentAs = BaseNameableObject.class ) + @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JsonView( {DetailedView.class, ExportView.class} ) @JacksonXmlElementWrapper( localName = "dataElementOperands", namespace = DxfNamespaces.DXF_2_0) @JacksonXmlProperty( localName = "dataElementOperand", namespace = DxfNamespaces.DXF_2_0) @@ -782,6 +797,16 @@ this.relatives = relatives; } + public List getCategoryDimensions() + { + return categoryDimensions; + } + + public void setCategoryDimensions( List categoryDimensions ) + { + this.categoryDimensions = categoryDimensions; + } + @JsonProperty @JsonView( {DetailedView.class, ExportView.class} ) @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = DxfNamespaces.DXF_2_0) === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDimension.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDimension.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDimension.java 2013-05-10 16:29:19 +0000 @@ -0,0 +1,73 @@ +package org.hisp.dhis.dataelement; + +/* + * 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.List; + +/** +* @author Lars Helge Overland +*/ +public class DataElementCategoryDimension +{ + private int id; + + private DataElementCategory dimension; + + private List items = new ArrayList(); + + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + + public DataElementCategory getDimension() + { + return dimension; + } + + public void setDimension( DataElementCategory dimension ) + { + this.dimension = dimension; + } + + public List getItems() + { + return items; + } + + public void setItems( List items ) + { + this.items = items; + } +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-04-22 17:49:11 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-05-10 16:29:19 +0000 @@ -175,6 +175,14 @@ Collection getDataElementCategoryOptions( Collection identifiers ); /** + * Retrieves the DataElementCategoryOptions with the given uids. + * + * @param uids the uids of the DataElementCategoryOption to retrieve. + * @return a Collection of DataElementCategoryOptions. + */ + Collection getDataElementCategoryOptionsByUid( Collection uids ); + + /** * Retrieves the DataElementCategoryOption with the given name. * * @param name the name. === 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-10 08:28:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2013-05-10 16:29:19 +0000 @@ -54,6 +54,13 @@ @Override public DimensionalObject getDimension( String uid ) { + DataElementCategory cat = identifiableObjectManager.get( DataElementCategory.class, uid ); + + if ( cat != null ) + { + return cat; + } + DataElementGroupSet degs = identifiableObjectManager.get( DataElementGroupSet.class, uid ); if ( degs != null ) @@ -68,18 +75,18 @@ return ougs; } - DataElementCategory cat = identifiableObjectManager.get( DataElementCategory.class, uid ); - - if ( cat != null ) - { - return cat; - } - return null; } public DimensionType getDimensionType( String uid ) { + DataElementCategory cat = identifiableObjectManager.get( DataElementCategory.class, uid ); + + if ( cat != null ) + { + return DimensionType.CATEGORY; + } + DataElementGroupSet degs = identifiableObjectManager.get( DataElementGroupSet.class, uid ); if ( degs != null ) @@ -94,13 +101,6 @@ return DimensionType.ORGANISATIONUNIT_GROUPSET; } - DataElementCategory cat = identifiableObjectManager.get( DataElementCategory.class, uid ); - - if ( cat != null ) - { - return DimensionType.CATEGORY; - } - final Map dimObjectTypeMap = new HashMap(); dimObjectTypeMap.put( DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X ); @@ -117,15 +117,15 @@ @Override public List getAllDimensions() { + Collection dcs = categoryService.getDataDimensionDataElementCategories(); Collection degs = identifiableObjectManager.getAll( DataElementGroupSet.class ); Collection ougs = identifiableObjectManager.getAll( OrganisationUnitGroupSet.class ); - Collection dcs = categoryService.getDataDimensionDataElementCategories(); final List dimensions = new ArrayList(); - + + dimensions.addAll( dcs ); dimensions.addAll( degs ); dimensions.addAll( ougs ); - dimensions.addAll( dcs ); return dimensions; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-04-22 17:49:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-05-10 16:29:19 +0000 @@ -235,6 +235,11 @@ } ); } + public Collection getDataElementCategoryOptionsByUid( Collection uids ) + { + return dataElementCategoryOptionStore.getByUid( uids ); + } + public Collection getAllDataElementCategoryOptions() { return i18n( i18nService, dataElementCategoryOptionStore.getAll() ); === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryDimension.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryDimension.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryDimension.hbm.xml 2013-05-10 16:29:19 +0000 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2013-05-10 12:07:51 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2013-05-10 16:29:19 +0000 @@ -106,6 +106,14 @@ + + + + + + + === modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2013-03-20 12:40:07 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2013-05-10 16:29:19 +0000 @@ -23,6 +23,8 @@ + + @@ -177,6 +179,8 @@ + + @@ -184,6 +188,12 @@ + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2013-05-10 12:07:51 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2013-05-10 16:29:19 +0000 @@ -35,6 +35,7 @@ import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT; import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT_GROUPSET; import static org.hisp.dhis.common.DimensionType.PERIOD; +import static org.hisp.dhis.common.DimensionType.CATEGORY; import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIMS; import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID; import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids; @@ -59,6 +60,8 @@ import org.hisp.dhis.common.DimensionService; import org.hisp.dhis.common.DimensionType; import org.hisp.dhis.common.DimensionalObject; +import org.hisp.dhis.dataelement.DataElementCategoryDimension; +import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementOperandService; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSetService; @@ -108,6 +111,9 @@ private DataElementService dataElementService; @Autowired + private DataElementCategoryService categoryService; + + @Autowired private DataElementOperandService operandService; @Autowired @@ -301,6 +307,8 @@ { DimensionType type = dimensionService.getDimensionType( dimension.getDimension() ); + String dimensionId = dimension.getDimension(); + List uids = getUids( dimension.getItems() ); if ( INDICATOR.equals( type ) ) @@ -371,6 +379,14 @@ chart.setOrganisationUnits( ous ); } + else if ( CATEGORY.equals( type ) ) + { + DataElementCategoryDimension categoryDimension = new DataElementCategoryDimension(); + categoryDimension.setDimension( categoryService.getDataElementCategory( dimensionId ) ); + categoryDimension.getItems().addAll( categoryService.getDataElementCategoryOptionsByUid( uids ) ); + + chart.getCategoryDimensions().add( categoryDimension ); + } else if ( DATAELEMENT_GROUPSET.equals( type ) ) { chart.getDataElementGroups().addAll( dataElementService.getDataElementGroupsByUid( uids ) ); @@ -379,8 +395,6 @@ { chart.getOrganisationUnitGroups().addAll( organisationUnitGroupService.getOrganisationUnitGroupsByUid( uids ) ); } - - //TODO categories and operands } }