AnalyticsUtils { public static <T> Map<String, T> convertDxToOperand( Map<String, T> valueMap, TotalType totalType ) { Map<String, T> map = Maps.newHashMap(); for ( Entry<String, T> entry : valueMap.entrySet() ) { List<String> items = Lists.newArrayList( entry.getKey().split( DimensionalObject.DIMENSION_SEP ) ); List<String> operands = Lists.newArrayList( items.subList( 0, totalType.getPropertyCount() + 1 ) ); List<String> dimensions = Lists.newArrayList( items.subList( totalType.getPropertyCount() + 1, items.size() ) ); if ( TotalType.AOC_ONLY == totalType ) { operands.add( 1, SYMBOL_WILDCARD ); } String operand = StringUtils.join( operands, DimensionalObjectUtils.COMPOSITE_DIM_OBJECT_PLAIN_SEP ); String dimension = StringUtils.join( dimensions, DimensionalObject.DIMENSION_SEP ); dimension = !dimension.isEmpty() ? ( DimensionalObject.DIMENSION_SEP + dimension ) : StringUtils.EMPTY; String key = operand + dimension; map.put( key, entry.getValue() ); } return map; }  static String getDebugDataSql( DataQueryParams params ); static List<DimensionalItemObject> getByDataDimensionItemType( DataDimensionItemType itemType, List<DimensionalItemObject> dataDimensionOptions ); static Number getRoundedValue( DataQueryParams params, Integer decimals, Double value ); static Object getRoundedValueObject( DataQueryParams params, Object value ); static ColumnDataType getColumnType( ValueType valueType, boolean spatialSupport ); static Map<String, T> convertDxToOperand( Map<String, T> valueMap, TotalType totalType ); static Map<String, Double> getDoubleMap( Map<String, Object> map ); static Map<String, Object> getAggregatedDataValueMapping( Grid grid ); static DataValueSet getDataValueSetFromGrid( DataQueryParams params, Grid grid ); static void handleGridForDataValueSet( DataQueryParams params, Grid grid ); static Object getIntegerOrValue( Object value, DimensionalItemObject item ); static Map<String, DimensionalItemObject> getDimensionalItemObjectMap( DataQueryParams params ); static Map<String, String> getDimensionItemNameMap( DataQueryParams params ); static Map<String, MetadataItem> getDimensionMetadataItemMap( DataQueryParams params ); static Map<String, String> getCocNameMap( DataQueryParams params ); static Map<String, String> getUidDisplayPropertyMap( List<QueryItem> queryItems, DisplayProperty displayProperty ); static Map<String, String> getUidDisplayPropertyMap( List<DimensionalObject> dimensions, boolean hierarchyMeta, DisplayProperty displayProperty ); static boolean periodIsOutsideApprovalMaxYears( Integer year, Integer maxYears ); static int getLevelFromOrgUnitDimensionName( String dimensionName ); static boolean isTableLayout( List<String> columns, List<String> rows ); static Double calculateYearlyWeightedAverage( Double year1Value, Double year2Value, Double factor ); static Double getBaseMonth( PeriodType periodType ); static void throwIllegalQueryEx( ErrorCode errorCode, Object... args ); static boolean isPeriodInPeriods( String period, List<DimensionalItemObject> periods ); static List<DimensionalItemObject> findDimensionalItems( String dimensionIdentifier,
        List<DimensionalItemObject> items ); static boolean hasPeriod( List<Object> row, int periodIndex ); static final String ERR_MSG_TABLE_NOT_EXISTING; }
