dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37960
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19392: Removed utils methods, replaced with guava methods.
------------------------------------------------------------
revno: 19392
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-06-14 14:54:38 +0200
message:
Removed utils methods, replaced with guava methods.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/ListUtils.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java
--
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/dataanalysis/DataAnalysisService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 2015-05-03 12:08:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 2015-06-14 12:54:38 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Date;
+import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.datavalue.DeflatedDataValue;
@@ -45,6 +46,6 @@
final int MAX_OUTLIERS = 500;
- Collection<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits, Collection<DataElement> dataElements,
+ List<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits, Collection<DataElement> dataElements,
Collection<Period> periods, Double stdDevFactor, Date from );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 2015-05-03 12:08:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 2015-06-14 12:54:38 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -78,9 +79,9 @@
* @param periods the periods.
* @param organisationUnits the organisation units.
* @param limit the max limit of violations to return.
- * @return a collection of data value violations.
+ * @return a list of data value violations.
*/
- Collection<DeflatedDataValue> getMinMaxViolations( Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos,
+ List<DeflatedDataValue> getMinMaxViolations( Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos,
Collection<Period> periods, Collection<OrganisationUnit> organisationUnits, int limit );
/**
@@ -92,9 +93,9 @@
* @param organisationUnit the OrganisationUnit.
* @param lowerBound the lower bound for the registered MinMaxDataElement.
* @param upperBound the upper bound for the registered MinMaxDataElement.
- * @return
+ * @return a list of DeflatedDataValues.
*/
- Collection<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
+ List<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, Map<Integer, Integer> lowerBoundMap, Map<Integer, Integer> upperBoundMap );
/**
@@ -103,7 +104,7 @@
*
* @param organisationUnit the source OrganisationUnit.
* @param limit the maximum number of DeflatedDataValues to return.
- * @return a collection of DeflatedDataValues.
+ * @return a list of DeflatedDataValues.
*/
- Collection<DeflatedDataValue> getFollowupDataValues( OrganisationUnit organisationUnit, int limit );
+ List<DeflatedDataValue> getFollowupDataValues( OrganisationUnit organisationUnit, int limit );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-14 12:36:27 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-14 12:54:38 +0000
@@ -148,6 +148,8 @@
import org.hisp.dhis.util.Timer;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.inject.internal.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -409,7 +411,7 @@
for ( Map.Entry<String, Double> entry : aggregatedDataMap.entrySet() )
{
- List<String> dataRow = ListUtils.getList( entry.getKey().split( DIMENSION_SEP ) );
+ List<String> dataRow = Lists.newArrayList( entry.getKey().split( DIMENSION_SEP ) );
List<String> targetRow = ListUtils.getAtIndexes( dataRow, completenessDimIndexes );
String targetKey = StringUtils.join( targetRow, DIMENSION_SEP );
@@ -1005,7 +1007,7 @@
{
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORY_OPTION_COMBO, null, DISPLAY_NAME_CATEGORYOPTIONCOMBO, new ArrayList<NameableObject>() );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( PERIOD_DIM_ID.equals( dimension ) )
@@ -1053,7 +1055,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.PERIOD, null, DISPLAY_NAME_PERIOD, asList( periodList ) );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( ORGUNIT_DIM_ID.equals( dimension ) )
@@ -1138,7 +1140,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT, null, DISPLAY_NAME_ORGUNIT, orgUnits );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( PROGRAM_INDICATOR_DIM_ID.equals( dimension ) )
@@ -1147,21 +1149,21 @@
DimensionalObject object = new BaseDimensionalObject( PROGRAM_INDICATOR_DIM_ID, DimensionType.PROGRAM_INDICATOR, null, DISPLAY_NAME_PROGRAM_INDICATOR, indicators );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( LONGITUDE_DIM_ID.contains( dimension ) )
{
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.STATIC, null, DISPLAY_NAME_LONGITUDE, new ArrayList<NameableObject>() );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( LATITUDE_DIM_ID.contains( dimension ) )
{
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.STATIC, null, DISPLAY_NAME_LATITUDE, new ArrayList<NameableObject>() );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
OrganisationUnitGroupSet ougs = idObjectManager.get( OrganisationUnitGroupSet.class, dimension );
@@ -1172,7 +1174,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT_GROUPSET, null, ougs.getDisplayName(), ous, allItems );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
DataElementGroupSet degs = idObjectManager.get( DataElementGroupSet.class, dimension );
@@ -1183,7 +1185,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.DATAELEMENT_GROUPSET, null, degs.getDisplayName(), des, allItems );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
CategoryOptionGroupSet cogs = idObjectManager.get( CategoryOptionGroupSet.class, dimension );
@@ -1194,7 +1196,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORYOPTION_GROUPSET, null, cogs.getDisplayName(), cogz, allItems );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
DataElementCategory dec = idObjectManager.get( DataElementCategory.class, dimension );
@@ -1205,7 +1207,7 @@
DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORY, null, dec.getDisplayName(), decos, allItems );
- return ListUtils.getList( object );
+ return Lists.newArrayList( object );
}
if ( allowNull )
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2015-05-28 15:04:54 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2015-06-14 12:54:38 +0000
@@ -215,6 +215,11 @@
}
}
+ public void moveDataDimensionFirst( DataQueryParams params )
+ {
+
+ }
+
@Override
public DataQueryGroups planQuery( DataQueryParams params, int optimalQueries, String tableName )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java 2015-05-28 15:04:54 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java 2015-06-14 12:54:38 +0000
@@ -47,9 +47,10 @@
import org.hisp.dhis.common.DimensionalObjectUtils;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.util.ListUtils;
import org.junit.Test;
+import com.google.inject.internal.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -116,11 +117,11 @@
{
DataQueryParams params = new DataQueryParams();
params.getDimensions().add( new BaseDimensionalObject( DimensionalObject.INDICATOR_DIM_ID, DimensionType.INDICATOR, null, null,
- ListUtils.getList( createIndicator( 'A', null ), createIndicator( 'B', null ) ) ) );
+ Lists.newArrayList( createIndicator( 'A', null ), createIndicator( 'B', null ) ) ) );
params.getDimensions().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, null, null,
- ListUtils.getList( createOrganisationUnit( 'A' ), createOrganisationUnit( 'B' ) ) ) );
+ Lists.newArrayList( createOrganisationUnit( 'A' ), createOrganisationUnit( 'B' ) ) ) );
params.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, null, null,
- ListUtils.getList( createPeriod( "201201" ), createPeriod( "201202" ) ) ) );
+ Lists.newArrayList( createPeriod( "201201" ), createPeriod( "201202" ) ) ) );
assertEquals( 2, params.getDimensions().size() );
assertEquals( 1, params.getFilters().size() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java 2015-05-28 18:21:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java 2015-06-14 12:54:38 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -95,7 +96,7 @@
// -------------------------------------------------------------------------
@Override
- public Collection<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits,
+ public List<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits,
Collection<DataElement> dataElements, Collection<Period> periods, Double stdDevFactor, Date from )
{
Set<DataElement> elements = new HashSet<>( dataElements );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2015-06-14 12:54:38 +0000
@@ -33,6 +33,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -70,14 +71,14 @@
// -------------------------------------------------------------------------
@Override
- public final Collection<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits,
+ public final List<DeflatedDataValue> analyse( Collection<OrganisationUnit> organisationUnits,
Collection<DataElement> dataElements, Collection<Period> periods, Double stdDevFactor, Date from )
{
log.info( "Starting std dev analysis, no of org units: " + organisationUnits.size() + ", factor: " + stdDevFactor + ", from: " + from );
Set<Integer> units = new HashSet<>( ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnits ) );
- Collection<DeflatedDataValue> outlierCollection = new ArrayList<>();
+ List<DeflatedDataValue> outlierCollection = new ArrayList<>();
loop : for ( DataElement dataElement : dataElements )
{
@@ -86,7 +87,7 @@
if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
{
- Collection<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo()
+ Set<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo()
.getOptionCombos();
for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java 2015-06-14 12:54:38 +0000
@@ -164,7 +164,7 @@
}
@Override
- public Collection<DeflatedDataValue> getMinMaxViolations( Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos,
+ public List<DeflatedDataValue> getMinMaxViolations( Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos,
Collection<Period> periods, Collection<OrganisationUnit> organisationUnits, int limit )
{
if ( dataElements.isEmpty() || categoryOptionCombos.isEmpty() || periods.isEmpty() || organisationUnits.isEmpty() )
@@ -202,7 +202,7 @@
}
@Override
- public Collection<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
+ public List<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, Map<Integer, Integer> lowerBoundMap, Map<Integer, Integer> upperBoundMap )
{
if ( lowerBoundMap == null || lowerBoundMap.isEmpty() || periods.isEmpty() )
@@ -216,7 +216,7 @@
log.debug( "No of pages: " + organisationUnitPages.size() );
- Collection<DeflatedDataValue> dataValues = new ArrayList<>();
+ List<DeflatedDataValue> dataValues = new ArrayList<>();
for ( List<Integer> unitPage : organisationUnitPages )
{
@@ -226,7 +226,7 @@
return dataValues;
}
- private Collection<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
+ private List<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, List<Integer> organisationUnits, Map<Integer, Integer> lowerBoundMap, Map<Integer, Integer> upperBoundMap )
{
String periodIds = TextUtils.getCommaDelimitedString( ConversionUtils.getIdentifiers( Period.class, periods ) );
@@ -257,7 +257,7 @@
}
@Override
- public Collection<DeflatedDataValue> getFollowupDataValues( OrganisationUnit organisationUnit, int limit )
+ public List<DeflatedDataValue> getFollowupDataValues( OrganisationUnit organisationUnit, int limit )
{
final String idLevelColumn = "idlevel" + organisationUnit.getOrganisationUnitLevel();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisServiceTest.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisServiceTest.java 2015-06-14 12:54:38 +0000
@@ -34,6 +34,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@@ -55,10 +56,11 @@
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.util.ListUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.inject.internal.Lists;
+
/**
* @author eirikmi
* @version $Id: MinMaxOutlierAnalysisServiceTest.java 883 2009-05-15 00:42:45Z daghf $
@@ -198,7 +200,7 @@
periods.add( periodA );
periods.add( periodE );
- Collection<DeflatedDataValue> result = minMaxOutlierAnalysisService.analyse( ListUtils.getCollection( organisationUnitA ), dataElementsA, periods, null, from );
+ List<DeflatedDataValue> result = minMaxOutlierAnalysisService.analyse( Lists.newArrayList( organisationUnitA ), dataElementsA, periods, null, from );
assertEquals( 2, result.size() );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisServiceTest.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisServiceTest.java 2015-06-14 12:54:38 +0000
@@ -35,6 +35,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@@ -54,10 +55,11 @@
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.util.ListUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.inject.internal.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -204,8 +206,8 @@
periods.add( periodA );
periods.add( periodE );
- Collection<DeflatedDataValue> values = stdDevOutlierAnalysisService.analyse(
- ListUtils.getCollection( organisationUnitA ), dataElementsA, periods, stdDevFactor, from );
+ List<DeflatedDataValue> values = stdDevOutlierAnalysisService.analyse(
+ Lists.newArrayList( organisationUnitA ), dataElementsA, periods, stdDevFactor, from );
double lowerBound = -34.51 * stdDevFactor;
double upperBound = 34.51 * stdDevFactor;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java 2015-06-01 23:57:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java 2015-06-14 12:54:38 +0000
@@ -554,34 +554,7 @@
+ " unaccept=" + ( p.isMayUnaccept() ? "T" : "F" )
+ " read=" + ( p.isMayReadData() ? "T" : "F" );
}
-
- /**
- * Returns approval status and permissions information as a string.
- * This allows a test to compare the result against a string and test
- * several things at once. More importantly, it shows in the log
- * all of the ways in which the test status and permissions differs from
- * expected, instead of showing only one different value. This can
- * save time in understanding the difference between the expected value
- * and the test result.
- *
- * @param mockUserService user to execute the test
- * @param dataSet Approval data set
- * @param period Approval period
- * @param organisationUnit Approval orgaisation unit
- * @param attributeOptionCombo Approval attribute option combination
- * @return A String representing the state, level, and allowed user actions
- */
- private String getStatusAndPermissions( CurrentUserService mockUserService, DataSet dataSet,
- Period period, OrganisationUnit organisationUnit,
- DataElementCategoryOptionCombo attributeOptionCombo )
- {
- setUser( mockUserService );
-
- DataApprovalStatus status = dataApprovalService.getDataApprovalStatusAndPermissions( dataSet, period, organisationUnit, attributeOptionCombo );
-
- return getStatusString( status );
- }
-
+
private String[] getUserApprovalsAndPermissions( CurrentUserService mockUserService, DataSet dataSet, Period period, OrganisationUnit orgUnit )
{
setUser( mockUserService );
=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/ListUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/ListUtils.java 2015-06-14 11:58:26 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/ListUtils.java 2015-06-14 12:54:38 +0000
@@ -28,11 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.apache.commons.lang3.StringUtils;
-
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -40,6 +37,8 @@
import java.util.List;
import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+
/**
* @author Lars Helge Overland
*/
@@ -199,45 +198,7 @@
return duplicates;
}
-
- /**
- * Returns a Collection with the given items.
- *
- * @param items the items which should be included in the Collection.
- * @return a Collection.
- */
- @SafeVarargs
- public static final <T> Collection<T> getCollection( final T... items )
- {
- List<T> list = new ArrayList<>();
-
- for ( T item : items )
- {
- list.add( item );
- }
-
- return list;
- }
-
- /**
- * Returns a List with the given items.
- *
- * @param items the items which should be included in the List.
- * @return a List.
- */
- @SafeVarargs
- public static final <T> List<T> getList( final T... items )
- {
- List<T> list = new ArrayList<>();
-
- for ( T item : items )
- {
- list.add( item );
- }
-
- return list;
- }
-
+
/**
* Removes empty strings from the given list. Empty includes null.
*
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2015-05-28 16:10:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2015-06-14 12:54:38 +0000
@@ -28,8 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.util.ListUtils.getCollection;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -57,6 +55,7 @@
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Sets;
import com.opensymphony.xwork2.Action;
/**
@@ -237,8 +236,8 @@
for ( OrganisationUnit organisationUnit : organisationUnits )
{
- List<DeflatedDataValue> values = new ArrayList<>( minMaxOutlierAnalysisService.analyse( getCollection( organisationUnit ),
- dataSet.getDataElements(), getCollection( period ), null, from ) );
+ List<DeflatedDataValue> values = new ArrayList<>( minMaxOutlierAnalysisService.analyse( Sets.newHashSet( organisationUnit ),
+ dataSet.getDataElements(), Sets.newHashSet( period ), null, from ) );
if ( !values.isEmpty() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java 2015-06-10 20:22:17 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java 2015-06-14 12:54:38 +0000
@@ -28,6 +28,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.Validate;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -48,23 +56,16 @@
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.filter.OrganisationUnitWithDataSetsFilter;
import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
-import org.hisp.dhis.util.FilterUtils;
-import org.hisp.dhis.util.ListUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.util.FilterUtils;
import org.hisp.dhis.validation.ValidationResult;
import org.hisp.dhis.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleService;
import org.joda.time.DateTime;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.Sets;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -158,10 +159,10 @@
Date from = new DateTime( period.getStartDate() ).minusYears( 2 ).toDate();
Collection<DeflatedDataValue> stdDevs = stdDevOutlierAnalysisService.analyse(
- ListUtils.getCollection( organisationUnit ), dataElements, ListUtils.getCollection( period ), factor, from );
+ Sets.newHashSet( organisationUnit ), dataElements, Sets.newHashSet( period ), factor, from );
Collection<DeflatedDataValue> minMaxs = minMaxOutlierAnalysisService.analyse(
- ListUtils.getCollection( organisationUnit ), dataElements, ListUtils.getCollection( period ), null, from );
+ Sets.newHashSet( organisationUnit ), dataElements, Sets.newHashSet( period ), null, from );
Collection<DeflatedDataValue> deflatedDataValues = CollectionUtils.union( stdDevs, minMaxs );