/** * Sorts the keys in the given map by splitting on the '-' character and * sorting the components alphabetically. * * @param valueMap the mapping of keys and values. */ public static void sortKeys( Map<String, Object> valueMap ) { Map<String, Object> map = new HashMap<>(); for ( String key : valueMap.keySet() ) { String sortKey = sortKey( key ); if ( sortKey != null ) { map.put( sortKey, valueMap.get( key ) ); } } valueMap.clear(); valueMap.putAll( map ); }
/** * Creates a key based on the given input. Sorts the key on its components * to remove significance of column order. */ private String getKey( NameableObject series, NameableObject category, AnalyticsType analyticsType ) { String key = series.getUid() + DIMENSION_SEP + category.getUid(); // Replace potential operand separator with dimension separator key = AnalyticsType.AGGREGATE.equals( analyticsType ) ? key.replace( DataElementOperand.SEPARATOR, DIMENSION_SEP ) : key; // TODO fix issue with keys including -. return BaseAnalyticalObject.sortKey( key ); }