=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java 2010-02-22 09:19:15 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java 2010-03-11 19:55:23 +0000 @@ -78,6 +78,7 @@ // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- + private CustomValueService customValueService; public CustomValueService getCustomValueService() @@ -152,7 +153,7 @@ { this.categoryService = categoryService; } - + private I18n i18n; public void setI18n( I18n i18n ) @@ -170,7 +171,6 @@ // ------------------------------------------------------------------------- // Comparator // ------------------------------------------------------------------------- - private Comparator dataElementComparator; public void setDataElementComparator( Comparator dataElementComparator ) @@ -181,7 +181,6 @@ // ------------------------------------------------------------------------- // DisplayPropertyHandler // ------------------------------------------------------------------------- - private DisplayPropertyHandler displayPropertyHandler; public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler ) @@ -192,7 +191,6 @@ // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- - private List customValues = new ArrayList(); public List getCustomValues() @@ -336,7 +334,6 @@ // ------------------------------------------------------------------------- // Input/output // ------------------------------------------------------------------------- - private Integer selectedDataSetId; public void setSelectedDataSetId( Integer selectedDataSetId ) @@ -366,7 +363,6 @@ // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - public String execute() throws Exception { @@ -387,23 +383,23 @@ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) ) { disabled = "disabled"; - } - + } + List dataElements = new ArrayList( dataSet.getDataElements() ); - if ( dataElements.size() == 0 ) + if ( dataElements.isEmpty() ) { return SUCCESS; - } - - Collections.sort( dataElements, dataElementComparator ); - + } + + Collections.sort( dataElements, dataElementComparator ); + orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements ); - - orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements ); + + orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements ); for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos ) - { + { Collection optionCombos = categoryService.sortOptionCombos( categoryCombo ); allOptionCombos.addAll( optionCombos ); @@ -443,24 +439,27 @@ for ( DataElementCategory cat : categoryCombo.getCategories() ) { - catColSpan = catColSpan / cat.getCategoryOptions().size(); - int total = optionCombos.size() / (catColSpan * cat.getCategoryOptions().size()); - Collection cols = new ArrayList( total ); - - for ( int i = 0; i < total; i++ ) + if ( !cat.getCategoryOptions().isEmpty() ) { - cols.add( i ); + catColSpan = catColSpan / cat.getCategoryOptions().size(); + int total = optionCombos.size() / ( catColSpan * cat.getCategoryOptions().size() ); + Collection cols = new ArrayList( total ); + + for ( int i = 0; i < total; i++ ) + { + cols.add( i ); + } + + /* + * TODO Cols are made to be a collection simply to facilitate a + * for loop in the velocity template - there should be a better + * way of "for" doing a loop. + */ + + colRepeat.put( cat.getId(), cols ); + + catRepeat.put( cat.getId(), catColSpan ); } - - /* - * TODO Cols are made to be a collection simply to facilitate a - * for loop in the velocity template - there should be a better - * way of "for" doing a loop. - */ - - colRepeat.put( cat.getId(), cols ); - - catRepeat.put( cat.getId(), catColSpan ); } catColRepeat.put( categoryCombo.getId(), colRepeat ); @@ -527,7 +526,7 @@ dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet ); - cdeFormExists = (dataEntryForm != null); + cdeFormExists = ( dataEntryForm != null ); if ( cdeFormExists ) { @@ -545,7 +544,7 @@ for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos ) { des = (List) orderedDataElements.get( categoryCombo ); - + displayPropertyHandler.handle( des ); Collections.sort( des, new DataElementSortOrderComparator() );