dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09156
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2365: Impl first step of organisation unit distribution report. Located in dhis-web-reporting module.
------------------------------------------------------------
revno: 2365
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-12-13 22:21:33 +0100
message:
Impl first step of organisation unit distribution report. Located in dhis-web-reporting module.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution/
dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/distribution.png
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm
modified:
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSingleSelect.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/index.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionService.java 2010-12-13 21:21:33 +0000
@@ -0,0 +1,12 @@
+package org.hisp.dhis.orgunitdistribution;
+
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+
+public interface OrgUnitDistributionService
+{
+ final String ID = OrgUnitDistributionService.class.getName();
+
+ Grid getOrganisationUnitDistribution( OrganisationUnitGroupSet groupSet, OrganisationUnit parent );
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2010-12-13 17:03:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2010-12-13 21:21:33 +0000
@@ -357,6 +357,7 @@
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 3, unitB ), unitD, unitE ) );
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 4, unitB ), unitH, unitI, unitJ, unitK ) );
}
+
@Test
public void testGetOrganisationUnitsByNameAndGroups()
{
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java 2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java 2010-12-13 21:21:33 +0000
@@ -33,7 +33,6 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2010-12-13 21:21:33 +0000
@@ -54,6 +54,7 @@
return getCount();
}
+ @SuppressWarnings("unchecked")
public Collection<Chart> getChartsBetween( int first, int max )
{
Criteria criteria = getCriteria();
@@ -62,6 +63,8 @@
criteria.setMaxResults( max );
return criteria.list();
}
+
+ @SuppressWarnings("unchecked")
public Collection<Chart> getChartsBetweenByName( String name, int first, int max )
{
Criteria criteria = getCriteria();
=== added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution'
=== added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl'
=== added file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java 2010-12-13 21:21:33 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.orgunitdistribution.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupNameComparator;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
+import org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService;
+import org.hisp.dhis.system.grid.ListGrid;
+import org.springframework.transaction.annotation.Transactional;
+
+public class DefaultOrgUnitDistributionService
+ implements OrgUnitDistributionService
+{
+ private static final Comparator<OrganisationUnit> ORGUNIT_COMPARATOR = new OrganisationUnitNameComparator();
+ private static final Comparator<OrganisationUnitGroup> ORGUNIT_GROUP_COMPARATOR = new OrganisationUnitGroupNameComparator();
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ @Override
+ @Transactional
+ @SuppressWarnings("unchecked")
+ public Grid getOrganisationUnitDistribution( OrganisationUnitGroupSet groupSet, OrganisationUnit parent )
+ {
+ Grid grid = new ListGrid();
+ grid.nextRow();
+
+ List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( parent.getChildren() );
+ List<OrganisationUnitGroup> groups = new ArrayList<OrganisationUnitGroup>( groupSet.getOrganisationUnitGroups() );
+
+ Collections.sort( units, ORGUNIT_COMPARATOR );
+ Collections.sort( groups, ORGUNIT_GROUP_COMPARATOR );
+
+ grid.addValue( "" ); // First header row column is empty
+
+ for ( OrganisationUnitGroup group : groups ) // Header row
+ {
+ grid.addValue( group.getName() );
+ }
+
+ for ( OrganisationUnit unit : units ) // Rows
+ {
+ grid.nextRow();
+ grid.addValue( unit.getName() );
+
+ Collection<OrganisationUnit> subTree = organisationUnitService.getOrganisationUnitWithChildren( unit.getId() );
+
+ for ( OrganisationUnitGroup group : groups ) // Columns
+ {
+ Collection<OrganisationUnit> result = CollectionUtils.intersection( subTree, group.getMembers() );
+
+ grid.addValue( result != null ? String.valueOf( result.size() ) : String.valueOf( 0 ) );
+ }
+ }
+
+ return grid;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-11-10 13:45:42 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-12-13 21:21:33 +0000
@@ -254,6 +254,8 @@
ref="org.hisp.dhis.dashboard.DashboardContentStore"/>
</bean>
+ <!-- Tally Sheet -->
+
<bean id="org.hisp.dhis.tallysheet.TallySheetService"
class="org.hisp.dhis.tallysheet.DefaultTallySheetService">
<property name="dataValueService"
@@ -262,7 +264,15 @@
<bean id="org.hisp.dhis.tallysheet.TallySheetPdfService"
class="org.hisp.dhis.tallysheet.DefaultTallySheetPdfService"/>
-
+
+ <!-- Organisation Unit Distribution -->
+
+ <bean id="org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService"
+ class="org.hisp.dhis.orgunitdistribution.impl.DefaultOrgUnitDistributionService">
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </bean>
+
<!-- DeletionHandler -->
<bean id="org.hisp.dhis.report.ReportDeletionHandler"
=== added directory 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution'
=== added file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java 2010-12-13 21:21:33 +0000
@@ -0,0 +1,67 @@
+package org.hisp.dhis.orgunitdistribution;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.junit.Test;
+
+import static junit.framework.Assert.*;
+
+public class OrgUnitDistributionServiceTest
+ extends DhisSpringTest
+{
+ private OrganisationUnitService organisationUnitService;
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ private OrgUnitDistributionService distributionService;
+
+ @Override
+ public void setUpTest()
+ throws Exception
+ {
+ organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
+
+ organisationUnitGroupService = (OrganisationUnitGroupService) getBean( OrganisationUnitGroupService.ID );
+
+ distributionService = (OrgUnitDistributionService) getBean( OrgUnitDistributionService.ID );
+ }
+
+ @Test
+ public void testGetOrganisationUnitsByNameAndGroups()
+ {
+ OrganisationUnit unitA = createOrganisationUnit( 'A' );
+ OrganisationUnit unitB = createOrganisationUnit( 'B', unitA );
+ unitA.getChildren().add( unitB );
+ OrganisationUnit unitC = createOrganisationUnit( 'C', unitA );
+ unitA.getChildren().add( unitC );
+ organisationUnitService.addOrganisationUnit( unitA );
+ organisationUnitService.addOrganisationUnit( unitB );
+ organisationUnitService.addOrganisationUnit( unitC );
+
+ OrganisationUnitGroup groupA = createOrganisationUnitGroup( 'A' );
+ OrganisationUnitGroup groupB = createOrganisationUnitGroup( 'B' );
+
+ groupA.getMembers().add( unitA );
+ groupA.getMembers().add( unitB );
+ groupB.getMembers().add( unitC );
+
+ organisationUnitGroupService.addOrganisationUnitGroup( groupA );
+ organisationUnitGroupService.addOrganisationUnitGroup( groupB );
+
+ OrganisationUnitGroupSet groupSet = createOrganisationUnitGroupSet( 'A' );
+ groupSet.getOrganisationUnitGroups().add( groupA );
+ groupSet.getOrganisationUnitGroups().add( groupB );
+
+ organisationUnitGroupService.addOrganisationUnitGroupSet( groupSet );
+
+ Grid grid = distributionService.getOrganisationUnitDistribution( groupSet, unitA );
+ assertNotNull( grid );
+ assertEquals( 3, grid.getWidth() );
+ assertEquals( 3, grid.getHeight() );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2010-10-01 18:28:58 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2010-12-13 21:21:33 +0000
@@ -273,7 +273,10 @@
{
linkTag.className = 'selected';
selectedOrganisationUnit.push( childId );
- addSelectedOrganisationUnitABCDEF( childId );
+
+ if ( typeof (window.addSelectedOrganisationUnitABCDEF) == 'function') {
+ addSelectedOrganisationUnitABCDEF( childId );// This code is completely ridiculous and must be removed
+ }
}
var childTag = document.createElement( 'li' );
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm 2010-10-20 06:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm 2010-12-13 21:21:33 +0000
@@ -5,7 +5,7 @@
<thead>
<tr>
<th colspan="2">$i18n.getString( "organisation_unit_selection_tree" )
- <select id="treeSelectedId" name="treeSelectedId" #if( $requied ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
+ <select id="treeSelectedId" name="treeSelectedId" #if( $required ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
</th>
</tr>
</thead>
@@ -54,7 +54,7 @@
function selectedOrganisationUnitXMLABCDEF( xml )
{
- #if( $requied )
+ #if( $required )
selectedOrganisationUnitListABCDEF.empty();
jQuery.each( jQuery( xml ).find( 'unitId'), function(i, item){
@@ -169,7 +169,7 @@
loadOrganisationUnitGroup();
selectionTreeSelection.setMultipleSelectionAllowed( true );
selectedOrganisationUnitListABCDEF = jQuery( "#treeSelectedId" );
- #if( $requied )
+ #if( $required )
selectionTreeSelection.setListenerFunction( selectOrganisationUnitABCDEF );
#end
#if( $cleanAll )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSingleSelect.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSingleSelect.vm 2010-09-14 09:03:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSingleSelect.vm 2010-12-13 21:21:33 +0000
@@ -5,7 +5,7 @@
<thead>
<tr>
<th colspan="2">$i18n.getString( "organisation_unit_selection_tree" )
- <select id="treeSelectedId" name="treeSelectedId" #if( $requied ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
+ <select id="treeSelectedId" name="treeSelectedId" #if( $required ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
</th>
</tr>
</thead>
@@ -38,7 +38,7 @@
jQuery(document).ready( function(){
selectionTreeSelection.setMultipleSelectionAllowed( false );
selectedOrganisationUnitListABCDEF = jQuery( "#treeSelectedId" );
- #if( $requied )
+ #if( $required )
selectionTreeSelection.setListenerFunction( selectOrganisationUnitABCDEF );
#end
#if( $cleanAll )
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/distribution.png'
Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/distribution.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/distribution.png 2010-12-13 21:21:33 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java 2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java 2010-12-13 21:21:33 +0000
@@ -37,9 +37,6 @@
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.chart.comparator.ChartTitleComparator;
import org.hisp.dhis.paging.ActionPagingSupport;
-import org.hisp.dhis.reporttable.ReportTable;
-
-import com.opensymphony.xwork2.Action;
/**
* @author Lars Helge Overland
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java 2010-12-13 15:18:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java 2010-12-13 21:21:33 +0000
@@ -32,13 +32,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.document.Document;
import org.hisp.dhis.document.DocumentService;
import org.hisp.dhis.paging.ActionPagingSupport;
-import org.hisp.dhis.report.Report;
-
-import com.opensymphony.xwork2.Action;
/**
* @author Lars Helge Overland
@@ -68,9 +64,9 @@
{
return documents;
}
-
+
private String key;
-
+
public String getKey()
{
return key;
@@ -90,14 +86,16 @@
if ( isNotBlank( key ) )
{
this.paging = createPaging( documentService.getDocumentCountByName( key ) );
-
- documents = new ArrayList<Document>( documentService.getDocumentsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+
+ documents = new ArrayList<Document>( documentService.getDocumentsBetweenByName( key, paging.getStartPos(),
+ paging.getPageSize() ) );
}
else
{
this.paging = createPaging( documentService.getDocumentCount() );
- documents = new ArrayList<Document>( documentService.getDocumentsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ documents = new ArrayList<Document>( documentService.getDocumentsBetween( paging.getStartPos(), paging
+ .getPageSize() ) );
}
return SUCCESS;
=== added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution'
=== added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action'
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java 2010-12-13 21:21:33 +0000
@@ -0,0 +1,141 @@
+package org.hisp.dhis.reporting.orgunitdistribution.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.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
+import org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetOrgUnitDistributionAction
+ implements Action
+{
+ private static final Comparator<OrganisationUnitGroupSet> GROUPSET_COMPARATOR = new OrganisationUnitGroupSetNameComparator();
+
+ private static final Log log = LogFactory.getLog( GetOrgUnitDistributionAction.class );
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
+ private OrgUnitDistributionService distributionService;
+
+ public void setDistributionService( OrgUnitDistributionService distributionService )
+ {
+ this.distributionService = distributionService;
+ }
+
+ private SelectionTreeManager selectionTreeManager;
+
+ public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+ {
+ this.selectionTreeManager = selectionTreeManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer groupSetId;
+
+ public void setGroupSetId( Integer groupSetId )
+ {
+ this.groupSetId = groupSetId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<OrganisationUnitGroupSet> groupSets;
+
+ public List<OrganisationUnitGroupSet> getGroupSets()
+ {
+ return groupSets;
+ }
+
+ private OrganisationUnitGroupSet selectedGroupSet;
+
+ public OrganisationUnitGroupSet getSelectedGroupSet()
+ {
+ return selectedGroupSet;
+ }
+
+ private Grid distribution;
+
+ public Grid getDistribution()
+ {
+ return distribution;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
+
+ Collections.sort( groupSets, GROUPSET_COMPARATOR );
+
+ OrganisationUnit selectedOrganisationUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
+
+ if ( groupSetId != null && groupSetId > 0 )
+ {
+ selectedGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( groupSetId );
+
+ log.info( "Get distribution for group set: " + selectedGroupSet + " and organisation unit: " + selectedOrganisationUnit );
+
+ distribution = distributionService.getOrganisationUnitDistribution( selectedGroupSet, selectedOrganisationUnit );
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java 2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java 2010-12-13 21:21:33 +0000
@@ -33,7 +33,6 @@
import java.util.Collections;
import java.util.List;
-import org.hisp.dhis.document.Document;
import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-11-29 22:36:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-12-13 21:21:33 +0000
@@ -517,4 +517,17 @@
ref="org.hisp.dhis.tallysheet.TallySheetPdfService"/>
</bean>
+ <!-- Organisation Unit Distribution -->
+
+ <bean id="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction"
+ class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction"
+ scope="prototype">
+ <property name="organisationUnitGroupService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+ <property name="distributionService"
+ ref="org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService"/>
+ <property name="selectionTreeManager"
+ ref="org.hisp.dhis.oust.manager.SelectionTreeManager"/>
+ </bean>
+
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2010-11-23 08:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2010-12-13 21:21:33 +0000
@@ -284,10 +284,16 @@
intro_pivot_table = Browse pivot tables, which can be pivoted on any of the indicator, organisation unit and period dimensions.
intro_report_table = Add and generate report tables. Report tables are highly customizable database tables which can be used as basis for reports.
intro_data_completeness = Browse the submission rates of data sets. This can be viewed by organisation unit and period, and later reported to PDF and Workbook.
+intro_orgunit_distribution_report = Browse the organisation unit distribution report.
+orgunit_distribution_report = Organisation Unit Distribution Report
add_indicator_chart = Add indicator chart
create_period_by_indicator_chart = Create period by indicator chart
value_x_selected_indicators = Value (X) - Selected indicators
value_x_available_indicators = Value (X) - Available indicators
category_y_selected_periods = Value (Y) - Selected periods
category_y_available_periods = Value (Y) - Available periods
-get_current_design = Get current design
\ No newline at end of file
+get_current_design = Get current design
+distribution_report = Distribution Report
+select_group_set = Select group set
+orgunit_distribution = Organisation unit distribution report
+get_report = Get report
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-12-13 21:21:33 +0000
@@ -418,6 +418,17 @@
<param name="bufferSize">1024</param>
</result>
</action>
+
+
+ <!-- Organisation Unit Distribution -->
+
+ <action name="displayOrgUnitDistribution" class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-reporting/viewOrgUnitDistribution.vm</param>
+ <param name="menu">/dhis-web-reporting/menu.vm</param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js</param>
+ <interceptor-ref name="organisationUnitTreeStack" />
+ </action>
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/index.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/index.vm 2010-07-25 13:30:52 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/index.vm 2010-12-13 21:21:33 +0000
@@ -6,6 +6,7 @@
#introListImgItem( "showDataSetReportForm.action" "dataset_report" "datasetreport" )
#introListImgItem( "displayViewDataCompletenessForm.action" "data_completeness" "datacompletenessreport" )
#introListImgItem( "displayViewDocumentForm.action" "static_report" "staticreport" )
+ #introListImgItem( "displayOrgUnitDistribution.action" "orgunit_distribution_report" "distribution" )
#introListImgItem( "tallySheetGenerator.action" "tally_sheet_generator" "tallysheetgenerator" )
#introListImgItem( "displayManageTableForm.action" "report_table" "reporttable" )
#introListImgItem( "displayViewChartForm.action" "chart" "chart" )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2010-07-25 13:30:52 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2010-12-13 21:21:33 +0000
@@ -5,6 +5,7 @@
<li><a href="showDataSetReportForm.action">$i18n.getString( "dataset_report" ) </a></li>
<li><a href="displayViewDataCompletenessForm.action">$i18n.getString( "data_completeness_report" ) </a></li>
<li><a href="displayViewDocumentForm.action">$i18n.getString( "static_report" ) </a></li>
+ <li><a href="displayOrgUnitDistribution.action">$i18n.getString( "distribution_report" ) </a></li>
<li><a href="tallySheetGenerator.action">$i18n.getString( "tally_sheet_generator" ) </a></li>
<li><a href="displayManageTableForm.action">$i18n.getString( "report_table" ) </a></li>
#if( $reportFramework == "birt" )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2010-10-15 08:07:52 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2010-12-13 21:21:33 +0000
@@ -1,10 +1,7 @@
<script type="text/javascript">
-
jQuery(document).ready( function(){
- // Override the listener after tree loaded succesfully
selectionTreeSelection.setListenerFunction( displayCompleteness );
});
-
</script>
<h3>$i18n.getString( "data_completeness_report" )</h3>
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm 2010-12-13 21:21:33 +0000
@@ -0,0 +1,51 @@
+
+<h3>$i18n.getString( "orgunit_distribution" )</h3>
+
+<div id="selectionTree" style="width:325px; height:200px"></div>
+
+<script type="text/javascript">
+selectionTreeSelection.setMultipleSelectionAllowed( false );
+selectionTree.buildSelectionTree();
+</script>
+
+<form action="displayOrgUnitDistribution.action" method="get">
+<p>
+<select id="groupSetId" name="groupSetId" style="width:325px">
+<option value="0">[ $i18n.getString( "select_group_set" ) ]</option>
+#foreach( $groupSet in $groupSets )
+<option value="$groupSet.id"
+#if( $selectedGroupSet.id && $groupSet.id == $selectedGroupSet.id ) selected="selected"#end
+>$!encoder.htmlEncode( $groupSet.name )</option>
+#end
+</select>
+</p>
+
+<p><input type="submit" value="$i18n.getString( 'get_report' )" style="width:100px"></p>
+
+<br>
+
+#if( $distribution )
+
+<table class="listTable">
+
+<thead>
+#foreach( $col in $distribution.getRow( 0 ) )
+<th>$encoder.htmlEncode( $col )</th>
+#end
+</thead>
+
+<tbody>
+#foreach( $row in $distribution.getRows() )
+#if( $velocityCount > 1 )
+<tr>
+#foreach( $col in $row )
+<td>${col}</td>
+#end
+</tr>
+#end
+#end
+</tbody>
+
+</table>
+
+#end
\ No newline at end of file