use of net.sourceforge.processdash.data.util.SimpleDataContext in project processdash by dtuma.
the class TaskScheduleChartUtil method getContextTags.
private static SimpleDataContext getContextTags(boolean filterInEffect, boolean isRollup, boolean hideNames) {
SimpleDataContext ctx = new SimpleDataContext();
TagData tag = TagData.getInstance();
ctx.put(EVSnippetEnvironment.EV_CONTEXT_KEY, tag);
if (isRollup)
ctx.put(EVSnippetEnvironment.ROLLUP_EV_CONTEXT_KEY, tag);
if (filterInEffect)
ctx.put(EVSnippetEnvironment.FILTERED_EV_CONTEXT_KEY, tag);
if (hideNames)
ctx.put(EVSnippetEnvironment.ANON_EV_CONTEXT_KEY, tag);
return ctx;
}
use of net.sourceforge.processdash.data.util.SimpleDataContext in project processdash by dtuma.
the class TaskScheduleChartUtil method getChartsForTaskList.
/**
* Retrieve a list of charts that are applicable for a particular task list.
* @param taskListID the ID of the task list
* @param data the data repository
* @param filterInEffect true if a filter is in effect
* @param isRollup true if the task list is a rollup
* @param hideNames true if the identities of individuals should be
* protected
*
* @return a collection of {@link ChartItem} objects describing the
* snippets for the relevant charts, and the settings that should
* be used to display those snippets.
*/
public static List<ChartItem> getChartsForTaskList(String taskListID, DataRepository data, boolean filterInEffect, boolean isRollup, boolean hideNames, ChartListPurpose purpose) {
Map<String, TaskScheduleChartSettings> chartSettings = TaskScheduleChartSettings.getSettingsForTaskList(taskListID, data);
Map<String, ChartItem> result = new HashMap<String, ChartItem>();
SimpleDataContext ctx = getContextTags(filterInEffect, isRollup, hideNames);
SnippetDefinitionManager.initialize();
for (SnippetDefinition snip : SnippetDefinitionManager.getSnippetsInCategory("ev")) {
if (snip.matchesContext(ctx)) {
try {
ChartItem item = new ChartItem(snip, chartSettings.remove(snip.getId()));
result.put(snip.getId(), item);
} catch (Exception e) {
logger.log(Level.WARNING, "Problem with EV Chart Snippet '" + snip.getId() + "'", e);
}
}
}
for (TaskScheduleChartSettings customChart : chartSettings.values()) {
ChartItem base = result.get(customChart.getChartID());
if (base != null) {
ChartItem custom = new ChartItem(base.snip, customChart);
result.put(customChart.getSettingsIdentifier(), custom);
}
}
List preferredCharts = new ArrayList<ChartItem>();
if (purpose == ChartListPurpose.ReportMain || purpose == ChartListPurpose.ReportAll) {
List<String> preferredChartOrdering = TaskScheduleChartSettings.getPreferredChartOrdering(taskListID, data);
for (String oneId : preferredChartOrdering) {
if (TaskScheduleChartSettings.SECONDARY_CHART_MARKER.equals(oneId)) {
if (purpose == ChartListPurpose.ReportMain)
break;
else
preferredCharts.add(null);
} else {
ChartItem chart = result.remove(oneId);
if (chart != null)
preferredCharts.add(chart);
}
}
if (purpose == ChartListPurpose.ReportMain)
return preferredCharts;
else if (!preferredCharts.contains(null))
preferredCharts.add(null);
}
List finalResult = new ArrayList<ChartItem>(result.values());
Collections.sort(finalResult);
finalResult.addAll(0, preferredCharts);
return finalResult;
}
Aggregations