=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridValue.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridValue.java 2013-09-12 18:06:02 +0000 @@ -0,0 +1,106 @@ +package org.hisp.dhis.common; + +/* + * Copyright (c) 2004-2013, 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.HashMap; +import java.util.Map; + +/** + * @author Lars Helge Overland + */ +public class GridValue +{ + private Object value; + + private Map attributes = new HashMap(); + + // --------------------------------------------------------------------- + // Constructors + // --------------------------------------------------------------------- + + public GridValue( Object value ) + { + this.value = value; + } + + public GridValue( Object value, Map attributes ) + { + this.value = value; + this.attributes = attributes; + } + + // --------------------------------------------------------------------- + // Logic + // --------------------------------------------------------------------- + + public void attr( Object attribute, Object value ) + { + this.attributes.put( attribute, value ); + } + + public Object attr( Object attribute ) + { + return this.attributes.get( attribute ); + } + + public boolean hasAttr( Object attribute ) + { + return this.attributes.containsKey( attribute ); + } + + @Override + public String toString() + { + return value != null ? value.toString() : null; + } + + // --------------------------------------------------------------------- + // Get and set methods + // --------------------------------------------------------------------- + + public Object getValue() + { + return value; + } + + public void setValue( Object value ) + { + this.value = value; + } + + public Map getAttributes() + { + return attributes; + } + + public void setAttributes( Map attributes ) + { + this.attributes = attributes; + } +} === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2013-09-12 18:06:02 +0000 @@ -36,6 +36,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -44,6 +45,7 @@ import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; +import org.hisp.dhis.common.GridValue; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; @@ -79,6 +81,9 @@ private static final String DEFAULT_HEADER = "Value"; private static final String TOTAL_HEADER = "Total"; private static final String SPACE = " "; + + private static final String ATTR_DE = "de"; + private static final String ATTR_CO = "co"; // ------------------------------------------------------------------------- // Dependencies @@ -194,10 +199,14 @@ for ( DataElement dataElement : dataElements ) { grid.addRow(); - grid.addValue( dataElement.getName() ); // Data element name + grid.addValue( new GridValue( dataElement.getName() ) ); // Data element name for ( DataElementCategoryOptionCombo optionCombo : optionCombos ) // Values { + Map attributes = new HashMap(); + attributes.put( ATTR_DE, dataElement.getUid() ); + attributes.put( ATTR_CO, optionCombo.getUid() ); + Double value = null; if ( selectedUnitOnly ) @@ -211,7 +220,7 @@ value = valueMap.get( dataElement.getUid() + SEPARATOR + optionCombo.getUid() ); } - grid.addValue( value ); + grid.addValue( new GridValue( value, attributes ) ); } if ( categoryCombo.doSubTotals() && !selectedUnitOnly ) // Sub-total @@ -220,7 +229,7 @@ { Double value = subTotalMap.get( dataElement.getUid() + SEPARATOR + categoryOption.getUid() ); - grid.addValue( value ); + grid.addValue( new GridValue( value ) ); } } @@ -228,7 +237,7 @@ { Double value = totalMap.get( String.valueOf( dataElement.getUid() ) ); - grid.addValue( value ); + grid.addValue( new GridValue( value ) ); } } @@ -238,6 +247,8 @@ return grids; } + // TODO convert to sections and render similarily + public Grid getDefaultDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set groups, boolean selectedUnitOnly, I18nFormat format, I18n i18n ) { List dataElements = new ArrayList( dataSet.getDataElements() ); === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2012-09-03 19:48:33 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2013-09-12 18:06:02 +0000 @@ -5,6 +5,11 @@ width: 90px; line-height: 170%; } + +.lAln +{ + text-align: left; +} #parse( "dhis-web-reporting/renderDataSetReportHeader.vm" ) @@ -28,7 +33,8 @@ #foreach( $col in $row ) #set( $index = ( $velocityCount - 1 ) ) -#if( $grid.getVisibleHeaders().get( $index ).meta )$!encoder.htmlEncode( $col )#else $!format.formatValue( $col )#end +#if( $grid.getVisibleHeaders().get( $index ).meta )$!encoder.htmlEncode( $col.value ) +#else$!format.formatValue( $col.value )#end #end #end