dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33766
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17296: Analaytics, split out method for getting dimensional objects by dimension params
------------------------------------------------------------
revno: 17296
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-27 14:50:54 -0400
message:
Analaytics, split out method for getting dimensional objects by dimension params
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.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/MockAnalyticsService.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2014-09-29 16:10:58 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2014-10-27 18:50:54 +0000
@@ -174,6 +174,15 @@
DataQueryParams getFromAnalyticalObject( AnalyticalObject object, I18nFormat format );
/**
+ * Creates a list of DimensionalObject from the given set of dimension params.
+ *
+ * @param dimensionParams the dimension URL params.
+ * @param format the i18n format.
+ * @return a list of DimensionalObject.
+ */
+ List<DimensionalObject> getDimensionalObjects( Set<String> dimensionParams, I18nFormat format );
+
+ /**
* Returns a list of persisted DimensionalObjects generated from the given
* dimension identifier and list of dimension options. The dx dimension
* will be exploded into concrete in|de|ds object identifiers and returned
=== 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 2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-10-27 18:50:54 +0000
@@ -800,30 +800,12 @@
if ( dimensionParams != null && !dimensionParams.isEmpty() )
{
- for ( String param : dimensionParams )
- {
- String dimension = DimensionalObjectUtils.getDimensionFromParam( param );
- List<String> options = DimensionalObjectUtils.getDimensionItemsFromParam( param );
-
- if ( dimension != null && options != null )
- {
- params.getDimensions().addAll( getDimension( dimension, options, null, format, false ) );
- }
- }
+ params.getDimensions().addAll( getDimensionalObjects( dimensionParams, format ) );
}
if ( filterParams != null && !filterParams.isEmpty() )
{
- for ( String param : filterParams )
- {
- String dimension = DimensionalObjectUtils.getDimensionFromParam( param );
- List<String> options = DimensionalObjectUtils.getDimensionItemsFromParam( param );
-
- if ( dimension != null && options != null )
- {
- params.getFilters().addAll( getDimension( dimension, options, null, format, false ) );
- }
- }
+ params.getFilters().addAll( getDimensionalObjects( filterParams, format ) );
}
if ( measureCriteria != null && !measureCriteria.isEmpty() )
@@ -871,6 +853,28 @@
return params;
}
+ @Override
+ public List<DimensionalObject> getDimensionalObjects( Set<String> dimensionParams, I18nFormat format )
+ {
+ List<DimensionalObject> list = new ArrayList<>();
+
+ if ( dimensionParams != null )
+ {
+ for ( String param : dimensionParams )
+ {
+ String dimension = DimensionalObjectUtils.getDimensionFromParam( param );
+ List<String> options = DimensionalObjectUtils.getDimensionItemsFromParam( param );
+
+ if ( dimension != null && options != null )
+ {
+ list.addAll( getDimension( dimension, options, null, format, false ) );
+ }
+ }
+ }
+
+ return list;
+ }
+
// TODO verify that current user can read each dimension and dimension item
// TODO optimize so that org unit levels + boundary are used in query instead of fetching all org units one by one
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 2014-09-29 16:10:58 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 2014-10-27 18:50:54 +0000
@@ -93,6 +93,12 @@
{
throw new NotImplementedException();
}
+
+ @Override
+ public List<DimensionalObject> getDimensionalObjects( Set<String> dimensionParams, I18nFormat format )
+ {
+ throw new NotImplementedException();
+ }
@Override
public List<DimensionalObject> getDimension( String dimension, List<String> items, Date relativePeriodDate,