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;
}
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;
}
}
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;
}
}
Aggregations