------------------------------------------------------------ revno: 19765 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Mon 2015-08-10 23:57:49 +0200 message: Analytics. Fixed bug with restore of favorites, related to proxies and class checks. modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.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/common/DimensionalObjectUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java 2015-08-04 12:59:15 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObjectUtils.java 2015-08-10 21:57:49 +0000 @@ -28,9 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.common.DataDimensionItem.DATA_DIMENSION_TYPE_CLASS_MAP; -import static org.hisp.dhis.common.DataDimensionItem.DATA_DIMENSION_TYPE_DOMAIN_MAP; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -43,9 +40,7 @@ import org.apache.commons.collections.ListUtils; import org.apache.commons.lang3.StringUtils; -import org.hisp.dhis.common.DataDimensionItem.DataDimensionItemType; import org.hisp.dhis.common.comparator.ObjectStringValueComparator; -import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementOperand; import com.google.common.collect.Sets; @@ -81,36 +76,6 @@ } /** - * Returns a list of data dimension options which match the given data - * dimension item type. - * - * @param itemType the data dimension item type. - * @param dataDimensionOptions the data dimension options. - * @return list of nameable objects. - */ - public static List<NameableObject> getByDataDimensionType( DataDimensionItemType itemType, List<NameableObject> dataDimensionOptions ) - { - List<NameableObject> list = new ArrayList<>(); - - for ( NameableObject object : dataDimensionOptions ) - { - if ( !object.getClass().equals( DATA_DIMENSION_TYPE_CLASS_MAP.get( itemType ) ) ) - { - continue; - } - - if ( object.getClass().equals( DataElement.class ) && !( ((DataElement) object).getDomainType().equals( DATA_DIMENSION_TYPE_DOMAIN_MAP.get( itemType ) ) ) ) - { - continue; - } - - list.add( object ); - } - - return list; - } - - /** * Creates a list of dimension identifiers based on the given list of * DimensionalObjects. * === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java 2015-07-02 23:34:24 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java 2015-08-10 21:57:49 +0000 @@ -28,19 +28,24 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.common.DataDimensionItem.DATA_DIMENSION_TYPE_CLASS_MAP; +import static org.hisp.dhis.common.DataDimensionItem.DATA_DIMENSION_TYPE_DOMAIN_MAP; import static org.hisp.dhis.system.util.DateUtils.getMediumDateString; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang.StringUtils; +import org.hisp.dhis.common.DataDimensionItem.DataDimensionItemType; import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.common.IllegalQueryException; import org.hisp.dhis.common.NameableObject; import org.hisp.dhis.common.NameableObjectUtils; import org.hisp.dhis.commons.util.TextUtils; +import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.util.ReflectionUtils; /** * @author Lars Helge Overland @@ -99,4 +104,37 @@ return sql; } + + /** + * Returns a list of data dimension options which match the given data + * dimension item type. + * + * @param itemType the data dimension item type. + * @param dataDimensionOptions the data dimension options. + * @return list of nameable objects. + */ + public static List<NameableObject> getByDataDimensionType( DataDimensionItemType itemType, List<NameableObject> dataDimensionOptions ) + { + List<NameableObject> list = new ArrayList<>(); + + for ( NameableObject object : dataDimensionOptions ) + { + Class<?> clazz = ReflectionUtils.getRealClass( object.getClass() ); + + if ( !clazz.equals( DATA_DIMENSION_TYPE_CLASS_MAP.get( itemType ) ) ) + { + continue; + } + + if ( clazz.equals( DataElement.class ) && !( ((DataElement) object).getDomainType().equals( DATA_DIMENSION_TYPE_DOMAIN_MAP.get( itemType ) ) ) ) + { + continue; + } + + list.add( object ); + } + + return list; + } + } === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-08-07 17:59:15 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-08-10 21:57:49 +0000 @@ -1578,7 +1578,7 @@ */ private void setDataDimensionOptions( DataDimensionItemType itemType, List<? extends NameableObject> options ) { - List<NameableObject> existing = DimensionalObjectUtils.getByDataDimensionType( itemType, getDimensionOptions( DATA_X_DIM_ID ) ); + List<NameableObject> existing = AnalyticsUtils.getByDataDimensionType( itemType, getDimensionOptions( DATA_X_DIM_ID ) ); DimensionalObject dimension = getDimension( DATA_X_DIM_ID ); if ( dimension == null ) @@ -1631,7 +1631,7 @@ { DimensionalObject dimension = getDimensionOrFilter( DATA_X_DIM_ID ); - List<NameableObject> items = DimensionalObjectUtils.getByDataDimensionType( itemType, dimension.getItems() ); + List<NameableObject> items = AnalyticsUtils.getByDataDimensionType( itemType, dimension.getItems() ); dimension.getItems().clear(); dimension.getItems().addAll( items ); @@ -1647,7 +1647,7 @@ for ( DataDimensionItemType itemType : itemTypes ) { - items.addAll( DimensionalObjectUtils.getByDataDimensionType( itemType, dimension.getItems() ) ); + items.addAll( AnalyticsUtils.getByDataDimensionType( itemType, dimension.getItems() ) ); } dimension.getItems().clear(); @@ -1662,7 +1662,7 @@ public List<NameableObject> getIndicators() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.INDICATOR, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.INDICATOR, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setIndicators( List<? extends NameableObject> indicators ) @@ -1672,12 +1672,12 @@ public List<NameableObject> getDataElements() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.AGGREGATE_DATA_ELEMENT, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.AGGREGATE_DATA_ELEMENT, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public List<NameableObject> getDataElementOperands() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.DATA_ELEMENT_OPERAND, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.DATA_ELEMENT_OPERAND, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setDataElements( List<? extends NameableObject> dataElements ) @@ -1687,7 +1687,7 @@ public List<NameableObject> getDataSets() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.DATA_SET, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.DATA_SET, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setDataSets( List<? extends NameableObject> dataSets ) @@ -1697,7 +1697,7 @@ public List<NameableObject> getProgramIndicators() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_INDICATOR, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_INDICATOR, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setProgramIndicators( List<? extends NameableObject> programIndicators ) @@ -1707,7 +1707,7 @@ public List<NameableObject> getProgramDataElements() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_DATA_ELEMENT, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_DATA_ELEMENT, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setProgramDataElements( List<? extends NameableObject> programDataElements ) @@ -1717,7 +1717,7 @@ public List<NameableObject> getProgramAttributes() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_ATTRIBUTE, getDimensionOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_ATTRIBUTE, getDimensionOptions( DATA_X_DIM_ID ) ) ); } public void setProgramAttributes( List<? extends NameableObject> programAttributes ) @@ -1809,17 +1809,17 @@ public List<NameableObject> getFilterIndicators() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.INDICATOR, getFilterOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.INDICATOR, getFilterOptions( DATA_X_DIM_ID ) ) ); } public List<NameableObject> getFilterDataElements() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.AGGREGATE_DATA_ELEMENT, getFilterOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.AGGREGATE_DATA_ELEMENT, getFilterOptions( DATA_X_DIM_ID ) ) ); } public List<NameableObject> getFilterDataSets() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.DATA_SET, getFilterOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.DATA_SET, getFilterOptions( DATA_X_DIM_ID ) ) ); } public List<NameableObject> getFilterPeriods() @@ -1854,12 +1854,12 @@ public List<NameableObject> getFilterProgramDataElements() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_DATA_ELEMENT, getFilterOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_DATA_ELEMENT, getFilterOptions( DATA_X_DIM_ID ) ) ); } public List<NameableObject> getFilterProgramAttributes() { - return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_ATTRIBUTE, getFilterOptions( DATA_X_DIM_ID ) ) ); + return ImmutableList.copyOf( AnalyticsUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_ATTRIBUTE, getFilterOptions( DATA_X_DIM_ID ) ) ); } public void setFilter( String filter, DimensionType type, NameableObject item )
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp