=== 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 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2014-09-16 16:40:46 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.indicator.Indicator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonView; @@ -66,6 +67,9 @@ @Scanned private List dataElements = new ArrayList<>(); + @Scanned + private List indicators = new ArrayList<>(); + private Set greyedFields = new HashSet<>(); private int sortOrder; @@ -215,6 +219,21 @@ this.dataElements = dataElements; } + @JsonProperty + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlElementWrapper(localName = "indicators", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "indicator", namespace = DxfNamespaces.DXF_2_0) + public List getIndicators() + { + return indicators; + } + + public void setIndicators( List indicators ) + { + this.indicators = indicators; + } + public int getSortOrder() { return sortOrder; === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml 2014-07-21 11:37:05 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/Section.hbm.xml 2014-09-16 16:40:46 +0000 @@ -31,6 +31,14 @@ foreign-key="fk_section_dataelementid" /> + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonSection.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonSection.vm 2014-06-13 07:55:17 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonSection.vm 2014-09-16 16:40:46 +0000 @@ -5,6 +5,7 @@ "name": "$!encoder.jsonEncode( ${section.displayName} )", "dataSet": "$!encoder.jsonEncode( ${section.dataSet.name} )", "categoryCombo": "$!encoder.jsonEncode( ${categoryCombo.name} )", - "dataElementCount": "$!{sectionDataElements.size()}" + "dataElementCount": "$!{sectionDataElements.size()}", + "indicatorCount": "$!{sectionIndicators.size()}" } } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionDataElementsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionDataElementsAction.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionDataElementsAction.java 2014-09-16 16:40:46 +0000 @@ -30,10 +30,10 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; import java.util.List; +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; @@ -66,13 +66,6 @@ this.categoryService = categoryService; } - private Comparator dataElementComparator; - - public void setDataElementComparator( Comparator dataElementComparator ) - { - this.dataElementComparator = dataElementComparator; - } - // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- @@ -136,7 +129,7 @@ } } - Collections.sort( dataElements, dataElementComparator ); + Collections.sort( dataElements, IdentifiableObjectNameComparator.INSTANCE ); return SUCCESS; } === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionIndicatorsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionIndicatorsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetSectionIndicatorsAction.java 2014-09-16 16:40:46 +0000 @@ -0,0 +1,100 @@ +package org.hisp.dhis.commons.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.dataset.Section; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.paging.ActionPagingSupport; + +/* + * Copyright (c) 2004-2014, 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. + */ + +public class GetSectionIndicatorsAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + private List indicators = new ArrayList<>(); + + public List getIndicators() + { + return indicators; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + if ( dataSetId == null ) + { + return SUCCESS; + } + + DataSet dataSet = dataSetService.getDataSet( dataSetId ); + + indicators = new ArrayList<>( dataSet.getIndicators() ); + + for ( Section section : dataSet.getSections() ) + { + indicators.removeAll( section.getIndicators() ); + } + + Collections.sort( indicators, IdentifiableObjectNameComparator.INSTANCE ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2014-08-25 15:20:12 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2014-09-16 16:40:46 +0000 @@ -385,6 +385,11 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2014-08-26 07:05:04 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2014-09-16 16:40:46 +0000 @@ -629,6 +629,13 @@ plainTextError + + + /dhis-web-commons/ajax/jsonIndicators.vm + + plainTextError + + /dhis-web-commons/ajax/jsonDataElementCategories.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java 2014-09-16 16:40:46 +0000 @@ -37,6 +37,8 @@ import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.dataset.SectionService; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorService; import com.opensymphony.xwork2.Action; @@ -61,6 +63,13 @@ this.dataElementService = dataElementService; } + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + private SectionService sectionService; public void setSectionService( SectionService sectionService ) @@ -93,17 +102,25 @@ this.description = description; } - private List selectedList = new ArrayList<>(); - - public void setSelectedList( List selectedList ) - { - this.selectedList = selectedList; + private List selectedDataElementList = new ArrayList<>(); + + public void setSelectedDataElementList( List selectedDataElementList ) + { + this.selectedDataElementList = selectedDataElementList; + } + + private List selectedIndicatorList = new ArrayList<>(); + + public void setSelectedIndicatorList( List selectedIndicatorList ) + { + this.selectedIndicatorList = selectedIndicatorList; } // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- + public String execute() throws Exception { @@ -118,12 +135,20 @@ List selectedDataElements = new ArrayList<>(); - for ( String id : selectedList ) + for ( String id : selectedDataElementList ) { selectedDataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) ); } + + List selectedIndicators = new ArrayList<>(); + + for ( String id : selectedIndicatorList ) + { + selectedIndicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) ); + } section.setDataElements( selectedDataElements ); + section.setIndicators( selectedIndicators ); dataSet.getSections().add( section ); sectionService.addSection( section ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java 2014-09-16 16:40:46 +0000 @@ -28,17 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; import java.util.List; -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.dataset.SectionService; @@ -59,13 +53,6 @@ this.sectionService = sectionService; } - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -124,7 +111,7 @@ // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - + public String execute() throws Exception { @@ -132,38 +119,8 @@ dataSet = section.getDataSet(); - dataElementOfDataSet = new ArrayList<>( dataSet.getDataElements() ); - - Collection
sections = dataSet.getSections(); - - for ( Section s : sections ) - { - dataElementOfDataSet.removeAll( s.getDataElements() ); - } - categoryCombo = section.getCategoryCombo(); - if ( categoryCombo != null ) - { - Iterator dataElementIterator = dataElementOfDataSet.iterator(); - - while ( dataElementIterator.hasNext() ) - { - DataElement de = dataElementIterator.next(); - - if ( !de.getCategoryCombo().equals( categoryCombo ) ) - { - dataElementIterator.remove(); - } - } - } - - dataElementGroups = new ArrayList<>( dataElementService.getAllDataElementGroups() ); - - Collections.sort( dataElementOfDataSet, new IdentifiableObjectNameComparator() ); - - Collections.sort( dataElementGroups, IdentifiableObjectNameComparator.INSTANCE ); - return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GetSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GetSectionAction.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GetSectionAction.java 2014-09-16 16:40:46 +0000 @@ -37,6 +37,7 @@ import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.dataset.SectionService; +import org.hisp.dhis.indicator.Indicator; import com.opensymphony.xwork2.Action; @@ -84,6 +85,13 @@ return sectionDataElements; } + private List sectionIndicators; + + public void setSectionIndicators( List sectionIndicators ) + { + this.sectionIndicators = sectionIndicators; + } + private DataElementCategoryCombo categoryCombo; public void setCategoryCombo( DataElementCategoryCombo categoryCombo ) @@ -107,9 +115,12 @@ sectionDataElements = new ArrayList<>( section.getDataElements() ); + sectionIndicators = new ArrayList<>( section.getIndicators() ); + categoryCombo = section.getDataElements().iterator().next().getCategoryCombo(); Collections.sort( sectionDataElements, new IdentifiableObjectNameComparator() ); + Collections.sort( sectionIndicators, new IdentifiableObjectNameComparator() ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java 2014-09-16 16:40:46 +0000 @@ -37,6 +37,8 @@ import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.dataset.SectionService; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorService; import com.opensymphony.xwork2.Action; @@ -63,6 +65,13 @@ this.dataElementService = dataElementService; } + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + private DataSetService dataSetService; public void setDataSetService( DataSetService dataSetService ) @@ -95,11 +104,18 @@ this.description = description; } - private List selectedList = new ArrayList<>(); - - public void setSelectedList( List selectedList ) - { - this.selectedList = selectedList; + private List selectedDataElementList = new ArrayList<>(); + + public void setSelectedDataElementList( List selectedDataElementList ) + { + this.selectedDataElementList = selectedDataElementList; + } + + private List selectedIndicatorList = new ArrayList<>(); + + public void setSelectedIndicatorList( List selectedIndicatorList ) + { + this.selectedIndicatorList = selectedIndicatorList; } // ------------------------------------------------------------------------- @@ -109,14 +125,20 @@ public String execute() throws Exception { + Section section = sectionService.getSection( sectionId.intValue() ); + List dataElements = new ArrayList<>(); - Section section = sectionService.getSection( sectionId.intValue() ); - - for ( String id : selectedList ) - { - DataElement d = dataElementService.getDataElement( Integer.parseInt( id ) ); - dataElements.add( d ); + for ( String id : selectedDataElementList ) + { + dataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) ); + } + + List indicators = new ArrayList<>(); + + for ( String id : selectedIndicatorList ) + { + indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) ); } DataSet dataSet = section.getDataSet(); @@ -130,6 +152,7 @@ } section.setDataElements( dataElements ); + section.setIndicators( indicators ); section.setName( sectionName ); section.setDescription( description ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2014-07-16 15:41:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2014-09-16 16:40:46 +0000 @@ -14,6 +14,7 @@ + - + @@ -55,12 +72,12 @@ - - - - - - + + + + + + @@ -73,23 +90,66 @@ - - - - - - + + + + + + + + + +
- - -
-
-
- -
- - -

-

+ +
+
+
+
+ +
+ + +

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm 2014-07-21 11:37:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm 2014-09-16 16:40:46 +0000 @@ -1,11 +1,11 @@ @@ -75,18 +92,18 @@ + + + +
$i18n.getString( "available_indicators" )$i18n.getString( "selected_indicators" )
+ + +
+
+
+ +
+ + +

+

- + -
-
-
- +
+
+
+
- #foreach ( $dataElement in $section.dataElements ) #end @@ -94,8 +111,55 @@ -

-

+

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107,5 +171,4 @@ -
$i18n.getString( "available_indicators" )$i18n.getString( "selected_indicators" )
+ + +
+
+
+ +
+ + +

+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 2011-08-19 21:33:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 2014-09-16 16:40:46 +0000 @@ -3,7 +3,8 @@ form.submit(); }, { 'beforeValidateHandler' : function() { - selectAllById('selectedList'); + selectAllById('selectedDataElementList'); + selectAllById('selectedIndicatorList'); }, 'rules' : getValidationRules("section") }); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 2011-08-19 21:33:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 2014-09-16 16:40:46 +0000 @@ -3,7 +3,8 @@ form.submit(); }, { 'beforeValidateHandler' : function() { - selectAllById('selectedList'); + selectAllById('selectedDataElementList'); + selectAllById('selectedIndicatorList'); }, 'rules' : getValidationRules("section") });