=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2010-07-07 10:22:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2010-07-10 12:15:44 +0000 @@ -56,16 +56,13 @@ { } - public Section( DataSet dataSet, List dataElements ) + public Section( String name, String title, DataSet dataSet, List dataElements, Set greyedFields ) { + this.name = name; + this.title = title; this.dataSet = dataSet; this.dataElements = dataElements; - } - - public Section( String name, DataSet dataSet ) - { - this.name = name; - this.dataSet = dataSet; + this.greyedFields = greyedFields; } // ------------------------------------------------------------------------- === added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java 2010-07-10 12:15:44 +0000 @@ -0,0 +1,135 @@ +package org.hisp.dhis.dataset; + +/* + * Copyright (c) 2004-2010, 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 junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.period.MonthlyPeriodType; +import org.junit.Test; + +/** + * @author Lars Helge Overland + */ +public class SectionStoreTest + extends DhisSpringTest +{ + private SectionStore sectionStore; + + private DataSet dataSet; + + private Section sectionA; + private Section sectionB; + private Section sectionC; + + @Override + public void setUpTest() + { + sectionStore = (SectionStore) getBean( SectionStore.ID ); + dataElementService = (DataElementService) getBean( DataElementService.ID ); + dataSetService = (DataSetService) getBean( DataSetService.ID ); + categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID ); + + dataSet = createDataSet( 'A', new MonthlyPeriodType() ); + dataSetService.addDataSet( dataSet ); + + DataElementCategoryCombo categoryCombo = categoryService.getDataElementCategoryComboByName( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME ); + + DataElement dataElementA = createDataElement( 'A', categoryCombo ); + DataElement dataElementB = createDataElement( 'B', categoryCombo ); + dataElementService.addDataElement( dataElementA ); + dataElementService.addDataElement( dataElementB ); + + List dataElements = new ArrayList(); + dataElements.add( dataElementA ); + dataElements.add( dataElementB ); + + Set operands = new HashSet( categoryService.getOperands( dataElements ) ); + + sectionA = new Section( "SectionA", "TitleA", dataSet, dataElements, operands ); + sectionB = new Section( "SectionB", "TitleB", dataSet, dataElements, operands ); + sectionC = new Section( "SectionC", "TitleC", dataSet, dataElements, operands ); + + } + + @Test + public void addGet() + { + int idA = sectionStore.addSection( sectionA ); + int idB = sectionStore.addSection( sectionB ); + int idC = sectionStore.addSection( sectionC ); + + assertEquals( sectionA, sectionStore.getSection( idA ) ); + assertEquals( sectionB, sectionStore.getSection( idB ) ); + assertEquals( sectionC, sectionStore.getSection( idC ) ); + + assertEquals( dataSet, sectionStore.getSection( idA ).getDataSet() ); + assertNotNull( sectionStore.getSection( idA ).getDataElements() ); + assertEquals( 2, sectionStore.getSection( idA ).getDataElements().size() ); + assertNotNull( sectionStore.getSection( idA ).getGreyedFields() ); + assertEquals( 2, sectionStore.getSection( idA ).getGreyedFields().size() ); + } + + @Test + public void delete() + { + int idA = sectionStore.addSection( sectionA ); + int idB = sectionStore.addSection( sectionB ); + int idC = sectionStore.addSection( sectionC ); + + assertNotNull( sectionStore.getSection( idA ) ); + assertNotNull( sectionStore.getSection( idB ) ); + assertNotNull( sectionStore.getSection( idC ) ); + + sectionStore.deleteSection( sectionA ); + + assertNull( sectionStore.getSection( idA ) ); + assertNotNull( sectionStore.getSection( idB ) ); + assertNotNull( sectionStore.getSection( idC ) ); + + sectionStore.deleteSection( sectionB ); + + assertNull( sectionStore.getSection( idA ) ); + assertNull( sectionStore.getSection( idB ) ); + assertNotNull( sectionStore.getSection( idC ) ); + + sectionStore.deleteSection( sectionC ); + + assertNull( sectionStore.getSection( idA ) ); + assertNull( sectionStore.getSection( idB ) ); + assertNull( sectionStore.getSection( idC ) ); + } +} === modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java' --- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2010-05-28 19:17:07 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2010-07-10 12:15:44 +0000 @@ -52,6 +52,7 @@ import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.dataset.SectionService; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; import org.hisp.dhis.expression.Expression; @@ -117,6 +118,8 @@ protected IndicatorService indicatorService; protected DataSetService dataSetService; + + protected SectionService sectionService; protected CompleteDataSetRegistrationService completeDataSetRegistrationService; === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2010-07-07 10:22:14 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2010-07-10 12:15:44 +0000 @@ -902,8 +902,6 @@ for ( DataElement element : dataSet.getDataElements() ) { - log.info( "Data Element in data set: " + element.getId() ); - map.put( element.getId(), element ); }