Search in sources :

Example 1 with SankeyChart

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;
}
Also used : PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Panel(com.vaadin.ui.Panel) Arrays(java.util.Arrays) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Secured(org.springframework.security.access.annotation.Secured) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ViewAction(com.hack23.cia.web.impl.ui.application.action.ViewAction) Locale(java.util.Locale) Map(java.util.Map) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) ContentRatio(com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio) MenuBar(com.vaadin.ui.MenuBar) Collectors(java.util.stream.Collectors) DecisionFlowChartManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionFlowChartManager) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Component(org.springframework.stereotype.Component) ChartIndicators(com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators) Layout(com.vaadin.ui.Layout) Collections(java.util.Collections) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ComboBox(com.vaadin.ui.ComboBox) VerticalLayout(com.vaadin.ui.VerticalLayout) List(java.util.List) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with SankeyChart

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;
}
Also used : SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ProposalCommitteeeSummary(com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.ProposalCommitteeeSummary) List(java.util.List)

Example 3 with SankeyChart

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;
}
Also used : SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ProposalCommitteeeSummary(com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.ProposalCommitteeeSummary) List(java.util.List) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)

Example 4 with SankeyChart

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;
}
Also used : PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Panel(com.vaadin.ui.Panel) Arrays(java.util.Arrays) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Secured(org.springframework.security.access.annotation.Secured) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ViewAction(com.hack23.cia.web.impl.ui.application.action.ViewAction) Locale(java.util.Locale) Map(java.util.Map) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) ContentRatio(com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio) MenuBar(com.vaadin.ui.MenuBar) Collectors(java.util.stream.Collectors) DecisionFlowChartManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionFlowChartManager) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Component(org.springframework.stereotype.Component) ChartIndicators(com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators) Layout(com.vaadin.ui.Layout) Collections(java.util.Collections) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ComboBox(com.vaadin.ui.ComboBox) VerticalLayout(com.vaadin.ui.VerticalLayout) List(java.util.List) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

SankeyChart (com.hack23.cia.web.widgets.charts.SankeyChart)4 List (java.util.List)4 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)3 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)2 DataContainer (com.hack23.cia.service.api.DataContainer)2 ViewAction (com.hack23.cia.web.impl.ui.application.action.ViewAction)2 DecisionFlowChartManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionFlowChartManager)2 ProposalCommitteeeSummary (com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.ProposalCommitteeeSummary)2 ContentRatio (com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio)2 ChartIndicators (com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators)2 PageMode (com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode)2 ComboBox (com.vaadin.ui.ComboBox)2 Layout (com.vaadin.ui.Layout)2 MenuBar (com.vaadin.ui.MenuBar)2 Panel (com.vaadin.ui.Panel)2 UI (com.vaadin.ui.UI)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Locale (java.util.Locale)2