use of com.hack23.cia.web.widgets.charts.SankeyChart in project cia by Hack23.
the class CommitteeDecisionFlowPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommittee.class);
final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
if (viewRiksdagenCommittee != null) {
String selectedYear = "2017/18";
if (parameters != null && parameters.contains("[") && parameters.contains("]")) {
selectedYear = parameters.substring(parameters.indexOf('[') + 1, parameters.lastIndexOf(']'));
}
ComboBox<String> comboBox = new ComboBox<>("Select year", Collections.unmodifiableList(Arrays.asList("2017/18", "2016/17", "2015/16", "2014/15", "2013/14", "2012/13", "2011/12", "2010/11")));
panelContent.addComponent(comboBox);
panelContent.setExpandRatio(comboBox, ContentRatio.SMALL2);
comboBox.setSelectedItem(selectedYear);
comboBox.addValueChangeListener(event -> {
if (!event.getSource().isEmpty()) {
UI.getCurrent().getNavigator().navigateTo(NAME + "/" + PageMode.CHARTS.toString() + "/" + ChartIndicators.DECISION_FLOW_CHART.toString() + "/" + pageId + "[" + event.getValue() + "]");
}
});
final Map<String, List<ViewRiksdagenCommittee>> committeeMap = dataContainer.getAll().stream().collect(Collectors.groupingBy(c -> c.getEmbeddedId().getOrgCode().toUpperCase(Locale.ENGLISH)));
SankeyChart chart = decisionFlowChartManager.createCommitteeDecisionFlow(viewRiksdagenCommittee, committeeMap, comboBox.getSelectedItem().orElse(selectedYear));
panelContent.addComponent(chart);
panelContent.setExpandRatio(chart, ContentRatio.LARGE);
}
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
panel.setCaption(new StringBuilder().append(NAME).append("::").append(COMMITTEE_DECISION_FLOW).toString());
return panelContent;
}
use of com.hack23.cia.web.widgets.charts.SankeyChart in project cia by Hack23.
the class DecisionFlowChartManagerImpl method createCommitteeDecisionFlow.
@Override
public SankeyChart createCommitteeDecisionFlow(final ViewRiksdagenCommittee viewRiksdagenCommittee, final Map<String, List<ViewRiksdagenCommittee>> committeeMap, final String rm) {
final List<ProposalCommitteeeSummary> createCommitteeSummary = decisionDataFactory.createCommitteeSummary(rm);
final SankeyChart chart = new SankeyChart();
final Map<String, List<ProposalCommitteeeSummary>> orgProposalMap = createCommitteeSummary.stream().collect(Collectors.groupingBy(ProposalCommitteeeSummary::getOrg));
for (final Entry<String, List<ProposalCommitteeeSummary>> entry : orgProposalMap.entrySet()) {
if (committeeMap.containsKey(entry.getKey()) && viewRiksdagenCommittee.getEmbeddedId().getOrgCode().equals(entry.getKey())) {
addDocTypeDecisionDataRows(chart, entry);
}
}
chart.drawChart();
return chart;
}
use of com.hack23.cia.web.widgets.charts.SankeyChart in project cia by Hack23.
the class DecisionFlowChartManagerImpl method createAllDecisionFlow.
@Override
public SankeyChart createAllDecisionFlow(final Map<String, List<ViewRiksdagenCommittee>> committeeMap, final String rm) {
final List<ProposalCommitteeeSummary> createCommitteeSummary = decisionDataFactory.createCommitteeSummary(rm);
final SankeyChart chart = new SankeyChart();
final Map<String, List<ProposalCommitteeeSummary>> orgProposalMap = createCommitteeSummary.stream().collect(Collectors.groupingBy(ProposalCommitteeeSummary::getOrg));
for (final Entry<String, List<ProposalCommitteeeSummary>> entry : orgProposalMap.entrySet()) {
if (committeeMap.containsKey(entry.getKey())) {
final Optional<ViewRiksdagenCommittee> vewRiksdagenCommittee = committeeMap.get(entry.getKey()).stream().findFirst();
if (vewRiksdagenCommittee.isPresent()) {
addDocTypeDataRows(chart, entry, vewRiksdagenCommittee.get());
addDecisionDataRows(chart, entry, vewRiksdagenCommittee.get());
}
}
}
chart.drawChart();
return chart;
}
use of com.hack23.cia.web.widgets.charts.SankeyChart in project cia by Hack23.
the class ParliamentDecisionFlowPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);
String selectedYear = "2017/18";
if (parameters != null && parameters.contains("[") && parameters.contains("]")) {
selectedYear = parameters.substring(parameters.indexOf('[') + 1, parameters.lastIndexOf(']'));
}
final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommittee.class);
final List<ViewRiksdagenCommittee> allCommittess = dataContainer.getAll();
final Map<String, List<ViewRiksdagenCommittee>> committeeMap = allCommittess.stream().collect(Collectors.groupingBy(c -> c.getEmbeddedId().getOrgCode().toUpperCase(Locale.ENGLISH)));
ComboBox<String> comboBox = new ComboBox<>("Select year", Collections.unmodifiableList(Arrays.asList("2017/18", "2016/17", "2015/16", "2014/15", "2013/14", "2012/13", "2011/12", "2010/11")));
panelContent.addComponent(comboBox);
panelContent.setExpandRatio(comboBox, ContentRatio.SMALL);
comboBox.setSelectedItem(selectedYear);
comboBox.addValueChangeListener(event -> {
if (!event.getSource().isEmpty()) {
UI.getCurrent().getNavigator().navigateTo(NAME + "/" + PageMode.CHARTS.toString() + "/" + ChartIndicators.DECISION_FLOW_CHART.toString() + "[" + event.getValue() + "]");
}
});
SankeyChart chart = decisionFlowChartManager.createAllDecisionFlow(committeeMap, comboBox.getSelectedItem().orElse(selectedYear));
panelContent.addComponent(chart);
panelContent.setExpandRatio(chart, ContentRatio.LARGE);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARLIAMENT_RANKING_VIEW, ApplicationEventGroup.USER, NAME, parameters, selectedYear);
panel.setCaption(new StringBuilder().append(NAME).append("::").append(PARLIAMENT_DECISION_FLOW).toString());
return panelContent;
}
Aggregations