=== modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/DefineDeTargetAssociationsAction.java' --- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/DefineDeTargetAssociationsAction.java 2011-04-27 17:15:13 +0000 +++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/DefineDeTargetAssociationsAction.java 2011-06-17 10:54:43 +0000 @@ -26,14 +26,11 @@ */ package org.hisp.dhis.detarget.action; -import java.util.Collection; import java.util.HashSet; -import java.util.Set; import org.hisp.dhis.detarget.DeTarget; import org.hisp.dhis.detarget.DeTargetService; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.oust.manager.SelectionTreeManager; import com.opensymphony.xwork2.Action; @@ -64,14 +61,14 @@ { this.deTargetService = deTargetService; } - +/* private OrganisationUnitService organisationUnitService; public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) { this.organisationUnitService = organisationUnitService; } - +*/ // ------------------------------------------------------------------------- // Getters & Setters @@ -91,17 +88,27 @@ public String execute() throws Exception { - Collection rootUnits = selectionTreeManager.getRootOrganisationUnits(); - - Set unitsInTheTree = new HashSet(); - + DeTarget deTarget = deTargetService.getDeTarget( deTargetId ); + + deTarget.updateOrganisationUnits( new HashSet( selectionTreeManager.getReloadedSelectedOrganisationUnits() ) ); + + deTargetService.updateDeTarget( deTarget ); + + //Collection rootUnits = selectionTreeManager.getRootOrganisationUnits(); + + //Set unitsInTheTree = new HashSet(); + + //getUnitsInTheTree( rootUnits, unitsInTheTree ); + /* DeTarget deTarget = deTargetService.getDeTarget( deTargetId ); System.out.println( " DeTarget Id : " + deTarget.getId() + " DETarget Name " + deTarget.getName() ); Set assignedSources = deTarget.getSources(); - assignedSources.removeAll( unitsInTheTree ); + //assignedSources.removeAll( unitsInTheTree ); + + assignedSources.removeAll( assignedSources ); Collection selectedOrganisationUnits = selectionTreeManager.getReloadedSelectedOrganisationUnits(); @@ -112,8 +119,22 @@ System.out.println( " size of selected Organisation Units : " + selectedOrganisationUnits.size() + " Size of assigned Sources " + assignedSources.size() ); deTargetService.updateDeTarget( deTarget ); - + */ return SUCCESS; } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- +/* + private void getUnitsInTheTree( Collection rootUnits, Set unitsInTheTree ) + { + for( OrganisationUnit root : rootUnits ) + { + unitsInTheTree.add( root ); + getUnitsInTheTree( root.getChildren(), unitsInTheTree ); + } + } + */ } === modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/DefineSurveyAssociationsAction.java' --- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/DefineSurveyAssociationsAction.java 2011-04-27 17:15:13 +0000 +++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/DefineSurveyAssociationsAction.java 2011-06-17 10:54:43 +0000 @@ -27,9 +27,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; import java.util.HashSet; -import java.util.Set; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.oust.manager.SelectionTreeManager; @@ -82,17 +80,26 @@ throws Exception { - Collection rootUnits = selectionTreeManager.getRootOrganisationUnits(); - - Set unitsInTheTree = new HashSet(); - - getUnitsInTheTree( rootUnits, unitsInTheTree ); + Survey survey = surveyService.getSurvey( surveyId ); + + survey.updateOrganisationUnits( new HashSet( selectionTreeManager.getReloadedSelectedOrganisationUnits() ) ); + + surveyService.updateSurvey( survey ); + + //Collection rootUnits = selectionTreeManager.getRootOrganisationUnits(); + + // Set unitsInTheTree = new HashSet(); + + //getUnitsInTheTree( rootUnits, unitsInTheTree ); + /* Survey survey = surveyService.getSurvey( surveyId ); Set assignedSources = survey.getSources(); - assignedSources.removeAll( unitsInTheTree ); + assignedSources.removeAll( assignedSources ); + + //assignedSources.removeAll( unitsInTheTree ); Collection selectedOrganisationUnits = selectionTreeManager.getSelectedOrganisationUnits(); @@ -101,14 +108,14 @@ survey.setSources( assignedSources ); surveyService.updateSurvey( survey ); - + */ return SUCCESS; } // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- - +/* private void getUnitsInTheTree( Collection rootUnits, Set unitsInTheTree ) { for( OrganisationUnit root : rootUnits ) @@ -117,4 +124,5 @@ getUnitsInTheTree( root.getChildren(), unitsInTheTree ); } } + */ } === modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/GetSurveyAction.java' --- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/GetSurveyAction.java 2010-09-15 13:23:57 +0000 +++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/GetSurveyAction.java 2011-06-17 10:54:43 +0000 @@ -28,10 +28,13 @@ */ import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.survey.Survey; import org.hisp.dhis.survey.SurveyService; @@ -44,7 +47,7 @@ public class GetSurveyAction implements Action { - private int surveyId; + private Survey survey; @@ -63,20 +66,33 @@ { this.surveyService = surveyService; } - + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + // ------------------------------------------------------------------------- // Getters & Setters // ------------------------------------------------------------------------- - public int getSurveyId() + private Integer surveyId; + + + public void setSurveyId( Integer surveyId ) + { + this.surveyId = surveyId; + } + + + public Integer getSurveyId() { return surveyId; } - public void setSurveyId( int surveyId ) - { - this.surveyId = surveyId; - } public Survey getSurvey() { @@ -104,7 +120,38 @@ { return description; } - + + // ------------------------------------------------------------------------- + // Getters & Setters + // ------------------------------------------------------------------------- + + private List indicatorGroups; + + public List getIndicatorGroups() + { + return indicatorGroups; + } + + private String indicatorGroupId; + + public void setIndicatorGroupId( String indicatorGroupId ) + { + this.indicatorGroupId = indicatorGroupId; + } + + private String selectedIndicators[]; + + public void setSelectedIndicators( String[] selectedIndicators ) + { + this.selectedIndicators = selectedIndicators; + } + + private List indicators; + + public List getIndicators() + { + return indicators; + } // ------------------------------------------------------------------------- // Action // ------------------------------------------------------------------------- @@ -116,12 +163,52 @@ surveyIndicators = new ArrayList( survey.getIndicators() ); + indicatorGroups = new ArrayList( indicatorService.getAllIndicatorGroups() ); + //Collections.sort( surveyIndicators, dataElementComparator ); //displayPropertyHandler.handle( dataSetDataElements ); //dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet ); - + + + if ( indicatorGroupId == null || indicatorGroupId.equalsIgnoreCase( "ALL" ) ) + { + indicators = new ArrayList( indicatorService.getAllIndicators() ); + } + else + { + IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( Integer.parseInt( indicatorGroupId ) ); + + indicators = new ArrayList( indicatorGroup.getMembers() ); + } + // System.out.println("\n\n +++ \n selectedIndicators list is : " + selectedIndicators + " ,selectedIndicators list size is : " + selectedIndicators.length ); + if ( selectedIndicators != null && selectedIndicators.length > 0 ) + { + Iterator iter = indicators.iterator(); + + while ( iter.hasNext() ) + { + Indicator indicator = iter.next(); + //System.out.println("\n\n +++ \n Indicator Id is : " + indicator.getId() + " , Indicator name is :" + indicator.getName() ); + + for ( int i = 0; i < selectedIndicators.length; i++ ) + { + //System.out.println("\n\n +++ \n Indicator Id is : " + indicator.getId() + " , Indicator name is :" + indicator.getName() ); + if ( indicator.getId() == Integer.parseInt( selectedIndicators[i] ) ) + { + iter.remove(); + } + } + } + } + + if ( surveyId != null ) + { + Survey survey = surveyService.getSurvey( surveyId ); + + indicators.removeAll( survey.getIndicators() ); + } return SUCCESS; } } === modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/IndicatorListFilteredByGroup.java' --- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/IndicatorListFilteredByGroup.java 2010-12-29 07:53:18 +0000 +++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/IndicatorListFilteredByGroup.java 2011-06-17 10:54:43 +0000 @@ -109,6 +109,8 @@ public String execute() throws Exception { + //System.out.println("\n\n +++ \n indicatorGroupId is : " + indicatorGroupId ); + if ( indicatorGroupId == null || indicatorGroupId.equalsIgnoreCase( "ALL" ) ) { indicators = new ArrayList( indicatorService.getAllIndicators() ); === modified file 'local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml 2011-01-20 13:19:33 +0000 +++ local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml 2011-06-17 10:54:43 +0000 @@ -83,7 +83,7 @@ - + - + - + + + + - + - + - - + --> - - + === modified file 'local/in/dhis-web-survey/src/main/resources/struts.xml' --- local/in/dhis-web-survey/src/main/resources/struts.xml 2011-01-17 07:45:29 +0000 +++ local/in/dhis-web-survey/src/main/resources/struts.xml 2011-06-17 10:54:43 +0000 @@ -18,30 +18,38 @@ - indicatorGroupListEditChain - + --> - + - getSurveyEditChain - + --> - - + + - + javascript/survey.js,javascript/IndicatorList.js --> + + + + + /main.vm + /dhis-web-survey/editSurvey.vm + javascript/survey.js,javascript/IndicatorList.js + + + @@ -95,71 +103,69 @@ - - /dhis-web-survey/responseIndicatorGroup.vm + /dhis-web-survey/responseIndicatorGroup.vm plainTextError javascript/survey.js + + + + + + + + - - defineSurveyAssociationsFormChain - - - - /main.vm /dhis-web-survey/surveyAssociations.vm ../dhis-web-commons/oust/oust.js,javascript/IndicatorList.js,javascript/associations.js - + + index.action - - - - getNumberOfLevelsSelectLevelChain - + getNumberOfLevelsSelectLevelChain - - getNumberOfLevelsSelectLevelChain - + getNumberOfLevelsSelectLevelChain - - getNumberOfLevelsSelectLevelChain - + getNumberOfLevelsSelectLevelChain getSurveySelectLevelChain - /main.vm /dhis-web-survey/surveyAssociations.vm - - ../dhis-web-commons/oust/oust.js,javascript/IndicatorsList.js,javascript/associations.js - + ../dhis-web-commons/oust/oust.js,javascript/IndicatorsList.js,javascript/associations.js - +--> /dhis-web-survey/responseSurveyObject.vm @@ -345,20 +351,29 @@ - - defineDeTargetAssociationsFormChain + defineDeTargetAssociationsFormChain--> - + - + /main.vm + /dhis-web-survey/deTargetAssociations.vm + ../dhis-web-commons/oust/oust.js,javascript/associations.js--> + + + + + /main.vm /dhis-web-survey/deTargetAssociations.vm ../dhis-web-commons/oust/oust.js,javascript/associations.js - - + + deTargetManagement.action