@Test public void testConvertDxToOperandCocOnly() { Map<String, Double> map = new HashMap<>(); map.put( "GauDLAiXPKT-kC1OT9Q1n1j-R9U8q7X1aJG", 10d ); map.put( "YkRvCLedQa4-h1dJ9W4dWor-Zrd4DAf8M99", 11d ); map.put( "PcfRp1HETO8-zqXKIEycBck-KBJBZopYMPV", 12d ); Map<String, Double> convertedMap = AnalyticsUtils.convertDxToOperand( map, TotalType.COC_ONLY ); assertTrue( convertedMap.containsKey( "GauDLAiXPKT.kC1OT9Q1n1j-R9U8q7X1aJG" ) ); assertTrue( convertedMap.containsKey( "YkRvCLedQa4.h1dJ9W4dWor-Zrd4DAf8M99" ) ); assertTrue( convertedMap.containsKey( "PcfRp1HETO8.zqXKIEycBck-KBJBZopYMPV" ) ); }
@Test public void testConvertDxToOperandCocOnlyNoDmensions() { Map<String, Double> map = new HashMap<>(); map.put( "GauDLAiXPKT-kC1OT9Q1n1j", 10d ); map.put( "YkRvCLedQa4-h1dJ9W4dWor", 11d ); map.put( "PcfRp1HETO8-zqXKIEycBck", 12d ); Map<String, Double> convertedMap = AnalyticsUtils.convertDxToOperand( map, TotalType.COC_ONLY ); assertTrue( convertedMap.containsKey( "GauDLAiXPKT.kC1OT9Q1n1j" ) ); assertTrue( convertedMap.containsKey( "YkRvCLedQa4.h1dJ9W4dWor" ) ); assertTrue( convertedMap.containsKey( "PcfRp1HETO8.zqXKIEycBck" ) ); }
@Test public void testConvertDxToOperandAocOnly() { Map<String, Double> map = new HashMap<>(); map.put( "GauDLAiXPKT-kC1OT9Q1n1j-2016", 10d ); map.put( "YkRvCLedQa4-h1dJ9W4dWor-2017", 11d ); map.put( "w1G4l0cSxOi-gQhAMdimKO4-2017", 12d ); Map<String, Double> convertedMap = AnalyticsUtils.convertDxToOperand( map, TotalType.AOC_ONLY ); assertTrue( convertedMap.containsKey( "GauDLAiXPKT.*.kC1OT9Q1n1j-2016" ) ); assertTrue( convertedMap.containsKey( "YkRvCLedQa4.*.h1dJ9W4dWor-2017" ) ); assertTrue( convertedMap.containsKey( "w1G4l0cSxOi.*.gQhAMdimKO4-2017" ) ); }
@Test public void testConvertDxToOperandCocAndAoc() { Map<String, Double> map = new HashMap<>(); map.put( "GauDLAiXPKT-kC1OT9Q1n1j-R9U8q7X1aJG-201701", 10d ); map.put( "YkRvCLedQa4-h1dJ9W4dWor-Zrd4DAf8M99-201702", 11d ); map.put( "PcfRp1HETO8-zqXKIEycBck-KBJBZopYMPV-201703", 12d ); Map<String, Double> convertedMap = AnalyticsUtils.convertDxToOperand( map, TotalType.COC_AND_AOC ); assertTrue( convertedMap.containsKey( "GauDLAiXPKT.kC1OT9Q1n1j.R9U8q7X1aJG-201701" ) ); assertTrue( convertedMap.containsKey( "YkRvCLedQa4.h1dJ9W4dWor.Zrd4DAf8M99-201702" ) ); assertTrue( convertedMap.containsKey( "PcfRp1HETO8.zqXKIEycBck.KBJBZopYMPV-201703" ) ); }
@Test public void testConvertDxToOperandNone() { Map<String, Double> map = new HashMap<>(); map.put( "GauDLAiXPKT-kC1OT9Q1n1j-R9U8q7X1aJG", 10d ); map.put( "YkRvCLedQa4-h1dJ9W4dWor-Zrd4DAf8M99", 11d ); map.put( "PcfRp1HETO8-zqXKIEycBck-KBJBZopYMPV", 12d ); Map<String, Double> convertedMap = AnalyticsUtils.convertDxToOperand( map, TotalType.NONE ); assertTrue( convertedMap.containsKey( "GauDLAiXPKT-kC1OT9Q1n1j-R9U8q7X1aJG" ) ); assertTrue( convertedMap.containsKey( "YkRvCLedQa4-h1dJ9W4dWor-Zrd4DAf8M99" ) ); assertTrue( convertedMap.containsKey( "PcfRp1HETO8-zqXKIEycBck-KBJBZopYMPV" ) ); }