dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33700
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17255: Removed category option groups from data approval web layer
------------------------------------------------------------
revno: 17255
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 22:45:00 +0200
message:
Removed category option groups from data approval web layer
removed:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStateRequest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.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/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js
--
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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalService.java 2014-10-23 20:41:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalService.java 2014-10-23 20:45:00 +0000
@@ -87,8 +87,7 @@
* @return the data approval status.
*/
DataApprovalStatus getDataApprovalStatus( DataSet dataSet, Period period,
- OrganisationUnit organisationUnit,
- DataElementCategoryOptionCombo attributeOptionCombo );
+ OrganisationUnit organisationUnit, DataElementCategoryOptionCombo attributeOptionCombo );
/**
* Returns the data approval status and permissions for a given data set,
@@ -120,9 +119,8 @@
* @return the data approval permissions (including status.)
*/
DataApprovalStatus getDataApprovalStatusAndPermissions( DataSet dataSet, Period period,
- OrganisationUnit organisationUnit,
- Set<CategoryOptionGroup> categoryOptionGroups,
- Set<DataElementCategoryOption> dataElementCategoryOptions );
+ OrganisationUnit organisationUnit, Set<CategoryOptionGroup> categoryOptionGroups,
+ Set<DataElementCategoryOption> dataElementCategoryOptions );
/**
* Returns a list of approval status and permissions for all of the
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStateRequest.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStateRequest.java 2014-08-14 05:46:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStateRequest.java 2014-10-23 20:45:00 +0000
@@ -47,8 +47,6 @@
private String ou;
- private String cog;
-
private String ab;
private Date ad;
@@ -95,18 +93,6 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public String getCog()
- {
- return cog;
- }
-
- public void setCog( String cog )
- {
- this.cog = cog;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getAb()
{
return ab;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2014-10-23 20:41:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2014-10-23 20:45:00 +0000
@@ -156,7 +156,7 @@
if ( status.getState().isApproved() && status.getDataApprovalLevel().getLevel() >= da.getDataApprovalLevel().getLevel() )
{
- it.remove(); // Already approved at this level -- no action needed.
+ it.remove(); // Already approved at this level, no action needed
}
else if ( !status.getState().isApprovable() )
{
@@ -319,6 +319,8 @@
{
tracePrint( "---------------------------------------------------------------------- getDataApprovalStatus" );
+ period = periodService.reloadPeriod( period );
+
tracePrint( "getDataApprovalStatus( " + dataSet.getName() + ", "
+ period.getPeriodType().getName() + " " + period.getName() + " " + period + ", "
+ organisationUnit.getName() + ", "
@@ -370,6 +372,8 @@
{
tracePrint( "---------------------------------------------------------------------- getDataApprovalStatusAndPermissions" );
+ period = periodService.reloadPeriod( period );
+
tracePrint( "getDataApprovalStatusAndPermissions( " + dataSet.getName() + ", "
+ period.getPeriodType().getName() + " " + period.getName() + " " + period + ", "
+ organisationUnit.getName() + ", "
@@ -409,6 +413,8 @@
{
tracePrint( "---------------------------------------------------------------------- getUserDataApprovalsAndPermissions" );
+ period = periodService.reloadPeriod( period );
+
List<List<DataApproval>> userDataApprovals = getUserDataApprovals( dataSets, period );
List<DataApprovalStatus> statusList = new ArrayList<>();
@@ -466,6 +472,8 @@
Set<DataElementCategoryOption> attributeOptions,
boolean isGetStatus )
{
+ dataApproval.setPeriod( periodService.reloadPeriod( dataApproval.getPeriod() ) );
+
if ( ( attributeOptionGroups == null || attributeOptionGroups.isEmpty() )
&& ( attributeOptions == null || attributeOptions.isEmpty() ) )
{
@@ -771,7 +779,7 @@
* @return Permissions along with status
*/
private DataApprovalStatus getPermissions( DataApprovalLevel dal, DataApprovalStatus status, DataApproval da )
- {
+ {
DataApprovalPermissions permissions = new DataApprovalPermissions();
tracePrint( "getPermissions - dal " + ( dal == null ? "(null)" : dal.getName() )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2014-10-23 19:13:58 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2014-10-23 20:45:00 +0000
@@ -32,11 +32,9 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -50,6 +48,7 @@
import org.hisp.dhis.dataapproval.DataApproval;
import org.hisp.dhis.dataapproval.DataApprovalLevel;
import org.hisp.dhis.dataapproval.DataApprovalLevelService;
+import org.hisp.dhis.dataapproval.DataApprovalPermissions;
import org.hisp.dhis.dataapproval.DataApprovalService;
import org.hisp.dhis.dataapproval.DataApprovalStateRequest;
import org.hisp.dhis.dataapproval.DataApprovalStateRequests;
@@ -57,8 +56,6 @@
import org.hisp.dhis.dataapproval.DataApprovalStateResponses;
import org.hisp.dhis.dataapproval.DataApprovalStatus;
import org.hisp.dhis.dataapproval.exceptions.DataApprovalException;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataset.DataSet;
@@ -136,14 +133,10 @@
public void getApprovalState(
@RequestParam String ds,
@RequestParam String pe,
- @RequestParam String ou,
- @RequestParam( required = false ) Set<String> cog,
- @RequestParam( required = false ) String cp, HttpServletResponse response )
+ @RequestParam String ou, HttpServletResponse response )
throws IOException
{
- log.info( "GET " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou
- + (cog == null || cog.isEmpty() ? "" : ("&cog=" + Arrays.toString( cog.toArray() )))
- + (cp == null ? "" : ("&cp=" + cp)) );
+ log.info( "GET " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
DataSet dataSet = dataSetService.getDataSet( ds );
@@ -169,27 +162,11 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
-
- if ( cog != null && !cog.isEmpty() )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroups( response, cog );
-
- if ( categoryOptionGroups == null )
- {
- return;
- }
- }
-
- Set<DataElementCategoryOption> categoryOptions = inputUtils.getAttributeOptions( response, cp );
-
- if ( categoryOptions != null && categoryOptions.isEmpty() )
- {
- return;
- }
-
DataApprovalStatus status = dataApprovalService
- .getDataApprovalStatusAndPermissions( dataSet, period, organisationUnit, categoryOptionGroups, categoryOptions );
+ .getDataApprovalStatusAndPermissions( dataSet, period, organisationUnit, null, null ); //TODO fix category stuff
+
+ DataApprovalPermissions permissions = status.getPermissions();
+ permissions.setState( status.getState().toString() );
JacksonUtils.toJson( response.getOutputStream(), status.getPermissions() );
}
@@ -319,11 +296,9 @@
public void saveApproval(
@RequestParam String ds,
@RequestParam String pe,
- @RequestParam String ou,
- @RequestParam( required = false ) String cog, HttpServletResponse response )
+ @RequestParam String ou, HttpServletResponse response )
{
- log.info( "POST " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou
- + (cog == null ? "" : ("&cog=" + cog)) );
+ log.info( "POST " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
DataSet dataSet = dataSetService.getDataSet( ds );
@@ -349,23 +324,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( cog != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, cog );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
-
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -376,7 +335,7 @@
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, new Date(), user );
+ period, organisationUnit, false, new Date(), user ); //TODO fix category stuff
try
{
@@ -390,8 +349,7 @@
@PreAuthorize( "hasRole('ALL') or hasRole('F_APPROVE_DATA') or hasRole('F_APPROVE_DATA_LOWER_LEVELS')" )
@RequestMapping( method = RequestMethod.POST, value = MULTIPLE_SAVE_RESOURCE_PATH )
- public void saveApprovalMultiple(
- @RequestBody DataApprovalStateRequests dataApprovalStateRequests,
+ public void saveApprovalMultiple( @RequestBody DataApprovalStateRequests dataApprovalStateRequests,
HttpServletResponse response )
{
List<DataApproval> dataApprovalList = new ArrayList<>();
@@ -423,23 +381,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( dataApprovalStateRequest.getCog() != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, dataApprovalStateRequest.getCog() );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
-
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -454,7 +396,7 @@
Date approvalDate = (dataApprovalStateRequest.getAd() == null) ? new Date() : dataApprovalStateRequest.getAd();
dataApprovalList.addAll( makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, approvalDate, user ) );
+ period, organisationUnit, false, approvalDate, user ) );
}
try
@@ -472,11 +414,9 @@
public void acceptApproval(
@RequestParam String ds,
@RequestParam String pe,
- @RequestParam String ou,
- @RequestParam( required = false ) String cog, HttpServletResponse response )
+ @RequestParam String ou, HttpServletResponse response )
{
- log.info( "POST " + RESOURCE_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou
- + (cog == null ? "" : ("&cog=" + cog)) );
+ log.info( "POST " + RESOURCE_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
DataSet dataSet = dataSetService.getDataSet( ds );
@@ -502,22 +442,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( cog != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, cog );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -528,7 +453,7 @@
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, new Date(), user );
+ period, organisationUnit, false, new Date(), user );
try
{
@@ -574,22 +499,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( dataApprovalStateRequest.getCog() != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, dataApprovalStateRequest.getCog() );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -603,7 +513,7 @@
Date approvalDate = (dataApprovalStateRequest.getAd() == null) ? new Date() : dataApprovalStateRequest.getAd();
dataApprovalList.addAll( makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, approvalDate, user ) );
+ period, organisationUnit, false, approvalDate, user ) );
}
try
@@ -625,11 +535,9 @@
public void removeApproval(
@RequestParam Set<String> ds,
@RequestParam String pe,
- @RequestParam String ou,
- @RequestParam( required = false ) String cog, HttpServletResponse response )
+ @RequestParam String ou, HttpServletResponse response )
{
- log.info( "DELETE " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou
- + (cog == null ? "" : ("&cog=" + cog)) );
+ log.info( "DELETE " + RESOURCE_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
Set<DataSet> dataSets = new HashSet<>( manager.getByUid( DataSet.class, ds ) );
@@ -655,23 +563,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( cog != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, cog );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
-
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -686,7 +578,7 @@
for ( DataSet dataSet : dataSets )
{
dataApprovalList.addAll( makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, new Date(), user ) );
+ period, organisationUnit, false, new Date(), user ) );
}
try
@@ -704,11 +596,9 @@
public void unacceptApproval(
@RequestParam String ds,
@RequestParam String pe,
- @RequestParam String ou,
- @RequestParam( required = false ) String cog, HttpServletResponse response )
+ @RequestParam String ou, HttpServletResponse response )
{
- log.info( "DELETE " + RESOURCE_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou
- + (cog == null ? "" : ("&cog=" + cog)) );
+ log.info( "DELETE " + RESOURCE_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
DataSet dataSet = dataSetService.getDataSet( ds );
@@ -734,22 +624,7 @@
return;
}
- Set<CategoryOptionGroup> categoryOptionGroups = null;
- Set<DataElementCategoryOption> categoryOptions = null;
-
- if ( cog != null )
- {
- categoryOptionGroups = inputUtils.getAttributeOptionGroup( response, cog );
-
- if ( categoryOptionGroups == null || categoryOptionGroups.isEmpty() )
- {
- return;
- }
-
- categoryOptions = getCommonOptions( categoryOptionGroups );
- }
-
- DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, categoryOptionGroups );
+ DataApprovalLevel dataApprovalLevel = dataApprovalLevelService.getHighestDataApprovalLevel( organisationUnit, null ); //TODO fix category stuff
if ( dataApprovalLevel == null )
{
@@ -760,7 +635,7 @@
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = makeDataApprovalList( dataApprovalLevel, dataSet,
- period, organisationUnit, categoryOptions, false, new Date(), user );
+ period, organisationUnit, false, new Date(), user );
try
{
@@ -777,42 +652,14 @@
// -------------------------------------------------------------------------
private List<DataApproval> makeDataApprovalList( DataApprovalLevel dataApprovalLevel, DataSet dataSet,
- Period period, OrganisationUnit organisationUnit, Set<DataElementCategoryOption> attributeOptions,
- boolean accepted, Date created, User creator )
+ Period period, OrganisationUnit organisationUnit, boolean accepted, Date created, User creator )
{
List<DataApproval> approvals = new ArrayList<>();
- if ( attributeOptions == null )
- {
- DataElementCategoryOptionCombo combo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
+ DataElementCategoryOptionCombo combo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
- approvals.add( new DataApproval( dataApprovalLevel, dataSet, period, organisationUnit, combo, accepted, created, creator ) );
- }
- else
- {
- for ( DataElementCategoryOption option : attributeOptions )
- {
- for ( DataElementCategoryOptionCombo combo : option.getCategoryOptionCombos() )
- {
- approvals.add( new DataApproval( dataApprovalLevel, dataSet, period, organisationUnit, combo, accepted, created, creator ) );
- }
- }
- }
+ approvals.add( new DataApproval( dataApprovalLevel, dataSet, period, organisationUnit, combo, accepted, created, creator ) );
return approvals;
}
-
- private Set<DataElementCategoryOption> getCommonOptions( Set<CategoryOptionGroup> categoryOptionGroups )
- {
- Iterator<CategoryOptionGroup> it = categoryOptionGroups.iterator();
-
- Set<DataElementCategoryOption> options = it.next().getMembers();
-
- while ( it.hasNext() )
- {
- options.retainAll( it.next().getMembers() );
- }
-
- return options;
- }
}
=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java 1970-01-01 00:00:00 +0000
@@ -1,273 +0,0 @@
-package org.hisp.dhis.reporting.dataapproval.action;
-
-/*
- * Copyright (c) 2004-2014, 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.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hisp.dhis.dataapproval.DataApprovalLevel;
-import org.hisp.dhis.dataapproval.DataApprovalLevelService;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.system.util.Filter;
-import org.hisp.dhis.system.util.FilterUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-public class GetCategoryOptionGroupsAction
- implements Action
-{
- @Autowired
- private DataApprovalLevelService approvalLevelService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Autowired
- private PeriodService periodService;
-
- @Autowired
- private DataElementCategoryService categoryService;
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private String ou;
-
- public void setOu( String ou )
- {
- this.ou = ou;
- }
-
- private String pe;
-
- public void setPe( String pe )
- {
- this.pe = pe;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private List<CategoryOptionGroup> categoryOptionGroups;
-
- public List<CategoryOptionGroup> getCategoryOptionGroups()
- {
- return categoryOptionGroups;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- /**
- * Category option groups will be filtered by i) group sets which are available
- * to the current user through approval levels and ii) the organisation unit
- * level selected.
- */
- @Override
- public String execute()
- throws Exception
- {
- if ( ou != null && pe != null )
- {
- OrganisationUnit unit = organisationUnitService.getOrganisationUnit( ou );
-
- Period period = periodService.getPeriod( pe );
-
- int orgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( unit.getId() );
-
- List<DataApprovalLevel> approvalLevels = approvalLevelService.getUserDataApprovalLevels();
-
- FilterUtils.filter( approvalLevels, new DataApprovalLevelOrgUnitLevelFilter( orgUnitLevel ) );
-
- Set<CategoryOptionGroupSet> groupSets = getCategoryOptionGroupSets( approvalLevels );
-
- categoryOptionGroups = new ArrayList<>( categoryService.getAllCategoryOptionGroups() );
-
- FilterUtils.filter( categoryOptionGroups, new CategoryOptionGroupGroupSetFilter( groupSets ) );
-
- FilterUtils.filter( categoryOptionGroups, new CategoryOptionPeriodOrganisationUnitFilter( period, unit ) );
-
- addNoneGroupIfNoGroupSet( approvalLevels, categoryOptionGroups );
- }
-
- return SUCCESS;
- }
-
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
- /**
- * Adds a category option group with name "none" if the given list of approval
- * levels is not empty and contains at least one level without a category
- * option group set associated with it.
- */
- private void addNoneGroupIfNoGroupSet( List<DataApprovalLevel> approvalLevels, List<CategoryOptionGroup> categoryOptionGroups )
- {
- boolean hasGroupSet = false;
- boolean hasNoGroupSet = false;
-
- for ( DataApprovalLevel level : approvalLevels )
- {
- if ( level.hasCategoryOptionGroupSet() )
- {
- hasGroupSet = true;
- }
- else
- {
- hasNoGroupSet = true;
- }
- }
-
- if ( hasGroupSet && hasNoGroupSet )
- {
- CategoryOptionGroup cog = new CategoryOptionGroup( "[ " + i18n.getString( "none") + " ]" );
- categoryOptionGroups.add( 0, cog );
- }
- }
-
- /**
- * Returns the category option group sets associated with the given list of
- * data approval levels.
- *
- * @param approvalLevels the collection of data approval levels.
- * @return a set of category option group sets.
- */
- private Set<CategoryOptionGroupSet> getCategoryOptionGroupSets( Collection<DataApprovalLevel> approvalLevels )
- {
- Set<CategoryOptionGroupSet> groupSets = new HashSet<>();
-
- for ( DataApprovalLevel level : approvalLevels )
- {
- if ( level != null && level.hasCategoryOptionGroupSet() )
- {
- groupSets.add( level.getCategoryOptionGroupSet() );
- }
- }
-
- return groupSets;
- }
-
- /**
- * Filter for org unit level on data approval levels.
- */
- class DataApprovalLevelOrgUnitLevelFilter
- implements Filter<DataApprovalLevel>
- {
- private int orgUnitLevel;
-
- public DataApprovalLevelOrgUnitLevelFilter( int orgUnitLevel )
- {
- this.orgUnitLevel = orgUnitLevel;
- }
-
- @Override
- public boolean retain( DataApprovalLevel level )
- {
- return level != null && level.getOrgUnitLevel() == orgUnitLevel;
- }
- }
-
- /**
- * Filter for group set on category option groups.
- */
- class CategoryOptionGroupGroupSetFilter
- implements Filter<CategoryOptionGroup>
- {
- private Set<CategoryOptionGroupSet> groupSets;
-
- public CategoryOptionGroupGroupSetFilter( Set<CategoryOptionGroupSet> groupSets )
- {
- this.groupSets = groupSets;
- }
-
- @Override
- public boolean retain( CategoryOptionGroup group )
- {
- return groupSets != null && groupSets.contains( group.getGroupSet() );
- }
- }
-
- /**
- * Filter for group set on period and organisation unit, based on whether
- * any member option groups match the period and organisation unit.
- */
- class CategoryOptionPeriodOrganisationUnitFilter
- implements Filter<CategoryOptionGroup>
- {
- private Period period;
- private OrganisationUnit organisationUnit;
-
- public CategoryOptionPeriodOrganisationUnitFilter( Period period, OrganisationUnit organisationUnit )
- {
- this.period = period;
- this.organisationUnit = organisationUnit;
- }
-
- @Override
- public boolean retain( CategoryOptionGroup group )
- {
- for ( DataElementCategoryOption option : group.getMembers() )
- {
- if ( ( option.getStartDate() == null || option.getStartDate().before( period.getEndDate() ) )
- && ( option.getEndDate() == null || option.getEndDate().after( period.getStartDate() ) ) )
- {
- if ( option.getOrganisationUnits().isEmpty() || organisationUnit.isEqualOrChildOf( option.getOrganisationUnits() ) )
- {
- return true;
- }
- }
- }
-
- return false;
- }
- }
-}
=== 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 2014-08-27 18:04:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2014-10-23 20:45:00 +0000
@@ -117,10 +117,6 @@
scope="prototype">
</bean>
- <bean id="org.hisp.dhis.reporting.dataapproval.action.GetCategoryOptionGroupsAction" class="org.hisp.dhis.reporting.dataapproval.action.GetCategoryOptionGroupsAction"
- scope="prototype">
- </bean>
-
<!-- Data completeness -->
<bean id="org.hisp.dhis.reporting.completeness.action.GetDataCompletenessOptionsAction" class="org.hisp.dhis.reporting.completeness.action.GetDataCompletenessOptionsAction"
=== 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 2014-04-11 11:43:13 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2014-10-23 20:45:00 +0000
@@ -198,11 +198,6 @@
<param name="stylesheets">style/dhis-web-reporting.css</param>
</action>
- <action name="getCategoryOptionGroups" class="org.hisp.dhis.reporting.dataapproval.action.GetCategoryOptionGroupsAction">
- <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonCategoryOptionGroups.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
- </action>
-
<!-- Organisation Unit Distribution -->
<action name="getOrgUnitDistribution" class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm 2014-06-24 16:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm 2014-10-23 20:45:00 +0000
@@ -106,12 +106,6 @@
#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
</div>
-<div class="inputSection" id="categoryOptionGroupSection" style="display:none">
-<label>$i18n.getString( "approval_entity" )</label><br>
-<select id="categoryOptionGroupId" name="categoryOptionGroupId" style="width:330px">
-</select>
-</div>
-
<div class="inputSection">
<input type="button" value='$i18n.getString( "get_data" )' style="width:120px" onclick="dhis2.appr.generateDataReport()">
<input type="button" value='$i18n.getString( "cancel" )' style="width:120px" onclick="dhis2.dsr.hideCriteria()">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js 2014-08-06 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js 2014-10-23 20:45:00 +0000
@@ -4,10 +4,6 @@
dhis2.appr.currentPeriodOffset = 0;
dhis2.appr.permissions = null;
-$( function() {
- dhis2.appr.displayCategoryOptionGroups();
-} );
-
//------------------------------------------------------------------------------
// Report
//------------------------------------------------------------------------------
@@ -44,16 +40,10 @@
}
}
-dhis2.appr.orgUnitSelected = function( orgUnits, orgUnitNames, children )
-{
- dhis2.appr.displayCategoryOptionGroups();
-};
-
dhis2.appr.displayPeriods = function()
{
var periodType = $( "#periodType" ).val();
dhis2.dsr.displayPeriodsInternal( periodType, dhis2.appr.currentPeriodOffset );
- dhis2.appr.displayCategoryOptionGroups();
};
dhis2.appr.displayNextPeriods = function()
@@ -73,34 +63,6 @@
dhis2.appr.periodSelected = function()
{
- dhis2.appr.displayCategoryOptionGroups();
-};
-
-dhis2.appr.displayCategoryOptionGroups = function()
-{
- var ou = selection.getSelected()[0];
- var pe = $( "#periodId" ).val();
-
- if ( !ou || !pe ) {
- return;
- }
-
- var url = "getCategoryOptionGroups.action";
-
- $.getJSON( url, {ou:ou, pe:pe}, function( json ) {
- if ( json.categoryOptionGroups && json.categoryOptionGroups.length > 1 ) {
- var html = "";
- $.each( json.categoryOptionGroups, function( index, group ) {
- html += "<option value=\"" + group.uid + "\" data-dimension=\"" + group.groupSet + "\">" + group.name + "</option>";
- } );
-
- $( "#categoryOptionGroupSection" ).show();
- $( "#categoryOptionGroupId" ).html( html );
- }
- else {
- $( "#categoryOptionGroupSection" ).hide();
- }
- } );
};
dhis2.appr.getDataReport = function()
@@ -110,15 +72,7 @@
pe: $( "#periodId" ).val(),
ou: selection.getSelected()[0]
};
-
- var cog = $( "#categoryOptionGroupId" ).val();
- var cogs = $( "#categoryOptionGroupId :selected" ).data( "dimension" );
-
- if ( cog && cogs ) {
- dataReport.dimension = cogs + ":" + cog;
- dataReport.cog = cog;
- }
-
+
return dataReport;
};
@@ -365,13 +319,13 @@
dhis2.appr.getApprovalUrl = function()
{
var data = dhis2.appr.getDataReport();
- var url = "../api/dataApprovals?ds=" + data.ds + "&pe=" + data.pe + "&ou=" + data.ou + "&cog=" + data.cog;
+ var url = "../api/dataApprovals?ds=" + data.ds + "&pe=" + data.pe + "&ou=" + data.ou;
return url;
};
dhis2.appr.getAcceptanceUrl = function()
{
var data = dhis2.appr.getDataReport();
- var url = "../api/dataApprovals/acceptances?ds=" + data.ds + "&pe=" + data.pe + "&ou=" + data.ou + "&cog=" + data.cog;
+ var url = "../api/dataApprovals/acceptances?ds=" + data.ds + "&pe=" + data.pe + "&ou=" + data.ou;
return url;
};