Search in sources :

Example 1 with Legend

use of org.hisp.dhis.legend.Legend in project dhis2-core by dhis2.

the class DhisConvenienceTest method createLegend.

public static Legend createLegend(char uniqueCharacter, Double startValue, Double endValue) {
    Legend legend = new Legend();
    legend.setAutoFields();
    legend.setName("Legend" + uniqueCharacter);
    legend.setStartValue(startValue);
    legend.setEndValue(endValue);
    legend.setColor("Color" + uniqueCharacter);
    return legend;
}
Also used : Legend(org.hisp.dhis.legend.Legend)

Example 2 with Legend

use of org.hisp.dhis.legend.Legend in project dhis2-core by dhis2.

the class JdbcEnrollmentAnalyticsManager method getCollapsedDataItemValue.

/**
     * Returns an item value for the given query, query item and value. Assumes that
     * data dimensions are collapsed for the given query. Returns the short name
     * of the given query item followed by the item value. If the given query item
     * has a legend set, the item value is treated as an id and substituted with
     * the matching legend name. If the given query item has an option set, the 
     * item value is treated as a code and substituted with the matching option 
     * name.
     */
private String getCollapsedDataItemValue(EventQueryParams params, QueryItem item, String itemValue) {
    String value = item.getItem().getDisplayShortName() + ITEM_NAME_SEP;
    Legend legend = null;
    Option option = null;
    if (item.hasLegendSet() && (legend = item.getLegendSet().getLegendByUid(itemValue)) != null) {
        return value + legend.getDisplayName();
    } else if (item.hasOptionSet() && (option = item.getOptionSet().getOptionByCode(itemValue)) != null) {
        return value + option.getDisplayName();
    } else {
        itemValue = StringUtils.defaultString(itemValue, NA);
        return value + itemValue;
    }
}
Also used : Legend(org.hisp.dhis.legend.Legend) Option(org.hisp.dhis.option.Option) DateUtils.getMediumDateString(org.hisp.dhis.system.util.DateUtils.getMediumDateString)

Example 3 with Legend

use of org.hisp.dhis.legend.Legend in project dhis2-core by dhis2.

the class JdbcEventAnalyticsManager method getCollapsedDataItemValue.

/**
     * Returns an item value for the given query, query item and value. Assumes that
     * data dimensions are collapsed for the given query. Returns the short name
     * of the given query item followed by the item value. If the given query item
     * has a legend set, the item value is treated as an id and substituted with
     * the matching legend name. If the given query item has an option set, the 
     * item value is treated as a code and substituted with the matching option 
     * name.
     * 
     * @param params the {@link EventQueryParams}..
     * @param item the {@link QueryItem}.
     * @param itemValue the item value.
     */
private String getCollapsedDataItemValue(EventQueryParams params, QueryItem item, String itemValue) {
    String value = item.getItem().getDisplayShortName() + ITEM_NAME_SEP;
    Legend legend = null;
    Option option = null;
    if (item.hasLegendSet() && (legend = item.getLegendSet().getLegendByUid(itemValue)) != null) {
        return value + legend.getDisplayName();
    } else if (item.hasOptionSet() && (option = item.getOptionSet().getOptionByCode(itemValue)) != null) {
        return value + option.getDisplayName();
    } else {
        itemValue = StringUtils.defaultString(itemValue, NA);
        return value + itemValue;
    }
}
Also used : Legend(org.hisp.dhis.legend.Legend) Option(org.hisp.dhis.option.Option) DateUtils.getMediumDateString(org.hisp.dhis.system.util.DateUtils.getMediumDateString)

Aggregations

Legend (org.hisp.dhis.legend.Legend)3 Option (org.hisp.dhis.option.Option)2 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)2