=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java 2013-12-20 12:55:20 +0000 @@ -0,0 +1,42 @@ +package org.hisp.dhis.dataelement; + +/* + * Copyright (c) 2004-2013, 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.Collection; + +import org.hisp.dhis.common.GenericDimensionalObjectStore; + +/** + * @author Lars Helge Overland + */ +public interface CategoryStore + extends GenericDimensionalObjectStore +{ + Collection getCategoriesByDimensionType( String dimensionType ); +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2013-10-08 17:16:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2013-12-20 12:55:20 +0000 @@ -70,6 +70,8 @@ public static final String DEFAULT_NAME = "default"; private Concept concept; + + private String dimensionType; @Scanned private List categoryOptions = new ArrayList(); @@ -204,6 +206,19 @@ } @JsonProperty + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + public String getDimensionType() + { + return dimensionType; + } + + public void setDimensionType( String dimensionType ) + { + this.dimensionType = dimensionType; + } + + @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JsonView( {DetailedView.class, ExportView.class} ) @JacksonXmlElementWrapper( localName = "categoryOptions", namespace = DxfNamespaces.DXF_2_0 ) === 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-12-20 12:15:39 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-12-20 12:55:20 +0000 @@ -126,6 +126,20 @@ */ Collection getAllDataElementCategories(); + /** + * Retrieves all DataElementCategories of dimension type disaggregation. + * + * @return a collection of DataElementCategoryCombos. + */ + Collection getDisaggregationCategories(); + + /** + * Retrieves all DataElementCategories of dimension type attribute. + * + * @return a collection of DataElementCategoryCombos. + */ + Collection getAttributeCategories(); + // ------------------------------------------------------------------------- // CategoryOption // ------------------------------------------------------------------------- === 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-12-20 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-12-20 12:55:20 +0000 @@ -61,9 +61,9 @@ // Dependencies // ------------------------------------------------------------------------- - private GenericDimensionalObjectStore categoryStore; + private CategoryStore categoryStore; - public void setCategoryStore( GenericDimensionalObjectStore categoryStore ) + public void setCategoryStore( CategoryStore categoryStore ) { this.categoryStore = categoryStore; } @@ -188,7 +188,17 @@ { return i18n( i18nService, categoryStore.getByConcept( concept ) ); } + + public Collection getDisaggregationCategories() + { + return i18n( i18nService, categoryStore.getCategoriesByDimensionType( DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION ) ); + } + public Collection getAttributeCategories() + { + return i18n( i18nService, categoryStore.getCategoriesByDimensionType( DataElementCategoryCombo.DIMENSION_TYPE_ATTTRIBUTE ) ); + } + @Override public Collection getDataElementCategoryBetween( int first, int max ) { === added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateCategoryStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateCategoryStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateCategoryStore.java 2013-12-20 12:55:20 +0000 @@ -0,0 +1,50 @@ +package org.hisp.dhis.dataelement.hibernate; + +/* + * Copyright (c) 2004-2013, 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.Collection; + +import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.common.hibernate.HibernateDimensionalObjectStore; +import org.hisp.dhis.dataelement.CategoryStore; +import org.hisp.dhis.dataelement.DataElementCategory; + +/** + * @author Lars Helge Overland + */ +public class HibernateCategoryStore + extends HibernateDimensionalObjectStore + implements CategoryStore +{ + @SuppressWarnings("unchecked") + public Collection getCategoriesByDimensionType( String dimensionType ) + { + return getCriteria( Restrictions.eq( "dimensionType", dimensionType ) ).list(); + } +} === 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-12-20 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-12-20 12:55:20 +0000 @@ -655,6 +655,7 @@ executeSql( "ALTER TABLE users ALTER COLUMN password DROP NOT NULL" ); executeSql( "update categorycombo set dimensiontype = '" + DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION + "' where dimensiontype is null" ); + executeSql( "update dataelementcategory set dimensiontype = '" + DataElementCategoryCombo.DIMENSION_TYPE_DISAGGREGATION + "' where dimensiontype is null" ); upgradeDataValuesWithAttributeOptionCombo(); upgradeMapViewsToAnalyticalObject(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-12-20 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-12-20 12:55:20 +0000 @@ -137,13 +137,13 @@ - + - @@ -453,8 +453,8 @@ - - + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml 2013-04-22 10:01:08 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml 2013-12-20 12:55:20 +0000 @@ -17,11 +17,11 @@ - - + + @@ -30,5 +30,7 @@ foreign-key="fk_category_categoryoptionid" /> + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryOptionStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryOptionStoreTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryOptionStoreTest.java 2013-12-20 12:55:20 +0000 @@ -59,7 +59,7 @@ @Override public void setUpTest() { - categoryOptionStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.dataelement.DataElementCategoryOptionStore" ); + categoryOptionStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.dataelement.CategoryOptionStore" ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryStoreTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementCategoryStoreTest.java 2013-12-20 12:55:20 +0000 @@ -81,7 +81,7 @@ { categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID ); - categoryStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.dataelement.DataElementCategoryStore" ); + categoryStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.dataelement.CategoryStore" ); conceptA = new Concept( "ConceptA" ); conceptB = new Concept( "ConceptB" ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java 2013-12-20 12:55:20 +0000 @@ -87,6 +87,13 @@ this.conceptId = conceptId; } + private String dimensionType; + + public void setDimensionType( String dimensionType ) + { + this.dimensionType = dimensionType; + } + private List selectedList = new ArrayList(); public void setSelectedList( List selectedList ) @@ -104,6 +111,7 @@ dataElementCategory.setName( name ); dataElementCategory.setDataDimension( dataDimension ); dataElementCategory.setConcept( conceptService.getConcept( conceptId ) ); + dataElementCategory.setDimensionType( dimensionType ); List options = new ArrayList(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/UpdateDataElementCategoryComboAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/UpdateDataElementCategoryComboAction.java 2013-12-20 12:15:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/UpdateDataElementCategoryComboAction.java 2013-12-20 12:55:20 +0000 @@ -75,13 +75,6 @@ this.name = name; } - private String dimensionType; - - public void setDimensionType( String dimensionType ) - { - this.dimensionType = dimensionType; - } - private boolean skipTotal; public void setSkipTotal( boolean skipTotal ) @@ -106,7 +99,6 @@ .getDataElementCategoryCombo( id ); categoryCombo.setName( name ); - categoryCombo.setDimensionType( dimensionType ); categoryCombo.setSkipTotal( skipTotal ); List updatedCategories = new ArrayList(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm 2013-07-19 08:23:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm 2013-12-20 12:55:20 +0000 @@ -56,7 +56,16 @@ - + + +