=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java 2011-04-22 21:04:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java 2011-05-09 10:42:32 +0000 @@ -37,6 +37,7 @@ import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler; import org.hisp.dhis.oust.manager.SelectionTreeManager; @@ -73,7 +74,14 @@ { this.dataElementComparator = dataElementComparator; } - + + private Comparator indicatorComparator; + + public void setIndicatorComparator( Comparator indicatorComparator ) + { + this.indicatorComparator = indicatorComparator; + } + private SelectionTreeManager selectionTreeManager; public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) @@ -111,20 +119,27 @@ return dataSetDataElements; } + private List dataSetIndicators; + + public List getDataSetIndicators() + { + return dataSetIndicators; + } + private DataEntryForm dataEntryForm; - + public DataEntryForm getDataEntryForm() { return dataEntryForm; } - + private DataElementCategoryCombo categoryCombo; public DataElementCategoryCombo getCategoryCombo() { - return categoryCombo; + return categoryCombo; } - + // ------------------------------------------------------------------------- // Action // ------------------------------------------------------------------------- @@ -136,14 +151,18 @@ dataSetDataElements = new ArrayList( dataSet.getDataElements() ); - Collections.sort( dataSetDataElements, dataElementComparator ); - + Collections.sort( dataSetDataElements, dataElementComparator ); + + dataSetIndicators = new ArrayList( dataSet.getIndicators() ); + + Collections.sort( dataSetIndicators, indicatorComparator ); + displayPropertyHandler.handle( dataSetDataElements ); - dataEntryForm = dataSet.getDataEntryForm(); - + dataEntryForm = dataSet.getDataEntryForm(); + selectionTreeManager.setSelectedOrganisationUnits( dataSet.getSources() ); - + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorGroupListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorGroupListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorGroupListAction.java 2011-05-09 10:42:32 +0000 @@ -0,0 +1,81 @@ +package org.hisp.dhis.dataset.action; + +/* + * 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 java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class IndicatorGroupListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List indicatorGroups; + + public List getIndicatorGroups() + { + return indicatorGroups; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + indicatorGroups = new ArrayList( indicatorService.getAllIndicatorGroups() ); + + Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorListFilteredByGroup.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorListFilteredByGroup.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/IndicatorListFilteredByGroup.java 2011-05-09 10:42:32 +0000 @@ -0,0 +1,169 @@ +package org.hisp.dhis.dataset.action; + +/* + * 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 java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class IndicatorListFilteredByGroup + implements Action +{ + private String indicatorGroupId; + + private String selectedIndicators[]; + + private List indicators; + + private Integer dataSetId; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private Comparator indicatorComparator; + + public void setIndicatorComparator( Comparator indicatorComparator ) + { + this.indicatorComparator = indicatorComparator; + } + + private DisplayPropertyHandler displayPropertyHandler; + + public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler ) + { + this.displayPropertyHandler = displayPropertyHandler; + } + + // ------------------------------------------------------------------------- + // Getters & Setters + // ------------------------------------------------------------------------- + + public void setIndicatorGroupId( String indicatorGroupId ) + { + this.indicatorGroupId = indicatorGroupId; + } + + public void setSelectedIndicators( String[] selectedIndicators ) + { + this.selectedIndicators = selectedIndicators; + } + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + public String getIndicatorGroupId() + { + return indicatorGroupId; + } + + public List getIndicators() + { + return indicators; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + if ( indicatorGroupId == null || indicatorGroupId.equals( "ALL" ) ) + { + indicators = new ArrayList( indicatorService.getAllIndicators() ); + } + else + { + IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( Integer.parseInt( indicatorGroupId ) ); + + indicators = new ArrayList( indicatorGroup.getMembers() ); + } + + if ( selectedIndicators != null && selectedIndicators.length > 0 ) + { + Iterator iter = indicators.iterator(); + + while ( iter.hasNext() ) + { + Indicator indicator = iter.next(); + + for ( int i = 0; i < selectedIndicators.length; i++ ) + { + if ( indicator.getId() == Integer.parseInt( selectedIndicators[i] ) ) + { + iter.remove(); + } + } + } + } + + if ( dataSetId != null ) + { + DataSet dataSet = dataSetService.getDataSet( dataSetId ); + + indicators.removeAll( dataSet.getIndicators() ); + } + + Collections.sort( indicators, indicatorComparator ); + + displayPropertyHandler.handle( indicators ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2011-03-03 06:16:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2011-05-09 10:42:32 +0000 @@ -29,11 +29,14 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Set; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; @@ -88,6 +91,13 @@ this.selectedList = selectedList; } + private Collection indicatorSelectedList = new HashSet(); + + public void setIndicatorSelectedList( Collection indicatorSelectedList ) + { + this.indicatorSelectedList = indicatorSelectedList; + } + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -113,6 +123,13 @@ this.dataElementService = dataElementService; } + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + // ------------------------------------------------------------------------- // Action // ------------------------------------------------------------------------- @@ -141,6 +158,13 @@ dataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) ); } + Set indicators = new HashSet(); + + for ( String id : indicatorSelectedList ) + { + indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) ); + } + PeriodType periodType = periodService.getPeriodTypeByName( frequencySelect ); DataSet dataSet = dataSetService.getDataSet( dataSetId ); @@ -150,12 +174,13 @@ dataSet.setCode( code ); dataSet.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) ); dataSet.setDataElements( dataElements ); - + dataSet.setIndicators( indicators ); + if ( dataSet.isMobile() ) { dataSet.setVersion( dataSet.getVersion() + 1 ); // TODO we should check if anything is actually updated before bumping version and push this to service layer } - + dataSetService.updateDataSet( dataSet ); return SUCCESS; === 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 2011-05-08 08:20:31 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-05-09 10:42:32 +0000 @@ -218,7 +218,18 @@ - + + + + + + + + + + @@ -226,6 +237,14 @@ + + + + + + + + + + indicatorListFilteredByGroup + F_DATASET_UPDATE + + + dataElementGroupListEditChain F_DATASET_UPDATE - + + indicatorGroupListEditChain + F_DATASET_UPDATE + + + getDataSetEditChain F_DATASET_UPDATE - + periodTypeListEditChain @@ -213,6 +225,12 @@ /dhis-web-maintenance-dataset/responseDataElementGroup.vm plainTextError + + + /dhis-web-maintenance-dataset/responseIndicatorGroup.vm + plainTextError + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-03-21 10:01:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-05-09 10:42:32 +0000 @@ -106,4 +106,69 @@ + + + ## Available Indicators + ## Filter + ## Selected Indicators + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "available_indicators" )$i18n.getString( "filter" )$i18n.getString( "selected_indicators" )
+ + $i18n.getString( "group" )
$i18n.getString( "name" )
+ + +
+
+
+ +
+ +
+ +
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js 2010-11-20 08:23:34 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js 2011-05-09 10:42:32 +0000 @@ -87,4 +87,49 @@ availableList.add( new Option( name, id ), null ); } -} \ No newline at end of file +} + +function filterByIndicatorGroup( selectedIndicatorGroup ) +{ + var request = new Request(); + + var requestString = 'filterAvailableIndicatorsByIndicatorGroup.action'; + + var params = 'indicatorGroupId=' + selectedIndicatorGroup; + + var selectedList = document.getElementById( 'indicatorSelectedList' ); + + for ( var i = 0; i < selectedList.options.length; ++i) + { + params += '&selectedIndicators=' + selectedList.options[i].value; + } + + // Clear the list + var availableList = document.getElementById( 'indicatorAvailableList' ); + + availableList.options.length = 0; + + request.setResponseTypeXML( 'indicatorGroup' ); + request.setCallbackSuccess( filterByIndicatorGroupCompleted ); + request.sendAsPost( params ); + request.send( requestString ); +} + +function filterByIndicatorGroupCompleted( indicatorGroup ) +{ + var indicators = indicatorGroup.getElementsByTagName( 'indicators' )[0]; + var indicatorList = indicators.getElementsByTagName( 'indicator' ); + + alert(indicatorList.length); + + var availableList = document.getElementById( 'indicatorAvailableList' ); + + for ( var i = 0; i < indicatorList.length; i++ ) + { + var indicator = indicatorList[i]; + var name = indicator.firstChild.nodeValue; + var id = indicator.getAttribute( 'id' ); + + availableList.add( new Option( name, id ), null ); + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseDataElementGroup.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseDataElementGroup.vm 2009-03-03 16:46:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseDataElementGroup.vm 2011-05-09 10:42:32 +0000 @@ -5,4 +5,4 @@ $encoder.xmlEncode( $dataElement.name ) #end - \ No newline at end of file + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseIndicatorGroup.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseIndicatorGroup.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/responseIndicatorGroup.vm 2011-05-09 10:42:32 +0000 @@ -0,0 +1,8 @@ + + + + #foreach( $indicator in $indicators ) + $encoder.xmlEncode( $indicator.name )
+ #end + +